# feat\(server\): hand a thread off to a linked environment · pingdotgg/t3code

[View on GitCafe](https://git.cafe/pingdotgg/t3code/commit/be89710151b212a24dc62721e0b3c46e67441475)

Repository: [pingdotgg/t3code](https://git.cafe/pingdotgg/t3code)

Visibility: public

Requested revision: be89710151b212a24dc62721e0b3c46e67441475

Requested commit: be89710151b212a24dc62721e0b3c46e67441475

Commit: be89710151b212a24dc62721e0b3c46e67441475

Tree: a8e1eec52e494e6b5bb6d7694d12705e4416a61f

Author: Julius Marminge

Committer: Julius Marminge

## Message

```
feat(server): hand a thread off to a linked environment

A thread can now move to a linked environment with its conversation and its
git work, with exactly one copy live. ThreadHandoff marks it departing,
which refuses new turns and keeps queued runs from starting; packs the
branch and working tree with HandoffGit; uploads the bundle through the
other side's signed attachment route; and calls t3_thread_import there,
which now takes the bundle and applies it in a new worktree before creating
the thread. Only then is the thread departed here and read-only. A failed
move marks it failed, which takes turns again, and nothing is left there.

An agent can move its own thread with t3_thread_handoff. The move then
waits as pending until its turn ends, starts the thread there with the
agent's continuationPrompt, and is cancelled by a user message sent before
the turn ends. A startup sweep runs moves that a restart cut short; import
ids derive from the handoff, so a retry finds the thread already there.

threadHandoff.options / start / cancel serve the clients.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

```

## Parents

- [75b2c90834b04ac7254bb95a713fd1c39a047384](https://git.cafe/pingdotgg/t3code/commit/75b2c90834b04ac7254bb95a713fd1c39a047384?format=markdown)

[Source at this commit](https://git.cafe/pingdotgg/t3code/tree/be89710151b212a24dc62721e0b3c46e67441475?format=markdown)
