Skip to content

Add keyboard shortcut to toggle the main sidebar#1666

Closed
nassimna wants to merge 5 commits intopingdotgg:mainfrom
nassimna:feature/sidebar-toggle-shortcut
Closed

Add keyboard shortcut to toggle the main sidebar#1666
nassimna wants to merge 5 commits intopingdotgg:mainfrom
nassimna:feature/sidebar-toggle-shortcut

Conversation

@nassimna
Copy link
Copy Markdown
Contributor

@nassimna nassimna commented Apr 1, 2026

What Changed

  • Added a new sidebar.toggle keybinding command to the shared keybinding contracts.
  • Shipped a default mod+b binding for sidebar.toggle when !terminalFocus, so it does not steal Ctrl+B / Cmd+B while the terminal is focused.
  • Handled the shortcut in the root app sidebar layout so it toggles the existing main left thread/project sidebar without affecting the diff sidebar.
  • Added contract, server, web, and browser coverage for command parsing, default binding behavior, label formatting, and sidebar toggle interaction.
  • Updated KEYBINDINGS.md to 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 !terminalFocus keeps terminal behavior predictable on Windows/Linux where Ctrl+B is commonly meaningful inside terminal sessions.

Scope

This PR is intentionally small and focused:

  • one new keybinding command
  • one default binding
  • one root-level shortcut handler for the existing left sidebar
  • matching docs and regression coverage

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+b when the terminal is not focused.

There is no visual redesign or new UI surface; the shortcut triggers the existing collapse/expand behavior.

Testing

  • bun fmt
  • bun lint
  • bun run --cwd packages/contracts typecheck
  • bun run --cwd apps/web typecheck
  • bun run --cwd apps/server typecheck

Notes

  • Repo-wide bun typecheck is currently blocked by an unrelated apps/marketing Astro/Vite rolldown export 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.toggle command to the shared keybinding contract and server defaults, shipping mod+b when !terminalFocus.

Implements a global shortcut handler in AppSidebarLayout that resolves configured keybindings (including terminal focus/open context) and calls toggleSidebar() 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 GitCore test to stub fetch during 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+b keyboard shortcut to toggle the main sidebar

  • Adds sidebar.toggle as a valid keybinding command in contracts/src/keybindings.ts and sets mod+b (when !terminalFocus) as its default in server/src/keybindings.ts.
  • Adds AppSidebarKeyboardShortcuts in AppSidebarLayout.tsx, which listens for keydown events, resolves the command against the current terminal focus/open context, and calls toggleSidebar() when matched.
  • Adds isSidebarToggleShortcut helper in web/src/keybindings.ts for detecting the shortcut in other contexts.

Macroscope summarized e4ae592.

- Register `mod+b` as `sidebar.toggle`
- Wire global handling in the web app and update shortcut helpers/tests
- Document the new default binding
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 1, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1c084b2e-ed81-4614-9a38-da7d6efb4c93

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@github-actions github-actions bot added size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Apr 1, 2026
@nassimna nassimna changed the title Add a sidebar toggle keyboard shortcut Add keyboard shortcut to toggle the main sidebar Apr 1, 2026
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp bot commented Apr 1, 2026

Approvability

Verdict: 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.

Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

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>"}`);
}
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.

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.

Fix in Cursor Fix in Web

@nassimna nassimna closed this Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant