Make /worktree enter switch the session in place rather than typing a command into a terminal pane.
This is the command path: a human runs it, the agent is idle, and ctx.waitForIdle() is safe to call. No arming, no deferral.
Shape worth trying
Replace the relaunchInPlace call in the enter branch with fork + switch. handoffCaveat still describes the move — it is delivered through withSession instead of travelling as PI_WT_HANDOFF on a relaunch command line.
Because the process no longer exits, most of the successor-verification apparatus loses its purpose: the code that reports where it landed is the code that moved it, and switchSession throws rather than landing somewhere unintended. Keep the assertion that the replacement's cwd is the intended target; drop the machinery built to survive a process boundary.
/worktree create follows the same shape once provisioning has completed, but keep it out of this issue — create has receipts and failure modes of its own, and enter is the clean case.
Constraints
Provisioning receipts still gate entry: a not-ready worktree is refused before any switch is attempted. The claim is still taken before the target is touched.
A switch failure must not roll back the worktree. Git succeeded; only the hop failed. Report it and leave the checkout in place, as the prior art does.
already-active must still short-circuit. Switching into the directory we are already in is a no-op that should not tear down a runtime.
Make
/worktree enterswitch the session in place rather than typing a command into a terminal pane.This is the command path: a human runs it, the agent is idle, and
ctx.waitForIdle()is safe to call. No arming, no deferral.Shape worth trying
Replace the
relaunchInPlacecall in the enter branch with fork + switch.handoffCaveatstill describes the move — it is delivered throughwithSessioninstead of travelling asPI_WT_HANDOFFon a relaunch command line.Because the process no longer exits, most of the successor-verification apparatus loses its purpose: the code that reports where it landed is the code that moved it, and
switchSessionthrows rather than landing somewhere unintended. Keep the assertion that the replacement's cwd is the intended target; drop the machinery built to survive a process boundary./worktree createfollows the same shape once provisioning has completed, but keep it out of this issue — create has receipts and failure modes of its own, and enter is the clean case.Constraints
Provisioning receipts still gate entry: a not-ready worktree is refused before any switch is attempted. The claim is still taken before the target is touched.
A switch failure must not roll back the worktree. Git succeeded; only the hop failed. Report it and leave the checkout in place, as the prior art does.
already-activemust still short-circuit. Switching into the directory we are already in is a no-op that should not tear down a runtime.