feat: expandable diff context in code review#247
Merged
backnotprop merged 3 commits intomainfrom Mar 8, 2026
Merged
Conversation
Switch from PatchDiff to FileDiff component from @pierre/diffs to enable GitHub-style "show more lines" buttons between hunks. The library handles all expansion UI when provided full file contents via oldLines/newLines. - Add /api/file-content endpoint to serve old/new file content per diff type - Add getFileContentsForDiff() helper with ref mapping for all diff types - Parse patch client-side via getSingularPatch(), augment with file contents - Update @pierre/diffs from 1.0.4 to 1.0.11 (scroll sync fix, no breaking changes) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…tents The previous approach spread file content arrays onto a partial-mode FileDiffMetadata, causing hunk index mismatches and Shiki decoration errors. Now uses processFile() to re-parse the patch with oldFile/newFile so hunk indices are computed against the full file (isPartial: false), which is required for expansion to work correctly. Also fixes a flash error on file switch by tagging fileContents with the filePath they were fetched for, preventing stale contents from being paired with the wrong patch during the render before useEffect fires. - Upgrade @pierre/diffs from ^1.0.x to ^1.1.0-beta.19 in all workspaces - Add test fixtures for disjoint hunks, deleted/renamed/new files Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Owner
Author
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
- Add AbortController to file-content fetch effect to cancel in-flight requests when switching files - Reject path traversal (.. or absolute paths) on /api/file-content - Document /api/file-content endpoint in CLAUDE.md Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PatchDifftoFileDiffcomponent from@pierre/diffsto enable GitHub-style expandable context between diff hunks/api/file-contentserver endpoint that serves old/new file content based on the active diff type (uncommitted, staged, last-commit, branch, worktree)FileDiffMetadatawitholdLines/newLines, unlocking the library's built-in expansion UI@pierre/diffsfrom 1.0.4 → 1.0.11 (scroll sync fix for unified mode, no breaking changes)Closes #243
Test plan
bun run dev:review— demo mode renders identically (no expansion, graceful fallback since/api/file-content404s)bun run build:hook && ~/.local/bin/plannotator reviewfrom a repo with changes:🤖 Generated with Claude Code