Create new comment on synchronize/reopened (not update canonical) by igerber · Pull Request #418 · igerber/diff-diff · GitHub
Skip to content

Create new comment on synchronize/reopened (not update canonical)#418

Merged
igerber merged 2 commits into
mainfrom
fix-rerun-on-push
May 12, 2026
Merged

Create new comment on synchronize/reopened (not update canonical)#418
igerber merged 2 commits into
mainfrom
fix-rerun-on-push

Conversation

@igerber

@igerber igerber commented May 12, 2026

Copy link
Copy Markdown
Owner

Summary

PR #416 expanded the workflow's `pull_request` trigger from `[opened]` to
`[opened, reopened, synchronize]` so PRs auto-re-review on push, but didn't update
the post-comment step. The step's `isRerun` check only treated `issue_comment` and
`pull_request_review_comment` as reruns (create new comment); every other event
fell through to update-canonical.

Effect: pushing a rebase or new commits to a PR re-runs the review and silently
overwrites the prior review comment via GitHub's update-comment API. GitHub does
not expose issue-comment edit history, so the previous review content is gone once
the update lands.

This fix treats any non-`opened` `pull_request` event as a rerun:

```js
const isRerun =
context.eventName === "issue_comment" ||
context.eventName === "pull_request_review_comment" ||
(context.eventName === "pull_request" &&
context.payload.action !== "opened");
```

Only `pull_request.opened` updates the canonical comment in place. Push, reopen,
manual `/ai-review`, and review-comment triggers all create a new comment so prior
review content is preserved and each push generates a notification.

Methodology references

  • N/A — infrastructure-only fix. No `diff_diff/` source files changed.

Validation

  • `pytest tests/test_openai_review.py -q` → 172 passed.
  • 2 new contract tests in `TestWorkflowCommentPosting` pin the `isRerun` expression's
    non-opened branch and comment-event branches so this can't silently regress.

Backward-compatibility

  • `` canonical marker preserved. Existing canonical
    comments continue to update on initial-open events.
  • `` rerun marker preserved (uniqueness per
    run prevents collisions with future reruns).

Security / privacy

  • Confirm no secrets/PII in this PR: Yes.

🤖 Generated with Claude Code

PR #416 expanded the workflow trigger from `pull_request: [opened]` to
`[opened, reopened, synchronize]` so PRs would auto-re-review on push,
but didn't update the post-comment step. That step's `isRerun` check
only treated `issue_comment` and `pull_request_review_comment` as reruns
(create new comment); every other event — including `pull_request:
synchronize` — fell through to the update-canonical branch.

Effect: pushing a rebase or new commits to a PR re-runs the review and
silently overwrites the prior review comment via the update-comment API.
GitHub does not expose issue-comment edit history, so the previous
review content is gone once the update lands. This is a real data-loss
footgun beyond the obvious UX regression (no notification on update,
review history not preserved).

Fix: treat any non-opened pull_request event as a rerun.

  const isRerun =
    context.eventName === "issue_comment" ||
    context.eventName === "pull_request_review_comment" ||
    (context.eventName === "pull_request" &&
     context.payload.action !== "opened");

Only `pull_request.opened` updates the canonical comment in place
(creating it if absent). Everything else — push, reopen, manual
/ai-review, or review-comment trigger — creates a new comment so prior
review content is preserved and each push generates a notification.

Tests: 2 new assertions in `TestWorkflowCommentPosting` that pin the
isRerun expression's non-opened branch + the comment-event branches,
so this can't silently regress again. 172 tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

R1 review on PR #418 caught the sibling-surface gap: the post-comment
step's JS `isRerun` was updated to treat synchronize/reopened as reruns,
but the prompt-build step's YAML `IS_RERUN` env was not. Effect: on
synchronize/reopened, a new comment was posted (correct) but the prompt
omitted the <previous-ai-review-output> block and re-review framing
(incorrect), so the model could not focus on whether prior findings were
addressed.

Fix mirrors the JS predicate into the YAML predicate:

  IS_RERUN: ${{ github.event_name == 'issue_comment'
             || github.event_name == 'pull_request_review_comment'
             || (github.event_name == 'pull_request'
                 && github.event.action != 'opened') }}

Also expands TestWorkflowCommentPosting to pin BOTH gates and the parity
between them, so future edits to one cannot silently diverge from the
other. New tests:

  - test_yaml_isrerun_includes_non_opened_pull_request
  - test_yaml_isrerun_still_includes_comment_events
  - test_both_gates_enumerate_same_triggers

175 tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

@igerber igerber added the ready-for-ci Triggers CI test workflows label May 12, 2026
@igerber igerber merged commit c86fc2e into main May 12, 2026
25 of 26 checks passed
@igerber igerber deleted the fix-rerun-on-push branch May 12, 2026 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ci Triggers CI test workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant