Skip to content

Replace code-review slash command with DispatchOps polling dispatcher - #5

Merged
jeffhandley merged 4 commits into
mainfrom
copilot/update-code-review-concurrency
Apr 12, 2026
Merged

jeffhandley merged 4 commits into
mainfrom
copilot/update-code-review-concurrency

Conversation

Copilot AI commented Apr 12, 2026 •

Copy link
Copy Markdown

Replaces the complex slash-command-triggered concurrency approach with a simple DispatchOps polling pattern that automatically finds and reviews qualifying PRs on a schedule.

Problems Fixed

Original issue: any comment could cancel a running review

The previous concurrency group expression grouped any PR comment (not just slash commands) from the PR author into the same cancellation bucket, causing regular discussion comments to silently kill in-progress reviews. The fix attempts using complex startsWith guards and per-actor fallback groups proved too complicated to reason about safely.

New approach: scheduled polling dispatcher

Instead of reacting to comments, a new code-review-dispatcher.yml workflow runs every 15 minutes and dispatches code-review runs automatically. A PR is eligible when all of the following are true:

  • Open and not a draft
  • Has at least one changed file (non-empty diff)
  • Head commit is ≥5 minutes old (avoids reviewing mid-push or during rapid commits)
  • No existing PR comment carries the marker <!-- aw-code-review-sha: <current-head-sha> --> (posted by the code-review agent after each completed review)

Up to 3 reviews are dispatched per cycle; subsequent polls pick up any remainder.

Files Changed

  • .github/workflows/code-review-dispatcher.yml (new) — standard GitHub Actions workflow (no agentic machinery needed; logic is fully deterministic). Runs on a 15-minute cron and manual workflow_dispatch. Uses a single-instance concurrency group (code-review-dispatcher, no cancel) to prevent overlapping polls. Requires actions: write to trigger workflow_dispatch on code-review.lock.yml.

  • .github/workflows/code-review.md — simplified to workflow_dispatch-only. Removed slash command trigger, complex concurrency expression, pre-activation authorization checks, and hide-comment safe output. Now uses a simple per-PR concurrency group (code-review-{pr_number}, cancel-in-progress: false) so a queued dispatch never stomps a running review. Agent body updated to always fetch/checkout the PR branch and embed <!-- aw-code-review-sha: SHA --> in every review comment.

  • .github/workflows/code-review.lock.yml — updated to match: removed issue_comment/pull_request_review_comment triggers, simplified concurrency block, removed authorize-invoker pre-activation step and its outputs, simplified activation if: condition.

Note: The frontmatter_hash in the lock file metadata has been set to a placeholder since gh aw compile was unavailable in this environment. Run gh aw compile code-review after merging to regenerate a clean lock file with the correct hash.

Note

This PR was generated by GitHub Copilot.

@jeffhandley

Copy link
Copy Markdown
Owner

@copilot this is way too complicated.

Try a new polling approach to find all PRs (from any author) that are open, non-draft, non-empty, with at least 5 minutes since the last push/synchronize, were the code-review skill has not yet run on the current state of the PR, and dispatch code-review runs against them. This follows the DispatchOps approach from gh-aw.

Copilot AI commented Apr 12, 2026

Copy link
Copy Markdown
Author

@copilot this is way too complicated.

Try a new polling approach to find all PRs (from any author) that are open, non-draft, non-empty, with at least 5 minutes since the last push/synchronize, were t...

Done in commit daeb15b5. Replaced the complicated concurrency approach with a simple DispatchOps polling pattern:

code-review-dispatcher.yml (new) — a standard GitHub Actions workflow that runs every 15 minutes and dispatches code-review.lock.yml for each open, non-draft PR that:

  • Has at least one changed file
  • Has a head commit ≥5 minutes old (avoids reviewing mid-push)
  • Has no existing review comment with <!-- aw-code-review-sha: <current-sha> --> for the current head commit

Dispatches up to 3 reviews per cycle; the next poll picks up any remaining PRs.

code-review.md — simplified to workflow_dispatch-only. No slash command, no concurrency group expression, no authorization checks. Uses a simple per-PR concurrency group (code-review-{pr_number}, no cancel) so a queued dispatch can't stomp a running one. Agent embeds the SHA marker so the dispatcher knows a review already exists.

code-review.lock.yml — updated to match: removed issue_comment/pull_request_review_comment triggers, simplified concurrency, and stripped the authorize-invoker pre-activation step.

Copilot AI changed the title Fix code-review workflow concurrency to prevent unwanted cancellations Replace code-review slash command with DispatchOps polling dispatcher Apr 12, 2026
@jeffhandley
jeffhandley marked this pull request as ready for review April 12, 2026 19:00
@jeffhandley
jeffhandley merged commit e765b21 into main Apr 12, 2026
1 check passed
@jeffhandley
jeffhandley deleted the copilot/update-code-review-concurrency branch April 12, 2026 19:38
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.

2 participants