Skip to content

Commit dfc1419

Browse files
committed
fix: add graphql query to detect PR comments' resolved status
1 parent 048699f commit dfc1419

1 file changed

Lines changed: 38 additions & 3 deletions

File tree

.agents/skills/address-review/SKILL.md

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,49 @@ The argument is a PR number (e.g. `/address-review 98`). If no number is given,
1313

1414
1. Save the current branch name: `git rev-parse --abbrev-ref HEAD`
1515
2. Checkout the PR branch: `gh pr checkout <number> --detach`
16-
3. Fetch all review comments:
16+
3. Fetch review data (pick one):
17+
18+
**REST (simple):** Lists inline review comments; it does **not** include per-thread `resolved` status, so you cannot rely on it alone to skip resolved threads.
1719

1820
```
1921
gh api repos/{owner}/{repo}/pulls/<number>/comments --paginate
2022
```
2123

22-
4. Group comments by file. For each comment, extract: `id`, `path`, `line` (or `original_line`), `body`, `user.login`, `in_reply_to_id` (to detect threads).
23-
5. Filter out threads that are already resolved or where the last message is from the PR author (likely already addressed).
24+
**GraphQL (for filtering resolved threads):** Returns `reviewThreads` with `isResolved`, `isOutdated`, paths/lines, and nested comments—use this when step 5 must honor “already resolved.” Paginate with `cursor` (use `null` or omit for the first page; then pass `reviewThreads.pageInfo.endCursor` while `hasNextPage` is true).
25+
26+
```
27+
gh api graphql -f query='
28+
query($owner:String!, $repo:String!, $number:Int!, $cursor:String) {
29+
repository(owner:$owner, name:$repo) {
30+
pullRequest(number:$number) {
31+
reviewThreads(first:100, after:$cursor) {
32+
pageInfo { hasNextPage endCursor }
33+
nodes {
34+
isResolved
35+
isOutdated
36+
path
37+
line
38+
originalLine
39+
comments(first:100) {
40+
nodes {
41+
databaseId
42+
body
43+
author { login }
44+
createdAt
45+
url
46+
}
47+
}
48+
}
49+
}
50+
}
51+
}
52+
}' -F owner={owner} -F repo={repo} -F number=<number> -F cursor=<cursor>
53+
```
54+
55+
First page: pass JSON `null` for `cursor` (see `gh help api` / your shell for how `gh` expects null). Later pages: set `cursor` to the previous response’s `reviewThreads.pageInfo.endCursor` until `hasNextPage` is false.
56+
57+
4. Group comments by file. For each comment, extract: `id`, `path`, `line` (or `original_line`), `body`, `user.login`, `in_reply_to_id` (to detect threads). If you used GraphQL, map `databaseId` to `id` and thread fields as needed.
58+
5. Filter out threads that are already resolved (when using GraphQL method).
2459
6. Present a numbered summary to the programmer:
2560

2661
```

0 commit comments

Comments
 (0)