feat(web): navigate back and forward with mod+[ and mod+] #13212
main fromrefs/pull/13212/head·merged by juliusmarminge View on GitHubThere was no keyboard way to go back to the page you just left, such as returning to the previous thread after following a link or leaving Settings.
This adds two rebindable commands, navigation.back and navigation.forward, bound to mod+[ and mod+] by default. They step through the app's route history the same way a browser's back and forward buttons do. The defaults include !terminalFocus, so terminals still receive the keys. The server's startup backfill adds the new defaults for existing users unless the shortcut is already taken. Both commands appear in Settings → Keybindings as "Navigation: Back" and "Navigation: Forward".
Surfaces:
- Web and desktop: handled once in
AppSidebarLayout, so every route gets it. - Mobile: not affected. It has its own hardware-keyboard
backcommand.
Tested with a new resolver test covering both keys and the terminal-focus exclusion, plus the existing keybinding tests for contracts, server, and settings.
Opus 5.5 via Claude Code in T3 Code
🤖 Generated with Claude Code
Summary by CodeRabbit#
- New Features
- Added
Mod+[andMod+]shortcuts to navigate backward and forward through browsing history. - The shortcuts are inactive while the terminal is focused and account for the current page and other focus states.
- Added
- Documentation
- Documented the navigation history shortcuts in the keyboard shortcut guide.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- apps/web/src/components/AppSidebarLayout.tsx line 174Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -147,3 +148,17 @@147148 );148149 }149150151+// Moves through the app's route history like a browser's back/forward buttons.152+function NavigationHistoryShortcuts() {153+ const keybindings = useAtomValue(primaryServerKeybindingsAtom);154+155+ useEffect(() => {156+ const onKeyDown = (event: KeyboardEvent) => {157+ if (event.defaultPrevented) return;158+ if (159+ event.target instanceof HTMLElement &&160+ event.target.closest("[data-keybinding-capture]")161+ ) {162+ return;163+ }164+ const command = resolveShortcutCommand(event, keybindings, {
🟡 Medium
components/AppSidebarLayout.tsx:164NavigationHistoryShortcutsevaluateswhenclauses with onlyterminalFocus, so bindings such asnavigation.backwithwhen: previewFocusnever fire in the preview andwhen: !previewFocusincorrectly matches there. Pass the complete shortcut context toresolveShortcutCommand, includingpreviewFocusand the other documented context flags.No longer relevant as of 150ed615675e0d8f0f9c3c10f5776d7b1103c5e1
Fixed in 150ed615675: the handler now passes terminalFocus, previewFocus, editableFocus and modelPickerOpen. terminalOpen/previewOpen are thread-scoped and not known at the layout level, so rules using them resolve as false here.
previewFocusis now covered, but the context is still incomplete: custom navigation bindings usingterminalOpenorpreviewOpenwill incorrectly evaluate those flags as false while the corresponding panel is open. Please provide their actual state as well.Fixed in edc68b9f7e6: terminalOpen and previewOpen are now read from the stores for the routed thread at keypress time (getState, so no extra re-renders). The context now matches the chat route's global shortcuts.
Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Provider Metric Main baseline This PR Impact PR ceiling Codex Total thread wire 13.5 KiB 13.5 KiB +1 B (+0.0%) 15.1 KiB ✅ Codex Thread snapshot wire 7.0 KiB 7.1 KiB +5 B (+0.1%) 7.3 KiB ✅ Codex Live turn WebSocket wire 6.4 KiB 6.4 KiB −4 B (−0.1%) 7.8 KiB ✅ Codex Live turn WebSocket decoded 56.2 KiB 56.2 KiB 0 B (0.0%) 66.4 KiB ✅ Codex Live turn messages 9 9 0 (0.0%) 21 ✅ Claude Total thread wire 13.5 KiB 13.5 KiB −4 B (−0.0%) 15.1 KiB ✅ Claude Thread snapshot wire 7.1 KiB 7.1 KiB +7 B (+0.1%) 7.3 KiB ✅ Claude Live turn WebSocket wire 6.4 KiB 6.4 KiB −11 B (−0.2%) 7.8 KiB ✅ Claude Live turn WebSocket decoded 57.0 KiB 57.0 KiB 0 B (0.0%) 66.4 KiB ✅ Claude Live turn messages 9 9 0 (0.0%) 21 ✅ Baseline:
23c7ab9· PR result:edc68b9· Source CI: successScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
- Codex decoded thread snapshot: 114.0 KiB
- Claude decoded thread snapshot: 114.6 KiB
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.
Approvability#
Verdict: Not approved
Macroscope's review found this PR not approvable — The PR adds globally handled history navigation and changes shared default keybindings, including startup backfill for existing configurations. This product-default change and app-wide behavior warrant human review.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).Navigate logical layers of code changes, visualize relationships, and explore their blast radius.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml
Review profile: CHILL
Plan: Team
Run ID:
20f67cdc-4d8c-4bc6-87e1-69c92a85ae92📥 Commits
Reviewing files that changed from the base of the PR and between 5c75eb293d5fdf82a8256efa71a3d5dc7c108975 and edc68b9f7e60e468c653104a621b5174db8b6bd2.
📒 Files selected for processing (1)
apps/web/src/components/AppSidebarLayout.tsx
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
📝 Walkthrough
Walkthrough#
The change adds default keyboard shortcuts for browser back and forward navigation. The sidebar listener supplies terminal, preview, editable-focus, model-picker, and thread-route context to shortcut resolution. It re-registers when the keybindings or route reference changes.
Changes#
Navigation shortcuts
Layer / File(s) Summary Navigation commands and defaults
packages/contracts/src/keybindings.ts,packages/shared/src/keybindings.ts,apps/web/src/keybindings.test.ts,docs/user/keybindings.mdAdds static commands and default shortcuts for back and forward navigation. Tests cover platform mappings and terminal focus. Documentation lists the shortcuts. Shortcut resolution context
apps/web/src/components/AppSidebarLayout.tsxProvides route-specific focus and visibility state to shortcut resolution. The keydown listener is re-registered when the keybindings or thread route reference changes. Priority: ⬇️ Low
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Feature
Suggested reviewers:
maria-rcksMerge Risk: ⚪ Minimal · up to
edc68The navigation shortcuts are mergeable after normal checks; no actionable issue is established by the available evidence.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
Check name Status Explanation Resolution Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold. ✅ Passed checks (4 passed)
Check name Status Explanation Title check ✅ Passed The title clearly and concisely describes the main change: adding back and forward navigation shortcuts using mod+[ and mod+]. Description check ✅ Passed The description explains what changed, why it changed, affected surfaces, platform scope, defaults, testing, and generated keybinding behavior. It does not use the template headings or include the che… 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. - Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
- Commit to this branch
- Create a new PR
Comment `@coderabbitai help` to get the list of available commands.juliusmarminge merged this829af7b
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed