feat: collapsible sidebar#2305
Conversation
Adds a `sidebar.toggle` keybinding command so users can collapse and re-expand the thread sidebar to focus on the active chat, addressing pingdotgg#2282. The default shortcut is `mod+b` and is gated on `!terminalFocus` so it doesn't interfere with shell shortcuts. - Contract: register `sidebar.toggle` as a static keybinding command. - Server: add the default rule so it gets backfilled into the user's keybindings.json on startup. - Web: lift `SidebarProvider` to the root so both the command palette and the global keydown handler in `_chat.tsx` can call `useSidebar().toggleSidebar()`. Expose sidebar state via `data-state` on the wrapper so header chrome can react without calling `useSidebar()`. - Palette: add a "Toggle sidebar" action with the bound shortcut hint. - Chrome: reserve 90px padding-left on the Electron drag-region headers when the sidebar is collapsed, so the macOS traffic lights don't overlap the active title; animate the padding to match the sidebar's width transition. - Tests + docs updated.
Lexical's core keydown handler claims mod+b for the bold formatting command and calls preventDefault, even under PlainTextPlugin. The existing `event.defaultPrevented` guard in the global chat shortcut handler then dropped the sidebar toggle before we could act. Move sidebar.toggle into its own effect bound on the capture phase so we see the event before Lexical does, and stopPropagation to keep it from reaching the editor. Other shortcuts (chat.new, chat.newLocal) stay on the bubble-phase listener since Lexical doesn't intercept their keys.
|
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 |
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.
Reviewed by Cursor Bugbot for commit 92c64f5. Configure here.
ApprovabilityVerdict: Needs human review This PR introduces a new user-facing feature allowing users to collapse/expand the sidebar via mod+b shortcut. While well-implemented with tests, new UI capabilities warrant human review to ensure the behavior meets product expectations. You can customize Macroscope's approvability policy. Learn more. |
The bubble-phase handler in ChatRouteGlobalShortcuts already bails out when useCommandPaletteStore.getState().open is true. The new capture-phase listener for sidebar.toggle was missing that guard, so mod+b would collapse the sidebar behind the open dialog. Flagged by Cursor Bugbot on PR pingdotgg#2305.
|
@juliusmarminge Do I need to authenticate with Vercel or is it something that needs approval? |
|
For someone who doesn't use T3 on fullscreen, this is very usefull! |
…debar # Conflicts: # apps/web/src/components/AppSidebarLayout.tsx # apps/web/src/components/ChatView.tsx
# Conflicts: # apps/server/src/keybindings.ts # apps/web/src/components/CommandPalette.tsx # apps/web/src/routes/__root.tsx
|
@basmilius is attempting to deploy a commit to the Ping Labs Team on Vercel. A member of the Team first needs to authorize it. |

What Changed
sidebar.togglekeybinding command bound tomod+bby default, gated onwhen: "!terminalFocus"so it stays out of the way inside the terminal drawer.SidebarProviderto the root layout so both the palette and the global chat shortcut handler can calluseSidebar().toggleSidebar().data-stateon the sidebar wrapper so chrome can react withgroup-data-*classes instead of reading the context everywhere.ChatView,NoActiveThreadState, settings) reservepl-[90px]when the sidebar is collapsed so the macOS traffic lights don't overlap the active title. Windows/Linux fall through to the existingwco:overrides. The padding transitions at the sameduration-200 ease-linearas the sidebar width, so it slides in sync.onKeyDownclaimsmod+bfor the bold command and callspreventDefault, which would trip theevent.defaultPreventedguard in the shared handler.apps/web/src/keybindings.test.ts,apps/server/src/keybindings.test.tsdefaults, andKEYBINDINGS.md.Why
Closes #2282. The thread sidebar was always visible, which made it hard to fully focus on the active chat. A toggle is the smallest useful change that enables focus mode while keeping thread switching (
mod+1..9,mod+shift+[/]) available even when the sidebar is collapsed — those listeners live onwindowinSidebar.tsxand the sidebar DOM stays mounted undercollapsible="offcanvas", so nothing extra was needed to satisfy that requirement from the issue.Reusing the existing
SidebarProvider/useSidebar()/ cookie persistence already shipped inui/sidebar.tsxkept the diff small and means sidebar state still survives reloads.UI Changes
Video attached showing open → collapsed → open with
mod+b, thread switching while collapsed, and the animated header padding on macOS so the traffic lights aren't covered.Schermopname.2026-04-23.om.12.20.58.mov
Checklist
Note
Medium Risk
Introduces a new global shortcut (
mod+b) and capture-phase keydown handler to toggle the sidebar, which can affect keyboard event precedence and editor behavior. Also changes layout/provider wiring and Electron header padding based on sidebar state, with moderate UI regression risk.Overview
Adds a new
sidebar.togglecommand (defaultmod+bwhen!terminalFocus) and surfaces it as a Toggle sidebar action in the command palette.Moves
SidebarProviderto the authenticated root so both the command palette and chat route global shortcuts can calluseSidebar().toggleSidebar(), and exposes sidebar state viadata-stateon the sidebar wrapper for styling.Updates Electron drag-region headers (chat, empty state, settings) to adjust left padding with a transition when the sidebar is collapsed, and adds tests/docs for the new default binding (including a capture-phase handler so the toggle wins over in-editor
mod+b).Reviewed by Cursor Bugbot for commit 8f620b9. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add collapsible sidebar with
mod+bkeyboard shortcutsidebar.togglecommand bound tomod+b(when not in terminal focus) as a default keybinding in shared/src/keybindings.ts and registered in the keybindings contract.SidebarProviderfromAppSidebarLayoutup to the root route soCommandPaletteand the global shortcut handler can both access sidebar context.mod+bbefore Lexical's bold handler can claim it.data-stateon the sidebar wrapper div, allowingChatViewandNoActiveThreadStateheaders to animate left-padding on collapse via CSS group selectors.sidebar.toggleshortcut.Macroscope summarized 8f620b9.