The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): sync right sidebar file tree to focused session tile
Mohammad1f44d42dafdf
diff --git a/apps/desktop/src/app/right-sidebar/index.test.tsx b/apps/desktop/src/app/right-sidebar/index.test.tsxindex 9a0720f3e94..2485f8981fd 100644--- a/apps/desktop/src/app/right-sidebar/index.test.tsx+++ b/apps/desktop/src/app/right-sidebar/index.test.tsx@@ -2,7 +2,9 @@ import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/reimport { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'import type { HermesReadDirResult } from '@/global'-import { $connection, $selectedStoredSessionId, $workspaceCwdOwner, setCurrentCwd } from '@/store/session'+import { $activeTreeGroup, $layoutTree } from '@/components/pane-shell/tree/store'+import { $connection, $selectedStoredSessionId, $sessions, $workspaceCwdOwner, setCurrentCwd } from '@/store/session'+import { $sessionStates, $sessionTiles } from '@/store/session-states'import { resetProjectTreeState } from './files/use-project-tree'@@ -69,4 +71,31 @@ describe('RightSidebarPane', () => {await waitFor(() => expect(screen.queryByRole('button', { name: 'Refresh tree' })).toBeNull())expect(readDir).not.toHaveBeenCalled()})++ it('reads the focused tile workspace cwd when a tile tab is focused', async () => {+ $selectedStoredSessionId.set('main-session')+ $workspaceCwdOwner.set('main-session')+ setCurrentCwd('/repo-main')++ $sessions.set([+ { cwd: '/repo-tile', id: 'tile-session' } as any+ ])+ $sessionTiles.set([+ { storedSessionId: 'tile-session', runtimeId: 'rt-tile', workspaceMode: 'sessions' } as any+ ])+ $layoutTree.set({+ id: 'grp-1',+ type: 'group',+ panes: ['session-tile:tile-session'],+ active: 'session-tile:tile-session'+ } as any)+ $activeTreeGroup.set('grp-1')++ render(<RightSidebarPane onActivateFile={vi.fn()} onActivateFolder={vi.fn()} />)++ const refresh = await screen.findByRole('button', { name: 'Refresh tree' })+ readDir.mockClear()+ fireEvent.click(refresh)+ await waitFor(() => expect(readDir).toHaveBeenCalledWith('/repo-tile'))+ })})diff --git a/apps/desktop/src/app/right-sidebar/index.tsx b/apps/desktop/src/app/right-sidebar/index.tsxindex e1e824c7a61..76ec2720bd9 100644--- a/apps/desktop/src/app/right-sidebar/index.tsx+++ b/apps/desktop/src/app/right-sidebar/index.tsx@@ -14,7 +14,8 @@ import { $panesFlipped } from '@/store/layout'import { notifyError } from '@/store/notifications'import { openPreview } from '@/store/preview'import { openFolderAsProject } from '@/store/projects'-import { $currentCwd, $selectedStoredSessionId, $workspaceCwdOwner } from '@/store/session'+import { $currentCwd, $selectedStoredSessionId, $sessions, $workspaceCwdOwner, sessionMatchesStoredId } from '@/store/session'+import { $focusedSessionState, $focusedStoredSessionId } from '@/store/session-states'import { SidebarPanelLabel } from '../shell/sidebar-label'@@ -33,11 +34,26 @@ export function RightSidebarPane({ onActivateFile, onActivateFolder }: RightSideconst currentCwd = useStore($currentCwd).trim()const selectedStoredSessionId = useStore($selectedStoredSessionId)const workspaceCwdOwner = useStore($workspaceCwdOwner)+ const focusedStoredSessionId = useStore($focusedStoredSessionId)+ const focusedSessionState = useStore($focusedSessionState)+ const sessions = useStore($sessions)- // A transition intentionally retains the old CWD until the new session- // confirms its workspace. Do not issue a filesystem read against that path:- // under a gateway switch it may belong to a different remote machine.- const hasWorkspace = Boolean(currentCwd) && (workspaceCwdOwner ?? null) === (selectedStoredSessionId ?? null)+ // When a tile tab is focused, use the focused tile's workspace cwd;+ // otherwise fall back to the primary session's cwd.+ const isTileFocused = Boolean(focusedStoredSessionId && focusedStoredSessionId !== selectedStoredSessionId)+ const tileCwd =+ isTileFocused && focusedStoredSessionId+ ? (+ focusedSessionState?.cwd ||+ sessions.find(s => sessionMatchesStoredId(s, focusedStoredSessionId))?.cwd ||+ ''+ ).trim()+ : ''++ const targetCwd = isTileFocused ? tileCwd : currentCwd+ const hasWorkspace = isTileFocused+ ? Boolean(tileCwd)+ : Boolean(currentCwd) && (workspaceCwdOwner ?? null) === (selectedStoredSessionId ?? null)const {collapseAll,@@ -52,7 +68,7 @@ export function RightSidebarPane({ onActivateFile, onActivateFolder }: RightSidesetNodeOpen,setShowIgnored,showIgnored- } = useProjectTree(hasWorkspace ? currentCwd : '')+ } = useProjectTree(hasWorkspace ? targetCwd : '')const cwdName =effectiveCwd