# \[Bug\]: Thread can't start a turn after its worktree and branch are removed by a merge · Issue \#19124 · pingdotgg/t3code

[View on GitCafe](https://git.cafe/pingdotgg/t3code/issues/19124)

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

Visibility: public

State: backlog

Priority: 0

## Description

[Discussion and activity](https://git.cafe/pingdotgg/t3code/issues/19124)

---

Area: apps/server

## Steps to reproduce
1. Run a thread in a worktree on a branch (Codex provider).
2. Land the work the way the agent does it: fast-forward the branch onto main, `git worktree remove <path>`, `git branch -d <branch>`.
3. Send any message in the thread.

## Expected behavior
The turn starts, or at worst fails with an error that says the checkout is missing and offers a way to recover it.

## Actual behavior
The turn fails a few seconds after it is requested (requested 17:09:27, failed 17:09:30), and the UI shows no error. Every later message fails the same way, so the thread stays stuck.

The recovery from #7839 only covers a missing worktree while the branch still exists: `thread.turn.start` runs `git worktree prune` and then `createWorktree({ refName: branch })`. With the branch deleted, `git worktree add <path> <branch>` fails, the failure is logged as a warning, and the turn continues into the provider. The Codex session then can't resume because its recorded cwd is the deleted worktree path and resume requires a matching cwd. Falling back to the project's default branch or the workspace root HEAD when the thread branch no longer resolves would recover this case.

## Impact
Blocks work completely

## Version or commit
0.0.46-nightly.20261013.3053

## Environment
Linux, local t3 serve, Codex provider (codex app-server 0.162.1). The thread's worktree was under `~/.t3/worktrees/<project>/<id>`.

## Logs or stack traces
The run row records no error for the failed run; the server only warns during the recreate attempt.

## Workaround
Recreate the branch at the merged commit and re-add the worktree at the exact original path:

    git branch <branch> main
    git worktree add <original worktree path> <branch>

Sending a message then works again with the Codex session intact, because the recorded cwd exists again.

