Skip to content

What happens to a running session when its terminal closes or its VM stops?

Decided 2026-10-04: B. Closing the terminal ends the session. The decision and its reasons are in the I46I46 (closed): S05-cli, S06-vm-lifecycle: session lifecycle, detach, sleep and failureS05-cli and S06-vm-lifecycle describe starting a session and its summary at the end, but not what happens in between, or when things go wrong: comment that starts Decision (2026-10-04):. Source: I46I46 (closed): S05-cli, S06-vm-lifecycle: session lifecycle, detach, sleep and failureS05-cli and S06-vm-lifecycle describe starting a session and its summary at the end, but not what happens in between, or when things go wrong:. Affects S05-cliS05-cli: Command Line InterfaceSpecify wb, the single user-facing command., S06-vm-lifecycleS06-vm-lifecycle: VM Lifecycle, Images and the Guest AgentHow guest images are built, how VMs are kept warm, how projects and sessions map onto guests, and what wb-guestd does., S08-workspace-and-gitS08-workspace-and-git: Workspace and Git Round TripHow code gets into the guest and how the agent's work gets back out, without sharing the host filesystem. and S13-guest-confinementS13-guest-confinement: Guest ConfinementControls inside the guest that narrow what a project user's processes can do, and tell the host which program opened each connection.. Note 2026-10-07: the decision is now in those specs, see “The spec change” below. The figures and sub-decisions further down show option A as recommended before the decision.

host: trustedwb claudeuser’s terminalwb-hostdsession recordwork VM: guest, untrustedwb-guestdholds the PTYclaudeworktree1. terminal closes,wb is killed2. socket drops:sleep, suspend, restart3. VM or wb-guestd dies

Figure 1. A session spans three processes and two links. Each numbered break needs a defined outcome. Break 1 is the detach decision. Break 2 is already half specified: wb-guestd pauses the session’s processes until the link returns (S13-guest-confinementS13-guest-confinement: Guest ConfinementControls inside the guest that narrow what a project user's processes can do, and tell the host which program opened each connection.). Break 3 loses the session.

startingattacheddetachedpausedendingWIP commit, pushendedlostwb exits 255terminal closeswb attachsocket down, and backclaude exitsVM or wb-guestd diesWIP pushedon next VM start

Figure 2. The recommended lifecycle (option A). “Paused” means the host-guest socket is down and the session’s processes are stopped in the guest: host sleep, idle suspend, or a wb-hostd restart (I48I48 (closed): S04-architecture: process supervision, failure, version skew and host resource limitsS04-architecture names the processes but not how they are supervised, what happens when one fails, or how they are upgraded:). Any state can go to “lost”. The figure shows the one from detached.

What option B became, with the sub-decisions it left open written the strict way:

The options are mine, built around the issue’s recommendation, which is option A.

Losing the client detaches an interactive session. claude keeps running, and wb attach <session> shows it again. The session ends when claude exits, or on wb end <session>, a new command. Pipe and -p sessions and ephemeral sessions end with their client.

  • Cost: a new state and two commands. Forgotten sessions keep a worktree and a guest process, but don’t keep the VM awake (sub-decisions).
  • Differs from claude: closing a terminal running plain claude kills it.

wb-guestd sends claude a hangup, then commits WIP and pushes, as on a normal exit. A new wb claude --continue resumes the conversation.

  • Cost: the least work. The new session starts from the host’s HEAD. The files the old one left uncommitted are only in its WIP branch.
  • Same as claude for the terminal, and a closed laptop lid over SSH loses the session.

As A, but a detached session ends as in B after a set time, for example 30 minutes.

  • Cost: as A, plus a timer. A long autonomous task is killed when the user walks away, which is the case detach is for.

Each option leaves the SEC* controls unchanged. wb attach shows guest output, so it follows the same rule as a session: no approval prompts in that terminal (SEC14-no-fake-approvalsSEC14-no-fake-approvals: Approvals cannot be spoofed by the guestApproval prompts are never rendered in the agent's terminal stream.).

Item Recommendation
When idle suspend may happen When no client is attached and the VM has had no session output, guest CPU load, or open guest connections for the idle period. A detached session alone doesn’t block it. wb attach restores the VM.
Host sleep The VM pauses with the host. On wake wb-guestd resynchronizes the clock (S06-vm-lifecycleS06-vm-lifecycle: VM Lifecycle, Images and the Guest AgentHow guest images are built, how VMs are kept warm, how projects and sessions map onto guests, and what wb-guestd does.). The session continues whether attached or detached.
Socket drops As S13-guest-confinementS13-guest-confinement: Guest ConfinementControls inside the guest that narrow what a project user's processes can do, and tell the host which program opened each connection. says: the session’s processes stop, and resume when the link returns. A restore after idle suspend is that case.
VM dies, or wb-guestd exits The session is lost. wb prints a wraith box: line and exits 255. The worktree stays on the data disk, and at the next VM start wb-hostd has wb-guestd commit and push its WIP.
Exit codes claude’s own code. 128+n when claude was killed by signal n. 255 when the session was lost or wb failed after the start. 2 for usage errors before the start (S05-cliS05-cli: Command Line InterfaceSpecify wb, the single user-facing command.). claude can also exit 2 or 255. The stderr line tells them apart.
Signals Interactive: Ctrl-C, Ctrl-Z and the rest are bytes in the terminal stream, window size changes are forwarded, and SIGHUP or SIGTERM to wb detaches. Non-interactive: SIGINT, SIGTERM, and SIGHUP are forwarded to claude, and wb waits for its exit code.
WIP push At session end, as S08-workspace-and-gitS08-workspace-and-git: Workspace and Git Round TripHow code gets into the guest and how the agent's work gets back out, without sharing the host filesystem. says. Also a snapshot to wb/<session-id>/wip on detach and before suspend, which the landing repository’s ref rule already allows.
Two clients One attached client per session. A second wb attach takes over and the first one detaches.
Parallel sessions Unchanged: a worktree and session id each (S06-vm-lifecycleS06-vm-lifecycle: VM Lifecycle, Images and the Guest AgentHow guest images are built, how VMs are kept warm, how projects and sessions map onto guests, and what wb-guestd does., S05-cliS05-cli: Command Line InterfaceSpecify wb, the single user-facing command.). Each wb prints its own summary. A session that ended detached shows its summary in wb sessions.
RequirementA. DetachB. EndC. Grace period
FR01-drop-inFR01-drop-in: Drop-in for claudewb is the single entry point for everything, structured as wb [wb flags] <command> [command args]. behaves like claude, exit code preservedterminal close differssameterminal close differs
FR05-parallel-sessionsFR05-parallel-sessions: Parallel sessionsSeveral sessions can run at once, in the same project and across projects. sessions run side by sideas specifiedno changesame as today
FR13-claude-stateFR13-claude-state: Claude Code state per projectClaude Code's conversation history, and the state it keeps only in the guest, persist per project, so --resume/--continue work within a project. history per projectsession continueshistory yes, files in WIP branchuntil the timer
FR14-ephemeralFR14-ephemeral: Ephemeral sessionsAn ephemeral mode runs a session with no persisted state. nothing persistsends with clientends with clientends with client
NFR03-footprintNFR03-footprint: FootprintIdle VMs suspend after a configurable period. idle VMs suspendactivity-based idleno detached sessionsbounded by timer
Work lost on a closed terminalnoneinterrupted taskafter the timer
Details and glossary

Why A for non-interactive sessions is different. A piped session (wb claude -p "…" | jq) has no one to come back to it: its input and output are tied to the pipe. Ending it with the client is what a script expects.

Why ephemeral sessions end with the client. FR14-ephemeralFR14-ephemeral: Ephemeral sessionsAn ephemeral mode runs a session with no persisted state. promises no persisted state. A detached ephemeral session would keep its throwaway user and files until someone ends it.

Why a second attach takes over. Sharing one session between terminals would need rules for whose window size wins and who may type. Taking over is what most users expect after moving to another terminal.

Glossary

  • Session: one run of claude in its own git worktree, with an id like myrepo-20261003-1412-k3f9.
  • Attach and detach: connecting a terminal to a running session, and leaving it running without one, as tmux does.
  • PTY: the terminal device a program like claude draws on. Its other end is held by wb-guestd.
  • Hangup: the signal a program gets when its terminal goes away. Most programs exit on it.
  • WIP commit: a commit of everything uncommitted in the worktree, marked as work in progress, so nothing is lost.
  • Idle suspend: saving the VM’s state to disk and stopping it after a quiet period (NFR03-footprintNFR03-footprint: FootprintIdle VMs suspend after a configurable period.).