Skip to content

Set up a deleted worktree again when it is recreated - #117

Open
ShriD5 wants to merge 2 commits into
mainfrom
t3-watch/2026-11-24-restore-setup
Open

ShriD5 wants to merge 2 commits into
mainfrom
t3-watch/2026-11-24-restore-setup

Conversation

@ShriD5

@ShriD5 ShriD5 commented Nov 24, 2026

Copy link
Copy Markdown
Owner

What T3 added

T3 Code (pingdotgg/t3code@e65b19d15e) now runs the project's setup scripts when it restores a thread's worktree that was removed outside the app. Before, the restored checkout was bare.

How Godspeed does it

Godspeed already recreates a chat's deleted worktree before its next turn (DocHost::recreate_missing_worktree, PR #41). It had the same gap as T3: no copied files and no setup.

  • WorktreeEnvironments::restore_setup (crates/engine/src/worktree_env.rs) copies the project environment's untracked files (copy rules) into the recreated checkout again. It then starts setup through the existing launch_setup: the environment's setup steps plus the project's setup Action, in the "(setup)" terminal.
  • DocHost::restore_worktree_setup calls it after a successful recreation. The project comes from the chat's project, or else from the worktree record. If setup fails to start, the failure is logged and the turn still runs, so a bad script never blocks the chat.
  • launch_setup now takes the worktree path instead of a whole Worktree, because the path is all it ever used. Its two existing callers are updated.
  • Ports and rendered setup steps stay on the worktree's record, so the recreated checkout keeps the ports it had before.

Tests

  • worktree_on_run::a_deleted_worktree_is_recreated_and_set_up_before_the_next_turn now saves an environment with a .env copy rule and a setup step. After the folder is deleted and the next turn runs, it checks that .env is back and that setup ran again. Without the fix the test fails because .env is missing.
  • cargo build -p godspeed: ok. cargo check --workspace --tests: ok.
  • cargo test -p zeron-engine --no-fail-fast: 1176 passed, 3 failed.
    • Already failing on main: git_actions_gh pull_requests_and_publishing_go_through_gh and local_first local_runtime_checks_public_releases_without_starting_edge_links.
    • Flaky under load: delegation_notifications stopped_parent_keeps_notification_durable.... It passes when run alone.

No screenshots: this is an engine change and the GUI was not launched.

What to check by eye

In a project with a setup Action or a worktree environment, start a worktree chat and let setup finish. Delete the worktree folder in Finder, then send another message. The "(setup)" terminal should run again and copied files such as .env should be back.

Also updates the T3 watch ledger (reviewed through t3code@2cc8e73014) and T3-GAPS.

🤖 Generated with Claude Code

A chat whose worktree folder was deleted gets it back before its next
turn, but only as a bare checkout: the project's copied files (.env and
friends) and its setup never ran, so the agent started in a worktree
that couldn't build or run. Recreation now copies the environment's
untracked files again and starts the setup steps and setup Action in the
(setup) terminal, like a new worktree. A setup that can't start is
logged and the turn goes ahead.

Inspired by: pingdotgg/t3code@e65b19d15e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant