fix(session): prefer current directory for implicit drafts

This commit is contained in:
Bohdan Triapitsyn
2026-06-24 00:43:19 +03:00
parent 08b866136e
commit 7f8e04d22f
3 changed files with 8 additions and 8 deletions
+5 -2
View File
@@ -4,6 +4,7 @@ import type { Snippet } from '@/types/snippet';
import { opencodeClient } from '@/lib/opencode/client';
import { runtimeFetch } from '@/lib/runtime-fetch';
import { useProjectsStore } from '@/stores/useProjectsStore';
import { useDirectoryStore } from '@/stores/useDirectoryStore';
export type SnippetScope = 'global' | 'project';
@@ -37,10 +38,12 @@ let loadInFlight: Promise<boolean> | null = null;
const getRequestDirectory = (): string | null => {
try {
const activeProject = useProjectsStore.getState().getActiveProject?.();
if (activeProject?.path?.trim()) return activeProject.path.trim();
const currentDirectory = useDirectoryStore.getState().currentDirectory;
if (currentDirectory?.trim()) return currentDirectory.trim();
const clientDir = opencodeClient.getDirectory();
if (clientDir?.trim()) return clientDir.trim();
const activeProject = useProjectsStore.getState().getActiveProject?.();
if (activeProject?.path?.trim()) return activeProject.path.trim();
} catch (error) {
console.warn('[SnippetsStore] Error resolving config directory:', error);
}