ResolveReviewThread resolves or unresolves a PR review thread using GraphQL mutations.
(ctx context.Context, client *githubv4.Client, threadID string, resolve bool)
| 2051 | |
| 2052 | // ResolveReviewThread resolves or unresolves a PR review thread using GraphQL mutations. |
| 2053 | func ResolveReviewThread(ctx context.Context, client *githubv4.Client, threadID string, resolve bool) (*mcp.CallToolResult, error) { |
| 2054 | if threadID == "" { |
| 2055 | return utils.NewToolResultError("threadId is required for resolve_thread and unresolve_thread methods"), nil |
| 2056 | } |
| 2057 | |
| 2058 | if resolve { |
| 2059 | var mutation struct { |
| 2060 | ResolveReviewThread struct { |
| 2061 | Thread struct { |
| 2062 | ID githubv4.ID |
| 2063 | IsResolved githubv4.Boolean |
| 2064 | } |
| 2065 | } `graphql:"resolveReviewThread(input: $input)"` |
| 2066 | } |
| 2067 | |
| 2068 | input := githubv4.ResolveReviewThreadInput{ |
| 2069 | ThreadID: githubv4.ID(threadID), |
| 2070 | } |
| 2071 | |
| 2072 | if err := client.Mutate(ctx, &mutation, input, nil); err != nil { |
| 2073 | return ghErrors.NewGitHubGraphQLErrorResponse(ctx, |
| 2074 | "failed to resolve review thread", |
| 2075 | err, |
| 2076 | ), nil |
| 2077 | } |
| 2078 | |
| 2079 | return utils.NewToolResultText("review thread resolved successfully"), nil |
| 2080 | } |
| 2081 | |
| 2082 | // Unresolve |
| 2083 | var mutation struct { |
| 2084 | UnresolveReviewThread struct { |
| 2085 | Thread struct { |
| 2086 | ID githubv4.ID |
| 2087 | IsResolved githubv4.Boolean |
| 2088 | } |
| 2089 | } `graphql:"unresolveReviewThread(input: $input)"` |
| 2090 | } |
| 2091 | |
| 2092 | input := githubv4.UnresolveReviewThreadInput{ |
| 2093 | ThreadID: githubv4.ID(threadID), |
| 2094 | } |
| 2095 | |
| 2096 | if err := client.Mutate(ctx, &mutation, input, nil); err != nil { |
| 2097 | return ghErrors.NewGitHubGraphQLErrorResponse(ctx, |
| 2098 | "failed to unresolve review thread", |
| 2099 | err, |
| 2100 | ), nil |
| 2101 | } |
| 2102 | |
| 2103 | return utils.NewToolResultText("review thread unresolved successfully"), nil |
| 2104 | } |
| 2105 | |
| 2106 | // AddCommentToPendingReviewParams contains the parameters for adding a comment to a pending review. |
| 2107 | type AddCommentToPendingReviewParams struct { |
no test coverage detected