Skip to content

The agent that grows with you

fix(desktop): remember the followed chat while chrome owns focus

kshitijk4poor1dfc500d88a8
diff --git a/apps/desktop/src/store/session-focus.ts b/apps/desktop/src/store/session-focus.ts
index 1f04701ef58..d6c05004f73 100644
--- a/apps/desktop/src/store/session-focus.ts
+++ b/apps/desktop/src/store/session-focus.ts
@@ -26,6 +26,17 @@ const rememberContentPane = () => {
if (!groupId || isChatPane(active)) {
$lastContentPane.set(active ?? null)
+
+ return
+ }
+
+ // Chrome owns focus: follow the remembered group when it fronts another
+ // chat (⌘1..9, drag-to-split) so a preview covering it later keeps it.
+ const last = $lastContentPane.get()
+ const content = last && tree ? findGroupOfPane(tree, last) : null
+
+ if (content && isChatPane(content.active)) {
+ $lastContentPane.set(content.active)
}
}
@@ -38,14 +49,11 @@ export const $focusedTreePaneId = computed(
let active = groupId && tree ? findGroup(tree, groupId)?.active : undefined
if (groupId && tree && !isChatPane(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
+ // Keep the remembered chat while chrome or a preview covers it.
+ active =
+ lastContentPane && findGroupOfPane(tree, lastContentPane)
+ ? lastContentPane
+ : findGroupOfPane(tree, 'workspace')?.active
}
if (active?.startsWith(TILE_PANE_PREFIX)) {
diff --git a/apps/desktop/src/store/session-sidebar-focus.test.ts b/apps/desktop/src/store/session-sidebar-focus.test.ts
index a8df42a8227..f9438f2f27a 100644
--- a/apps/desktop/src/store/session-sidebar-focus.test.ts
+++ b/apps/desktop/src/store/session-sidebar-focus.test.ts
@@ -91,6 +91,20 @@ describe('session focus while interacting with the sidebar', () => {
])
)
expect($focusedStoredSessionId.get()).toBe('other')
+
+ // A preview later covering the followed chat keeps it, not the stale remembered tile.
+ $layoutTree.set(
+ split('row', [
+ group(['sessions'], { active: 'sessions', id: 'sidebar' }),
+ group(['workspace', pane('main')], { active: pane('main'), id: 'main' }),
+ group([pane('split'), pane('other'), 'preview-tile:file:test'], {
+ active: 'preview-tile:file:test',
+ 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', () => {