Repository navigation
[Feature]: Run a project action before worktree removal (runOnWorktreeRemove), for resources outside the worktree
#14804
Replies: 3 comments
|
@t3dotgg & @juliusmarminge is there a chance we could get a hook like this? I'm trying to migrate from Orca to T3 Code. Without a hook like this, we can't clean up, and eventually the environment will just crash. |
|
Same need here, and the same Orca migration. Our setup creates a per-worktree Postgres database on a shared server, so removal has to drop it, stop dev servers started in the worktree, and delete the branch. Orca runs |
|
NOTE: This comment was left by gpt-6.1-sol high on behalf of Dj Gilcrease. I built a runnable prototype for this use case as an external Worktree Environments plugin, released as v0.1.0. The plugin proposal update has screenshots, a failure/retry recording, configuration examples and verification limits. Its If teardown fails, the checkout is kept and its owning thread is restored/unsettled with a visible failure notice. Fix the script and retry removal. Required cleanup goes in the pre-removal hook; after-removal notifications are best effort. The cleanup recipe is recorded before setup so changing the project's recipe later does not silently replace cleanup ownership. This requires the proposed plugin-host fork and is not available in stock T3 Code. It is an optional script runner, not a built-in Docker/Postgres integration; scripts must be idempotent, and deletion outside T3 cannot trigger hooks. The UI demo uses a synthetic external resource. It also gives this feature need an external implementation to try while the plugin proposal is discussed: users can publish and maintain their own environment workflows without putting each integration into T3's core. Design feedback on the shared lifecycle boundary can go to the linked update. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Before submitting
Area
apps/server
Problem or use case
runOnWorktreeCreatecan start resources that live outside the worktree, for example a per-worktree Postgres container (docker compose -p <slug> up). There is no matching hook for removal.When a thread is deleted in the UI, T3 Code removes the worktree directory, but the container and its volume stay. They accumulate until Docker consumes most of the machine's RAM and disk.
The teardown needs state that lives in the worktree (in our case a
.dev/workspace.envholding the compose project name). Once the directory is gone, that state is gone too, so a cleanup after the fact cannot work reliably.Proposed solution
Add an optional project action flag,
runOnWorktreeRemove, that:git worktree removeT3CODE_WORKTREE_PATH/T3CODE_PROJECT_ROOT, like the create actionSmallest useful scope
Run the flagged action before
git worktree removeon manual thread delete. The other removal paths can follow.Alternatives considered
Examples or references
Contribution
All reactions