From 25d31ce4329daf9512df4e0236e02d89d05b0842 Mon Sep 17 00:00:00 2001 From: kaitranntt Date: Tue, 13 Jan 2026 16:03:02 -0500 Subject: [PATCH] fix(ci): prevent AI review self-cancellation with smart concurrency Root cause: When the bot posts a review comment, GitHub fires an issue_comment event that joins the same concurrency group and cancels the in-progress run BEFORE job `if` conditions are evaluated. Solution: Non-actionable triggers (bot comments, comments without /review) get a unique per-run group via format('skip-{0}', github.run_id), while legitimate triggers share the PR-based group for proper cancellation of outdated reviews. --- .github/workflows/ai-review.yml | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ai-review.yml b/.github/workflows/ai-review.yml index 4431d8f3..b724e730 100644 --- a/.github/workflows/ai-review.yml +++ b/.github/workflows/ai-review.yml @@ -24,10 +24,26 @@ on: required: true type: string -# Simple concurrency: one review per PR at a time -# With track_progress disabled, no bot comments are posted during review +# Smart concurrency: Prevents self-cancellation when bot posts review comment +# +# Problem: When the bot posts a review comment, GitHub fires an issue_comment event. +# This new workflow run joins the same concurrency group and cancels the in-progress +# run BEFORE job `if` conditions are evaluated - causing "operation was canceled" error. +# +# Solution: Non-actionable triggers (bot comments, comments without /review) get a +# unique per-run group, while legitimate triggers share the PR-based group for proper +# cancellation of outdated reviews. concurrency: - group: ai-review-${{ github.event.pull_request.number || github.event.issue.number || github.event.inputs.pr_number }} + group: >- + ai-review-${{ + github.event_name == 'issue_comment' && ( + github.event.comment.user.type == 'Bot' || + !contains(github.event.comment.body, '/review') + ) && format('skip-{0}', github.run_id) || + github.event.pull_request.number || + github.event.issue.number || + github.event.inputs.pr_number + }} cancel-in-progress: true jobs: