Skip to content

Add collapsible sidebar and inline diff context comments#2743

Closed
felixfong227 wants to merge 13 commits into
pingdotgg:mainfrom
felixfong227:felix/integrate-pr-2305-1003
Closed

Add collapsible sidebar and inline diff context comments#2743
felixfong227 wants to merge 13 commits into
pingdotgg:mainfrom
felixfong227:felix/integrate-pr-2305-1003

Conversation

@felixfong227
Copy link
Copy Markdown

@felixfong227 felixfong227 commented May 17, 2026

Summary

  • Add a collapsible thread sidebar with mod+b support, plus command-palette access to toggle it.
  • Hide sidebar controls on settings routes so the layout stays fixed where collapsing is not allowed.
  • Introduce inline diff context comment drafting and rendering in the composer, including retry/restoration handling and send-state stripping.
  • Tighten diff panel comment hydration, memoization, and line-range normalization so draft comments render consistently.
  • Update keybinding contracts and docs for the new sidebar toggle command.

Testing

  • Not run
  • Added/updated unit coverage for sidebar collapse gating, command palette send-state stripping, diff context comment helpers, composer draft persistence, and diff panel logic.
  • No full repo validation was run in this turn; bun fmt, bun lint, bun typecheck, and bun run test were 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.toggle command with default mod+b, integrates it into the command palette, and wires a capture-phase global shortcut handler to avoid editor conflicts; sidebar collapsing is disabled on /settings routes 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

  • Adds a collapsible sidebar controlled by mod+b, with a canCollapseAppSidebar guard that disables collapsing on settings routes; a 'Toggle sidebar' action is also added to the command palette.
  • Introduces DiffContextCommentDraft as 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.
  • Adds full lifecycle management for diff context comments in composerDraftStore (add, update, remove, clear, persist, restore on failed send), with prompt placeholder sync using the U+E000 sentinel character.
  • Sent messages now render diff context comment chips inline in the messages timeline alongside the prompt text.
  • Risk: SidebarProvider is moved from AppSidebarLayout to the root route, changing the provider boundary for all sidebar consumers.

Macroscope summarized d4bc48a.

maskdotdev and others added 13 commits April 22, 2026 16:06
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
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 17, 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: 33fe6a1d-3e14-43c0-8450-32f9c7164015

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:XXL 1,000+ changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels May 17, 2026
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 2 potential issues.

Fix All in Cursor

❌ 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,
],
);
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.

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)
Fix in Cursor Fix in Web

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)]">
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.

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit d4bc48a. Configure here.

@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented May 17, 2026

Approvability

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL 1,000+ 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.

3 participants