Skip to content

feat(sidebar): add Mod+B keybinding to toggle sidebar#153

Open
sak0a wants to merge 1 commit into
mainfrom
feature/port-3497-sidebar-toggle
Open

feat(sidebar): add Mod+B keybinding to toggle sidebar#153
sak0a wants to merge 1 commit into
mainfrom
feature/port-3497-sidebar-toggle

Conversation

@sak0a

@sak0a sak0a commented Jun 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds sidebar.toggle command mapped to Mod+B (⌘B on Mac, Ctrl+B on other platforms)
  • Implements global shortcut handler at the SidebarProvider level so toggle works across all routes
  • Persists sidebar open/closed state to cookie (sidebar_state) for retention across reloads
  • Updates SidebarTrigger visibility to respect sidebar state via data-state attribute
  • Adds new Sidebar keybinding category in settings (between Command Palette and Chat)
  • Includes comprehensive tests for shortcut resolution and label generation

Testing

  • ✅ Keybinding test verifies Mod+B resolves to sidebar.toggle when terminal not focused
  • ✅ Keybinding test verifies Mod+B is ignored when terminal is focused
  • ✅ Label generation test confirms shortcut displays as ⌘B on Mac, Ctrl+B on other platforms
  • Manual: Test toggle works in chat view
  • Manual: Test toggle works in settings view
  • Manual: Test toggle works in no-active-thread state
  • Manual: Verify sidebar state persists across page reload
  • Manual: Verify Mod+B doesn't toggle sidebar when typing in composer

Ports upstream t3code pingdotgg#3497. ryco already has a collapsible main sidebar
(shadcn SidebarProvider with offcanvas collapse + SidebarRail), so this
adds the missing pieces: a keybinding, persistence, and a desktop reopen
affordance when collapsed.

- contracts: register sidebar.toggle command; shared: default it to Mod+B
  (when !terminalFocus, distinct from existing bindings). Flows through
  the server keybinding seed and the settings keybindings UI.
- AppSidebarLayout hosts a global handler inside SidebarProvider so the
  toggle works on every route (chat, settings, no-active-thread), not
  just the chat view. It resolves the configured command and ignores the
  shortcut while typing (so Mod+B can still bold in the composer).
- Persist collapsed state: read the sidebar_state cookie the provider
  already writes to seed defaultOpen on reload.
- Expose data-state on the sidebar wrapper and reveal the existing header
  SidebarTriggers on desktop when collapsed, so there is a reopen control
  without the sidebar rail (which is offscreen when collapsed).
- keybindingCategories: add a Sidebar category + 'Toggle sidebar' label.
- Tests: resolve/label Mod+B -> sidebar.toggle (web), fixture updated.

Adapted to ryco's keybinding registry and shadcn sidebar; did not port
upstream's titlebar/traffic-light inset polish (ryco's layout differs).
@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@sak0a, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 59 minutes and 38 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a2747075-6ec8-4ee3-9c96-f64c239bcf60

📥 Commits

Reviewing files that changed from the base of the PR and between a68d236 and d56c535.

📒 Files selected for processing (10)
  • apps/web/src/components/AppSidebarLayout.tsx
  • apps/web/src/components/NoActiveThreadState.tsx
  • apps/web/src/components/chat/ChatHeader.tsx
  • apps/web/src/components/ui/sidebar.tsx
  • apps/web/src/keybindings.test.ts
  • apps/web/src/lib/keybindingCategories.ts
  • apps/web/src/routes/_chat.index.tsx
  • apps/web/src/routes/_settings.diagnostics.tsx
  • packages/contracts/src/keybindings.ts
  • packages/shared/src/keybindings.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/port-3497-sidebar-toggle

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.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M labels Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant