Skip to content

The agent that grows with you

fix(desktop): follow the content group's chat while chrome owns focus

kshitijk4poorfeecf5776b0f
diff --git a/apps/desktop/src/store/session-focus.ts b/apps/desktop/src/store/session-focus.ts
index 9454b9b04f9..d864ddba1de 100644
--- a/apps/desktop/src/store/session-focus.ts
+++ b/apps/desktop/src/store/session-focus.ts
@@ -36,10 +36,14 @@ export const $focusedTreePaneId = computed(
let active = groupId && tree ? findGroup(tree, groupId)?.active : undefined
if (groupId && tree && !isChatPane(active)) {
- active =
- lastContentPane && findGroupOfPane(tree, lastContentPane)
- ? lastContentPane
- : findGroupOfPane(tree, 'workspace')?.active
+ // Follow the remembered pane's group when it fronts another chat
+ // (⌘1..9, drag-to-split); keep the pane while a preview covers it.
+ const content = lastContentPane ? findGroupOfPane(tree, lastContentPane) : null
+ active = content
+ ? isChatPane(content.active)
+ ? content.active
+ : lastContentPane!
+ : findGroupOfPane(tree, 'workspace')?.active
}
if (active?.startsWith('session-tile:')) {
diff --git a/apps/desktop/src/store/session-sidebar-focus.test.ts b/apps/desktop/src/store/session-sidebar-focus.test.ts
index 497f8248235..a8df42a8227 100644
--- a/apps/desktop/src/store/session-sidebar-focus.test.ts
+++ b/apps/desktop/src/store/session-sidebar-focus.test.ts
@@ -80,6 +80,17 @@ describe('session focus while interacting with the sidebar', () => {
tools.focus()
expect($activeTreeGroup.get()).toBe('tools')
expect($focusedStoredSessionId.get()).toBe('split')
+
+ // The remembered group fronting another chat while chrome owns focus (⌘1..9, drag-to-split) is followed.
+ $layoutTree.set(
+ split('row', [
+ group(['sessions'], { active: 'sessions', id: 'sidebar' }),
+ group(['workspace', pane('main')], { active: pane('main'), id: 'main' }),
+ group([pane('split'), pane('other')], { active: pane('other'), id: 'split' }),
+ group(['files', 'terminal'], { active: 'files', id: 'tools' })
+ ])
+ )
+ expect($focusedStoredSessionId.get()).toBe('other')
})
it('retains the chat when a preview replaces its active tab in the same group', () => {