Add keyboard shortcut to toggle the main sidebar#1666
Add keyboard shortcut to toggle the main sidebar#1666nassimna wants to merge 5 commits intopingdotgg:mainfrom
Conversation
- Register `mod+b` as `sidebar.toggle` - Wire global handling in the web app and update shortcut helpers/tests - Document the new default binding
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
ApprovabilityVerdict: Needs human review This PR introduces a new keyboard shortcut (mod+b) to toggle the main sidebar, which is new user-facing behavior. While the implementation is well-scoped, uses existing keybinding infrastructure, and includes comprehensive tests, the addition of a new keyboard shortcut warrants a quick human review. The open comment about test reliability is low-severity and affects only test code. You can customize Macroscope's approvability policy. Learn more. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| } | ||
|
|
||
| throw new Error(`${errorMessage} Last state: ${sidebarRoot.dataset.state ?? "<missing>"}`); | ||
| } |
There was a problem hiding this comment.
Toggle retry loop may oscillate and never converge
Low Severity
triggerSidebarToggleShortcutUntilState dispatches a toggle shortcut on every loop iteration. Unlike the triggerChatNewShortcutUntilPath pattern it was modeled after (where each dispatch cumulatively creates a new thread), each sidebar toggle dispatch reverses the previous one. If the state check after waitForLayout ever misses the updated DOM state due to a rendering delay, the next iteration dispatches another toggle, flipping the sidebar back — creating an oscillation that can never converge to the target state and will time out after 8 seconds.


What Changed
sidebar.togglekeybinding command to the shared keybinding contracts.mod+bbinding forsidebar.togglewhen!terminalFocus, so it does not stealCtrl+B/Cmd+Bwhile the terminal is focused.KEYBINDINGS.mdto document the new command and default binding.Why
The app already has first-class keyboard support for terminal actions, diff toggling, and sidebar thread navigation, but the main left sidebar itself did not have a built-in keyboard toggle.
This change keeps the implementation inside the existing keybinding system instead of adding a one-off listener path, and it follows the same conditional shortcut model already used elsewhere in the app. Scoping the default binding to
!terminalFocuskeeps terminal behavior predictable on Windows/Linux whereCtrl+Bis commonly meaningful inside terminal sessions.Scope
This PR is intentionally small and focused:
It does not change the diff sidebar behavior, add new settings UI, or alter existing keybinding precedence rules.
UI Changes
This is an interaction-only UI change.
Before: the main left sidebar could only be toggled through the existing UI controls.
After: the same sidebar can also be toggled with
mod+bwhen the terminal is not focused.There is no visual redesign or new UI surface; the shortcut triggers the existing collapse/expand behavior.
Testing
bun fmtbun lintbun run --cwd packages/contracts typecheckbun run --cwd apps/web typecheckbun run --cwd apps/server typecheckNotes
bun typecheckis currently blocked by an unrelatedapps/marketingAstro/Viterolldownexport error in this environment.Note
Low Risk
Low risk: introduces one new keybinding command and a scoped global keydown handler, plus doc/test updates; functional impact is limited to sidebar toggling and keybinding resolution.
Overview
Adds a new
sidebar.togglecommand to the shared keybinding contract and server defaults, shippingmod+bwhen!terminalFocus.Implements a global shortcut handler in
AppSidebarLayoutthat resolves configured keybindings (including terminal focus/open context) and callstoggleSidebar()to collapse/expand the main left sidebar.Updates documentation and expands contract/server/web/browser tests to cover parsing, default binding/labels, shortcut matching, and end-to-end sidebar toggle behavior; also adjusts a
GitCoretest to stubfetchduring a remote-name-with-slashes checkout scenario.Written by Cursor Bugbot for commit e4ae592. This will update automatically on new commits. Configure here.
Note
Add
mod+bkeyboard shortcut to toggle the main sidebarsidebar.toggleas a valid keybinding command in contracts/src/keybindings.ts and setsmod+b(when!terminalFocus) as its default in server/src/keybindings.ts.AppSidebarKeyboardShortcutsin AppSidebarLayout.tsx, which listens forkeydownevents, resolves the command against the current terminal focus/open context, and callstoggleSidebar()when matched.isSidebarToggleShortcuthelper in web/src/keybindings.ts for detecting the shortcut in other contexts.Macroscope summarized e4ae592.