Skip to content

Commit 53f22d2

Browse files
committed
Fix address-review comment fetching and thread resolution flow
Applied via @cursor push command
1 parent 8b2f132 commit 53f22d2

1 file changed

Lines changed: 22 additions & 10 deletions

File tree

commands/address-review.md

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,31 @@ gh api repos/${REPO}/issues/comments/{COMMENT_ID} | jq '{body: .body, user: .use
4242
**If a specific review ID is provided (`#pullrequestreview-...`):**
4343

4444
```bash
45-
gh api repos/${REPO}/pulls/{PR_NUMBER}/reviews/{REVIEW_ID}/comments | jq '[.[] | {id: .id, path: .path, body: .body, line: .line, start_line: .start_line, user: .user.login}]'
45+
# Review body (often contains summary feedback)
46+
gh api repos/${REPO}/pulls/{PR_NUMBER}/reviews/{REVIEW_ID} | jq '{id: .id, body: .body, state: .state, user: .user.login, html_url: .html_url}'
47+
48+
# Inline comments for this review
49+
gh api --paginate repos/${REPO}/pulls/{PR_NUMBER}/reviews/{REVIEW_ID}/comments | jq '[.[] | {id: .id, node_id: .node_id, path: .path, body: .body, line: .line, start_line: .start_line, user: .user.login, in_reply_to_id: .in_reply_to_id}]'
4650
```
4751

48-
**If only PR number is provided (fetch all PR review comments):**
52+
Include the review body as a general comment when it contains actionable feedback.
53+
54+
**If only PR number is provided (fetch all PR comments):**
4955

5056
```bash
51-
gh api repos/${REPO}/pulls/{PR_NUMBER}/comments | jq '[.[] | {id: .id, path: .path, body: .body, line: .line, start_line: .start_line, user: .user.login, in_reply_to_id: .in_reply_to_id}]'
57+
# Inline code review comments
58+
gh api --paginate repos/${REPO}/pulls/{PR_NUMBER}/comments | jq '[.[] | {id: .id, node_id: .node_id, type: "review", path: .path, body: .body, line: .line, start_line: .start_line, user: .user.login, in_reply_to_id: .in_reply_to_id}]'
59+
60+
# General PR discussion comments (not tied to specific lines)
61+
gh api --paginate repos/${REPO}/issues/{PR_NUMBER}/comments | jq '[.[] | {id: .id, node_id: .node_id, type: "issue", body: .body, user: .user.login, html_url: .html_url}]'
62+
```
63+
64+
For review comments, fetch review thread metadata and attach `thread_id` by matching each review comment's `node_id`:
65+
66+
```bash
67+
OWNER=${REPO%/*}
68+
NAME=${REPO#*/}
69+
gh api graphql --paginate -f owner="${OWNER}" -f name="${NAME}" -F pr={PR_NUMBER} -f query='query($owner:String!, $name:String!, $pr:Int!, $endCursor:String) { repository(owner:$owner, name:$name) { pullRequest(number:$pr) { reviewThreads(first:100, after:$endCursor) { nodes { id isResolved comments(first:100) { nodes { id databaseId } } } pageInfo { hasNextPage endCursor } } } } }' | jq '[.data.repository.pullRequest.reviewThreads.nodes[] | {thread_id: .id, is_resolved: .isResolved, comments: [.comments.nodes[] | {node_id: .id, id: .databaseId}]}]'
5270
```
5371

5472
**Filtering comments:**
@@ -118,13 +136,7 @@ gh api repos/${REPO}/issues/{PR_NUMBER}/comments -X POST -f body="<response>"
118136
gh api repos/${REPO}/pulls/{PR_NUMBER}/comments/{COMMENT_ID}/replies -X POST -f body="<response>"
119137
```
120138

121-
**For standalone review comments (not in a thread):**
122-
123-
```bash
124-
gh api repos/${REPO}/pulls/{PR_NUMBER}/comments -X POST -f body="<response>" -f commit_id="<COMMIT_SHA>" -f path="<FILE_PATH>" -f line=<LINE_NUMBER> -f side="RIGHT"
125-
```
126-
127-
Note: `side` is required when using `line`. Use `"RIGHT"` for the PR commit side (most common) or `"LEFT"` for the base commit side.
139+
Use the `/replies` endpoint for all existing review comments, including standalone top-level comments.
128140

129141
The response should briefly explain:
130142

0 commit comments

Comments
 (0)