fix(session): prefer current directory for implicit drafts
This commit is contained in:
@@ -246,13 +246,13 @@ describe('openNewSessionDraft project binding', () => {
|
||||
useDirectoryStore.getState().setDirectory(projectB.path, { showOverlay: false });
|
||||
});
|
||||
|
||||
test('binds draft to active project when current directory differs', () => {
|
||||
test('keeps implicit draft on current directory when active project differs', () => {
|
||||
useSessionUIStore.getState().openNewSessionDraft();
|
||||
const draft = useSessionUIStore.getState().newSessionDraft;
|
||||
|
||||
expect(draft.open).toBe(true);
|
||||
expect(draft.selectedProjectId).toBe(projectA.id);
|
||||
expect(draft.directoryOverride).toBe(projectA.path);
|
||||
expect(draft.selectedProjectId).toBe(projectB.id);
|
||||
expect(draft.directoryOverride).toBe(projectB.path);
|
||||
});
|
||||
|
||||
test('respects explicit directoryOverride over active project', () => {
|
||||
|
||||
@@ -626,7 +626,6 @@ export const useSessionUIStore = create<SessionUIState>()((set, get) => ({
|
||||
if (explicitProject || explicitDirectory !== null) {
|
||||
return explicitProject ?? inferredProjectFromDir ?? fallbackProject
|
||||
}
|
||||
if (activeProject) return activeProject
|
||||
if (currentDirectory) return currentDirProject ?? fallbackProject
|
||||
return persistedProjectByDir ?? persistedProjectById ?? fallbackProject
|
||||
})()
|
||||
@@ -634,8 +633,6 @@ export const useSessionUIStore = create<SessionUIState>()((set, get) => ({
|
||||
const directory = (() => {
|
||||
if (explicitDirectory !== null) return explicitDirectory
|
||||
if (explicitProject) return normalizePath(explicitProject.path ?? null)
|
||||
const selectedProjectPath = normalizePath(selectedProject?.path ?? null)
|
||||
if (selectedProjectPath && selectedProjectPath !== currentDirectory) return selectedProjectPath
|
||||
if (currentDirectory) return currentDirectory
|
||||
if (persistedTarget?.directory) return persistedTarget.directory
|
||||
return normalizePath(selectedProject?.path ?? null)
|
||||
|
||||
Reference in New Issue
Block a user