Skip to content

Prevent duplicate Copilot review comments on sequential reviews and reply interactions - #11

Closed
halotukozak with Copilot wants to merge 3 commits into
masterfrom
copilot/avoid-duplicate-comments
Closed

Prevent duplicate Copilot review comments on sequential reviews and reply interactions#11
halotukozak with Copilot wants to merge 3 commits into
masterfrom
copilot/avoid-duplicate-comments

Conversation

Copilot AI commented Mar 18, 2026

Copy link
Copy Markdown
Contributor

Copilot duplicates review comments both when new commits are pushed and when users reply to its existing comments, causing comment accumulation across review cycles.

Changes

  • New workflow (.github/workflows/copilot-review.yml) with two triggers:

    • pull_request (opened, synchronize, reopened) — cleans up stale Copilot comments, then re-requests a fresh review
    • pull_request_review_comment (created) — cleans up stale Copilot comments before Copilot auto-re-reviews in response to a reply; skips re-requesting review since Copilot handles that itself
  • Infinite-loop guard — job is skipped when github.actor is a known Copilot bot login (github-copilot[bot], copilot-pull-request-reviewer[bot]), preventing Copilot's own comment events from re-triggering the workflow

  • Scoped cleanup — only deletes review comments authored by known Copilot bot logins (exact allowlist, not substring match) via paginated listReviewComments + deleteReviewComment

  • Safe PR-number resolutioncontext.payload.pull_request?.number ?? context.issue.number handles both event payload shapes


💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

Co-authored-by: halotukozak <64359735+halotukozak@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix duplicate comments in sequential reviews Avoid duplicate Copilot review comments on sequential PR updates Mar 18, 2026
Copilot AI requested a review from halotukozak March 18, 2026 11:11
Co-authored-by: halotukozak <64359735+halotukozak@users.noreply.github.com>
Copilot AI changed the title Avoid duplicate Copilot review comments on sequential PR updates Prevent duplicate Copilot review comments on sequential reviews and reply interactions Mar 18, 2026
@halotukozak
halotukozak marked this pull request as ready for review March 18, 2026 11:27
Copilot AI review requested due to automatic review settings March 18, 2026 11:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a GitHub Actions workflow to prevent Copilot PR review comment duplication across new commits and comment-reply-triggered re-reviews by cleaning up prior Copilot-authored review comments and (on PR open/sync) re-requesting a fresh Copilot review.

Changes:

  • Introduces .github/workflows/copilot-review.yml triggered on pull_request and pull_request_review_comment events.
  • Deletes existing Copilot-authored PR review comments (allowlisted bot logins) via paginated API calls before a new review cycle.
  • Adds an infinite-loop guard to skip runs when the triggering actor is a Copilot bot.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

copilot-review:
# Skip draft PRs; skip when Copilot itself triggers the event to prevent infinite loops
if: |
github.event.pull_request.draft == false &&
if: |
github.event.pull_request.draft == false &&
!contains(fromJSON('["github-copilot[bot]","copilot-pull-request-reviewer[bot]"]'), github.actor)
runs-on: ubuntu-latest
Comment on lines +9 to +12
permissions:
contents: read
pull-requests: write

@halotukozak
halotukozak deleted the copilot/avoid-duplicate-comments branch March 23, 2026 15:52
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.

3 participants