The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): build the focused-pane cwd on main's session focus; keep it through Files/Terminal chrome
Brooklyn Nicholson349372199a1c
diff --git a/apps/desktop/src/store/session-focus.ts b/apps/desktop/src/store/session-focus.tsindex 31ded4a5f56..cfd797bf248 100644--- a/apps/desktop/src/store/session-focus.ts+++ b/apps/desktop/src/store/session-focus.ts@@ -4,15 +4,21 @@ import { findGroup, findGroupOfPane } from '@/components/pane-shell/tree/model'import { $activeTreeGroup, $layoutTree } from '@/components/pane-shell/tree/store'import { $workspaceMode } from '@/components/pane-shell/workspace-scope'-// The sidebar still owns keyboard focus, but navigating its chrome must not-// replace the chat being worked in with the route's (possibly hidden) primary.+// A chat surface: the primary's workspace or a session tile. Everything else a+// zone can show — the sessions list, Files, Terminal, a preview tab — is chrome.+const isChatPane = (paneId?: string): boolean => paneId === 'workspace' || Boolean(paneId?.startsWith('session-tile:'))++// Chrome can own keyboard focus, but working in it (navigating the sessions+// list, browsing Files, typing in Terminal) must not replace the chat being+// worked in with the route's (possibly hidden) primary — the Files rail and+// statusbar follow this chat, so they would jump projects mid-click.const $lastContentGroup = atom<null | string>(null)$activeTreeGroup.subscribe(groupId => {const tree = $layoutTree.get()const active = groupId && tree ? findGroup(tree, groupId)?.active : undefined- if (active !== 'sessions') {+ if (!groupId || isChatPane(active)) {$lastContentGroup.set(groupId)}})@@ -22,7 +28,7 @@ export const $focusedTreePaneId = computed((groupId, tree, workspaceMode, lastContentGroup) => {let active = groupId && tree ? findGroup(tree, groupId)?.active : undefined- if (active === 'sessions' && tree) {+ if (groupId && tree && !isChatPane(active)) {const content = lastContentGroup ? findGroup(tree, lastContentGroup) : nullactive = (content ?? findGroupOfPane(tree, 'workspace'))?.active}diff --git a/apps/desktop/src/store/session-sidebar-focus.test.ts b/apps/desktop/src/store/session-sidebar-focus.test.tsindex e456e4c41a3..960a904c30a 100644--- a/apps/desktop/src/store/session-sidebar-focus.test.ts+++ b/apps/desktop/src/store/session-sidebar-focus.test.ts@@ -67,6 +67,19 @@ describe('session focus while interacting with the sidebar', () => {expect($focusedStoredSessionId.get()).toBe('main')})+ it('keeps the remembered chat while Files or Terminal own focus', () => {+ const tree = $layoutTree.get()!+ $layoutTree.set(+ split('row', [tree, group(['files', 'terminal'], { active: 'files', id: 'tools' })])+ )+ const tools = target('tools')++ target('split').focus()+ tools.focus()+ expect($activeTreeGroup.get()).toBe('tools')+ expect($focusedStoredSessionId.get()).toBe('split')+ })+it('uses the visible main tab on restore and after the remembered split closes', () => {const sidebar = target('sidebar')sidebar.focus()diff --git a/apps/desktop/src/store/session-states.ts b/apps/desktop/src/store/session-states.tsindex 8fb416a9364..deed4f0b72a 100644--- a/apps/desktop/src/store/session-states.ts+++ b/apps/desktop/src/store/session-states.ts@@ -22,9 +22,8 @@ import { atom, computed } from 'nanostores'import { setSessionOwnerResolver } from '@/api/client'import { routeSessionId } from '@/app/routes'import type { ClientSessionState } from '@/app/types'-import { findGroup, findGroupOfPane, type LayoutNode } from '@/components/pane-shell/tree/model'+import { findGroupOfPane, type LayoutNode } from '@/components/pane-shell/tree/model'import {- $activeTreeGroup,$layoutTree,focusedSessionTabAnchor,isPaneVisible,@@ -3024,29 +3023,8 @@ export const $focusedSessionIsTile = computed($focusedTreePaneId, active =>Boolean(active?.startsWith(TILE_PANE_PREFIX)))-export const $focusedStoredSessionId = computed(- [$activeTreeGroup, $layoutTree, $selectedStoredSessionId],- (groupId, tree, selected) => {- const active = groupId && tree ? findGroup(tree, groupId)?.active : undefined-- if (active?.startsWith(TILE_PANE_PREFIX)) {- return active.slice(TILE_PANE_PREFIX.length)- }-- // The interaction tracker can point at sidebar or tool CHROME (files,- // terminal, sessions list, bots roster) while a chat still holds the main- // zone's active tab. In both sessions and Bot Mode, the main zone's active- // tile answers so clicks in side chrome do not drop the on-screen session.- if (tree) {- const mainActive = findGroupOfPane(tree, 'workspace')?.active-- if (mainActive?.startsWith(TILE_PANE_PREFIX)) {- return mainActive.slice(TILE_PANE_PREFIX.length)- }- }-- return selected- }+export const $focusedStoredSessionId = computed([$focusedTreePaneId, $selectedStoredSessionId], (active, selected) =>+ active?.startsWith(TILE_PANE_PREFIX) ? active.slice(TILE_PANE_PREFIX.length) : selected)/** Every session currently OPEN as a surface: the primary's selection plus