> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dureai.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Sessions, worktrees, and recovery

> The ownership model behind Dure's managed agents and what each recovery path actually guarantees.

## A managed agent is more than a terminal

A managed agent combines three identities:

* a provider conversation,
* a Dure pane and agent record,
* a Git worktree and branch.

Hmux owns the provider process and PTY. Dure attaches as a client over a
versioned protocol. This process boundary is why closing the app window does not
terminate a managed local agent.

## Reattachment

When Dure reconnects, the host sends a canonical screen snapshot plus subsequent
output. The client does not need to replay the entire terminal log just to paint
the current screen.

A generation-fenced controller lease decides which client may write. Additional
clients can observe without silently stealing the keyboard from the current
controller.

<video controls muted playsInline title="Dure reconnecting to the same live Hmux-owned Codex session" className="w-full aspect-video rounded-xl" poster="/images/hmux-app-reconnect.png" src="https://mintcdn.com/hebbian/gBhXllKfo-gr_XE_/videos/hmux-app-reconnect.webm?fit=max&auto=format&n=gBhXllKfo-gr_XE_&q=85&s=92c12c2f82d750e887a0a9fd47d7408c" data-path="videos/hmux-app-reconnect.webm">
  Your browser does not support embedded video.
  <a href="/videos/hmux-app-reconnect.webm">Open the reconnect video.</a>
</video>

## Worktree ownership

Each worktree-backed agent receives its own working directory and branch. This
isolates Git indexes and file edits, but it does not isolate operating-system
resources such as ports, processes, credentials, or network access.

<Warning>
  A worktree is not a security sandbox. Provider approval settings and the
  permissions of your user account still determine what an agent can do.
</Warning>

## Three different recovery cases

| Event                                  | Result                                                                                                                     |
| -------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| App quit, app crash, or webview reload | The managed host keeps the live process and Dure reattaches.                                                               |
| Host process exit                      | The live PTY and process are gone. Session Recovery may offer a provider-aware restart when enough identity was recorded.  |
| Machine reboot                         | No process survives. `hmux restore` recreates a saved shell recipe on a new PTY; this is recreation, not process survival. |

## Managed versus ordinary panes

Run an agent CLI manually inside an ordinary terminal and Dure still recognizes
the provider and its activity from the real process tree and terminal evidence.
You can keep using the terminal normally without adding or registering the agent
first.

Automatic recognition is not the same as managed promotion. Start a managed
provider session through the add-agent flow, or use the conversion action shown
for a reviewed terminal state. Conversion runs only at a safe boundary because
it must preserve the exact provider conversation and pane identity.

See [current limits](/en/current-limits) before relying on the same behavior for
SSH projects.
