Fix file rename and deletion display in diff review#75
Open
Conversation
For new/deleted files the diff parser's lookahead skips the ---/+++ lines when a "new file mode"/"deleted file mode" line is present, so formatDiff never emitted them. The frontend relied on the +++ line to identify the filename and create the file header box; without it, all content lines were dumped as plain text with no syntax highlighting or collapsible box. For renamed files (both with and without content changes) formatDiff likewise omitted the rename markers, so the frontend showed "Modified" instead of "Renamed". Backend (server/renderer.go): - For NEW files: emit "--- /dev/null" + "+++ b/<name>" after DiffHeader - For DELETED files: emit "--- a/<name>" + "+++ /dev/null" after DiffHeader - For MODIFIED renames with changes: emit "rename from/to" + "---/+++" - For rename-only (no content): parse names from the diff --git line and emit "rename from/to" + "---/+++" so the frontend gets the file header - Add extractGitDiffNames() helper Frontend (bun_client/frontend/src/components/Review.tsx): - Add origName?: string to ParsedLine interface - Track fallbackOrigName alongside fallbackFilename - "--- /dev/null" → set pendingFileStatus = 'new' - "+++ /dev/null" → create file-header using fallbackFilename with fileStatus 'deleted' (instead of setting currentFile = '/dev/null') - "rename from X" → set fallbackOrigName = X, pendingFileStatus = 'renamed' - "rename to Y" → update fallbackFilename = Y, pendingFileStatus = 'renamed' - Propagate origName to all file-header ParsedLine pushes - renderDiff: show "origName → newName" for renamed file headers https://claude.ai/code/session_01DzjiHjQR52hnwWcPZGF22H
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
Improves handling of renamed, new, and deleted files in the diff review UI. The backend now explicitly emits
---/+++lines for new and deleted files, and properly detects renames. The frontend now displays renamed files with an arrow notation (e.g., "old.txt → new.txt") and correctly tracks the original filename.Changes
Backend (renderer.go):
--- /dev/nulland+++ /dev/nulllines for new and deleted files so the frontend can identify filenames correctlyOrigNamediffers fromNewNameextractGitDiffNames()helper to parse filenames fromdiff --githeaders for rename-only changesrename from/rename tolines for all rename scenariosFrontend (Review.tsx):
origNamefield to track original filename for renamed filesrename fromandrename tolines separately--- /dev/nullto identify new files+++ /dev/nullto identify deleted filesfallbackOrigNamebetween filesTest Plan
go build ./...passesgo test ./...passeshttps://claude.ai/code/session_01DzjiHjQR52hnwWcPZGF22H