Repository navigation
fix(work): pin the format of patches the Host parses - #284
Merged
Lucas1479 merged 1 commit intoNov 3, 2026
Merged
Conversation
collect_git_delta and collect_diff run plain `git diff`, so the user's diff configuration decides the shape of the patch that parse_unified_diff renders in the Work attempt diff canvas and that the Work page shows as raw text: - diff.mnemonicPrefix=true turns `git diff HEAD` prefixes into c/ and w/, so the canvas names the file "w/app.py" and lists the real path a second time as a hunk-less "modified" entry; - color.diff=always wraps every line in ANSI escapes, so no header or hunk is recognised and every file shows 0 additions and 0 deletions; - diff.noprefix=true drops the a/ and b/ prefixes; - diff.external replaced collect_diff's patch, which, unlike the attempt delta, did not pass --no-ext-diff. Add PATCH_FORMAT_ARGS (--no-ext-diff, --no-color, --src-prefix=a/, --dst-prefix=b/) to server/local_git.py and use it for the committed and working-tree attempt patches and for collect_diff's patch. These options override the configuration for one command only, so the user's Git setup is left untouched. Fixes Code-Amadeus#279
Lucas1479
approved these changes
Nov 3, 2026
Lucas1479
left a comment
Member
There was a problem hiding this comment.
Thank you for the focused fix and regression coverage. The shared patch-format arguments repair the four configurations reported in #279 at the Host Git-output boundary without changing user configuration. I independently checked real Git output for prefix/color handling and the external-driver boundary. All 15 hosted checks pass on this head. Additional submodule/copy/blank-context configurations are separate pre-existing follow-ups and do not block this scoped fix.
5 of 7 tasks
Lucas1479
added a commit
that referenced
this pull request
Nov 3, 2026
## 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 - [x] 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 #284 and #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 - [x] One coherent content-preservation fix - [x] No new dependency, schema, fallback or public configuration - [x] No secrets, personal state or restricted assets - [x] CPU/model-less baseline retained --------- Co-authored-by: Lucas1479 <sli776@aucklanduni.ac.nz>
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 and why
collect_git_deltaandcollect_diffran plaingit diff, so the user's own diff configuration decided the format of the patch thatparse_unified_diffrenders in the Work attempt diff canvas, and that the Work page shows as raw text (details in #279):diff.mnemonicPrefix=trueturnsgit diff HEADprefixes intoc//w/. The canvas names the filew/app.pyand lists the real path again as a hunk-less "modified" entry.color.diff=alwayswraps every line in ANSI escapes. No header or hunk is recognised, so every file shows 0 additions and 0 deletions.diff.noprefix=truedrops thea//b/prefixes.diff.externalreplacedcollect_diff's patch. Unlike the attempt delta,collect_diffdid not pass--no-ext-diff.This PR adds
PATCH_FORMAT_ARGS(--no-ext-diff --no-color --src-prefix=a/ --dst-prefix=b/) toserver/local_git.pyand uses it for the committed and working-tree attempt patches and forcollect_diff's patch. The options override the configuration for one command only, so the user's Git setup is left untouched.--name-only,-zand porcelain status calls are not affected by these settings and are unchanged.Fixes #279
Linked Issue for product-semantic or public-contract changes: none (routine fix)
Change class
Owning layer:
server/local_git.py, the Host helper that runs Git for machine consumers, and its callers inserver/work_artifact_registry.py, which produce the attempt patch.User-visible effect, or
none: users with those Git settings see the correct files, hunks and counts in the attempt diff canvas, and a readable raw patch.Compatibility or migration impact, or
none: none. Patches persisted by earlier attempts are not rewritten. New attempts store the standarda//b/format that the parser already expects.Evidence
Commands and manual journeys run:
python -m pytest -q 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: 48 passed (Linux,uv sync --locked --extra dev).The new tests
test_attempt_patch_ignores_user_diff_format_config(parametrized fordiff.mnemonicPrefix,diff.noprefixandcolor.diff=always, covering committed and working-tree patches throughparse_unified_diff) andtest_provider_diff_patch_ignores_user_diff_format_configfail onmainand pass with this change.python -m ruff check serverand the changed test files: passed.Full
pytest testson Linux (VN overlay tests needingtkinterexcluded): 6115 passed, 84 failed. Re-running the failing files on unmodifiedmaingives the same failures (ACP/Codex SDK, AUIP entry boot, Windows-only wallpaper and desktop tests), except twotest_codex_approval_cancel.pycases that were timing-flaky under load; that file passes 14/14 on both branches when run alone.Relevant Python tests pass
CPU/model-less baseline remains supported
Electron
npm run buildpasses when Electron code changedDependency audit passes when dependencies changed
Before/after screenshots are attached for visible UI changes
Documentation/examples are updated for changed settings or contracts
Final check