fix(diff): drop the phantom trailing row from every edit's diff - #22
Merged
Conversation
An edit rendered a fourth row past the end of a three-line file:
⎿ Added 1 line, removed 1 line
1 alpha
2 -beta
2 +BETA-changed
3 gamma
4 No newline at end of file
`\ No newline at end of file` is a patch MARKER, not a line, and the row
renderer has no marker for it — `\` parses as an unknown prefix, so it
came out as an ordinary context line, numbered one past the file.
It is also not true. The diff is computed over the tool's applied HUNK,
not the whole file: a fragment that stops mid-file has no trailing newline
by construction, and `alpha\nbeta\ngamma\n` on disk is perfectly fine. So
the row asserted something false about the user's file, in the one place a
reader looks to see what changed.
Filtered where the hunks are built, which is the only producer, so replay
gets the same shape. Upstream renders no such row; the diff is now
byte-identical to what Claude Code 2.1.235 shows for the same edit.
Also tidies the gallery's mutation scenarios: `write` and `edit` each own
their own file and the leftovers are cleared at bootstrap, so `edit`
exercises the diff card instead of failing on yesterday's file, and it
reads before editing the way the harness requires.
Co-Authored-By: Claude Opus 5 <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.
What
An edit rendered a fourth row past the end of a three-line file:
Why
\ No newline at end of fileis a patch marker, not a line, and the row renderer has no marker for it —\parses as an unknown prefix, so it came out as an ordinary context line, numbered one past the file.It is also not true. The diff is computed over the tool's applied hunk, not the whole file: a fragment that stops mid-file has no trailing newline by construction, and
alpha\nbeta\ngamma\non disk is perfectly fine. So the row asserted something false about the user's file, in the one place a reader looks to see what changed.Filtered where the hunks are built — the only producer — so replay gets the same shape. Claude Code 2.1.235 renders no such row; the diff is now byte-identical to its output for the same edit.
Also
The gallery's mutation scenarios each own their own file, and leftovers are cleared at bootstrap. Previously
writecreatedgallery.txtand theeditscenario then failed on it (cannot overwrite existing … without reading it first) instead of exercising the diff card.editalso now reads before editing, the way the harness requires.Test
npm run typecheck,npm test— 150 files / 1940 passingnode scripts/verify-boundary.mjs\-prefixed rowscripts/tool-gallery.py edit🤖 Generated with Claude Code