From 15b8643a64afa0d0fa352d281a2667039793de60 Mon Sep 17 00:00:00 2001 From: Ammar Date: Mon, 8 Dec 2025 19:17:49 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20fix:=20workspace=20sidebar=20upd?= =?UTF-8?q?ates=20immediately=20on=20creation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The useWorkspaceRecency hook was subscribed to states.subscribeAny, but workspace recency is bumped via derived.bump("recency"). This caused a delay between workspace creation and the sidebar reflecting the new workspace. Fixed by: 1. Adding subscribeDerived method that delegates to derived.subscribeAny 2. Updating useWorkspaceRecency to use subscribeDerived instead of subscribe _Generated with mux_ --- src/browser/stores/WorkspaceStore.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/browser/stores/WorkspaceStore.ts b/src/browser/stores/WorkspaceStore.ts index 18ba5c1dd5..b5e67b3e5c 100644 --- a/src/browser/stores/WorkspaceStore.ts +++ b/src/browser/stores/WorkspaceStore.ts @@ -401,6 +401,12 @@ export class WorkspaceStore { */ subscribe = this.states.subscribeAny; + /** + * Subscribe to derived state changes (recency, etc.). + * Use for hooks that depend on derived.bump() rather than states.bump(). + */ + subscribeDerived = this.derived.subscribeAny; + /** * Subscribe to changes for a specific workspace. * Only notified when this workspace's state changes. @@ -1087,11 +1093,12 @@ export function useWorkspaceStoreRaw(): WorkspaceStore { /** * Hook to get workspace recency timestamps. + * Subscribes to derived state since recency is updated via derived.bump("recency"). */ export function useWorkspaceRecency(): Record { const store = getStoreInstance(); - return useSyncExternalStore(store.subscribe, () => store.getWorkspaceRecency()); + return useSyncExternalStore(store.subscribeDerived, () => store.getWorkspaceRecency()); } /**