Skip to content

Commit 3140f86

Browse files
committed
feat: implement ResolveReviewThread function
1 parent f4f1fec commit 3140f86

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

pkg/github/pullrequests.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,6 +1746,60 @@ func DeletePendingPullRequestReview(ctx context.Context, client *githubv4.Client
17461746
return utils.NewToolResultText("pending pull request review successfully deleted"), nil
17471747
}
17481748

1749+
// ResolveReviewThread resolves or unresolves a PR review thread using GraphQL mutations.
1750+
func ResolveReviewThread(ctx context.Context, client *githubv4.Client, threadID string, resolve bool) (*mcp.CallToolResult, error) {
1751+
if threadID == "" {
1752+
return utils.NewToolResultError("threadId is required for resolve_thread and unresolve_thread methods"), nil
1753+
}
1754+
1755+
if resolve {
1756+
var mutation struct {
1757+
ResolveReviewThread struct {
1758+
Thread struct {
1759+
ID githubv4.ID
1760+
IsResolved githubv4.Boolean
1761+
}
1762+
} `graphql:"resolveReviewThread(input: $input)"`
1763+
}
1764+
1765+
input := githubv4.ResolveReviewThreadInput{
1766+
ThreadID: githubv4.ID(threadID),
1767+
}
1768+
1769+
if err := client.Mutate(ctx, &mutation, input, nil); err != nil {
1770+
return ghErrors.NewGitHubGraphQLErrorResponse(ctx,
1771+
"failed to resolve review thread",
1772+
err,
1773+
), nil
1774+
}
1775+
1776+
return utils.NewToolResultText("review thread resolved successfully"), nil
1777+
}
1778+
1779+
// Unresolve
1780+
var mutation struct {
1781+
UnresolveReviewThread struct {
1782+
Thread struct {
1783+
ID githubv4.ID
1784+
IsResolved githubv4.Boolean
1785+
}
1786+
} `graphql:"unresolveReviewThread(input: $input)"`
1787+
}
1788+
1789+
input := githubv4.UnresolveReviewThreadInput{
1790+
ThreadID: githubv4.ID(threadID),
1791+
}
1792+
1793+
if err := client.Mutate(ctx, &mutation, input, nil); err != nil {
1794+
return ghErrors.NewGitHubGraphQLErrorResponse(ctx,
1795+
"failed to unresolve review thread",
1796+
err,
1797+
), nil
1798+
}
1799+
1800+
return utils.NewToolResultText("review thread unresolved successfully"), nil
1801+
}
1802+
17491803
// AddCommentToPendingReview creates a tool to add a comment to a pull request review.
17501804
func AddCommentToPendingReview(t translations.TranslationHelperFunc) inventory.ServerTool {
17511805
schema := &jsonschema.Schema{

0 commit comments

Comments
 (0)