fix: prevent worktree modal from disappearing after opening (#1585)
The worktree dialog state was local React state in SessionSidebar, which gets destroyed when the component unmounts (mobile drawer close, VSCode view switch). This caused the modal to briefly appear then disappear. Three changes: - Move newWorktreeDialogOpen from local state to useUIStore so it survives component unmount - Guard useProjectSessionSelection layout effect to skip when the worktree dialog is open (prevents auto-session-selection from closing the sidebar) - Remove setSessionSwitcherOpen(false) from worktree button handler on mobile (prevents drawer close that unmounts the sidebar) Fixes #1414
This commit is contained in:
@@ -3,6 +3,7 @@ import type { Session } from '@opencode-ai/sdk/v2';
|
||||
import type { SessionGroup, SessionNode } from '../types';
|
||||
import { normalizePath } from '../utils';
|
||||
import type { MainTab } from '@/stores/useUIStore';
|
||||
import { useUIStore } from '@/stores/useUIStore';
|
||||
|
||||
type ProjectSection = {
|
||||
project: { id: string; normalizedPath: string };
|
||||
@@ -93,6 +94,10 @@ export const useProjectSessionSelection = (args: Args): { currentSessionDirector
|
||||
return;
|
||||
}
|
||||
|
||||
if (useUIStore.getState().isNewWorktreeDialogOpen) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (previousActiveProjectRef.current === activeProjectId) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user