Skip to content

feat: add list_recent_unresolved tool to surface comments on merged PRs#183

Merged
ichoosetoaccept merged 1 commit intomainfrom
02-18-feat-add-list_recent_unresolved-tool-to-surface-comments-on-merged-prs
Feb 18, 2026
Merged

feat: add list_recent_unresolved tool to surface comments on merged PRs#183
ichoosetoaccept merged 1 commit intomainfrom
02-18-feat-add-list_recent_unresolved-tool-to-surface-comments-on-merged-prs

Conversation

@ichoosetoaccept
Copy link
Member

@ichoosetoaccept ichoosetoaccept commented Feb 18, 2026

Summary

Add a list_recent_unresolved MCP tool that scans recently merged PRs for unresolved review threads. Closes #182.

Problem

When agents review PR stacks, they only discover the current open stack via gt log. Reviewers like Greptile that post late-arriving comments on already-merged PRs are invisible — agents miss actionable feedback.

Solution

New tool: list_recent_unresolved

  • Fetches the N most recently merged PRs via gh pr list --state merged
  • Reuses existing _fetch_pr_summary() (lightweight GraphQL — first comment per thread only)
  • Filters to only PRs with unresolved threads (skips clean ones)
  • Returns StackReviewStatusResult — same format as summarize_review_status, zero new models

Parameters:

  • repo: explicit repo or auto-detect
  • limit: how many merged PRs to scan (default 10, max 50)

Changes

  • src/codereviewbuddy/tools/stack.py: _fetch_merged_prs() helper + list_recent_unresolved() async function
  • src/codereviewbuddy/server.py: register MCP tool
  • tests/test_stack.py: 5 new tests
  • tests/test_mcp_integration.py: update expected tool set + count

Copy link
Member Author

ichoosetoaccept commented Feb 18, 2026

@greptile-apps
Copy link

greptile-apps bot commented Feb 18, 2026

Greptile Summary

Adds a new list_recent_unresolved MCP tool that scans recently merged PRs for unresolved review threads, addressing the blind spot where late-arriving reviewer comments on already-merged PRs go unnoticed by agents.

  • New _fetch_merged_prs() helper fetches merged PRs via gh pr list --state merged, capped at 50
  • list_recent_unresolved() iterates merged PRs, reuses existing _fetch_pr_summary() GraphQL query, and filters to only PRs with unresolved threads
  • Returns StackReviewStatusResult — zero new models, consistent with summarize_review_status
  • MCP tool registered in server.py with proper error handling and workspace detection
  • 7 new tests covering filtering, empty states, auto-detection, progress reporting, and CLI argument passing
  • Integration test updated to expect 12 tools

Confidence Score: 4/5

  • This PR is safe to merge — clean additive feature with good test coverage and no breaking changes.
  • The implementation is well-structured, follows existing codebase patterns exactly, reuses existing models and helpers, and has comprehensive test coverage. No new dependencies or breaking changes. The only minor concern is the sequential GraphQL calls for each merged PR (no concurrency), but this matches the existing pattern in summarize_review_status.
  • No files require special attention.

Important Files Changed

Filename Overview
src/codereviewbuddy/tools/stack.py Adds _fetch_merged_prs() helper and list_recent_unresolved() async function. Clean implementation that reuses existing _fetch_pr_summary() and follows established patterns. Sequential GraphQL calls per merged PR could be slow for large limits but is consistent with how summarize_review_status works.
src/codereviewbuddy/server.py Registers new list_recent_unresolved MCP tool with proper error/cancellation handling. Follows the established pattern of other tool handlers including _check_auto_detect_prerequisites with has_pr=True.
tests/test_stack.py 7 new tests covering core scenarios: filtering PRs with unresolved threads, empty states, all-resolved case, auto-detection, progress reporting, and CLI argument verification. Good coverage with clear test data fixtures.
tests/test_mcp_integration.py Correctly adds list_recent_unresolved to expected tool set and bumps expected tool count from 11 to 12.

Sequence Diagram

sequenceDiagram
    participant Agent as MCP Agent
    participant Server as server.py
    participant Stack as stack.py
    participant GH as gh CLI / GraphQL

    Agent->>Server: list_recent_unresolved(repo, limit)
    Server->>Server: _get_workspace_cwd()
    Server->>Server: _check_auto_detect_prerequisites()
    Server->>Stack: list_recent_unresolved()

    alt repo provided
        Stack->>Stack: split("owner/repo")
    else repo not provided
        Stack->>GH: get_repo_info()
        GH-->>Stack: (owner, repo_name)
    end

    Stack->>GH: _fetch_merged_prs(gh pr list --state merged)
    GH-->>Stack: [{number, title, url, mergedAt}, ...]

    loop For each merged PR
        Stack->>GH: _fetch_pr_summary(GraphQL reviewThreads)
        GH-->>Stack: PRReviewStatusSummary
        alt unresolved > 0
            Stack->>Stack: append to summaries
        end
    end

    Stack-->>Server: StackReviewStatusResult(prs with unresolved only)
    Server-->>Agent: StackReviewStatusResult
Loading

Last reviewed commit: 27e69e4

Copy link
Member Author

ichoosetoaccept commented Feb 18, 2026

Merge activity

  • Feb 18, 10:46 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Feb 18, 10:47 AM UTC: Graphite rebased this pull request as part of a merge.
  • Feb 18, 10:51 AM UTC: Graphite couldn't merge this PR because it failed optional checks and "ignore optional checks" was not selected.

@ichoosetoaccept ichoosetoaccept changed the base branch from 02-18-fix-check-stderr-for-claude-code-detection-and-exclude-empty-env-from-deeplink to graphite-base/183 February 18, 2026 10:46
@ichoosetoaccept ichoosetoaccept changed the base branch from graphite-base/183 to main February 18, 2026 10:46
@ichoosetoaccept ichoosetoaccept force-pushed the 02-18-feat-add-list_recent_unresolved-tool-to-surface-comments-on-merged-prs branch from 4916c9d to d0d8ee4 Compare February 18, 2026 10:47
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@blacksmith-sh

This comment has been minimized.

@ichoosetoaccept ichoosetoaccept force-pushed the 02-18-feat-add-list_recent_unresolved-tool-to-surface-comments-on-merged-prs branch from d0d8ee4 to 482c17f Compare February 18, 2026 10:54
@ichoosetoaccept ichoosetoaccept force-pushed the 02-18-feat-add-list_recent_unresolved-tool-to-surface-comments-on-merged-prs branch from 482c17f to 27e69e4 Compare February 18, 2026 11:00
@ichoosetoaccept ichoosetoaccept merged commit 46d7d9d into main Feb 18, 2026
6 checks passed
@ichoosetoaccept ichoosetoaccept deleted the 02-18-feat-add-list_recent_unresolved-tool-to-surface-comments-on-merged-prs branch February 18, 2026 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: surface unresolved comments on recently merged PRs

1 participant