Skip to content

feat(enter): switch the session in-process instead of relaunching #19

Description

@neilwashere

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions