Skip to content

[Bug]: "Could not recreate the worktree" names the thread's intact worktree when a nested repo's worktree was replaced by a clone #45774

Done

Description

@djinna

Before submitting

Area

Server: worktree restore on turn start (restoreMissingWorktree → TaskFolders.restore)

Steps to reproduce

  1. Have a project whose root repo contains a second, gitignored git repository that T3 discovers as a project folder (here DerivedData.noindex/site, a clone that a publish script keeps).
  2. Start a worktree thread. T3 creates the root worktree and, inside it, a linked worktree of the nested repo at <worktree>/DerivedData.noindex/site (its .git is a file).
  3. In that thread, run a project script that checks [ -d "$OUT/.git" ] and, finding no .git directory, does rm -rf "$OUT" and git clones the nested repo there instead. The folder is now a full clone, not a linked worktree.
  4. Send another message in the thread.

Expected behavior

The turn starts. The thread's own worktree is intact. Failing that, the error should name the folder that's in the way and say what to do.

Actual behavior

Every new turn fails before the agent starts, with a banner and a red "Couldn't recreate thread workspace" message:

Could not recreate the worktree for branch 't3/…' at ~/.t3/worktrees//t3-….

The path it names is the thread's root worktree, which exists and is fine. The real reason is only in the server trace, from TaskFolders.restore:

TaskFolderError: ~/.t3/worktrees//t3-…/DerivedData.noindex/site holds a checkout that is not a worktree of /DerivedData.noindex/site. Move it away to restore the thread's worktree.

restoreMissingWorktree wraps that in WorktreeRecreateError with the thread's worktreePath (restoreMissingWorktree.ts#L231), and its message getter drops the cause, so the actionable detail from TaskFolders.ts#L1669 never reaches the UI.

Impact

The thread can't be resumed, and the message points at the wrong folder (one that plainly exists), so it reads as T3 losing the worktree. It happened to two threads in one project on the same day; in both, the agent had run the publish script in the thread's worktree. Two more of that project's worktrees were in the same state.

Version or commit

T3 Code (Beta) 0.1.12, commit ca81b7b

Environment

macOS 26.7.3, Apple silicon; Claude Code provider.

Logs or stack traces

TaskFolders.restore  TaskFolderError: <worktree>/DerivedData.noindex/site holds a checkout that is not a worktree of <project>/DerivedData.noindex/site. Move it away to restore the thread's worktree.
restoreMissingWorktree  WorktreeRecreateError: Could not recreate the worktree for branch 't3/…' at <worktree>.
orchestrationV2.providerTurnStart.start  WorktreeRecreateError (same)
ProviderTurnStartService.start  ProviderTurnStartError

Workaround

Delete the clone at <worktree>/DerivedData.noindex/site; going by the restore code, the next turn then recreates the nested worktree. On our side the script now keeps its clone outside the project. From reading TaskFolders.restore, listing the folder under ignoreRepositories in t3.json should also let the thread resume, since a clone there is dropped from the task folder; I haven't tried it.

Suggestions

The main problem is the message: it names the thread's root worktree, which exists, and drops the actionable cause.

  • Show the cause's detail in the banner, or carry the failing checkout's path in WorktreeRecreateError rather than the thread's root.
  • Possibly: for a discovered (not explicitly added) nested repo, let the turn start with a warning when its checkout was replaced, as is already done for ignoreRepositories clones.

Activity

  1. djinna commented on Nov 30, 2026

    @djinna
    Author

    Confirmed the workaround: after deleting the clone at <worktree>/DerivedData.noindex/site, the next message in the affected thread went through, and T3 recreated the nested repo's linked worktree there (.git is a file pointing at the main repo's worktrees/ entry again, no longer prunable).

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions