angelxmoreno / angelxmoreno/mcp-github-code-review

Implement individual thread comment pagination for threads with >100 comments

Open
#4 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1
Forks
0
PR merge metrics
No merged PRs in 30d

Description

## Problem

Currently, the GitHubService implements pagination for review threads (unlimited threads can be fetched), but individual thread comments are limited to the first 100 comments per thread. When a thread has >100 comments, we log a warning but don't fetch the remaining comments.

## Current Implementation Status

✅ **Completed**: Review threads pagination (no 100-thread limit)
✅ **Completed**: First 100 comments per thread fetched
⚠️ **Limited**: Individual thread comments >100 are not fetched

## Proposed Solution

Create a separate function `fetchRemainingCommentsForThread()` that:

1. **Takes thread-specific parameters**: threadId, cursor, owner, repo, prNumber
2. **Uses thread-specific GraphQL query**:
```graphql
query($owner: String!, $repo: String!, $pr: Int!, $threadId: ID!, $cursor: String) {
repository(owner: $owner, name: $repo) {
pullRequest(number: $pr) {
reviewThread(id: $threadId) {
comments(first: 100, after: $cursor) {
nodes {
databaseId, body, author { login }, createdAt, url,
path, position, isMinimized
}
pageInfo { hasNextPage endCursor }
}
}
}
}
}
```
3. **Iterates through all comment pages** until `hasNextPage` is false
4. **Called conditionally** only when `thread.comments.pageInfo.hasNextPage` is true

## Implementation Details

### New Method Signature
```typescript
private async fetchRemainingCommentsForThread(
owner: string,
repo: string,
prNumber: number,
threadId: string,
cursor: string
): Promise
```

### Integration Point
Update `extractCommentsFromThread()` to:
- Check if `thread.comments.pageInfo.hasNextPage` is true
- If true, call `fetchRemainingCommentsForThread()` with the cursor
- Merge results with initial 100 comments

### Error Handling
- Use same GitHubServiceError pattern as existing methods
- Add appropriate logging for comment pagination progress
- Handle GraphQL errors gracefully

## Why This Approach

1. **Incremental Enhancement**: Builds on existing solid foundation
2. **Performance**: Only makes additional calls when needed (rare case)
3. **Separation of Concerns**: Different pagination strategies in separate functions
4. **Future-Ready**: Current implementation already captures necessary cursors
5. **Backward Compatible**: No breaking changes to existing API

## Acceptance Criteria

- [ ] `fetchRemainingCommentsForThread()` method implemented
- [ ] Integration with `extractCommentsFromThread()`
- [ ] Proper TypeScript types for thread-specific GraphQL response
- [ ] Unit tests covering comment pagination scenarios
- [ ] Update existing warning log to debug level (since we'll fetch remaining)
- [ ] Performance testing with threads that have >100 comments

## Priority

**Medium** - This is an enhancement for edge cases. Most threads have <100 comments, and we already solve the main pagination problem (unlimited threads).

## Related

Implements complete solution for cursor-based pagination comment from PR review.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading the GitHubService implementation and extractCommentsFromThread(), then compare the existing review-thread pagination with the thread-specific GraphQL query in this issue. Done means comments beyond the first 100 are fetched and merged, errors and progress are handled consistently, the warning is downgraded, and unit tests cover paginated and non-paginated threads.

Written by the indexing model from the issue text.

Assessment

Tech stack
github, typescript
Domain
api, backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.