Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/4147-review-line-comment-counts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@schlessera/brain-ui-sdk": minor
"@schlessera/brain-ui-server": minor
"@schlessera/brain-ui-react": patch
---

Each review in a GitHub pull request read now says how many line comments it has (#4147), and the chat shows "Show n line comments" on that review. The SDK's review schema gains an optional `line_comments` (an exact count, or `null` for unknown; a result recorded earlier has none and reads as unknown), and `GITHUB_LIMITS.reviewComments` (100). The host counts from one bounded page of the pull request's review comments and gives every review `null` rather than a partial total when that page is cut short, a comment names no review, or GitHub's own total disagrees. In the chat, pressing a review's control loads only that review's comments through the detail route, following sparse pages a bounded number per press; a pull request whose reviews are not all counted, or not all in the result, still offers the other line comments in one section. Nothing loaded reaches the conversation.
6 changes: 6 additions & 0 deletions api-report/ui-sdk.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8431,6 +8431,7 @@ signatures (every public export and the types it is made of)
body_truncated: z.ZodBoolean;
html_url: z.ZodNullable<z.ZodURL>;
id: z.ZodNumber;
line_comments: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
state: z.ZodEnum<{
approved: "approved";
changes_requested: "changes_requested";
Expand Down Expand Up @@ -8853,6 +8854,7 @@ signatures (every public export and the types it is made of)
body_truncated: z.ZodBoolean;
html_url: z.ZodNullable<z.ZodURL>;
id: z.ZodNumber;
line_comments: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
state: z.ZodEnum<{
approved: "approved";
changes_requested: "changes_requested";
Expand Down Expand Up @@ -9067,6 +9069,7 @@ signatures (every public export and the types it is made of)
queryChars: 256;
refChars: 255;
requestedReviewers: 30;
reviewComments: 100;
reviews: 100;
searchDefault: 10;
searchMax: 30;
Expand Down Expand Up @@ -9217,6 +9220,7 @@ signatures (every public export and the types it is made of)
body_truncated: z.ZodBoolean;
html_url: z.ZodNullable<z.ZodURL>;
id: z.ZodNumber;
line_comments: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
state: z.ZodEnum<{
approved: "approved";
changes_requested: "changes_requested";
Expand Down Expand Up @@ -9535,6 +9539,7 @@ signatures (every public export and the types it is made of)
body_truncated: z.ZodBoolean;
html_url: z.ZodNullable<z.ZodURL>;
id: z.ZodNumber;
line_comments: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
state: z.ZodEnum<{
approved: "approved";
changes_requested: "changes_requested";
Expand Down Expand Up @@ -9734,6 +9739,7 @@ signatures (every public export and the types it is made of)
body_truncated: z.ZodBoolean;
html_url: z.ZodNullable<z.ZodURL>;
id: z.ZodNumber;
line_comments: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
state: z.ZodEnum<{
approved: "approved";
changes_requested: "changes_requested";
Expand Down
13 changes: 13 additions & 0 deletions docs/integration-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ same-commit update of the index or relevant authoritative component. How they ar

The reasoning is in [decisions/contract-versioning.md](decisions/contract-versioning.md).

## Per-review line-comment counts (additive, 0.45.0, #4147)

Each review in a `brain_github_issue_read` pull request result gains
`line_comments`: the exact number of line comments on that review, or `null`
when the host could not establish one. The host counts them from one bounded
page of the pull request's review comments and never reports a partial total.
A review in an internal detail page carries `null`, and a result recorded
before 0.45.0 has no field, which reads as `null`.
`GITHUB_LIMITS` gains `reviewComments` (100), the page the count is taken from.
Field names, inputs and existing meanings are unchanged. See
[the MCP component](integration-contract/mcp.md#per-review-line-comment-counts-additive-0450-4147).
This ships in a minor.

## Extraction classifier setting (additive, 0.45.0, #4088)

The governance policy gains optional `taint.classifier`, `off` (the default) or
Expand Down
27 changes: 27 additions & 0 deletions docs/integration-contract/mcp.md
Original file line number Diff line number Diff line change
Expand Up @@ -1539,6 +1539,33 @@ any GitHub text returns, the session's taint is recorded with the new source
`github_result` ([governance events](../http-api.md)); if that record cannot
be written, the text is withheld.

### Per-review line-comment counts (additive, 0.45.0, #4147)

Each item of a pull request's `reviews` gains `line_comments`, a nonnegative
integer or `null`:

- A number is the exact total of line comments (review comments) on that
review, zero included. The host takes it from one request for the pull
request's review comments, at most `GITHUB_LIMITS.reviewComments` (100), and
groups them by GitHub's `pull_request_review_id`.
- `null` means unknown. Every review's count is `null` when that page is not
the whole collection (GitHub names a next page), when any comment is
malformed or names no review, when the page disagrees with the pull
request's own `review_comments` total, or when the credential cannot read
review comments (`forbidden`, `not_found`). Other failures of that request
fail the read with their usual typed error. There is never a partial total,
and zero is reported only when the complete page has none.
- A pull request with no reviews in its result makes no extra request, and an
issue read is unchanged.
- A review in a `reviews` detail page ([#3796](../http-api.md#github-detail-pages-internal-0450-3796))
carries `null`: the page counts nothing.
- The field is optional in `GITHUB_REVIEW_SCHEMA`, so a result recorded before
it existed still parses; a consumer reads its absence as `null`. Negative,
fractional or non-numeric values are refused.

The count is metadata on new results only; it adds no tool, input or request
the model can make.

### GitHub data routing (additive, 0.45.0, #4029)

GitHub is the provider-policy recipient `github`
Expand Down
9 changes: 9 additions & 0 deletions docs/integration-contract/package-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,15 @@ input and forwards `{ tool, input }` to the optional new
[the MCP component](mcp.md#host-github-tools-additive-0450-3797). No existing
export changes.

## Per-review line-comment counts (additive, 0.45.0, #4147)

`@schlessera/brain-ui-sdk/tool-contracts` adds the optional, nullable
`line_comments` field to `GITHUB_REVIEW_SCHEMA` (and so to `GithubReview` and
every payload and detail page that holds a review), and
`GITHUB_LIMITS.reviewComments` (100). Shapes and the counting rules are in
[the MCP component](mcp.md#per-review-line-comment-counts-additive-0450-4147).
No existing export changes.

## GitHub detail-page types (additive, 0.45.0, #3796)

`@schlessera/brain-ui-sdk/tool-contracts` (re-exported from `/server`) adds
Expand Down
23 changes: 23 additions & 0 deletions packages/ui-react/src/components/chat/renderers/github-mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,29 @@ export function commentProps(comment: GithubComment | GithubReviewComment, scope
};
}

/**
* A review's known, positive line-comment count (#4147), or `null`. Zero,
* unknown (`null`) and a result recorded before the count existed (absent)
* all show no "Show n line comments".
*/
export function lineCommentCount(review: GithubReview): number | null {
const count = review.line_comments;
return typeof count === "number" && Number.isSafeInteger(count) && count > 0 ? count : null;
}

/**
* Which line comments the per-review controls reach (#4147). `counted` holds
* every review whose total the host established, zero included: its line
* comments, if any, load on that review. `remainder` is true when some line
* comments may belong to no counted review: a review in the result whose
* count is unknown or absent, or reviews the result does not carry at all.
* Only then does the pull request offer them in one section of its own.
*/
export function lineCommentCoverage(pr: GithubPullRequest): { counted: ReadonlySet<number>; remainder: boolean } {
const counted = new Set(pr.reviews.items.filter((r) => typeof r.line_comments === "number").map((r) => r.id));
return { counted, remainder: pr.reviews.has_more || counted.size < pr.reviews.items.length };
}

export function reviewProps(review: GithubReview, scope: GithubLinkScope | null, fetchedAt: string, avatarFor: AvatarFor) {
return {
reviewer: person(review.author, avatarFor),
Expand Down
Loading
Loading