Skip to content

Commit 79f82e8

Browse files
committed
fix(desktop): ignore browser shortcuts and mouse buttons before any chat opens a browser
1 parent f98d129 commit 79f82e8

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

‎apps/desktop/src/main/browser-agent/session.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,13 @@ describe('browser-agent session', () => {
352352
session = freshSession(win)
353353
})
354354

355+
it('ignores browser shortcuts and mouse buttons before any chat has opened a browser', () => {
356+
session.disposeBrowserScope('chat-test')
357+
358+
expect(session.handleFocusedShortcut('back', win)).toBe(false)
359+
expect(session.handleFocusedShortcut('close-tab', win)).toBe(false)
360+
})
361+
355362
it('invalidates only top-frame starts and identifies same-document commits', () => {
356363
const onTabNavigated = vi.fn()
357364
session = freshSession(win, { onTabNavigated })

‎apps/desktop/src/main/browser-agent/session.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3809,6 +3809,8 @@ export function handleFocusedShortcut(
38093809
shortcut: FocusedResourceShortcut,
38103810
ownerWindow?: BrowserWindow | null
38113811
): boolean {
3812+
// Accelerators and mouse buttons arrive before any chat has opened a browser.
3813+
if (!getActiveBrowserScopeId()) return false
38123814
// Tab-management accelerators belong to the visible Browser even after
38133815
// focus moves into Sim chrome. Otherwise Cmd-T/L/Shift-T silently stop
38143816
// behaving like browser shortcuts, and Cmd-W becomes especially unsafe.

0 commit comments

Comments
 (0)