Skip to content

feat(web): add Ctrl+Tab MRU thread switcher with glass HUD - #46124

Closed
lucas-ventura wants to merge 1 commit into
pingdotgg:mainfrom
lucas-ventura:feat/mru-thread-switcher
Closed

lucas-ventura wants to merge 1 commit into
pingdotgg:mainfrom
lucas-ventura:feat/mru-thread-switcher

Conversation

@lucas-ventura

Copy link
Copy Markdown

Problem

Switching rapidly between the two most recently used threads (or cycling back through recently visited threads across projects) currently requires stepping linearly through the sidebar (mod+shift+[ / mod+shift+]) or using numbered jumps (mod+1–9). There is no Ctrl+Tab / Ctrl+Shift+Tab most-recently-used (MRU) switcher like Arc or desktop editors provide.

Change

Adds an MRU recent-thread switcher triggered by Ctrl+Tab (thread.recentNext) and Ctrl+Shift+Tab (thread.recentPrevious):

Scope

Single focused enhancement adding Ctrl+Tab / Ctrl+Shift+Tab MRU thread switching across contracts, shared default keybindings, web switcher UI, translations, tests, and keybinding docs. (Note: this is a new feature contribution rather than a bug fix; happy to move to an Ideas discussion if preferred per CONTRIBUTING.md.)

Verification

  • Automated checks (vp run check:changed & vp run i18n:check):
    • vp format — pass (23 files)
    • vp lint — pass (0 warnings, 0 errors across 206 rules)
    • vp knip — pass
    • vp typecheck — pass across 40 packages
    • vp test — pass across 8 files / 104 tests, including:
      • RecentThreadSwitcher.logic.test.ts (6 unit tests covering MRU deduplication, ordering fallback, next/previous start indices, cyclic stepping, modifier-release handling, and timestamp resolution)
      • RecentThreadSwitcher.browser.test.tsx (3 Chromium browser tests verifying quick Ctrl+Tab toggle without HUD flash, hold-to-reveal HUD with Claude/Codex/Antigravity provider logos and commit on Ctrl release, and immediate reveal on second Tab + Escape cancel)
      • keybindings.test.ts (verifying ctrl+tab / ctrl+shift+tab resolution on desktop outside terminals, and non-matching on web or focused terminals)
    • vp react compiler — pass (6 files)
    • vp run i18n:check — pass (all catalogs match source)
  • Manual interactive verification (isolated dev server in Chromium):
    • Verified quick Ctrl+Tab toggles between the two most recent threads with no HUD flash.
    • Verified holding Ctrl+Tab reveals the glass HUD in both dark and light themes with aligned provider logos (Cursor, Claude, Codex, Antigravity), cycles forward/backward on Tab / Shift+Tab, and navigates on Ctrl release.
    • Verified Settings → Keybindings lists Thread: Next Recent (⌃ Tab) and Thread: Previous Recent (⌃ ⇧ Tab) with When: isDesktop && !terminalFocus.

Demo & Screenshots

Quick toggle & hold-to-cycle interaction

MRU thread switcher demo

Glass switcher HUD (Dark mode)

Glass switcher HUD in dark mode

Glass switcher HUD (Light mode)

Glass switcher HUD in light mode

Settings → Keybindings

Settings Keybindings showing Thread: Next Recent and Thread: Previous Recent


Written with Gemini 4 Neon in T3 Code (Antigravity harness).

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:XL 500-999 changed lines (additions + deletions). labels Nov 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR changes the test suite by +10 test cases (browser +3, unit +7, server 0).

New browser test files: apps/web/src/components/RecentThreadSwitcher.browser.test.tsx.
Each browser test file costs CI seconds of module loading before its first test runs; a unit test costs milliseconds.

Keep tests that would fail for a real reason, and test logic below the UI where it can be. See Testing.

const unsubscribeDrafts = useComposerDraftStore.subscribe(() =>
recordCurrentRouteVisit(router),
);
window.addEventListener("keyup", onKeyUp, true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium components/RecentThreadSwitcher.tsx:293

Releasing Ctrl inside a rendered HTML document never reaches this parent window keyup listener, so commitSelected() is not called and the HUD stays open instead of navigating to the selected thread. The frame bridge forwards only keydown; forward modifier keyup events to the parent or otherwise deliver the release to this listener.

Also found in 1 other location(s)

apps/web/src/components/files/BrowserDocumentFrame.tsx:75

Forwarding these commands starts a switcher session that cannot finish from the focused HTML preview. BrowserDocumentFrame replays only keydown, and the HTML bootstrap in packages/shared/src/htmlRender.ts forwards no keyup; RecentThreadSwitcher waits for the parent window's keyup to commit and never moves focus out of the iframe. Thus Ctrl+Tab inside a rendered document leaves the HUD open instead of switching when Ctrl is released (even a quick tap). Escape/Enter are not forwarded either. MDN's Element: keyup event documents that key events target the focused element and bubble to its Document/Window. Forward modifier releases as well, or transfer focus/handle these commands without a hold session.

🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/web/src/components/RecentThreadSwitcher.tsx around line 293:

Releasing Ctrl inside a rendered HTML document never reaches this parent `window` `keyup` listener, so `commitSelected()` is not called and the HUD stays open instead of navigating to the selected thread. The frame bridge forwards only `keydown`; forward modifier `keyup` events to the parent or otherwise deliver the release to this listener.

Also found in 1 other location(s):
- apps/web/src/components/files/BrowserDocumentFrame.tsx:75 -- Forwarding these commands starts a switcher session that cannot finish from the focused HTML preview. `BrowserDocumentFrame` replays only `keydown`, and the HTML bootstrap in `packages/shared/src/htmlRender.ts` forwards no `keyup`; `RecentThreadSwitcher` waits for the parent window's `keyup` to commit and never moves focus out of the iframe. Thus Ctrl+Tab inside a rendered document leaves the HUD open instead of switching when Ctrl is released (even a quick tap). Escape/Enter are not forwarded either. MDN's `Element: keyup event` documents that key events target the focused element and bubble to its Document/Window. Forward modifier releases as well, or transfer focus/handle these commands without a hold session.

environmentThreadShells.delegatedUnderParentAtom,
);
const candidates: RecentThreadCandidate[] = [];
for (const thread of shells) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium components/RecentThreadSwitcher.tsx:75

Moved handoff sources remain in the MRU candidate list, so after thread A moves to B, Ctrl+Tab can select stale A and ThreadHandoffFollower redirects back to B instead of reaching the previous distinct thread. This loop filters deleted, archived, and parented shells but not moved copies; exclude keys in movedThreadCopyKeys, matching navigationThreadShellsAtom.

🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/web/src/components/RecentThreadSwitcher.tsx around line 75:

Moved handoff sources remain in the MRU candidate list, so after thread A moves to B, `Ctrl+Tab` can select stale A and `ThreadHandoffFollower` redirects back to B instead of reaching the previous distinct thread. This loop filters deleted, archived, and parented shells but not moved copies; exclude keys in `movedThreadCopyKeys`, matching `navigationThreadShellsAtom`.

@macroscopeapp

macroscopeapp Bot commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs Human Approval

Macroscope's review found this PR requires human approval — Adds a recent-thread switcher with default desktop Ctrl+Tab shortcuts and a new line-level lint suppression, both requiring human review. Two supplied Medium findings also flag preview-frame completion and moved-thread navigation issues.

Needs human approval because:

  • 2 blocking correctness issues found at or above your repo's Minimum Blocking Severity

Adjust the Minimum Blocking Severity for this repo — including turning it Off — in Settings. You can add or adjust custom eligibility rules. Learn more.

@juliusmarminge

Copy link
Copy Markdown
Member

Thanks for this. #36480 makes the same change and is the one being kept.

#36480 already adds the same quick-toggle and hold-to-cycle Ctrl+Tab interaction. It also reuses the app’s command surface and sidebar status components, keeping thread status and environment information consistent with the rest of the app.

Your glass HUD offers a different presentation, but the underlying feature overlaps. Please bring any remaining interaction improvements to that pull request so we can review one implementation.

Closing as a duplicate.

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

Labels

size:XL 500-999 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants