已关闭
Support PR review discussions with unresolved thread metadata #13
urandon创建于  6月27日关闭于  6月28日
urandon
urandon成员
6月27日 创建

Problem

The request in pimenovdmitry/gckit#1 describes a PR review workflow that agents need but gitcode-mcp does not currently expose as a complete user-facing capability.

Today we can read a PR record and some flat comment-like data, but we do not provide a reliable way for an agent to ask: "what review comments still need action, where are they in the diff, and what replies belong to the same thread?"

Required capability

Support reading PR/MR review discussions in a form that is useful for agent follow-up work:

  • list all review discussions/comments for a PR/MR;
  • include file path and line metadata for code review comments when GitCode provides it;
  • distinguish general PR comments from inline code review comments;
  • filter to unresolved review discussions;
  • keep replies grouped with their parent discussion/thread;
  • preserve enough author, timestamp, and resolution metadata for a human or agent to understand the thread;
  • make the result available through normal agent-facing read flows, not only manual curl or external tools.

Acceptance

  • Given a PR/MR with review discussions, a user can fetch all discussions and see every note/reply grouped by discussion.
  • Given the same PR/MR, a user can request unresolved-only discussions and get only threads that still need attention.
  • Inline review comments include file path and relevant line/range metadata when present.
  • General PR comments remain visible and are not confused with inline review comments.
  • Empty PR/MR discussion state returns an empty result, not an opaque error.
  • The capability is documented with at least one public-safe example.

Out of scope

  • Creating PR/MR records; tracked separately by #2.
  • PR/MR-to-issue relation setup; tracked separately by #4.
  • Updating existing issue comments; tracked separately by #7.
likedislike
urandonurandon成员
6月27日 添加了label:enhancement
urandon
urandon成员
6月28日 评论:

Design proposal for #13.

Scope: implement this as a cache-first read feature on top of the existing PR comments collection before adding any speculative GitCode endpoint. The current adapter already reads GET /api/v5/repos/{owner}/{repo}/pulls/{number}/comments; #13 should make the payload richer, durable, and agent-friendly.

Architecture:

flowchart TD
  A["GitCode PR comments API"] --> B["gitcode.PRComment normalizer"]
  B --> C["BulkSyncPRComments"]
  C --> D["cache: pr_comment source + review metadata"]
  D --> E["service.ListPRDiscussions"]
  E --> F["CLI read command"]
  E --> G["MCP list_pr_discussions"]

Data shape:

erDiagram
  PULL_REQUEST ||--o{ PR_COMMENT : has
  PR_DISCUSSION ||--o{ PR_COMMENT : groups
  PR_COMMENT {
    string id
    string discussion_id
    string kind
    string body
    string author
    string path
    int line
    int start_line
    bool resolved
    string parent_id
  }

Proposed changes:

  1. Extend gitcode.PRComment normalization to preserve optional review metadata when GitCode provides it: inline/general kind, path/file path, line/range/position fields, parent/reply id, resolvable/resolved state, author, timestamps, and discussion id.
  2. Persist the metadata during BulkSyncPRComments so normal reads do not need live network access.
  3. Add a service read API that returns discussions grouped by discussion_id, with fallback grouping for general comments that do not have a discussion id. Replies should stay in the same group through parent/discussion ids.
  4. Add unresolved-only filtering. Because resolved may be absent from some GitCode payloads, use tri-state semantics internally: absent metadata should not be treated as resolved.
  5. Expose the read through MCP as list_pr_discussions and through a CLI command with JSON output. Empty PR/comment state should return discussions: [].
  6. Update docs with a sanitized public-safe example and note that inline path/line/resolution fields are present only when GitCode includes them.

Test plan:

  • GitCode model/client fixture test for inline review comment metadata decoding.
  • Service test for grouping replies under discussions and separating general vs inline comments.
  • Service/MCP test for unresolved_only filtering and empty-state behavior.
  • CLI test for JSON output shape.
  • Regression test that existing PR comment sync still creates searchable pr_comment sources.

Main design choice: I would keep the live API surface narrow for this PR and avoid endpoint discovery churn. If later evidence shows GitCode has a better discussions endpoint than /pulls/{number}/comments, the provider can swap to it behind the same service/MCP contract.

likedislike
urandonurandon成员
6月28日 关联了pull request:Implement cached PR review discussions
urandonurandon成员
6月28日 关闭了 issue