Skip to content

feat: subscribe to pull_request.synchronize and .reopened (Bug #35)#50

Open
avrabe wants to merge 1 commit intomainfrom
fix/subscribe-pr-events
Open

feat: subscribe to pull_request.synchronize and .reopened (Bug #35)#50
avrabe wants to merge 1 commit intomainfrom
fix/subscribe-pr-events

Conversation

@avrabe
Copy link
Copy Markdown
Contributor

@avrabe avrabe commented May 1, 2026

Summary

Why

The bot only subscribed to .opened and .closed. Force-pushes and reopens were silent. reviewPullRequest already supersedes prior bot comments, so re-running on synchronize is a no-op visually if the diff is unchanged and a clean replacement otherwise.

Out of scope

The bug listed five additional events (pull_request_review*, check_run.rerequested, installation.*). Those need behavioural decisions (what should the bot do when a human leaves a review?) and are deferred to a follow-up.

Test plan

  • npm test → 838 pass (was 834, +4 new)
  • npm run lint → clean
  • Live-fire on a rivet PR after deploy: confirm a force-push triggers a new bot review and supersedes the old one

Risk

Low. Same code path as .opened for the review side. Synchronize fires on every push, so review load goes up — existing throttling in reviewPullRequest (_reviewTimestamps) handles it.

🤖 Generated with Claude Code

Why: Probot/Octokit-expert agent flagged that the bot only listened to
`pull_request.opened` and `.closed`. Real-world PR lifecycles include:
  - force-push / new commits → `synchronize` (bot was silent)
  - reopen-after-close → `reopened` (bot was silent)
The bot couldn't re-review on force-push, which was the most-asked-for
behaviour during rivet PR triage.

What:
  - Extract `handlePullRequestOpenedOrReopened` so `.opened` and
    `.reopened` share one code path (auto-merge enable + AI review +
    dependabot config check).
  - New `pull_request.synchronize` handler runs only AI review.
    `reviewPullRequest` already calls `supersedePreviousReviews`, so the
    older bot review is hidden and the PR shows only the latest.
  - Bot-authored PRs (dependabot, etc.) are still skipped on synchronize
    just like on opened.

Out of scope (deferred to a follow-up): pull_request_review,
pull_request_review_comment, check_run.rerequested,
installation.created, installation_repositories.added — these need
non-trivial behaviour decisions and shouldn't be lumped in.

Test plan:
  - 4 new tests in __tests__/integration/app.test.js covering:
    subscription registration, synchronize → review, synchronize-bot →
    skip, reopened → review.
  - Updated `app.on` call-count assertion 6 → 8.
  - npm test → 838 pass (was 834).
  - npm run lint → clean.

Risk: low — handler shares the same code path as `.opened` for review,
which is exercised in production daily. The synchronize event arrives
on every push so the AI review queue load increases, but the existing
`reviewPullRequest` already throttles via `_reviewTimestamps` and
supersedes previous reviews.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant