Skip to content

fix(work): preserve line framing throughout attempt diffs - #283

Merged
Lucas1479 merged 4 commits into
Code-Amadeus:mainfrom
NopeCharon:fix/unified-diff-line-framing
Nov 3, 2026
Merged

Lucas1479 merged 4 commits into
Code-Amadeus:mainfrom
NopeCharon:fix/unified-diff-line-framing

Conversation

@NopeCharon

@NopeCharon NopeCharon commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Fixes #281. Git patch lines are delimited by LF. Python's splitlines() also splits form feeds, vertical tabs and Unicode separators that belong inside a source line, producing truncated text, phantom changes and incorrect line numbers in the Work diff canvas.

The parser now splits only on LF and retains its existing CRLF display handling. The Host's new-file patch generator uses the same LF framing, preserves empty/trailing blank lines and emits the missing-final-newline marker based on LF. Final Git-delta assembly no longer strips source whitespace from the last patch line.

Owning layers: server/unified_diff.py and server/work_artifact_registry.py. Existing output schemas, permissions and attribution rules are unchanged. The generator is shared by Git-untracked files and new files in non-Git workspaces.

Change class

  • Routine bug fix with regression coverage
  • Product-semantic or public-contract change
  • Isolated experiment

Evidence

  • The author's parser regression and real Git examples demonstrate the original count/text corruption.
  • Eight generator-to-parser cases cover embedded separators, other control characters, empty files, blank/trailing blank lines, CRLF, missing final LF and bare CR.
  • Three end-to-end attempt cases cover Git-tracked, Git-untracked and filesystem-new files, including trailing form-feed/space preservation.
  • New regressions were observed failing before their corresponding fixes.
  • On Windows/Python 3.12.10, python -X utf8 -m pytest tests/test_local_git_provider_diff.py tests/test_work_artifact_registry.py tests/test_unified_diff_canvas.py tests/test_work_export_integration.py -q: 61 passed on head 9b8bbe869901b53ca707eb1486a721b0218d1ade, including merged fix(work): pin the format of patches the Host parses #284 and fix(work): keep spaced paths from diff headers in the attempt diff canvas #282.
  • Ruff on all four changed files and git diff --check: passed.
  • No live provider calls or local Electron journey were needed for this parser/generator change; hosted checks cover the broader application.

Final check

  • One coherent content-preservation fix
  • No new dependency, schema, fallback or public configuration
  • No secrets, personal state or restricted assets
  • CPU/model-less baseline retained

parse_unified_diff iterated over source.splitlines(). str.splitlines()
also breaks at form feed, vertical tab, \x1c-\x1e, \x85, U+2028 and
U+2029, none of which end a line in Git's patch output. Such a character
inside a source line split the line in two: the remainder was either
dropped, truncating the shown text, or, when it began with "-", "+" or a
space, rendered as a phantom removed/added/context line. That changed
the additions/deletions counts and shifted every later line number in
the hunk.

Form feeds are common page separators in Python, C and Lisp sources and
U+2028 appears in JavaScript and JSON strings.

Split on "\n" and remove a trailing "\r", which keeps the previous
handling of CRLF content lines and CRLF-framed patches.

Fixes Code-Amadeus#281
@NopeCharon
NopeCharon requested a review from Lucas1479 as a code owner November 2, 2026 12:53
@Lucas1479 Lucas1479 changed the title fix(work): split attempt diff lines only at newlines fix(work): preserve line framing throughout attempt diffs Nov 3, 2026
@Lucas1479

Copy link
Copy Markdown
Member

Thank you for the focused parser fix and regression coverage. I have completed the same line-framing invariant in the Host-generated new-file patch path and added eight generator-to-parser cases plus three full attempt cases. Those tests also exposed final Git-delta .strip() removing trailing source characters; that trim is now removed. The regressions were observed failing before their fixes. The final composition with #284 and #282 passes all 61 relevant tests on Windows, plus Ruff and diff checks. The updated implementation is on 9b8bbe869901b53ca707eb1486a721b0218d1ade; waiting for its hosted CI before squash merge.

@Lucas1479
Lucas1479 merged commit f86c72a into Code-Amadeus:main Nov 3, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Work diff canvas splits hunk lines at form feeds and Unicode line separators

2 participants