Skip to content

Display as much of the raw diff as possible while staying within GitHub's comment character limit#25

Merged
AlexWaygood merged 3 commits intomainfrom
claude/expand-pr-diff-display-3UK67
Mar 23, 2026
Merged

Display as much of the raw diff as possible while staying within GitHub's comment character limit#25
AlexWaygood merged 3 commits intomainfrom
claude/expand-pr-diff-display-3UK67

Conversation

@AlexWaygood
Copy link
Copy Markdown
Member

Since we anyway collapse the raw diff if it grows too large, I'd prefer to be able to see the full diff in the PR comment if it will fit within GitHub's character comment limit. This PR implements that. The line-count-based sampling strategy is replaced with character-budget-based sampling that:

  • Calculates remaining character budget after accounting for existing markdown content and wrapper markup overhead
  • Computes the character cost of each diff change entry
  • Greedily selects changes that fit within the budget (deterministically shuffled for fairness)
  • Respects the max_raw_diff_lines limit if explicitly provided

…PR diff display

Instead of truncating the raw diff to a hardcoded 100 entries, compute
a character budget based on GitHub's 65,536-character comment limit
minus the space already used by the rest of the comment.  The sampling
logic now greedily fills the budget with randomly-shuffled entries,
displaying as many changes as will fit.  The old --max-raw-diff-lines
flag is preserved (default None) for backward compatibility but is no
longer needed in the common case.

https://claude.ai/code/session_01AQNDHAwavNHvBNnCQKAkx3
@AlexWaygood AlexWaygood requested a review from sharkdp March 22, 2026 23:14
@AlexWaygood AlexWaygood merged commit 73fe4d9 into main Mar 23, 2026
@AlexWaygood AlexWaygood deleted the claude/expand-pr-diff-display-3UK67 branch March 23, 2026 13:09
@AlexWaygood
Copy link
Copy Markdown
Member Author

tested in astral-sh/ruff#24136 -- it looks good:
image

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.

3 participants