Before rewriting any transition, establish that an in-process switch actually delivers what a relaunch delivers. Everything downstream assumes it does.
Do this behind a flag on /worktree enter only: command-driven, human-initiated, already idle. Lowest possible blast radius.
Shape worth trying
Mirror the prior art's src/session.ts:
awaitctx.waitForIdle();constforked=SessionManager.forkFrom(sourceSessionFile,worktreePath);awaitctx.switchSession(forked.getSessionFile(),{withSession: async(ctx)=>{/* report from the replacement ctx only */},});Then verify, in a real session, against a real worktree:
Constraints
Flag-gated, no default behaviour change, no deletions. The relaunch path stays fully intact and reachable for the whole spike.
Deliverable is a findings note plus a go/no-go, not a merged feature. A red result on tool rebinding or resource reloading stops the epic; a red result on the ephemeral or zero-turn cases is a scope note, not a stop.
Before rewriting any transition, establish that an in-process switch actually delivers what a relaunch delivers. Everything downstream assumes it does.
Do this behind a flag on
/worktree enteronly: command-driven, human-initiated, already idle. Lowest possible blast radius.Shape worth trying
Mirror the prior art's
src/session.ts:Then verify, in a real session, against a real worktree:
bashruns in the worktree —pwdreports the worktree pathread/editresolve repo-relative paths against the worktree.pi/extensions load, and its skills and AGENTS.md are in contextprocess.cwd()is unchanged — confirm the divergence exists and note everything that reads it--no-session) session survives; the prior art copies the active branch into a persisted target rather than losing itsession_before_switchfiring does not let an unrelated extension silently cancel our hop without us noticing-p/ print mode, sincemodes/print-mode.js:71wiresswitchSessiontooConstraints
Flag-gated, no default behaviour change, no deletions. The relaunch path stays fully intact and reachable for the whole spike.
Deliverable is a findings note plus a go/no-go, not a merged feature. A red result on tool rebinding or resource reloading stops the epic; a red result on the ephemeral or zero-turn cases is a scope note, not a stop.