Repository navigation
CONTRACT: feat(ui-sdk, ui-server, ui-react): per-review line-comment count, so each review gets its own "Show n line comments" (#4147) - #4196
Conversation
…count, so each review gets its own "Show n line comments" (#4147) The shared review payload gains an optional, nullable `line_comments`, and GITHUB_LIMITS gains `reviewComments` (100). A pull request read counts each review's line comments from one bounded page of its review comments, grouped by pull_request_review_id, and reports null for every review rather than a partial total when the page is cut short, a comment names no review or is malformed, GitHub's own total disagrees, or the credential cannot read them. Detail-page reviews carry null; a legacy result without the field reads as unknown. The chat shows "Show n line comments" on each review with a known positive count. Its press mounts that review's section, which loads #3796's review-comments part filtered to the review, follows sparse pages at most four per press and stops at the known count. The PR-wide section is retired when every review in a complete list is counted; it remains, filtered to the comments no counted review reaches, when a review's count is unknown or the result does not carry every review. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No uploads on this PR yet This PR changes UI files (
Tips for agentsLabel each shot so reviewers know what they're seeing. Labels apply to every file in a call, so run one uploads put after.png --pr 4196 --meta path=/settings --state after --caption "Saved settings toast"
uploads put chat.png --pr 4196 --app ios --screen "Chat" --state afterNo CLI? With the Uploads MCP, call This comment updates with each upload, so you don't need to post the images yourself. A shot or two in the PR description is still welcome. Check what's attached with Workspace admins can turn this comment off in Settings → GitHub · docs |
Collisions
|
Independent reviewReviewed head 7e4f005 against base d2b0a81. Reviewer: agent. No findings. {
"version": 1,
"kind": "brain-review-receipt",
"pr": 4196,
"head": "7e4f0053d6aca0ab54a148d06a3b8e647266f1bd",
"base": "d2b0a814bb0a9750fc76c7602c1a41df58579284",
"reviewer": "agent",
"outcome": "no-findings",
"findings": []
} |
…line-comment-count
Closes #4147
What changed
A pull request read now tells each review how many line comments it has, and the chat puts "Show n line comments" on that review. The shared review payload gains an optional, nullable
line_comments(GITHUB_REVIEW_SCHEMA), andGITHUB_LIMITSgainsreviewComments(100). The host makes one extra request,/pulls/{n}/comments?per_page=100, only when the result carries reviews, groups the comments bypull_request_review_idand gives every review its exact total, a genuine zero included. When that page is not the whole collection (GitHub names a next page), a comment is malformed or names no review, the page disagrees with the pull request's ownreview_commentstotal, or the credential cannot read review comments (403/404), every review's count isnull; there is never a partial total. Other failures of that request (rate limit, 5xx, timeout) fail the read with their usual typed error, as for the other PR requests. Detail-page reviews carrynull. A result recorded before the field existed still parses, and its absence reads as unknown.In the chat, a review with a known positive count shows the kit's unchanged
GitHubReviewcontrol. Its press mounts that review's section, which loads #3796'sreview-commentspart, keeps only that review's comments, follows pages that keep none at most four per press (ceil(reviewComments / page size)), and stops paging once the known count is shown. Zero,nulland an absent count show no control, and nothing loads before the press. The PR-wide "Show line comments" section is retired when every review in a complete list has its count. It remains, filtered to the comments no counted review reaches, only when some review's count is unknown or absent, or when the result does not carry every review (reviews.has_more). That covers the criterion added on 2026-11-17: line comments can load for every review that has them, including when the result carries none of the PR's reviews.Why this shape
review_commentstotal is used only to reject a page, never to produce a number, as the issue requires.checks()already gives a credential without access. The read worked without this request before, so a read must not now fail because of a metadata field. Other errors keep the existing typed refusal path.reviews.items.lengthas before. The kit already has the label slot for this, so the design does not change.DetailPartauto-follows pages that add nothing, which is unbounded in principle. Filtered sections switch that off and follow insideuseDetailwithin a per-press page budget. The reader sees either new rows or a truthful "Load more · k of n shown".Proof
Focused suites:
packages/ui-sdk/tests/github-tool-contract.test.ts,packages/ui-server/tests/github-tools-host.test.ts,github-details.test.ts,github-write-tools.test.ts,ws-github*.test.ts,packages/ui-backend-pi/tests/github-tools.test.ts,packages/ui-react/tests/render/github-tools.test.tsxandtests/github-details.test.ts: 203 pass. One unrelated failure,github-reference-git.test.ts("actual Git uses the fixed bounded HTTPS wire"), fails the same way on anorigin/mainworktree, so it is environment-only.Real browser (
ui-react-layout, pinned Chromium 1243 on the host):packages/ui-react/tests/browser/github-tools.layout.tsx, 2/2 pass. The new case presses each review's control in turn and checks the following: no detail call before the press, exactly onereview-commentscall after it, that review's comments under it, another review's never drawn, only GETs, and the chat store byte-identical.Failing-first and mutation receipts. Each mutation was applied, the named assertion was seen failing, and the code was restored.
.optional())GITHUB_LINE_COMMENTS_LEGACY_ABSENTz.number()(no int/nonnegative)GITHUB_LINE_COMMENTS_REFUSED -1GITHUB_LINE_COMMENTS_EXACT_PER_REVIEWGITHUB_LINE_COMMENTS_CAPPED_UNKNOWNGITHUB_LINE_COMMENTS_UNVALIDATED_MEMBERSHIP nullGITHUB_LINE_COMMENTS_TOTAL_MISMATCHCAPPED_UNKNOWN,FORBIDDEN_UNKNOWN,TOTAL_MISMATCH,UNVALIDATED_MEMBERSHIPorigin/main(failing-first)LINE_COMMENTS_GLOBAL_FALLBACK_RETIREDreview_idfilterLINE_COMMENTS_FILTERED_TO_REVIEW,LINE_COMMENTS_EMPTY_FOR_REVIEW,LINE_COMMENTS_FOLLOW_BOUNDEDLINE_COMMENTS_FOLLOW_BOUNDEDLINE_COMMENTS_STOP_AT_COUNTLINE_COMMENTS_GLOBAL_FALLBACK_RETIREDreview_idfilterProvider history. The keyless guard (
packages/ui-backend-claude/tests/provider-history.test.ts,packages/ui-backend-pi/tests/provider-history.test.ts) could not run on this host. Both fail before any turn withworker_host_unsupported(bwrap cannot create a user namespace;kernel.apparmor_restrict_unprivileged_userns=1), including with sandbox escalation. Nothing on the turn's path changed except new tool-result bytes: a new result carries one more field, appended as new content. Tools, the system prompt and earlier messages are untouched. The line comments themselves go only through #3796's display route, which its server test already proves leaves provider history unchanged (GITHUB_DETAIL_HISTORY_UNCHANGED). The render and browser tests check that the chat store and the "Brain read" line stay identical after loading.{"version":1,"kind":"brain-check-pr-receipt","head":"b5f7de9c6b2e297976674e594b69cae47d2679ce","base":"origin/main","mode":"focused","startedAt":"2026-11-17T20:42:38.665Z","finishedAt":"2026-11-17T20:45:16.400Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":37487.94270199999},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":276.85823600000003},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":196.16299399999843},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":29.973383999997168},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":119722.880693}]}Checklist
.changeset/4147-review-line-comment-counts.md: ui-sdk and ui-server minor, ui-react patch).CONTRACT:commit, withapi-report/ui-sdk.txt.docs/reflect the change.Anything left open
packages/ui-react/src/components/chat/tool-cards/github-cards.tsx(the W4GithubCommentPreview, a different region fromPullRequestCard/useDetailhere) andtests/render/github-tools.test.tsx(this PR only appends adescribe).🤖 Generated with Claude Code