From e2de8088ff0a11ea9453abfbdbc5aa080b676747 Mon Sep 17 00:00:00 2001 From: Ziqiang Zhang <206405555+Daiyuanranfeng@users.noreply.github.com> Date: Wed, 11 Nov 2026 10:27:36 +0800 Subject: [PATCH 1/2] feat: include pull request review reaction counts --- README.md | 1 + .../__toolsnaps__/pull_request_read.snap | 100 +++++++++++++++++ pkg/github/consolidated_pull_request_types.go | 16 +-- pkg/github/minimal_types.go | 47 ++++---- pkg/github/pullrequests.go | 106 ++++++++++++++++-- pkg/github/pullrequests_test.go | 4 + ..._consolidated_pull_request_outputs_test.go | 21 +++- 7 files changed, 254 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index 432541f434..aed09a826c 100644 --- a/README.md +++ b/README.md @@ -1315,6 +1315,7 @@ For negotiated supported protocol versions `2026-07-28` or newer, the consolidat - **pull_request_read** - Get details for a single pull request - **OAuth Challenge Scopes**: `repo` - `after`: Cursor for pagination, used only by the get_review_comments method. Pass the endCursor from the previous page's PageInfo to fetch the next page. (string, optional) + - `include_reactions`: Include reaction counts for get_reviews or get_review_comments. Defaults to false. (boolean, optional) - `method`: Action to specify what pull request data needs to be retrieved from GitHub. Possible options: 1. get - Get details of a specific pull request. diff --git a/pkg/github/__toolsnaps__/pull_request_read.snap b/pkg/github/__toolsnaps__/pull_request_read.snap index c99d4276e2..447ab5055c 100644 --- a/pkg/github/__toolsnaps__/pull_request_read.snap +++ b/pkg/github/__toolsnaps__/pull_request_read.snap @@ -11,6 +11,10 @@ "description": "Cursor for pagination, used only by the get_review_comments method. Pass the endCursor from the previous page's PageInfo to fetch the next page.", "type": "string" }, + "include_reactions": { + "description": "Include reaction counts for get_reviews or get_review_comments. Defaults to false.", + "type": "boolean" + }, "method": { "description": "Action to specify what pull request data needs to be retrieved from GitHub. \nPossible options: \n 1. get - Get details of a specific pull request.\n 2. get_diff - Get the diff of a pull request.\n 3. get_status - Get combined commit status of a head commit in a pull request.\n 4. get_files - Get the list of files changed in a pull request. Use with pagination parameters to control the number of results returned.\n 5. get_commits - Get the list of commits on a pull request. Use with pagination parameters to control the number of results returned.\n 6. get_review_comments - Get review threads on a pull request. Each thread contains logically grouped review comments made on the same code location during pull request reviews. Returns thread metadata and comments with nullable current and original line-range coordinates (line, start_line, original_line, original_start_line). Current coordinates are omitted when unavailable, such as for outdated comments. Use cursor-based pagination (perPage, after) to control results.\n 7. get_reviews - Get the reviews on a pull request. When asked for review comments, use get_review_comments method. Use with pagination parameters to control the number of results returned.\n 8. get_comments - Get comments on a pull request. Use this if user doesn't specifically want review comments. Use with pagination parameters to control the number of results returned.\n 9. get_check_runs - Get check runs for the head commit of a pull request. Check runs are the individual CI/CD jobs and checks that run on the PR.\n", "enum": [ @@ -505,6 +509,54 @@ "path": { "type": "string" }, + "reactions": { + "additionalProperties": false, + "properties": { + "+1": { + "type": "integer" + }, + "-1": { + "type": "integer" + }, + "confused": { + "type": "integer" + }, + "eyes": { + "type": "integer" + }, + "heart": { + "type": "integer" + }, + "hooray": { + "type": "integer" + }, + "laugh": { + "type": "integer" + }, + "rocket": { + "type": "integer" + }, + "total_count": { + "description": "Total number of results.", + "type": "integer" + } + }, + "required": [ + "total_count", + "+1", + "-1", + "laugh", + "confused", + "heart", + "hooray", + "rocket", + "eyes" + ], + "type": [ + "null", + "object" + ] + }, "start_line": { "description": "One-based diff line number.", "type": [ @@ -768,6 +820,54 @@ "id": { "type": "integer" }, + "reactions": { + "additionalProperties": false, + "properties": { + "+1": { + "type": "integer" + }, + "-1": { + "type": "integer" + }, + "confused": { + "type": "integer" + }, + "eyes": { + "type": "integer" + }, + "heart": { + "type": "integer" + }, + "hooray": { + "type": "integer" + }, + "laugh": { + "type": "integer" + }, + "rocket": { + "type": "integer" + }, + "total_count": { + "description": "Total number of results.", + "type": "integer" + } + }, + "required": [ + "total_count", + "+1", + "-1", + "laugh", + "confused", + "heart", + "hooray", + "rocket", + "eyes" + ], + "type": [ + "null", + "object" + ] + }, "state": { "description": "Review state; empty for a sparse response.", "enum": [ diff --git a/pkg/github/consolidated_pull_request_types.go b/pkg/github/consolidated_pull_request_types.go index 6d6abaed63..b1e46c2f0b 100644 --- a/pkg/github/consolidated_pull_request_types.go +++ b/pkg/github/consolidated_pull_request_types.go @@ -14,13 +14,14 @@ import ( ) type PullRequestReadInput struct { - Method string `json:"method"` - Owner string `json:"owner"` - Repo string `json:"repo"` - PullNumber int `json:"pullNumber"` - Page *int `json:"page,omitempty"` - PerPage *int `json:"perPage,omitempty"` - After *string `json:"after,omitempty"` + Method string `json:"method"` + Owner string `json:"owner"` + Repo string `json:"repo"` + PullNumber int `json:"pullNumber"` + Page *int `json:"page,omitempty"` + PerPage *int `json:"perPage,omitempty"` + After *string `json:"after,omitempty"` + IncludeReactions bool `json:"include_reactions,omitempty"` } type CreatePullRequestInput struct { @@ -415,6 +416,7 @@ var pullRequestArgumentSpecs = map[string]pullRequestArgumentSpec{ "read": { required: []string{"method", "owner", "repo"}, requiredInts: []string{"pullNumber"}, ints: []string{"page", "perPage"}, + bools: []string{"include_reactions"}, methods: []string{"get", "get_diff", "get_status", "get_files", "get_commits", "get_review_comments", "get_reviews", "get_comments", "get_check_runs"}, }, "create": { diff --git a/pkg/github/minimal_types.go b/pkg/github/minimal_types.go index d355eb1a2e..80c974464c 100644 --- a/pkg/github/minimal_types.go +++ b/pkg/github/minimal_types.go @@ -781,14 +781,15 @@ type MinimalProjectStatusUpdate struct { // MinimalPullRequestReview is the trimmed output type for pull request review objects to reduce verbosity. type MinimalPullRequestReview struct { - ID int64 `json:"id"` - State string `json:"state"` - Body string `json:"body,omitempty"` - HTMLURL string `json:"html_url"` - User *MinimalUser `json:"user,omitempty"` - CommitID string `json:"commit_id,omitempty"` - SubmittedAt string `json:"submitted_at,omitempty"` - AuthorAssociation string `json:"author_association,omitempty"` + ID int64 `json:"id"` + State string `json:"state"` + Body string `json:"body,omitempty"` + HTMLURL string `json:"html_url"` + User *MinimalUser `json:"user,omitempty"` + CommitID string `json:"commit_id,omitempty"` + SubmittedAt string `json:"submitted_at,omitempty"` + AuthorAssociation string `json:"author_association,omitempty"` + Reactions *MinimalReactions `json:"reactions,omitempty"` } // Helper functions @@ -1947,16 +1948,17 @@ type MinimalPageInfo struct { // MinimalReviewComment is the trimmed output type for PR review comment objects. type MinimalReviewComment struct { - Body string `json:"body,omitempty"` - Path string `json:"path"` - Line *int `json:"line,omitempty"` - OriginalLine *int `json:"original_line,omitempty"` - StartLine *int `json:"start_line,omitempty"` - OriginalStartLine *int `json:"original_start_line,omitempty"` - Author string `json:"author,omitempty"` - CreatedAt string `json:"created_at,omitempty"` - UpdatedAt string `json:"updated_at,omitempty"` - HTMLURL string `json:"html_url"` + Body string `json:"body,omitempty"` + Path string `json:"path"` + Line *int `json:"line,omitempty"` + OriginalLine *int `json:"original_line,omitempty"` + StartLine *int `json:"start_line,omitempty"` + OriginalStartLine *int `json:"original_start_line,omitempty"` + Author string `json:"author,omitempty"` + CreatedAt string `json:"created_at,omitempty"` + UpdatedAt string `json:"updated_at,omitempty"` + HTMLURL string `json:"html_url"` + Reactions *MinimalReactions `json:"reactions,omitempty"` } // MinimalReviewThread is the trimmed output type for PR review thread objects. @@ -2285,10 +2287,11 @@ func convertToMinimalReviewThread(thread reviewThreadNode) MinimalReviewThread { func convertToMinimalReviewComment(c reviewCommentNode) MinimalReviewComment { m := MinimalReviewComment{ - Body: sanitize.Content(string(c.Body)), - Path: string(c.Path), - Author: string(c.Author.Login), - HTMLURL: c.URL.String(), + Body: sanitize.Content(string(c.Body)), + Path: string(c.Path), + Author: string(c.Author.Login), + HTMLURL: c.URL.String(), + Reactions: summarizeReviewReactions(c.ReactionGroups), } if c.Line != nil { diff --git a/pkg/github/pullrequests.go b/pkg/github/pullrequests.go index 70fdfa197a..29ce096f92 100644 --- a/pkg/github/pullrequests.go +++ b/pkg/github/pullrequests.go @@ -56,6 +56,10 @@ Possible options: Type: "number", Description: "Pull request number", }, + "include_reactions": { + Type: "boolean", + Description: "Include reaction counts for get_reviews or get_review_comments. Defaults to false.", + }, }, Required: []string{"method", "owner", "repo", "pullNumber"}, } @@ -148,10 +152,10 @@ Possible options: if err != nil { return utils.NewToolResultError(err.Error()), nil, nil } - result, output, err := getPullRequestReviewComments(ctx, gqlClient, deps, owner, repo, pullNumber, cursorPagination) + result, output, err := getPullRequestReviewComments(ctx, gqlClient, deps, owner, repo, pullNumber, cursorPagination, input.IncludeReactions) return attachIFC(result), output, err case "get_reviews": - result, output, err := getPullRequestReviews(ctx, client, deps, owner, repo, pullNumber, pagination) + result, output, err := getPullRequestReviews(ctx, client, deps, owner, repo, pullNumber, pagination, input.IncludeReactions) return attachIFC(result), output, err case "get_comments": result, output, err := getIssueComments(ctx, client, deps, owner, repo, pullNumber, pagination) @@ -510,9 +514,47 @@ type reviewCommentNode struct { Author struct { Login githubv4.String } - CreatedAt githubv4.DateTime - UpdatedAt githubv4.DateTime - URL githubv4.URI + CreatedAt githubv4.DateTime + UpdatedAt githubv4.DateTime + URL githubv4.URI + ReactionGroups []reviewReactionGroup `graphql:"reactionGroups @include(if: $includeReactions)"` +} + +type reviewReactionGroup struct { + Content githubv4.ReactionContent + Users struct { + TotalCount githubv4.Int + } `graphql:"users(first: 1)"` +} + +func summarizeReviewReactions(groups []reviewReactionGroup) *MinimalReactions { + if groups == nil { + return nil + } + summary := &MinimalReactions{} + for _, group := range groups { + count := int(group.Users.TotalCount) + summary.TotalCount += count + switch group.Content { + case githubv4.ReactionContentThumbsUp: + summary.PlusOne = count + case githubv4.ReactionContentThumbsDown: + summary.MinusOne = count + case githubv4.ReactionContentLaugh: + summary.Laugh = count + case githubv4.ReactionContentConfused: + summary.Confused = count + case githubv4.ReactionContentHeart: + summary.Heart = count + case githubv4.ReactionContentHooray: + summary.Hooray = count + case githubv4.ReactionContentRocket: + summary.Rocket = count + case githubv4.ReactionContentEyes: + summary.Eyes = count + } + } + return summary } type pageInfoFragment struct { @@ -523,11 +565,11 @@ type pageInfoFragment struct { } func GetPullRequestReviewComments(ctx context.Context, gqlClient *githubv4.Client, deps ToolDependencies, owner, repo string, pullNumber int, pagination CursorPaginationParams) (*mcp.CallToolResult, error) { - result, _, err := getPullRequestReviewComments(ctx, gqlClient, deps, owner, repo, pullNumber, pagination) + result, _, err := getPullRequestReviewComments(ctx, gqlClient, deps, owner, repo, pullNumber, pagination, false) return result, err } -func getPullRequestReviewComments(ctx context.Context, gqlClient *githubv4.Client, deps ToolDependencies, owner, repo string, pullNumber int, pagination CursorPaginationParams) (*mcp.CallToolResult, *PullRequestReadOutput, error) { +func getPullRequestReviewComments(ctx context.Context, gqlClient *githubv4.Client, deps ToolDependencies, owner, repo string, pullNumber int, pagination CursorPaginationParams, includeReactions bool) (*mcp.CallToolResult, *PullRequestReadOutput, error) { cache, err := deps.GetRepoAccessCache(ctx) if err != nil { return nil, nil, fmt.Errorf("failed to get repo access cache: %w", err) @@ -547,6 +589,7 @@ func getPullRequestReviewComments(ctx context.Context, gqlClient *githubv4.Clien "prNum": githubv4.Int(int32(pullNumber)), //nolint:gosec // pullNumber is controlled by user input validation "first": githubv4.Int(*gqlParams.First), "commentsPerThread": githubv4.Int(100), + "includeReactions": githubv4.Boolean(includeReactions), } // Add cursor if provided @@ -599,11 +642,11 @@ func getPullRequestReviewComments(ctx context.Context, gqlClient *githubv4.Clien } func GetPullRequestReviews(ctx context.Context, client *github.Client, deps ToolDependencies, owner, repo string, pullNumber int, pagination PaginationParams) (*mcp.CallToolResult, error) { - result, _, err := getPullRequestReviews(ctx, client, deps, owner, repo, pullNumber, pagination) + result, _, err := getPullRequestReviews(ctx, client, deps, owner, repo, pullNumber, pagination, false) return result, err } -func getPullRequestReviews(ctx context.Context, client *github.Client, deps ToolDependencies, owner, repo string, pullNumber int, pagination PaginationParams) (*mcp.CallToolResult, *PullRequestReadOutput, error) { +func getPullRequestReviews(ctx context.Context, client *github.Client, deps ToolDependencies, owner, repo string, pullNumber int, pagination PaginationParams, includeReactions bool) (*mcp.CallToolResult, *PullRequestReadOutput, error) { cache, err := deps.GetRepoAccessCache(ctx) if err != nil { return nil, nil, fmt.Errorf("failed to get repo access cache: %w", err) @@ -652,14 +695,57 @@ func getPullRequestReviews(ctx context.Context, client *github.Client, deps Tool reviews = filteredReviews } + var reactions map[string]*MinimalReactions + if includeReactions { + reactions, err = fetchReviewReactions(ctx, deps, reviews) + if err != nil { + return ghErrors.NewGitHubGraphQLErrorResponse(ctx, "failed to get pull request review reactions", err), nil, nil + } + } minimalReviews := make([]MinimalPullRequestReview, 0, len(reviews)) for _, review := range reviews { - minimalReviews = append(minimalReviews, convertToMinimalPullRequestReview(review)) + minimal := convertToMinimalPullRequestReview(review) + minimal.Reactions = reactions[review.GetNodeID()] + minimalReviews = append(minimalReviews, minimal) } return MarshalledTextResult(minimalReviews), &PullRequestReadOutput{Reviews: &minimalReviews}, nil } +func fetchReviewReactions(ctx context.Context, deps ToolDependencies, reviews []*github.PullRequestReview) (map[string]*MinimalReactions, error) { + ids := make([]githubv4.ID, 0, len(reviews)) + for _, review := range reviews { + if id := review.GetNodeID(); id != "" { + ids = append(ids, githubv4.ID(id)) + } + } + if len(ids) == 0 { + return nil, nil + } + client, err := deps.GetGQLClient(ctx) + if err != nil { + return nil, err + } + var query struct { + Nodes []struct { + Review struct { + ID githubv4.ID + ReactionGroups []reviewReactionGroup + } `graphql:"... on PullRequestReview"` + } `graphql:"nodes(ids: $ids)"` + } + if err := client.Query(ctx, &query, map[string]any{"ids": ids}); err != nil { + return nil, err + } + reactions := make(map[string]*MinimalReactions, len(query.Nodes)) + for _, node := range query.Nodes { + if id, ok := node.Review.ID.(string); ok { + reactions[id] = summarizeReviewReactions(node.Review.ReactionGroups) + } + } + return reactions, nil +} + // PullRequestWriteUIResourceURI is the URI for the create_pull_request tool's MCP App UI resource. const PullRequestWriteUIResourceURI = "ui://github-mcp-server/pr-write" diff --git a/pkg/github/pullrequests_test.go b/pkg/github/pullrequests_test.go index 546094910c..7f137611d1 100644 --- a/pkg/github/pullrequests_test.go +++ b/pkg/github/pullrequests_test.go @@ -2251,6 +2251,7 @@ func Test_GetPullRequestComments(t *testing.T) { "prNum": githubv4.Int(42), "first": githubv4.Int(30), "commentsPerThread": githubv4.Int(100), + "includeReactions": githubv4.Boolean(false), "after": (*githubv4.String)(nil), }, githubv4mock.DataResponse(map[string]any{ @@ -2419,6 +2420,7 @@ func Test_GetPullRequestComments(t *testing.T) { "prNum": githubv4.Int(42), "first": githubv4.Int(30), "commentsPerThread": githubv4.Int(100), + "includeReactions": githubv4.Boolean(false), "after": githubv4.String("cursor-page-2"), }, githubv4mock.DataResponse(map[string]any{ @@ -2467,6 +2469,7 @@ func Test_GetPullRequestComments(t *testing.T) { "prNum": githubv4.Int(999), "first": githubv4.Int(30), "commentsPerThread": githubv4.Int(100), + "includeReactions": githubv4.Boolean(false), "after": (*githubv4.String)(nil), }, githubv4mock.ErrorResponse("Could not resolve to a PullRequest with the number of 999."), @@ -2492,6 +2495,7 @@ func Test_GetPullRequestComments(t *testing.T) { "prNum": githubv4.Int(42), "first": githubv4.Int(30), "commentsPerThread": githubv4.Int(100), + "includeReactions": githubv4.Boolean(false), "after": (*githubv4.String)(nil), }, githubv4mock.DataResponse(map[string]any{ diff --git a/pkg/github/typed_consolidated_pull_request_outputs_test.go b/pkg/github/typed_consolidated_pull_request_outputs_test.go index 60afd2f1f1..2cb3d6aa45 100644 --- a/pkg/github/typed_consolidated_pull_request_outputs_test.go +++ b/pkg/github/typed_consolidated_pull_request_outputs_test.go @@ -149,10 +149,12 @@ func consolidatedPullRequestDeps(t *testing.T) BaseDeps { case path == "/repos/owner/repo/pulls/1/commits": write(http.StatusOK, `[{"sha":"abc","html_url":"https://github.com/owner/repo/commit/abc","commit":{"message":"msg","author":{"name":"Octo","email":"octo@example.com","date":"2026-01-01T00:00:00Z"}}}]`) case path == "/repos/owner/repo/pulls/1/reviews": - write(http.StatusOK, `[{"id":9,"state":"APPROVED","body":"lgtm","html_url":"https://github.com/owner/repo/pull/1#pullrequestreview-9","user":{"login":"octocat"},"commit_id":"abc","author_association":"MEMBER"}]`) + write(http.StatusOK, `[{"id":9,"node_id":"R_1","state":"APPROVED","body":"lgtm","html_url":"https://github.com/owner/repo/pull/1#pullrequestreview-9","user":{"login":"octocat"},"commit_id":"abc","author_association":"MEMBER"}]`) case path == "/repos/owner/repo/pulls/3/reviews": // A successful null list payload is normalized to an empty list. write(http.StatusOK, `null`) + case path == "/repos/owner/repo/pulls/4/reviews": + write(http.StatusOK, `[{"id":10,"node_id":"R_EMPTY","state":"COMMENTED","html_url":"https://github.com/owner/repo/pull/4#pullrequestreview-10"}]`) case path == "/repos/owner/repo/issues/1/comments": write(http.StatusOK, `[{"id":42,"body":"hello","html_url":"https://github.com/owner/repo/pull/1#issuecomment-42"}]`) case path == "/repos/owner/repo/pulls/1/merge": @@ -174,7 +176,8 @@ func consolidatedPullRequestDeps(t *testing.T) BaseDeps { })}} gql := &http.Client{Transport: recorderTransport{handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { var req struct { - Query string `json:"query"` + Query string `json:"query"` + Variables map[string]any `json:"variables"` } require.NoError(t, json.NewDecoder(r.Body).Decode(&req)) var body string @@ -193,6 +196,16 @@ func consolidatedPullRequestDeps(t *testing.T) BaseDeps { body = `{"data":{"resolveReviewThread":{"thread":{"id":"T_1","isResolved":true}}}}` case strings.Contains(q, "reviewThreads("): body = typedPRReviewThreads + if req.Variables["includeReactions"] == true { + body = strings.Replace(body, `"body":"nit"`, `"body":"nit","reactionGroups":[{"content":"HEART","users":{"totalCount":1}}]`, 1) + } + case strings.Contains(q, "nodes(ids:") && strings.Contains(q, "... on PullRequestReview"): + if reflect.DeepEqual(req.Variables["ids"], []any{"R_EMPTY"}) { + body = `{"data":{"nodes":[{"id":"R_EMPTY","reactionGroups":[]}]}}` + } else { + assert.Equal(t, []any{"R_1"}, req.Variables["ids"]) + body = `{"data":{"nodes":[{"id":"R_1","reactionGroups":[{"content":"THUMBS_UP","users":{"totalCount":2}},{"content":"ROCKET","users":{"totalCount":1}}]}]}}` + } case strings.Contains(q, "reviews(first: 100"): body = `{"data":{"repository":{"pullRequest":{"reviews":{"nodes":[{"id":"R_1","author":{"userId":"U_1"}}],"pageInfo":{"hasNextPage":false,"endCursor":""}}}}}}` case strings.Contains(q, "viewer{"): @@ -286,8 +299,12 @@ func TestTypedConsolidatedPullRequestOutputs(t *testing.T) { {"pull_request_read", map[string]any{"method": "get_commits", "pullNumber": 2}, `[]`}, {"pull_request_read", map[string]any{"method": "get_review_comments", "pullNumber": 1, "perPage": 10, "after": "cursor"}, `{"review_threads":[{"id":"T_1","is_resolved":false,"is_outdated":false,"is_collapsed":false,"comments":[{"body":"nit","path":"file","line":3,"original_line":3,"author":"octocat","created_at":"2026-01-01T00:00:00Z","updated_at":"2026-01-01T00:00:00Z","html_url":"https://github.com/owner/repo/pull/1#discussion_r1"}],"total_count":1}],"totalCount":1,"pageInfo":{"hasNextPage":false,"hasPreviousPage":false,"startCursor":"s","endCursor":"e"}}`}, {"pull_request_read", map[string]any{"method": "get_reviews", "pullNumber": 1}, `[{"id":9,"state":"APPROVED","body":"lgtm","html_url":"https://github.com/owner/repo/pull/1#pullrequestreview-9","user":{"login":"octocat"},"commit_id":"abc","author_association":"MEMBER"}]`}, + {"pull_request_read", map[string]any{"method": "get_reviews", "pullNumber": 1, "include_reactions": true}, `[{"id":9,"state":"APPROVED","body":"lgtm","html_url":"https://github.com/owner/repo/pull/1#pullrequestreview-9","user":{"login":"octocat"},"commit_id":"abc","author_association":"MEMBER","reactions":{"total_count":3,"+1":2,"-1":0,"laugh":0,"confused":0,"heart":0,"hooray":0,"rocket":1,"eyes":0}}]`}, + {"pull_request_read", map[string]any{"method": "get_review_comments", "pullNumber": 1, "include_reactions": true}, `{"review_threads":[{"id":"T_1","is_resolved":false,"is_outdated":false,"is_collapsed":false,"comments":[{"body":"nit","path":"file","line":3,"original_line":3,"author":"octocat","created_at":"2026-01-01T00:00:00Z","updated_at":"2026-01-01T00:00:00Z","html_url":"https://github.com/owner/repo/pull/1#discussion_r1","reactions":{"total_count":1,"+1":0,"-1":0,"laugh":0,"confused":0,"heart":1,"hooray":0,"rocket":0,"eyes":0}}],"total_count":1}],"totalCount":1,"pageInfo":{"hasNextPage":false,"hasPreviousPage":false,"startCursor":"s","endCursor":"e"}}`}, {"pull_request_read", map[string]any{"method": "get_reviews", "pullNumber": 2}, `[]`}, {"pull_request_read", map[string]any{"method": "get_reviews", "pullNumber": 3}, `[]`}, + {"pull_request_read", map[string]any{"method": "get_reviews", "pullNumber": 3, "include_reactions": true}, `[]`}, + {"pull_request_read", map[string]any{"method": "get_reviews", "pullNumber": 4, "include_reactions": true}, `[{"id":10,"state":"COMMENTED","html_url":"https://github.com/owner/repo/pull/4#pullrequestreview-10","reactions":{"total_count":0,"+1":0,"-1":0,"laugh":0,"confused":0,"heart":0,"hooray":0,"rocket":0,"eyes":0}}]`}, {"pull_request_read", map[string]any{"method": "get_comments", "pullNumber": 1}, `[{"id":42,"body":"hello","html_url":"https://github.com/owner/repo/pull/1#issuecomment-42"}]`}, {"pull_request_read", map[string]any{"method": "get_comments", "pullNumber": 2}, `[]`}, {"pull_request_read", map[string]any{"method": "get_check_runs", "pullNumber": 1}, `{"total_count":1,"check_runs":[{"id":5,"name":"build","status":"completed","conclusion":"success"}]}`}, From 8c8dfb35b62fb49268dcb6958e7957df457db2e5 Mon Sep 17 00:00:00 2001 From: 206432729 <206432729@qq.com> Date: Wed, 11 Nov 2026 11:17:54 +0800 Subject: [PATCH 2/2] fix: count all actors in review reactions --- pkg/github/pullrequests.go | 2 +- pkg/github/typed_consolidated_pull_request_outputs_test.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/github/pullrequests.go b/pkg/github/pullrequests.go index 29ce096f92..4a8b7960e3 100644 --- a/pkg/github/pullrequests.go +++ b/pkg/github/pullrequests.go @@ -524,7 +524,7 @@ type reviewReactionGroup struct { Content githubv4.ReactionContent Users struct { TotalCount githubv4.Int - } `graphql:"users(first: 1)"` + } `graphql:"users: reactors(first: 1)"` } func summarizeReviewReactions(groups []reviewReactionGroup) *MinimalReactions { diff --git a/pkg/github/typed_consolidated_pull_request_outputs_test.go b/pkg/github/typed_consolidated_pull_request_outputs_test.go index 2cb3d6aa45..0498bfcae5 100644 --- a/pkg/github/typed_consolidated_pull_request_outputs_test.go +++ b/pkg/github/typed_consolidated_pull_request_outputs_test.go @@ -197,9 +197,11 @@ func consolidatedPullRequestDeps(t *testing.T) BaseDeps { case strings.Contains(q, "reviewThreads("): body = typedPRReviewThreads if req.Variables["includeReactions"] == true { + assert.Contains(t, q, "users: reactors(first: 1){totalCount}") body = strings.Replace(body, `"body":"nit"`, `"body":"nit","reactionGroups":[{"content":"HEART","users":{"totalCount":1}}]`, 1) } case strings.Contains(q, "nodes(ids:") && strings.Contains(q, "... on PullRequestReview"): + assert.Contains(t, q, "users: reactors(first: 1){totalCount}") if reflect.DeepEqual(req.Variables["ids"], []any{"R_EMPTY"}) { body = `{"data":{"nodes":[{"id":"R_EMPTY","reactionGroups":[]}]}}` } else {