This document explains the enhanced comment resolution feature that combines both GitHub's REST API and GraphQL API for comprehensive comment resolution functionality.
The enhanced solution provides two levels of comment resolution:
- Visual Resolution (REST API): Updates the comment content to show it's been resolved
- Native Resolution (GraphQL API): Actually resolves the conversation thread in GitHub's UI
- Fetches the original comment content
- Appends a resolution notice with the LLM's reasoning
- Updates the comment body using GitHub's REST API
- Queries GitHub's GraphQL API to find review threads
- Locates the specific thread containing the resolved comment
- Uses the
resolveReviewThreadmutation to mark the conversation as resolved
// Update comment content to show resolution
await this.octokit.pulls.updateReviewComment({
owner: this.config.owner,
repo: this.config.repo,
comment_id: commentId,
body: resolvedBody, // Original content + resolution notice
});// Find the review thread
const findThreadQuery = `
query FindReviewThread($owner: String!, $repo: String!, $prNumber: Int!) {
repository(owner: $owner, name: $repo) {
pullRequest(number: $prNumber) {
reviewThreads(first: 100) {
nodes {
id
isResolved
comments(first: 1) {
nodes {
databaseId
}
}
}
}
}
}
}
`;
// Resolve the thread
const graphqlQuery = `
mutation ResolveReviewThread($threadId: ID!) {
resolveReviewThread(input: { threadId: $threadId }) {
thread {
id
isResolved
}
}
}
`;- Comments show clear resolution notices with reasoning
- Threads are properly collapsed in GitHub's UI
- Native "resolved" badges appear in the GitHub interface
- Works with existing GitHub review workflows
- Preserves original comment content
- Maintains audit trail of resolution reasoning
- Resolved conversations are hidden from active discussions
- Clear visual indicators of what was resolved and why
- Follows GitHub's native UX patterns
When a comment is resolved, it gets updated to show:
Consider adding input validation here
---
✅ **Resolved by CodePress Review**
> Input validation was added in lines 45-52 using Joi schema validationAnd the conversation thread gets natively resolved in GitHub's UI.
The implementation includes comprehensive error handling:
- Rate Limiting: Automatic retry with exponential backoff
- GraphQL Errors: Graceful fallback if thread resolution fails
- Comment Updates: Separate error handling for content updates
- Thread Discovery: Safe handling when threads can't be found
- Uses
databaseIdto match REST API comment IDs with GraphQL comment nodes - Handles pagination by looping through all review threads to find the containing thread
- Only resolves threads that aren't already resolved
- Both REST and GraphQL calls respect GitHub's rate limits
- Uses existing rate limit handler for retry logic
- Batches operations efficiently
- Efficient pagination for fetching review threads
- Minimal API calls per resolution
- Efficient thread matching algorithm
The enhanced resolution is automatically used when the LLM identifies resolved comments:
for (const resolvedComment of agentResponse.resolvedComments) {
try {
await this.githubClient.resolveReviewComment(
this.config.pr,
parseInt(resolvedComment.commentId, 10),
resolvedComment.reason,
);
} catch (error) {
console.error(
`Failed to resolve comment ${resolvedComment.commentId}:`,
error,
);
}
}Potential improvements to consider:
- Bulk Operations: Resolve multiple threads in a single GraphQL mutation
- Thread Metadata: Store additional resolution metadata
- Unresolve Capability: Add ability to unresolve comments if needed
- Resolution Types: Different resolution types (fixed, won't fix, duplicate, etc.)
This enhanced approach provides the best of both worlds:
- Visual clarity through updated comment content
- Native functionality through proper thread resolution
- Complete integration with GitHub's review workflow
The solution ensures that resolved comments are properly handled both visually and functionally, providing a seamless experience for developers using the CodePress Review system.