Repository navigation
fix(worktree): stop push-target rollback deleting a sibling's remote - #16569
Conversation
A push target that reuses an existing Orca-created fork remote inherits ownership of it (`remoteCreated = isRemoteCreatedByKnownWorktree(...)`), so the final worktree to be deleted can remove it. Rollback then reused that same flag to decide whether to undo its own work -- but a reused remote was not added by this call, and a live sibling worktree is still pushing to it. A failed fetch during create therefore deleted a remote another worktree depends on. Track `remoteAddedHere` separately: ownership stays inherited for cleanup, while rollback only removes a remote this call actually added. Both the local and the SSH path had the same bug and are fixed together. Original work by Jinjing (AmethystLiang) in 616d2a4ec8c; split out of that branch so the release fix in #16550 stayed a clean cherry-pick.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughPush-target preparation now distinguishes remotes created by the current invocation from reused remotes. Standard and SSH setup paths remove a remote after fetch failure only when the current invocation added it. Regression tests verify that reused remotes owned by sibling worktrees remain configured and that fetch errors propagate. Merge Risk: ⚪ Minimal · up to This change narrows rollback cleanup so reused remotes owned by sibling worktrees are preserved while locally added remotes are still removed; no actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description clearly explains the bug, the fix, the affected local and SSH paths, and the validation results. However, it omits the required Linked Issue entry, Visual Proof or an explicit N/A explanation, the Testing checklist, AI Disclosure, Review, Agent skill upstream boundary, Notes, and the repository Checklist. Resolution Add the required template sections and complete them. Include a linked issue using
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…tablyai#16569) A push target that reuses an existing Orca-created fork remote inherits ownership of it (`remoteCreated = isRemoteCreatedByKnownWorktree(...)`), so the final worktree to be deleted can remove it. Rollback then reused that same flag to decide whether to undo its own work -- but a reused remote was not added by this call, and a live sibling worktree is still pushing to it. A failed fetch during create therefore deleted a remote another worktree depends on. Track `remoteAddedHere` separately: ownership stays inherited for cleanup, while rollback only removes a remote this call actually added. Both the local and the SSH path had the same bug and are fixed together. Original work by Jinjing (AmethystLiang) in 616d2a4ec8c; split out of that branch so the release fix in stablyai#16550 stayed a clean cherry-pick. (cherry picked from commit 1c9fb84)
…tablyai#16569) A push target that reuses an existing Orca-created fork remote inherits ownership of it (`remoteCreated = isRemoteCreatedByKnownWorktree(...)`), so the final worktree to be deleted can remove it. Rollback then reused that same flag to decide whether to undo its own work -- but a reused remote was not added by this call, and a live sibling worktree is still pushing to it. A failed fetch during create therefore deleted a remote another worktree depends on. Track `remoteAddedHere` separately: ownership stays inherited for cleanup, while rollback only removes a remote this call actually added. Both the local and the SSH path had the same bug and are fixed together. Original work by Jinjing (AmethystLiang) in 616d2a4ec8c; split out of that branch so the release fix in stablyai#16550 stayed a clean cherry-pick.
…tablyai#16569) A push target that reuses an existing Orca-created fork remote inherits ownership of it (`remoteCreated = isRemoteCreatedByKnownWorktree(...)`), so the final worktree to be deleted can remove it. Rollback then reused that same flag to decide whether to undo its own work -- but a reused remote was not added by this call, and a live sibling worktree is still pushing to it. A failed fetch during create therefore deleted a remote another worktree depends on. Track `remoteAddedHere` separately: ownership stays inherited for cleanup, while rollback only removes a remote this call actually added. Both the local and the SSH path had the same bug and are fixed together. Original work by Jinjing (AmethystLiang) in 616d2a4ec8c; split out of that branch so the release fix in stablyai#16550 stayed a clean cherry-pick. (cherry picked from commit 1c9fb84)
…tablyai#16569) A push target that reuses an existing Orca-created fork remote inherits ownership of it (`remoteCreated = isRemoteCreatedByKnownWorktree(...)`), so the final worktree to be deleted can remove it. Rollback then reused that same flag to decide whether to undo its own work -- but a reused remote was not added by this call, and a live sibling worktree is still pushing to it. A failed fetch during create therefore deleted a remote another worktree depends on. Track `remoteAddedHere` separately: ownership stays inherited for cleanup, while rollback only removes a remote this call actually added. Both the local and the SSH path had the same bug and are fixed together. Original work by Jinjing (AmethystLiang) in 616d2a4ec8c; split out of that branch so the release fix in stablyai#16550 stayed a clean cherry-pick.
Split out of
616d2a4ec8c, which also carried the Windows relay fix that shipped as #16550. Original work by @AmethystLiang; I dropped it from that branch so the release cherry-pick stayed minimal, and this is it getting its own PR. Unrelated to Windows.The bug
When a push target reuses an existing Orca-created fork remote, it deliberately inherits ownership of it, so that the last worktree using it can clean it up:
Rollback then reused that same flag to decide whether to undo its own work:
But
remoteCreatedbeing true doesn't mean this call added the remote — it can equally mean a sibling worktree added it and is still pushing to it. So if the fetch fails while creating a worktree that reused a sibling's fork remote, rollback deletes that remote out from under the sibling.The two meanings were never separable from one flag: cleanup needs "does anyone own this," rollback needs "did I add this."
The fix
Track
remoteAddedHerealongsideremoteCreated. Ownership semantics are unchanged — cleanup still inherits. Rollback now only removes a remote this call actually ranremote addfor.The local path (
worktree-push-target-setup.ts) and the SSH path (worktree-remote.ts) had the same bug independently, so both are fixed.Validation
Both regression tests were confirmed to catch the bug — reverting just the production change while keeping the tests fails exactly the two new cases:
With the fix: 17/17 pass.
pnpm tcclean, oxlint clean.