Skip to content

feat(diff-panel): add per-file collapse toggle in diff panel#1125

Open
huxcrux wants to merge 5 commits intopingdotgg:mainfrom
huxcrux:feature/diff-panel-collapse-chevron-up
Open

feat(diff-panel): add per-file collapse toggle in diff panel#1125
huxcrux wants to merge 5 commits intopingdotgg:mainfrom
huxcrux:feature/diff-panel-collapse-chevron-up

Conversation

@huxcrux
Copy link
Contributor

@huxcrux huxcrux commented Mar 15, 2026

What Changed

Adds a per-file collapse toggle in the diff panel. Each file still starts expanded by default, but users can now collapse an individual file body from the existing diff header and expand it again inline.

The change keeps the current diff rendering flow intact, preserves click-to-open behavior for file headers, and auto-expands a targeted file when the UI deep-links to a specific diff file in the diff panel.

Fixes: #1122

Why

Large diffs in the diff panel are harder to scan when every file stays open at once. This adds a minimal control to reduce visual noise without introducing a broader diff panel redesign or changing the existing diff data flow.

UI Changes

Before:
image

After:
image
image

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Add per-file collapse toggle to the diff panel

  • Each file header in the diff panel now shows a chevron toggle button that collapses or expands the file's diff body, hiding content via the diff-file-collapsed CSS class.
  • Collapse state is managed with a Set of file keys via helpers in diffPanelCollapse.ts; selecting a file auto-expands it if collapsed and defers scroll until after expansion.
  • Header clicks still open the file in the editor unless the click target is the collapse toggle (data-diff-collapse-toggle).
  • Collapse state resets when the patch changes.

Macroscope summarized 4948c41.


Note

Low Risk
Low risk UI-only change that adds per-file collapsed state and some scroll/selection side effects; potential issues are limited to diff panel interaction quirks (collapse/expand, auto-scroll) rather than data or security.

Overview
Adds a per-file collapse/expand control to the diff panel by injecting a chevron button into each FileDiff header and hiding the file body when collapsed via a new diff-file-collapsed CSS rule.

Introduces diffPanelCollapse helpers (with tests) to compute stable file keys, toggle/reset collapsed state, and auto-expand a deep-linked diffFilePath; the panel resets collapse state when the selected patch changes and avoids opening files-in-editor when the collapse button is clicked.

Written by Cursor Bugbot for commit 4948c41. This will update automatically on new commits. Configure here.

@coderabbitai
Copy link

coderabbitai bot commented Mar 15, 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: 08cdf023-5a3b-42fb-90a7-cc05e53b3f1f

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:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Mar 15, 2026
@huxcrux huxcrux mentioned this pull request Mar 15, 2026
3 tasks
@binbandit
Copy link
Contributor

Nice one!

@EverythingSuckz
Copy link

bump

@huxcrux huxcrux force-pushed the feature/diff-panel-collapse-chevron-up branch from 3cf4a31 to 25d9f15 Compare March 24, 2026 17:38
Copy link
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.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

@huxcrux huxcrux marked this pull request as draft March 24, 2026 22:03
@huxcrux huxcrux marked this pull request as ready for review March 24, 2026 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 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.

[Feature]: Add collapsible diff

3 participants