From 753e312c13f84d978300f1f61e2fdf48d0e31ca3 Mon Sep 17 00:00:00 2001 From: xintaofei Date: Tue, 21 Apr 2026 21:44:33 +0800 Subject: [PATCH] fix(workspace): resolve folder lookups against all folders for branch and file tree --- src/components/tabs/tab-bar.tsx | 6 +++--- src/contexts/active-folder-context.tsx | 6 +++--- src/contexts/app-workspace-context.tsx | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/components/tabs/tab-bar.tsx b/src/components/tabs/tab-bar.tsx index 4a1f429..a96498c 100644 --- a/src/components/tabs/tab-bar.tsx +++ b/src/components/tabs/tab-bar.tsx @@ -24,14 +24,14 @@ export function TabBar() { toggleTileMode, reorderTabs, } = useTabContext() - const { folders, branches } = useAppWorkspace() + const { allFolders, branches } = useAppWorkspace() const { mode, activePane } = useWorkspaceContext() const folderIndex = useMemo(() => { const map = new Map() - for (const f of folders) map.set(f.id, { name: f.name }) + for (const f of allFolders) map.set(f.id, { name: f.name }) return map - }, [folders]) + }, [allFolders]) const handleRevealInSidebar = useCallback((folderId: number) => { window.dispatchEvent( diff --git a/src/contexts/active-folder-context.tsx b/src/contexts/active-folder-context.tsx index 11a8103..f1a087e 100644 --- a/src/contexts/active-folder-context.tsx +++ b/src/contexts/active-folder-context.tsx @@ -20,14 +20,14 @@ export function useActiveFolder() { } export function ActiveFolderProvider({ children }: { children: ReactNode }) { - const { folders, activeFolderId } = useAppWorkspace() + const { allFolders, activeFolderId } = useAppWorkspace() const activeFolder = useMemo( () => activeFolderId != null - ? (folders.find((f) => f.id === activeFolderId) ?? null) + ? (allFolders.find((f) => f.id === activeFolderId) ?? null) : null, - [activeFolderId, folders] + [activeFolderId, allFolders] ) const value = useMemo( diff --git a/src/contexts/app-workspace-context.tsx b/src/contexts/app-workspace-context.tsx index 8e089ff..8f66ab0 100644 --- a/src/contexts/app-workspace-context.tsx +++ b/src/contexts/app-workspace-context.tsx @@ -135,7 +135,7 @@ export function AppWorkspaceProvider({ children }: AppWorkspaceProviderProps) { setAllFolders(allList) setBranches((prev) => { const next = new Map(prev) - for (const f of openList) { + for (const f of allList) { if (!next.has(f.id)) { next.set(f.id, f.git_branch ?? null) } @@ -175,8 +175,8 @@ export function AppWorkspaceProvider({ children }: AppWorkspaceProviderProps) { }, [fetchFolders, refreshConversations]) const getFolder = useCallback( - (id: number) => folders.find((f) => f.id === id), - [folders] + (id: number) => allFolders.find((f) => f.id === id), + [allFolders] ) const updateConversationLocal = useCallback( @@ -290,7 +290,7 @@ export function AppWorkspaceProvider({ children }: AppWorkspaceProviderProps) { useEffect(() => { if (activeFolderId == null) return const folderId = activeFolderId - const folder = folders.find((f) => f.id === folderId) + const folder = allFolders.find((f) => f.id === folderId) if (!folder) return let cancelled = false @@ -322,7 +322,7 @@ export function AppWorkspaceProvider({ children }: AppWorkspaceProviderProps) { cancelled = true if (timer) clearTimeout(timer) } - }, [activeFolderId, folders]) + }, [activeFolderId, allFolders]) const stats = useMemo( () => (conversations.length > 0 ? computeStats(conversations) : null),