Skip to content

fix(diff): remove misleading overflow indicator from condense_unified_diff - #2652

Merged
KuSh merged 2 commits into
rtk-ai:developfrom
guyoron1:fix/diff-overflow-message
Aug 30, 2026
Merged

KuSh merged 2 commits into
rtk-ai:developfrom
guyoron1:fix/diff-overflow-message

Conversation

@guyoron1

@guyoron1 guyoron1 commented Jun 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #2653.

condense_unified_diff prints ALL change lines in full (honoring the "Never truncate diff content" comment), then appends ... +N more when total changes exceed 10. This misleads LLM consumers into requesting "remaining" data that was already shown, wasting tokens on redundant fetches.

Before: 200 changes printed, then ... +190 more (implies 190 lines were hidden)
After: 200 changes printed, no misleading indicator

Test plan

  • Updated test_condense_unified_diff_overflow_count_accuracy → renamed to test_condense_unified_diff_large_no_false_overflow_indicator, now asserts NO overflow message appears and verifies all lines are present
  • Existing test_condense_unified_diff_no_false_overflow continues to pass
  • All 23 diff_cmd tests pass
  • cargo fmt --all && cargo clippy --all-targets && cargo test --all clean (2237 tests, 0 failures)

@guyoron1
guyoron1 force-pushed the fix/diff-overflow-message branch from d312ac6 to 34f9a34 Compare June 27, 2026 08:57
…_diff

All change lines are already printed in full (the comment says "Never
truncate diff content"), but "... +N more" was appended when total
changes exceeded 10.  This confused LLM consumers into requesting
"remaining" data that was already shown, wasting tokens.
…ssert

The section header still read "truncation accuracy" and one test still
referred to a 10-line display cap. Neither describes the code any more:
condense_unified_diff emits every change line, and this PR removes the
indicator that claimed otherwise.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

@KuSh KuSh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approving. Reviewed at depth and found nothing to change in the fix itself.

What I verified:

  • The changes vec is never capped — every +/- line is pushed unconditionally and all are emitted — so total > 10 → "+{total-10} more" was pure fabrication, always claiming hidden lines that had in fact just been printed. Removing it is the correct fix, not a masking of real truncation.
  • added/removed are still consumed by the [file] {} (+{} -{}) header, so no dead variables.
  • condense_unified_diff has one caller (run_stdin), and no other module, test or doc references the overflow string. The other ... +N more occurrences in the repo (deps.rs, pip_cmd.rs, summary.rs, prettier_cmd.rs) back real truncation and are untouched.
  • Output only shrinks, so never_worse's raw-fallback behaviour is unaffected.
  • cargo fmt --check, cargo clippy --all-targets and cargo test --all (2583 unit + integration) are clean on the head.

Confirmed live on 0.46.0 before the change, so this is a real user-facing lie, not a theoretical one:

$ rtk diff - < twelve_changes.diff | tail -1
  ... +14 more          # after printing all 24 change lines

I pushed one commit to your branch (7aa6347): the test module's section header still read // --- truncation accuracy --- and test_condense_unified_diff_no_false_overflow still mentioned a "10-line display cap". Neither describes the code once the indicator is gone, and leaving them would have re-planted the same misconception this PR removes. Shout if you'd rather word them differently.

Thanks for this one — it's a small diff, but "the filter tells the model that data is missing when it isn't" costs a re-fetch every time, and that's the expensive kind of wrong.

@KuSh
KuSh merged commit 947467e into rtk-ai:develop Aug 30, 2026
9 of 10 checks passed
@rtk-release-bot rtk-release-bot Bot mentioned this pull request Aug 30, 2026
KuSh added a commit to kylehgc/rtk that referenced this pull request Aug 30, 2026
`" +"` / `" -"` match a one-space indent, but the form this guards
against is two spaces, so the assertion passed on the code it rejects
and only the equality loop above it killed the mutant. Match on leading
whitespace instead. Verified by neutralising that loop and reverting the
flush sites: the assertion now fails on its own.

The trailer the old comment carved out for is gone with rtk-ai#2652, so the
scoping it justified is no longer needed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

condense_unified_diff emits misleading '... +N more' after showing all lines

2 participants