worktrunk icon indicating copy to clipboard operation
worktrunk copied to clipboard

review-pr: duplicate CI failure comment during dismiss-and-recomment flow

Open worktrunk-bot opened this issue 8 months ago • 1 comments

Problem

In run 22831994262 on PR #1381, the review bot posted the same CI failure comment twice within 7 seconds (23:11:10 and 23:11:17 UTC). Both reviews are COMMENTED on commit a464e0d4 with identical bodies starting "CI failed — 11 shell wrapper / PTY snapshot tests need updating..."

Evidence from the GitHub API:

Review 3912161478: COMMENTED at 2026-03-08T23:11:10Z
Review 3912161573: COMMENTED at 2026-03-08T23:11:17Z

Root Cause

This is a different code path than the one fixed in #1321 (which added a retry guard for initial review submission). This duplicate occurs during the dismiss-and-recomment flow when the bot:

  1. Approves the PR
  2. CI fails
  3. Bot tries to dismiss its own approval via gh api .../dismissals (POST — fails)
  4. Bot posts CI failure comment via gh pr review --comment
  5. Bot retries dismissal via gh api .../dismissals -X PUT (succeeds)
  6. Bot posts CI failure comment again via gh pr review --comment

The existing retry guard (added in #1322) checks for an existing review before the initial review submission. But this flow bypasses that guard because it's posting a CI failure follow-up comment, not the initial review verdict.

Suggested Fix

The review-pr skill's CI monitoring section should include a duplicate check before posting CI failure comments, similar to the existing guard for initial reviews:

# Before posting CI failure comment, check if one was already posted for this SHA
EXISTING_COMMENT=$(gh api "repos/$REPO/pulls/<number>/reviews" \
  --jq "[.[] | select(.user.login == \"$BOT_LOGIN\" and .commit_id == \"$HEAD_SHA\" and .state == \"COMMENTED\")] | last | .submitted_at // empty")

If a COMMENTED review already exists for the current SHA, skip posting another one.

worktrunk-bot avatar Mar 09 '26 00:03 worktrunk-bot

Resolved by commit dabeffcb (fix(review-pr): add CI failure verification and duplicate comment guard). The review-pr skill now includes a duplicate comment guard that checks for existing COMMENTED reviews before posting.

worktrunk-bot avatar Mar 09 '26 06:03 worktrunk-bot