fix: preserve chat folder assignments on reload

Prevents folder cleanup before sessions finish loading
Keeps saved chat folder memberships after desktop reload
This commit is contained in:
Bohdan Triapitsyn
2026-06-05 20:58:54 +03:00
parent 3bfb7ba6aa
commit 48b0a4f292
2 changed files with 5 additions and 1 deletions
@@ -848,6 +848,7 @@ export const SessionSidebar: React.FC<SessionSidebarProps> = ({
const isSessionsLoading = useSessionUIStore((state) => state.isLoading); const isSessionsLoading = useSessionUIStore((state) => state.isLoading);
useSessionFolderCleanup({ useSessionFolderCleanup({
isSessionsLoading, isSessionsLoading,
hasLoadedGlobalSessions,
sessions, sessions,
archivedSessions, archivedSessions,
normalizedProjects, normalizedProjects,
@@ -12,6 +12,7 @@ type WorktreeMeta = { path: string };
type Args = { type Args = {
isSessionsLoading: boolean; isSessionsLoading: boolean;
hasLoadedGlobalSessions: boolean;
sessions: Session[]; sessions: Session[];
archivedSessions: Session[]; archivedSessions: Session[];
normalizedProjects: NormalizedProject[]; normalizedProjects: NormalizedProject[];
@@ -23,6 +24,7 @@ type Args = {
export const useSessionFolderCleanup = (args: Args): void => { export const useSessionFolderCleanup = (args: Args): void => {
const { const {
isSessionsLoading, isSessionsLoading,
hasLoadedGlobalSessions,
sessions, sessions,
archivedSessions, archivedSessions,
normalizedProjects, normalizedProjects,
@@ -32,7 +34,7 @@ export const useSessionFolderCleanup = (args: Args): void => {
} = args; } = args;
React.useEffect(() => { React.useEffect(() => {
if (isSessionsLoading) { if (isSessionsLoading || !hasLoadedGlobalSessions) {
return; return;
} }
@@ -86,6 +88,7 @@ export const useSessionFolderCleanup = (args: Args): void => {
archivedSessions, archivedSessions,
availableWorktreesByProject, availableWorktreesByProject,
cleanupSessions, cleanupSessions,
hasLoadedGlobalSessions,
isSessionsLoading, isSessionsLoading,
isVSCode, isVSCode,
normalizedProjects, normalizedProjects,