GeezerVison is showing github.com — Project scripts: add worktree deletion lifecycle hooks by paul-bouzian · Pull Request #425 · pingdotgg/t3code
Conversation
paul-bouzian
commented
Mar 7, 2026
•
edited by macroscopeapp
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary
- add a second lifecycle hook so project scripts can run automatically when a worktree is deleted
- run deletion hooks on the server before
git worktree remove and abort the delete flow on failures or timeouts
- preserve manual script execution while enforcing one create hook and one delete hook in the UI
Changes
- extend the shared project script contract with
runOnWorktreeDelete and add a new projects.runLifecycleScript native API method
- add a dedicated server-side lifecycle runner and reuse a shared project script runtime env helper across web and server
- update the project actions UI, lifecycle selectors, and thread deletion flow to support delete hooks, labels, invariants, and failure-aware worktree removal
Testing
cd apps/web && bun run test -- src/projectScripts.test.ts src/worktreeDeleteFlow.test.ts src/wsNativeApi.test.ts - Pass (26 tests)
cd apps/server && bun run test -- src/projectScriptRunner.test.ts src/wsServer.test.ts src/orchestration/decider.projectScripts.test.ts src/orchestration/Layers/ProjectionSnapshotQuery.test.ts src/orchestration/Layers/ProjectionPipeline.test.ts - Pass (62 tests)
cd packages/contracts && bun run test -- src/orchestration.test.ts - Pass (12 tests)
bun lint - Pass
- Manual UI verification - Pass (confirmed locally that the delete hook runs from the worktree cwd, receives
T3CODE_PROJECT_ROOT and T3CODE_WORKTREE_PATH, and blocks deletion on failure)
- Not run:
bun typecheck
Local checkout currently resolves mismatched effect versions under Bun 1.2.19 ([email protected] at the workspace root and [email protected] nested under @effect/platform-node), which produces unrelated server-side type errors.
Risks and Rollback
- Risk: worktree deletion now intentionally waits for the configured cleanup hook and aborts on failures or timeouts, so a broken cleanup script can block deletion until it is fixed or disabled
- Rollback: revert commit
ed0a0248f1376a4651cfbf34611a3d2a4c212f45
Notes
- no SQL migration is required; legacy
ProjectScript payloads decode with runOnWorktreeDelete = false
Note
Add worktree deletion lifecycle hooks and implement apps/server/src/projectScriptRunner.ts runProjectLifecycleScript with a 300s timeout, 1MB buffer, normalized errors, and WebSocket handler apps/server/src/wsServer.ts for WS_METHODS.projectsRunLifecycleScript
Introduce delete lifecycle hooks across contracts, web UI, and server, add a centralized env builder, and wire a server-side runner with normalized error handling and a websocket RPC; update tests to cover lifecycle selection, env propagation, and failure cases.
📍Where to Start
Start with runProjectLifecycleScript in projectScriptRunner.ts, then review the websocket handler case for WS_METHODS.projectsRunLifecycleScript in wsServer.ts, and the UI flow in worktreeDeleteFlow.ts.
Macroscope summarized ed0a024.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add a dedicated delete lifecycle hook for project scripts and run it before worktree removal.
Keep lifecycle invariants enforced in the UI and expose a server-side runner for failure-aware execution.
Co-authored-by: Codex <[email protected]>
Important
Review skipped
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 4b4af682-1ecc-4ea4-88fc-31f95fcf30f9
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Post copyable unit tests in a comment
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment @coderabbitai help to get the list of available commands and usage tips.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Closing as part of an open-PR triage — main has moved a lot since this was opened (the branch conflicts and the files it touches have been substantially reworked), so it's no longer reviewable as-is. If you're still interested, please feel free to resubmit against current main. Thanks!
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|