Add collapsible sidebar and inline diff context comments#2743
Add collapsible sidebar and inline diff context comments#2743felixfong227 wants to merge 13 commits into
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.
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.
…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
…05-1003 # Conflicts: # apps/web/src/routes/__root.tsx
# Conflicts: # apps/web/src/components/ComposerPromptEditor.tsx # apps/web/src/components/DiffPanel.tsx # apps/web/src/components/chat/ChatComposer.tsx # apps/web/src/components/chat/MessagesTimeline.tsx # apps/web/src/components/chat/TraitsPicker.browser.tsx # apps/web/src/composerDraftStore.ts
- Add shared route logic for sidebar collapse eligibility - Keep the app sidebar fixed open in settings views - Remove the toggle action from the command palette when collapse is disabled
|
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 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit d4bc48a. Configure here.
| removeComposerDraftDiffContextComment, | ||
| setPrompt, | ||
| ], | ||
| ); |
There was a problem hiding this comment.
Double placeholder removal corrupts prompt with multiple comments
High Severity
removeComposerDiffContextCommentFromDraft removes the inline placeholder from the prompt via setPrompt, then calls removeComposerDraftDiffContextComment which also removes the placeholder from current.prompt inside its set() updater. Since zustand's set() is synchronous, the second action sees the already-modified prompt and removes the wrong placeholder (the next one in sequence). With 2+ comments, backspacing one comment's chip removes an extra placeholder belonging to a different comment, corrupting the prompt state.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit d4bc48a. Configure here.
|
|
||
| {isElectron && ( | ||
| <div className="drag-region flex h-[52px] shrink-0 items-center border-b border-border px-5 wco:h-[env(titlebar-area-height)] wco:pr-[calc(100vw-env(titlebar-area-width)-env(titlebar-area-x)+1em)]"> | ||
| <div className="drag-region flex h-[52px] shrink-0 items-center border-b border-border px-5 transition-[padding-left] duration-200 ease-linear wco:h-[env(titlebar-area-height)] wco:pr-[calc(100vw-env(titlebar-area-width)-env(titlebar-area-x)+1em)] group-data-[state=collapsed]/sidebar-wrapper:pl-[90px] group-data-[state=collapsed]/sidebar-wrapper:wco:pl-[calc(env(titlebar-area-x)+1em)]"> |
There was a problem hiding this comment.
Settings header gets incorrect padding when sidebar collapsed
Medium Severity
The settings header uses group-data-[state=collapsed]/sidebar-wrapper:pl-[90px], but on settings routes the sidebar renders with collapsible="none" (always visible at full width). The SidebarProvider wrapper's data-state persists as "collapsed" from a previous chat route, so the header gets 90px left padding even though the sidebar is fully visible — creating a misaligned layout with no way to fix it from the settings page.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit d4bc48a. Configure here.
ApprovabilityVerdict: Needs human review This PR introduces substantial new features (collapsible sidebar and inline diff context comments) with new UI components, state management, and cross-cutting changes. A high-severity unresolved review comment identifies a prompt corruption bug when handling multiple comments. You can customize Macroscope's approvability policy. Learn more. |


Summary
mod+bsupport, plus command-palette access to toggle it.Testing
Not runbun fmt,bun lint,bun typecheck, andbun run testwere not executed here.Note
Medium Risk
Introduces new composer/diff-panel state (persisted to storage) and new global keyboard handling for
mod+b, which could affect message sending/restoration and shortcut behavior across routes.Overview
Collapsible sidebar toggle: Adds a new
sidebar.togglecommand with defaultmod+b, integrates it into the command palette, and wires a capture-phase global shortcut handler to avoid editor conflicts; sidebar collapsing is disabled on/settingsroutes and the layout/provider wiring is adjusted to support this.Inline diff context comments: Introduces draft diff comments that can be created from diff line selections, previewed/edited in the diff view, represented as inline chips in the composer, appended as a hidden prompt context block on send, and stripped from visible prompt text/message rendering; composer draft persistence/hydration, send retry restoration (
restoreComposerSendContent), and prompt-context parsing are updated accordingly (with new unit coverage).Reviewed by Cursor Bugbot for commit d4bc48a. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add collapsible sidebar and inline diff context comments to the composer
mod+b, with acanCollapseAppSidebarguard that disables collapsing on settings routes; a 'Toggle sidebar' action is also added to the command palette.DiffContextCommentDraftas a first-class composer concept: users can select lines in the diff panel to create inline comments, which appear as chips in the composer editor and are serialized into the outgoing message as a structured<diff_context_comments>block.composerDraftStore(add, update, remove, clear, persist, restore on failed send), with prompt placeholder sync using theU+E000sentinel character.SidebarProvideris moved fromAppSidebarLayoutto the root route, changing the provider boundary for all sidebar consumers.Macroscope summarized d4bc48a.