Skip to content

fix(item): don't open a redundant PR when item done runs after the PR already merged - #329

Merged
getappz merged 1 commit into
masterfrom
task/349
Jul 25, 2026
Merged

fix(item): don't open a redundant PR when item done runs after the PR already merged#329
getappz merged 1 commit into
masterfrom
task/349

Conversation

@getappz

@getappz getappz commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Summary

  • push_and_open_pr() (src/worktree.rs) unconditionally called github::pulls::create() for the item's branch, with no check for an existing PR. GitHub's API only rejects a duplicate while the existing PR is still open -- once it's merged (or manually closed), a second PR against the same branch is perfectly legal to create.
  • Observed live 2026-07-25: PR fix(worktree): never let doctor reclaim delete the main worktree #327 was created manually and merged, then item done on the same item auto-opened redundant PR fix: doctor reclaim can delete the main/canonical worktree, cascading to all linked worktrees #328 against the same branch (had to be closed manually).
  • Adds pulls::find_existing(client, repo, branch) -- lists PRs with state=all and finds one whose head.ref matches the branch -- and calls it from push_and_open_pr before create. If a match is found (open, merged, or manually closed), reuses its URL instead of opening a duplicate.
  • Lookup failures are soft-failed the same way the rest of this function already is: logged, then falls through to create -- a rare duplicate is a smaller harm than silently never opening a PR on a transient lookup error.

Test plan

  • cargo test --bin agentflare github::pulls:: -- 14 passed, 0 failed (incl. 2 new find_existing tests)
  • cargo clippy --bin agentflare --all-targets --all-features -- -D warnings -A unsafe_code -A clippy::pedantic -- clean
  • cargo fmt -- clean

… already merged

push_and_open_pr() unconditionally called pulls::create() for the
item's branch. GitHub's API only rejects a duplicate while an existing
PR is still open -- once it's merged (or manually closed), a second PR
against the same branch is perfectly legal, which is exactly how
item done re-running on an already-merged item opened a redundant PR
(2026-07-25: PR #328 duplicating already-merged #327).

Add pulls::find_existing() to check for any PR (open/merged/closed)
matching the branch before creating a new one, and use it in
push_and_open_pr -- if found, reuse its url instead of opening a
duplicate.
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@getappz, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 14 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 67f1190d-de9c-473a-b61a-44439ed7aea9

📥 Commits

Reviewing files that changed from the base of the PR and between e88cccd and 3892fd6.

📒 Files selected for processing (2)
  • src/github/pulls.rs
  • src/worktree.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch task/349

Comment @coderabbitai help to get the list of available commands.

@getappz
getappz merged commit 41330f4 into master Jul 25, 2026
16 checks passed
@getappz
getappz deleted the task/349 branch July 25, 2026 07:25
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