Skip to content

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

Open
huxcrux wants to merge 3 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 3 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/expand toggle to the diff panel

  • Adds a collapse/expand toggle button in each file header in DiffPanel.tsx, tracking collapsed state as a Set of file keys.
  • Collapsed files hide their code content via a new diff-file-collapsed CSS rule (display: none on <pre> and virtualizer buffer).
  • Collapse state resets when a new patch is selected; selecting a collapsed file auto-expands it and skips scroll-into-view when collapsed.
  • Extracts shared helpers (toggleCollapsedDiffFile, resetCollapsedDiffFiles, expandCollapsedDiffFileForPath, buildFileDiffRenderKey, resolveFileDiffPath) into diffPanelCollapse.ts with full Vitest coverage.
  • Behavioral Change: clicking the file header now opens the editor unless the click target is the new collapse toggle button.

Macroscope summarized 523a0b1.

@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: df0b030f-90cc-4ee8-ac90-288a4afd791f

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
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

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.

Tip

You can enable review details to help with troubleshooting, context usage and more.

Enable the reviews.review_details setting to include review details such as the model used, the time taken for each step and more in the review comments.

@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!

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

2 participants