fix(sessions): rewrite stale new-chat drafts before send
When a regular new-chat draft inherits a deleted lastDirectory, update the visible draft target to the active project immediately. lastDirectory still stays unchanged until session creation succeeds. Co-authored-by: serkraser <serkraser@gmail.com>
This commit is contained in:
co-authored by
serkraser
parent
90e79b04a4
commit
9090733908
@@ -456,6 +456,22 @@ describe('createSession draft lifecycle', () => {
|
||||
expect(useSessionUIStore.getState().newSessionDraft.title).toBe('Draft title');
|
||||
});
|
||||
|
||||
test('rewrites an implicit new-chat draft to the active project before the session is created', async () => {
|
||||
useProjectsStore.setState({
|
||||
projects: [{ id: 'project-main', path: '/projects/main', label: 'Main' }],
|
||||
activeProjectId: 'project-main',
|
||||
});
|
||||
useDirectoryStore.getState().setDirectory('/private/deleted-worktree', { showOverlay: false });
|
||||
opencodeClient.getDirectoryAvailability = async () => 'missing';
|
||||
|
||||
useSessionUIStore.getState().openNewSessionDraft();
|
||||
await Bun.sleep(0);
|
||||
|
||||
expect(useSessionUIStore.getState().newSessionDraft.directoryOverride).toBe('/projects/main');
|
||||
expect(useSessionUIStore.getState().newSessionDraft.selectedProjectId).toBe('project-main');
|
||||
expect(getDeferredSafeStorage().getItem('lastDirectory')).toBe('/private/deleted-worktree');
|
||||
});
|
||||
|
||||
test('falls back to the current active project when a regular new-chat directory is missing', async () => {
|
||||
const createSessionCalls = [];
|
||||
useProjectsStore.setState({
|
||||
|
||||
Reference in New Issue
Block a user