Skip to content

fix(work): count changes past the line cap in the attempt diff canvas - #299

Merged
Lucas1479 merged 1 commit into
Code-Amadeus:mainfrom
NopeCharon:fix/diff-counts-past-line-cap
Nov 12, 2026
Merged

Lucas1479 merged 1 commit into
Code-Amadeus:mainfrom
NopeCharon:fix/diff-counts-past-line-cap

Conversation

@NopeCharon

Copy link
Copy Markdown
Contributor

What and why

Fixes #298. parse_unified_diff caps the rendered hunk lines at max_lines (2400 by default) and marks the result 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 +N / -M / clipped summary 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. lineCount still reports the rendered lines and truncated still 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

  • Routine fix, documentation, test, maintenance, or presentation-only UI
  • Product-semantic or public-contract change discussed in the linked Issue
  • Isolated, default-off experiment

Owning layer: server/unified_diff.py

User-visible effect, or none: a clipped attempt diff lists each file's real +/- counts and the real patch totals instead of +0 -0 for 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 new test_parse_unified_diff_counts_changes_past_the_line_cap fails on current main and passes with the fix.

  • ruff check and ruff format --check on 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 build passes when Electron code changed

  • Dependency 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

  • This PR addresses one coherent problem without unrelated cleanup
  • It does not add a speculative API, fallback, or compatibility path
  • No secrets, local state, model weights, voice material, or restricted assets are included
  • Third-party notices and provenance are preserved

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
@Lucas1479

Copy link
Copy Markdown
Member

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 Lucas1479 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Lucas1479
Lucas1479 merged commit c1c7f69 into Code-Amadeus:main Nov 12, 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 lists files after the line cap as +0 -0

2 participants