Repository navigation
Conversation
Every run of the review posts a fresh summary via `gh pr comment`, so a PR pushed N times accumulates N top-level claude[bot] comments. Two independent causes, both need fixing: the prompt tells the model to `gh pr comment`, and without `track_progress` + `use_sticky_comment` the action never provides a reusable comment to update. Add an opt-in `sticky_summary` input (default false; the existing step is untouched behind `if: !inputs.sticky_summary`). When enabled: - The action creates/reuses one tracking comment; the model rewrites its body via `update_claude_comment` to reflect the current head commit. - Top-level comment creation is denied at the permission layer (no `gh pr comment`/`gh pr review`, `gh api` narrowed to GraphQL + the review-comment replies endpoint, creation mutations denied by glob). - Tag mode (forced by `track_progress`) adds edit/commit/push tools by itself; those are denied so the review stays read-only. - Thread reconcile reads threads via GraphQL instead of one unpaginated REST page (30 items, silently truncated on long PRs), includes human replies, and truncates resolved threads to a 300-char gist to bound context. - A thread a human already confirmed is resolved without an extra reply; "still unresolved" is only re-posted when the related code changed or a human replied since the last comment. - Stale-head guard: stop writing if the PR head moved past the reviewed commit. - Regression check against resolved threads by meaning, and report defect classes (all sibling sites) as one finding. - Inline comments are posted with `confirmed: true` and the post-session classifier is disabled, so real findings are not dropped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
[Medium impact] The new review behavior affects PR comments only for callers that enable sticky mode. 建议先修正过期检查再合并;默认未启用新模式的调用方不受该问题影响。
|
| The commit you review is `git log -1 --format=%H` in the checkout. | ||
| Before Step 1 actions, before posting inline comments in Step 4, and before Step 5, run | ||
| `gh pr view ${{ github.event.pull_request.number || inputs.pr_number }} --json headRefOid,state,isDraft`. | ||
| If `headRefOid` differs from the reviewed commit, or the PR is no longer open / is a draft, **stop writing anything** | ||
| and end with a final message that this run is obsolete. A newer run owns the PR; replies based on an old commit are wrong. |
| gh api graphql -f query='{ repository(owner:"${{ github.repository_owner }}", name:"${{ github.event.repository.name }}") { pullRequest(number:${{ github.event.pull_request.number || inputs.pr_number }}) { reviewThreads(first:100) { nodes { id isResolved isOutdated comments(first:20) { nodes { databaseId author { login } path line originalLine createdAt body } } } } } } }' \ | ||
| --jq '[.data.repository.pullRequest.reviewThreads.nodes[] | select(.comments.nodes[0].author.login == "claude") | {id, isResolved, isOutdated, dbid: .comments.nodes[0].databaseId, path: .comments.nodes[0].path, line: (.comments.nodes[0].line // .comments.nodes[0].originalLine), lastActivity: .comments.nodes[-1].createdAt, lastAuthor: .comments.nodes[-1].author.login} + (if .isResolved then {gist: (.comments.nodes[0].body | gsub("<[^>]*>";"") | gsub("\\[[^]]*\\]\\([^)]*\\)";"") | .[0:300])} else {body: .comments.nodes[0].body, replies: [.comments.nodes[1:][] | {a: .author.login, at: .createdAt, body}]} end)]' |
There was a problem hiding this comment.
🟡 Changes recommended
The GraphQL allowance can bypass mutation deny rules, allowing the write-capable token to create top-level posts that this mode is intended to prohibit.
3 open issues
What changed in this PR
Adds opt-in sticky summaries to the reusable code-review workflow, aiming to reduce repeated top-level bot comments while preserving the legacy behavior by default.
Changes:
- Introduces
sticky_summary, using action-managed tracking comments for in-place summary updates. - Adds human-aware thread reconciliation, regression matching, and stale-head checks.
- Restricts model tools and configures confirmed inline findings to post immediately.
| File | Description |
|---|---|
README.md |
Documents sticky mode, caller requirements, and upstream limitations; also reformats tables. |
.github/workflows/code-review.yml |
Adds the input and separate sticky-review step with updated prompts, tracking settings, and tool restrictions. |
Review effort: Balanced
| --allowedTools "Read,Glob,Grep,mcp__github_comment__update_claude_comment,mcp__github_inline_comment__create_inline_comment,Bash(gh api graphql:*),Bash(gh api repos/*/pulls/*/comments/*/replies*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr checks:*),Bash(git log:*),Bash(git blame:*),Bash(git diff:*)" | ||
| --disallowedTools "Bash(*addComment*),Bash(*addPullRequestReview*),Bash(*pulls/*/reviews*),Bash(*issues/*/comments*),Bash(gh pr comment:*),Bash(gh pr review:*),Edit,MultiEdit,Write,NotebookEdit,Bash(git add:*),Bash(git commit:*),Bash(git rm:*),Bash(git push:*),Bash(*git-push.sh*),mcp__github_file_ops__commit_files,mcp__github_file_ops__delete_files" |
| gh api graphql -f query='{ repository(owner:"${{ github.repository_owner }}", name:"${{ github.event.repository.name }}") { pullRequest(number:${{ github.event.pull_request.number || inputs.pr_number }}) { reviewThreads(first:100) { nodes { id isResolved isOutdated comments(first:20) { nodes { databaseId author { login } path line originalLine createdAt body } } } } } } }' \ | ||
| --jq '[.data.repository.pullRequest.reviewThreads.nodes[] | select(.comments.nodes[0].author.login == "claude") | {id, isResolved, isOutdated, dbid: .comments.nodes[0].databaseId, path: .comments.nodes[0].path, line: (.comments.nodes[0].line // .comments.nodes[0].originalLine), lastActivity: .comments.nodes[-1].createdAt, lastAuthor: .comments.nodes[-1].author.login} + (if .isResolved then {gist: (.comments.nodes[0].body | gsub("<[^>]*>";"") | gsub("\\[[^]]*\\]\\([^)]*\\)";"") | .[0:300])} else {body: .comments.nodes[0].body, replies: [.comments.nodes[1:][] | {a: .author.login, at: .createdAt, body}]} end)]' |
| - **Still present** → reply **only if there is something new**: the relevant code changed since `lastActivity` | ||
| (`git log --since="{lastActivity}" --format='%h %s' -- {path}` is non-empty) but did not fix it, or a human | ||
| replied after your last comment. Then state precisely what remains. Otherwise **stay silent** — the sticky |


Problem
Every review run posts a new summary via
gh pr comment, so a PR pushed N times collects N top-level claude[bot] comments. Two independent causes: the prompt tells the model togh pr comment, and withouttrack_progress+use_sticky_commentthe action never provides a reusable comment to update.The current thread reconcile also has gaps observed on real PRs:
pulls/N/comments, 30 items, filtered after fetching), so on long PRs older threads are invisible and issues get re-reported.confirmed: trueare buffered for the post-session classifier, which can drop real findings.Change
New opt-in input
sticky_summary(defaultfalse). The existing step is byte-identical, only guarded byif: ${{ !inputs.sticky_summary }}, so current callers are unaffected. When enabled, a second step runs:track_progress+use_sticky_comment: the action (not the model) creates one tracking comment and reuses it on later runs; the model rewrites its body viaupdate_claude_commentto describe the current head.gh pr comment/gh pr review;gh apinarrowed to GraphQL + the review-comment replies endpoint; creation mutations / review and issue-comment endpoints denied by glob.track_progress) adds edit /git commit/ push tools by itself; these are denied so the review stays read-only.--jqto bound context.git log --since) or a human replied since the last comment.gh pr view --json headRefOid).confirmed: true+classify_inline_comments: false.Verified against the pinned action SHA: tag mode registers the inline-comment MCP server from
--allowedTools; agent mode already runscheckHumanActor, so noallowed_botschange is needed;confirmedexists oncreate_inline_comment. The new thread query + jq was run against a real PR (6 threads → 3.2 KB).Behavior differences vs. the legacy path
create-initial.ts) matches the first claude[bot] top-level comment and is not paginated (~30); documented in README.Not included
conclusionoutput, and bumping the pin would affect every caller.Testing
ifguards checked. actionlint not run locally.sticky_summary: true.🤖 Generated with Claude Code