Skip to content

[Bug]: A message to a thread whose worktree directory is gone starts no run and reports nothing; the automatic re-create fails with branch_checked_out_in_worktree; git and PR polling continue against the missing directory #21374

Closed as not planned

Description

@MattRiddell

Before submitting

Area

apps/server

Steps to reproduce

  1. Create a thread in a T3-managed worktree and let a turn complete.
  2. Remove the worktree directory outside T3 (git worktree remove <path>; a cleanup job did this for us) and, to hit the second failure, check the same branch out in another worktree.
  3. Dispatch a message to the thread.

Expected behavior

  • The dispatch returns an error the caller can see (worktree_missing), and the thread shows it.
  • The automatic re-create handles a branch that is checked out elsewhere (detach, a new branch name, or a clear refusal), instead of failing silently.
  • Background git/PR polling stops for a thread whose worktree is gone.

Actual behavior

Impact

Major degradation or frequent failure

Version or commit

0.0.46-nightly.20261008.2819 (and 0.0.4x for the silent OK). Our local patches do not touch worktree handling.

Environment

Linux (Ubuntu, kernel 7.0.0-38-generic), compiled @t3code/t3-linux-x64 binary (Node.js v26.8.2 in crash traces), t3 serve --host 127.0.0.1 --port 3773 --base-dir ~/.t3 as a systemd --user service, headless; Tailscale serve in front; clients: macOS desktop app, iOS app, web. 40–50 live threads at a time over 8 Claude Code instances (claudeAgent), 3 Codex instances and ACP providers (Grok CLI, OpenCode with GLM). ~16,900 threads in statev2.sqlite (40.4 GB). Threads are created, woken and stopped by our own tooling over the /ws RPC (orchestration.dispatchCommand), not by a human in the UI.

Running build: 0.0.46-nightly.20261008.2819 with two local server patches (GitHub PR-sync cadence, Grok multi-task wait). Each draft says whether the patch touches the reported area.

Logs or stack traces

provider turn start recreating missing worktree { threadId: '<id>', worktreePath: '/data/t3-worktrees/<repo>/<branch>' }
git worktree add failed (branch_checked_out_in_worktree)
diffCheckpoints: git diff (/data/t3-worktrees/ProcessFrontend/todo-16044) exited with 128 - fatal: cannot change to '/data/t3-worktrees/ProcessFrontend/todo-16044': No such file or directory

Workaround

Before every dispatch our tooling stats the thread's worktreePath and refuses with its own NO-TURN cause=worktree-missing; a watcher then creates a new thread in a fresh worktree. Our cleanup job also refuses to remove a worktree that still has a live thread.

Activity

  1. juliusmarminge commented on Oct 18, 2026

    @juliusmarminge
    Member

    Note

    Grok responding on behalf of Julius.

    Closing as a duplicate of #19124. It's the same path: on main, when re-creating a missing worktree fails, the error is only logged and the turn never starts, so the sender gets nothing back. Your branch_checked_out_in_worktree case is another way to land there, deleted branch or not, so let's track it in #19124.

    Git and PR polling against the missing directory is part of the same family, and it's noted there and in #21372.

    On your setup: your cleanup job removed worktrees that still had live threads. T3 only re-creates a worktree as a recovery step, so your current guard (don't remove a worktree with a live thread) is the right one.

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

    duplicateThis issue or pull request already existsvia-triageFiled through npx t3 triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions