Skip to content

fix(browser): unstick Ctrl+Tab switcher when opened from a focused browser guest - #9966

Merged
nwparker merged 1 commit into
stablyai:mainfrom
Fazalkadivar21:fix/switch-tab
Jul 24, 2026
Merged

nwparker merged 1 commit into
stablyai:mainfrom
Fazalkadivar21:fix/switch-tab

Conversation

@Fazalkadivar21

@Fazalkadivar21 Fazalkadivar21 commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes the in-app browser's Ctrl+Tab tab switcher, which opened the MRU overlay but never committed or closed it, leaving it stranded on screen.

ELI5

When you pressed Ctrl+Tab inside the built-in browser, the "switch tab" popup would appear and then get stuck open. Now it closes and switches tabs the way it should.

Root cause & fix

In setupGuestShortcutForwarding (src/main/browser/browser-guest-ui.ts), the recent-tab-switcher chord handler called event.preventDefault() on the Ctrl+Tab keydown. In Electron, calling preventDefault() on the Tab keydown suppresses the subsequent Control keyup, so the overlay never received its commit keyup and stayed open. The fix removes preventDefault() from the keydown path (the commit keyup path still calls it), matching the existing main-window behavior in createMainWindow.ts.

Evidence

Validated & rebased onto latest main during a bug-bash triage on 2026-07-23.

  • Test files: src/main/browser/browser-guest-ui.test.ts, src/main/browser/browser-manager.test.ts
  • On branch (fix present): 2 files passed, 79 tests passed.
  • Fix reverted (test kept): 2 tests fail at browser-guest-ui.test.ts:502 and browser-manager.test.ts:2602, both asserting expect(keyDownPreventDefault).not.toHaveBeenCalled().
  • Lint clean: npx oxlint src/main/browser/browser-guest-ui.ts reports no findings.
On branch (fix present):
  Test Files  2 passed (2)
  Tests  79 passed (79)

Fix reverted, tests kept:
  Test Files  2 failed (2)
  Tests  2 failed | 77 passed (79)
  - browser-guest-ui.test.ts:502  expect(keyDownPreventDefault).not.toHaveBeenCalled()
      -> expected not to be called, but called 1 time
  - browser-manager.test.ts:2602  expect(keyDownPreventDefault).not.toHaveBeenCalled()
      -> expected not to be called, but called 1 time

Trade-offs

None — pure fix.

Regression risk

Zero-regression: only the guest Ctrl+Tab keydown branch changes by dropping one preventDefault() call; the commit keyup path and all other input forwarding remain byte-identical, and the two updated unit tests prove both the fixed behavior and its absence when reverted.

Credit to original author @Fazalkadivar21. Validated, rebased, and (where applicable) hardened via automated bug-bash review; original fix design preserved.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Updated Ctrl+Tab guest shortcut handling so the initial keydown no longer calls preventDefault. The switching state update and renderer keydown message remain unchanged, and tests now assert that keydown does not prevent the default while preserving existing keyup expectations.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change well, but it omits required template sections like Screenshots, Testing, AI Review Report, Security Audit, and Notes. Add the missing template sections, including screenshots or 'No visual change', a testing checklist, AI review report, security audit, and notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main fix: preventing the Ctrl+Tab switcher from getting stuck in a browser guest.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Electron suppresses guest keyups after a prevented Ctrl+Tab keydown, so the
MRU switcher never received ui:ctrlTabKeyUp and stayed stuck open (stablyai#9937).
Match the main-window path: forward the chord without preventDefault.

Co-authored-by: Cursor <[email protected]>
@nwparker
nwparker merged commit 34caad7 into stablyai:main Jul 24, 2026
@nwparker

Copy link
Copy Markdown
Contributor

Thanks so much for this, @Fazalkadivar21 — unstick Ctrl+Tab switcher when opened from a focused browser guest. Reviewed, rebased on latest main, and merged. Really appreciate the contribution! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants