From 125094d37138ede533676470b5fbff410e779068 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Art=D1=91m?= <470045+yart@users.noreply.github.com> Date: Tue, 21 Apr 2026 23:13:54 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20=D1=81=D0=BE=D1=85=D1=80=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=BB=20pinned=20sessions=20=D0=BF=D0=BE=D1=81=D0=BB?= =?UTF-8?q?=D0=B5=20reload=20(#943)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/ui/src/components/session/SessionSidebar.tsx | 2 ++ .../session/sidebar/hooks/useSidebarPersistence.ts | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/ui/src/components/session/SessionSidebar.tsx b/packages/ui/src/components/session/SessionSidebar.tsx index 954fb01d..77f19327 100644 --- a/packages/ui/src/components/session/SessionSidebar.tsx +++ b/packages/ui/src/components/session/SessionSidebar.tsx @@ -275,6 +275,7 @@ export const SessionSidebar: React.FC = ({ const sync = useSync(); const liveSessions = useAllLiveSessions(); const liveSessionStatuses = useAllSessionStatuses(); + const hasLoadedGlobalSessions = useGlobalSessionsStore((state) => state.hasLoaded); const globalActiveSessions = useGlobalSessionsStore((state) => state.activeSessions); const archivedSessions = useGlobalSessionsStore((state) => state.archivedSessions); const currentSessionId = useSessionUIStore((state) => state.currentSessionId); @@ -476,6 +477,7 @@ export const SessionSidebar: React.FC = ({ const { scheduleCollapsedProjectsPersist } = useSidebarPersistence({ isVSCode, + hasLoadedGlobalSessions, safeStorage, keys: { sessionExpanded: SESSION_EXPANDED_STORAGE_KEY, diff --git a/packages/ui/src/components/session/sidebar/hooks/useSidebarPersistence.ts b/packages/ui/src/components/session/sidebar/hooks/useSidebarPersistence.ts index 67406851..061b8c30 100644 --- a/packages/ui/src/components/session/sidebar/hooks/useSidebarPersistence.ts +++ b/packages/ui/src/components/session/sidebar/hooks/useSidebarPersistence.ts @@ -19,6 +19,7 @@ type Keys = { type Args = { isVSCode: boolean; + hasLoadedGlobalSessions: boolean; safeStorage: SafeStorageLike; keys: Keys; sessions: Session[]; @@ -34,6 +35,7 @@ type Args = { export const useSidebarPersistence = (args: Args) => { const { isVSCode, + hasLoadedGlobalSessions, safeStorage, keys, sessions, @@ -114,6 +116,10 @@ export const useSidebarPersistence = (args: Args) => { }, [keys.projectCollapse, keys.sessionExpanded, safeStorage, setCollapsedProjects, setExpandedParents]); React.useEffect(() => { + if (!hasLoadedGlobalSessions) { + return; + } + const existingSessionIds = new Set(sessions.map((session) => session.id)); setPinnedSessionIds((prev) => { let changed = false; @@ -127,7 +133,7 @@ export const useSidebarPersistence = (args: Args) => { }); return changed ? next : prev; }); - }, [sessions, setPinnedSessionIds]); + }, [hasLoadedGlobalSessions, sessions, setPinnedSessionIds]); React.useEffect(() => { try {