Repository navigation
fix(work): count changes past the line cap in the attempt diff canvas - #299
Conversation
parse_unified_diff caps the rendered hunk lines at max_lines and marks the result as truncated. The additions/deletions counters were incremented after that cap check, so once the cap was reached every later changed line was dropped from the counts as well as from the rendered lines. A file whose changes started after the cap was listed in the attempt diff canvas as +0 -0, the file crossing the cap showed only its first changes, and the canvas summary under-reported the attempt's totals. Count added and removed lines before the cap check, so the cap bounds only which line items are stored. lineCount still reports the rendered lines, and truncated still marks the clipped hunks. Add a regression test where the cap falls inside the first file: both files keep their real counts, and the rendered lines stop at the cap. Fixes Code-Amadeus#298
|
Thanks for the focused fix and regression test, and for your continued improvements to the diff canvas. Keeping the change counts accurate when the rendered patch is clipped is a useful improvement. The before/after regression and additional boundary checks passed during review, and all 15 CI checks are green. |
Lucas1479
left a comment
There was a problem hiding this comment.
Reviewed 96fe6a4. The counters now correctly include changes past the rendering cap while preserving rendered-line limits and existing file-cap behavior. Independently verified all 11 targeted tests, failure of the new regression on the unmodified base and success on this head, 65 boundary combinations, and the default-cap large-file scenario. Ruff checks pass and all 15 hosted checks are green. No blocking findings.
What and why
Fixes #298.
parse_unified_diffcaps the rendered hunk lines atmax_lines(2400 by default) and marks the resulttruncated. The additions/deletions counters were incremented after that cap check, so once the cap was reached every later changed line was dropped from the counts as well as from the rendered lines. A file whose changes started after the cap was listed in the attempt diff canvas as+0 -0, the file crossing the cap showed only its first changes, and the+N / -M / clippedsummary under-reported the attempt.Added and removed lines are now counted before the cap check, so the cap bounds only which line items are stored.
lineCountstill reports the rendered lines andtruncatedstill marks the clipped hunks; the file cap (max_files) is unchanged.Linked Issue for product-semantic or public-contract changes: none (routine fix; tracked in #298)
Change class
Owning layer:
server/unified_diff.pyUser-visible effect, or
none: a clipped attempt diff lists each file's real+/-counts and the real patch totals instead of+0 -0for files past the line cap.Compatibility or migration impact, or
none: none; the canvas diff shape is unchanged.Evidence
Commands and manual journeys run:
python tests/test_unified_diff_canvas.py: passes; the newtest_parse_unified_diff_counts_changes_past_the_line_capfails on currentmainand passes with the fix.ruff checkandruff format --checkon the changed files,git diff --check: clean.The rest of the suite is left to CI.
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