review: aggregate comment-size budget guard - #6095
Merged
Merged
Conversation
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
JSONbored
force-pushed
the
review/comment-blocker-fix-context
branch
from
July 15, 2026 09:13
4de0443 to
6b99f6b
Compare
JSONbored
force-pushed
the
review/comment-size-budget-guard
branch
from
July 15, 2026 09:14
ebcb765 to
6f67ba8
Compare
Base automatically changed from
review/comment-blocker-fix-context
to
review/comment-decision-driver-chips
July 15, 2026 09:23
JSONbored
force-pushed
the
review/comment-decision-driver-chips
branch
from
July 15, 2026 09:26
dca092b to
c1f0695
Compare
A maximally-featured PR could carry up to 18 optional collapsibles (each capping only itself -- e.g. Changed files alone up to 200 rows / 30KB) with no shared budget across them, and no check anywhere before the body was handed to GitHub -- a comment over GitHub's real ~65536-char cap would just silently fail to post. Added renderWithinBudget: renders the comment, and if it exceeds a 60,000-char budget, drops the LOWEST-priority optional collapsibles one at a time from the end of the chain (the construction order already puts the heaviest/most decorative sections -- Visual preview, Scroll preview, Changed files -- last) until it fits. Disposition- relevant content (headline, verdict, blockers, per-blocker AI fix context, decision drivers) is rendered directly by renderUnifiedReviewComment, never part of extraCollapsibles, so it can never be dropped. When trimming happens, a small note is appended to the comment itself so the omission is visible to whoever reads it. Closes #6069
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6095 +/- ##
=======================================
Coverage 95.24% 95.24%
=======================================
Files 595 595
Lines 47062 47073 +11
Branches 15021 15025 +4
=======================================
+ Hits 44824 44835 +11
Misses 1493 1493
Partials 745 745
Flags with carried forward coverage won't be shown. Click here to find out more.
|
JSONbored
force-pushed
the
review/comment-size-budget-guard
branch
from
July 15, 2026 09:27
6f67ba8 to
cd05d7f
Compare
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.
Closes #6069. Last item in #6065.
Stacked on #6086 (the per-blocker fix-context PR) -- same file (
unified-comment-bridge.ts), and this guard needs to wrap the render call site that PR touches.Summary
Up to 18 optional collapsibles can appear on one comment (Nits, Copy-for-AI-agents, Flagged checks, Linked issue satisfaction, Review context, Contributor next steps, Signal definitions, Chat, Manifest validation, Auto-merge readiness, Changed files, Finding categories, Impact map, Fix handoff, Visual findings/preview, Scroll preview), each capping only itself (Changed files alone up to 200 rows / 30KB). Nothing checked the aggregate size before handing the body to GitHub — a maximally-featured PR could silently exceed GitHub's real ~65,536-character comment cap and fail to post, with no proactive truncation anywhere in the path.
renderWithinBudget: renders the comment; if it exceeds a 60,000-char budget (safe headroom under GitHub's real cap, matching the same limitMAX_STORED_BODY_CHARSinsrc/db/repositories.tsalready codifies for incoming bodies), it drops the lowest-priority optional collapsibles from the end of the chain, one at a time, re-rendering and re-measuring each time, until it fits or none are left to drop.buildUnifiedCommentBody's own construction order, which already puts the heaviest/most decorative sections last (Visual preview / Scroll preview's image tables, Changed files' up-to-200-row table) — no new priority list needed, the existing chain order already sorts roughly biggest/most-optional-last.renderUnifiedReviewComment, never part ofextraCollapsibles, so this loop cannot drop it, by construction (not just by convention).Test plan
npx vitest run test/unit/unified-comment-bridge.test.ts(+ the other comment-rendering suites) — 87/87 (+253 total across the related files), including 3 new tests: a normal-sized comment is completely untouched, a 75KB-of-optional-content comment gets trimmed with the note appended and core content intact, and a single collapsible bigger than the whole budget still returns a valid bodynpx tsc --noEmitcleannpm run docs:drift-check,npm run manifest:drift-check,npm run command-reference:check— pass