Repository navigation
Conversation
…ly skip teardown on explicit retry The v2 destroy saga only ever executed a literal <worktree>/.superset/teardown.sh and skipped teardown entirely whenever force was set, so: - teardown command arrays in .superset/config.json (what the v2 Scripts editor writes, and what the docs promise runs on delete) were never executed — regression of PR ParadevAI#178 behavior introduced by the v2 unification in PR ParadevAI#3443 - any "Delete anyway" on a dirty workspace, and every CLI/SDK/MCP delete (force hard-coded), silently skipped teardown Changes: - runTeardown resolves like setup does: config.json teardown commands (incl. user override + config.local.json overlay) -> worktree teardown.sh -> main repo teardown.sh; skips are logged - new skipTeardown destroy input replaces force as the teardown bypass; it is only set by the TeardownFailedPane retry. force still means "delete despite dirty files": teardown runs, failures downgrade to a warning - destroy result gains teardownStatus for observability
📝 WalkthroughWalkthroughThis PR adds config-aware teardown command resolution in host-service, decouples a new ChangesConfig-aware teardown resolution and skipTeardown flow
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant DashboardSidebarDeleteDialog
participant useDestroyDialogState
participant useDestroyWorkspace
participant WorkspaceCleanupRouter
participant runTeardown
DashboardSidebarDeleteDialog->>useDestroyDialogState: run({ force, skipTeardown })
useDestroyDialogState->>useDestroyWorkspace: destroy({ deleteBranch, force, skipTeardown })
useDestroyWorkspace->>WorkspaceCleanupRouter: destroy mutation (skipTeardown)
alt skipTeardown false
WorkspaceCleanupRouter->>runTeardown: run teardown (repoPath, projectId, worktreePath)
runTeardown-->>WorkspaceCleanupRouter: status (ok/failed/skipped)
else skipTeardown true
WorkspaceCleanupRouter-->>WorkspaceCleanupRouter: teardownStatus = "not-run"
end
WorkspaceCleanupRouter-->>useDestroyWorkspace: { teardownStatus, success, warnings }
useDestroyWorkspace-->>useDestroyDialogState: result with teardownStatus
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
Ready to review this PR? Stage has broken it down into 5 individual chapters for you: Chapters generated by Stage for commit de1edcd on Jul 7, 2026 5:01am UTC. |
Greptile SummaryThis PR updates workspace deletion so teardown scripts run on the v2 host-service path. The main changes are:
Confidence Score: 4/5The config-array teardown path needs a compatibility fix before merging.
packages/host-service/src/runtime/teardown/teardown.ts
|
| Filename | Overview |
|---|---|
| packages/host-service/src/runtime/teardown/teardown.ts | Adds config-aware teardown resolution, but config commands are executed through bash instead of matching setup command shell behavior. |
| packages/host-service/src/trpc/router/workspace-cleanup/workspace-cleanup.ts | Decouples teardown skipping from forced deletion and reports teardown status. |
| apps/desktop/src/renderer/hooks/host-service/useDestroyWorkspace/useDestroyWorkspace.ts | Passes the optional skipTeardown flag through the renderer host-service hook. |
| apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/components/DashboardSidebarDeleteDialog/DashboardSidebarDeleteDialog.tsx | Routes normal confirmation and teardown-failure retry to the correct destroy options. |
| apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/components/DashboardSidebarDeleteDialog/hooks/useDestroyDialogState/useDestroyDialogState.ts | Forwards skipTeardown through the delete state machine while keeping dirty-conflict retries running teardown. |
| packages/host-service/src/runtime/setup/config.ts | Adds a teardown command accessor that mirrors setup command filtering. |
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
packages/host-service/src/runtime/teardown/teardown.ts:200
**Config Commands Use Wrong Shell**
When a project has config-array teardown commands, this wraps them in `bash -c` even though setup config commands run in the user's terminal shell. A workspace can create successfully with shell-specific setup/teardown config, then fail during delete because the teardown command is re-parsed by non-interactive bash instead of the same shell contract used for setup.
Reviews (1): Last reviewed commit: "fix(host-service): resolve teardown from..." | Re-trigger Greptile
|
|
||
| /** Same `exec bash` trick as above, for config-declared command strings. */ | ||
| export function buildTeardownCommandString(command: string): string { | ||
| return `exec bash -c ${singleQuote(command)}`; |
There was a problem hiding this comment.
Config Commands Use Wrong Shell
When a project has config-array teardown commands, this wraps them in bash -c even though setup config commands run in the user's terminal shell. A workspace can create successfully with shell-specific setup/teardown config, then fail during delete because the teardown command is re-parsed by non-interactive bash instead of the same shell contract used for setup.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/host-service/src/runtime/teardown/teardown.ts
Line: 200
Comment:
**Config Commands Use Wrong Shell**
When a project has config-array teardown commands, this wraps them in `bash -c` even though setup config commands run in the user's terminal shell. A workspace can create successfully with shell-specific setup/teardown config, then fail during delete because the teardown command is re-parsed by non-interactive bash instead of the same shell contract used for setup.
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
packages/host-service/src/trpc/router/workspace-cleanup/workspace-cleanup.ts (1)
137-159: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winStale phase-list doc line contradicts the new force semantics below it.
Line 137 still reads
1. Teardown — run .superset/teardown.sh (skip if force), but the updated Force semantics block right below (Lines 147-159) now explicitly states force no longer skips teardown (onlyskipTeardowndoes), and teardown resolution is config-aware rather than tied to the literal.superset/teardown.shpath. This leaves two contradictory statements in the same doc comment.📝 Proposed fix
- * 1. Teardown — run .superset/teardown.sh (skip if force) + * 1. Teardown — resolve & run configured teardown (skip if skipTeardown)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/host-service/src/trpc/router/workspace-cleanup/workspace-cleanup.ts` around lines 137 - 159, Update the phase-list doc in workspace-cleanup so it matches the current force and teardown behavior. In the comment near the cleanup flow summary, change the “Teardown” bullet to reflect that force does not skip teardown and that teardown is controlled by `skipTeardown`, not the force flag; also avoid hard-coding `.superset/teardown.sh` if the implementation uses config-aware teardown resolution. Keep the wording consistent with the Force semantics block and the `skipTeardown` description in the same comment.apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/components/DashboardSidebarDeleteDialog/hooks/useDestroyDialogState/useDestroyDialogState.ts (1)
118-136: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winConflict retry should hard-code
skipTeardown: false, not pass it through.The retry after a
conflicterror passes the caller-suppliedskipTeardownthrough unchanged. Since the dirty-worktree conflict fires in phase 0 (before teardown runs in phase 1), the retry should always run teardown regardless of the original flag's value. Today this is masked because the only caller passingskipTeardown: truealso passesforce: true, which the!forceguard already excludes from this branch — but that coupling is incidental, not enforced, and a future call site combiningforce: falsewithskipTeardown: truewould silently skip teardown on retry even though it never ran.🔧 Proposed fix
if (e.kind === "conflict" && !force) { - result = await destroy({ deleteBranch, force: true, skipTeardown }); + result = await destroy({ deleteBranch, force: true, skipTeardown: false }); } else {Based on the PR plan's documented requirement that this retry "must pass skipTeardown: false semantics... teardown has not run yet at that point".
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/components/DashboardSidebarDeleteDialog/hooks/useDestroyDialogState/useDestroyDialogState.ts` around lines 118 - 136, The conflict-retry path in useDestroyDialogState should always force teardown on retry instead of propagating the caller’s skipTeardown value. Update the retry call inside the catch block around destroy(...) so the second invocation hard-codes skipTeardown to false while still setting force to true, since this branch is only for the dirty-worktree conflict before teardown runs. Keep the change localized to useDestroyDialogState and the destroy(...) retry logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@plans/done/20260707-1351-v2-delete-teardown-resolution.md`:
- Around line 168-170: The teardown validation example uses the wrong config
shape, so update the manual end-to-end check to match the documented teardown
array contract. In the teardown verification snippet, replace the nested object
form with the same plain command array shape used by the implementation, and
keep the example centered on making the teardown observable with a command like
appending to a log. Refer to the teardown example in this plan section so the
manual test exercises the same contract as the parser and execution path.
---
Outside diff comments:
In
`@apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/components/DashboardSidebarDeleteDialog/hooks/useDestroyDialogState/useDestroyDialogState.ts`:
- Around line 118-136: The conflict-retry path in useDestroyDialogState should
always force teardown on retry instead of propagating the caller’s skipTeardown
value. Update the retry call inside the catch block around destroy(...) so the
second invocation hard-codes skipTeardown to false while still setting force to
true, since this branch is only for the dirty-worktree conflict before teardown
runs. Keep the change localized to useDestroyDialogState and the destroy(...)
retry logic.
In
`@packages/host-service/src/trpc/router/workspace-cleanup/workspace-cleanup.ts`:
- Around line 137-159: Update the phase-list doc in workspace-cleanup so it
matches the current force and teardown behavior. In the comment near the cleanup
flow summary, change the “Teardown” bullet to reflect that force does not skip
teardown and that teardown is controlled by `skipTeardown`, not the force flag;
also avoid hard-coding `.superset/teardown.sh` if the implementation uses
config-aware teardown resolution. Keep the wording consistent with the Force
semantics block and the `skipTeardown` description in the same comment.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 4f98530d-2ad3-47c4-8d8f-8ac870c3e608
📒 Files selected for processing (9)
apps/desktop/src/renderer/hooks/host-service/useDestroyWorkspace/useDestroyWorkspace.tsapps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/components/DashboardSidebarDeleteDialog/DashboardSidebarDeleteDialog.tsxapps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/components/DashboardSidebarDeleteDialog/hooks/useDestroyDialogState/useDestroyDialogState.tspackages/host-service/src/runtime/setup/config.tspackages/host-service/src/runtime/teardown/teardown.test.tspackages/host-service/src/runtime/teardown/teardown.tspackages/host-service/src/trpc/router/workspace-cleanup/workspace-cleanup.tspackages/host-service/test/integration/teardown.integration.test.tsplans/done/20260707-1351-v2-delete-teardown-resolution.md
| Manual end-to-end check, using any project whose teardown is declared in config.json (K3 is ideal). Make the teardown observable, e.g. append to the project's teardown script (or temporarily set in the main repo's `.superset/config.local.json`): | ||
|
|
||
| { "teardown": { "after": ["date >> /tmp/superset-teardown-ran.log"] } } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Fix the teardown config example.
This validation snippet uses { "teardown": { "after": [...] } }, which doesn't match the teardown array shape documented earlier in the plan. It should show a plain command array so the manual test exercises the same contract as the implementation.
♻️ Proposed fix
- { "teardown": { "after": ["date >> /tmp/superset-teardown-ran.log"] } }
+ { "teardown": ["date >> /tmp/superset-teardown-ran.log"] }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| Manual end-to-end check, using any project whose teardown is declared in config.json (K3 is ideal). Make the teardown observable, e.g. append to the project's teardown script (or temporarily set in the main repo's `.superset/config.local.json`): | |
| { "teardown": { "after": ["date >> /tmp/superset-teardown-ran.log"] } } | |
| Manual end-to-end check, using any project whose teardown is declared in config.json (K3 is ideal). Make the teardown observable, e.g. append to the project's teardown script (or temporarily set in the main repo's `.superset/config.local.json`): | |
| { "teardown": ["date >> /tmp/superset-teardown-ran.log"] } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@plans/done/20260707-1351-v2-delete-teardown-resolution.md` around lines 168 -
170, The teardown validation example uses the wrong config shape, so update the
manual end-to-end check to match the documented teardown array contract. In the
teardown verification snippet, replace the nested object form with the same
plain command array shape used by the implementation, and keep the example
centered on making the teardown observable with a command like appending to a
log. Refer to the teardown example in this plan section so the manual test
exercises the same contract as the parser and execution path.
There was a problem hiding this comment.
2 issues found across 9 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="plans/done/20260707-1351-v2-delete-teardown-resolution.md">
<violation number="1" location="plans/done/20260707-1351-v2-delete-teardown-resolution.md:25">
P3: The ExecPlan in `plans/done/` contains two Open Questions that are already answered by Decisions D3 and D4 later in the same document. In a completed plan, these should be marked resolved or moved out of the Open Questions section so future readers don't re-escalate already-made product decisions.
Additionally, the Progress checklist leaves the "Manual marker-file scenario" item unchecked even though all other milestones are checked and the Outcomes section describes it as intentionally outstanding. For a living document that states its sections must be kept up to date, leaving this ambiguously unchecked in a `done/` plan can suggest it was forgotten rather than deferred. Consider marking it `[~]` or `[x] (deferred — automated coverage equivalent)` to make intent explicit.</violation>
</file>
<file name="packages/host-service/src/trpc/router/workspace-cleanup/workspace-cleanup.ts">
<violation number="1" location="packages/host-service/src/trpc/router/workspace-cleanup/workspace-cleanup.ts:147">
P2: The destroy-phase JSDoc list still says teardown is `run .superset/teardown.sh` and is `skip if force`, but both claims are now obsolete. The newly added `Force semantics` section below correctly says the opposite (`"delete despite dirty files" — NOT "skip teardown"`), and the PR description confirms teardown now resolves from overlaid `config.json` files (not just `.superset/teardown.sh`). Please update the phase list so it no longer contradicts the detailed semantics or the actual implementation: change the teardown line to reflect config-based resolution and replace `skip if force` with `skip if skipTeardown`.</violation>
</file>
Architecture diagram
sequenceDiagram
participant UI as Renderer (Dialog)
participant Dialog as useDestroyDialogState
participant DestroySvc as useDestroyWorkspace
participant TRPC as TRPC Client
participant Backend as workspaceCleanup.destroy
participant Resolve as resolveTeardownCommand
participant Teardown as runTeardown
participant Terminal as PTY Session
Note over UI,Terminal: Workspace deletion v2 – teardown resolution (this PR)
UI->>Dialog: onConfirm({ force, skipTeardown: false })
Dialog->>DestroySvc: destroy({ workspaceId, deleteBranch, force, skipTeardown })
DestroySvc->>TRPC: mutate destroy with input
TRPC->>Backend: destroyWorkspace(ctx, input)
Backend->>Backend: skip preflight if force
alt skipTeardown === false
Backend->>Resolve: resolveTeardownCommand(repoPath, worktreePath, projectId)
Resolve->>Resolve: loadSetupConfig → getResolvedTeardownCommands
alt commands in config.json exist
Resolve->>Resolve: buildTeardownCommandString(commands.join(' && '))
Note over Resolve: exec bash -c '…' (same fish-safe trick as setup)
else worktree has .superset/teardown.sh
Resolve->>Resolve: buildTeardownInitialCommand(worktree script)
else main repo has .superset/teardown.sh
Resolve->>Resolve: buildTeardownInitialCommand(mainRepo script)
else nothing configured
Resolve->>Resolve: log skip, return null
end
Resolve-->>Backend: initialCommand or null
alt initialCommand exists
Backend->>Teardown: runTeardown(initialCommand, timeoutMs)
Teardown->>Terminal: createSession + exec bash -c '…'
Terminal-->>Teardown: exit status / timedOut
Teardown-->>Backend: TeardownResult { status }
alt status === "failed"
alt force === false
Backend->>Backend: throw TRPCError (TEARDOWN_FAILED)
Backend-->>TRPC: error
TRPC-->>DestroySvc: error
DestroySvc-->>Dialog: error
Dialog-->>UI: show TeardownFailedPane
UI->>Dialog: onForceDelete() → run({ force: true, skipTeardown: true })
else force === true
Backend->>Backend: log warning, add to warnings[]
end
else status === "ok"
Backend->>Backend: teardownStatus = "ok"
end
else initialCommand null
Backend->>Backend: log, teardownStatus = "skipped"
end
else skipTeardown === true
Backend->>Backend: teardownStatus = "skipped"
Note over Backend: Used only on retry after teardown failure
end
Backend->>Backend: continue local/cloud cleanup (unchanged)
Backend-->>TRPC: result { teardownStatus, warnings, … }
TRPC-->>DestroySvc: result
DestroySvc-->>Dialog: result
Dialog-->>UI: close dialog with teardownStatus
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| * still visible and delete can be retried instead of orphaning disk state. | ||
| * | ||
| * Force semantics: | ||
| * Force semantics ("delete despite dirty files" — NOT "skip teardown"): |
There was a problem hiding this comment.
P2: The destroy-phase JSDoc list still says teardown is run .superset/teardown.sh and is skip if force, but both claims are now obsolete. The newly added Force semantics section below correctly says the opposite ("delete despite dirty files" — NOT "skip teardown"), and the PR description confirms teardown now resolves from overlaid config.json files (not just .superset/teardown.sh). Please update the phase list so it no longer contradicts the detailed semantics or the actual implementation: change the teardown line to reflect config-based resolution and replace skip if force with skip if skipTeardown.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/host-service/src/trpc/router/workspace-cleanup/workspace-cleanup.ts, line 147:
<comment>The destroy-phase JSDoc list still says teardown is `run .superset/teardown.sh` and is `skip if force`, but both claims are now obsolete. The newly added `Force semantics` section below correctly says the opposite (`"delete despite dirty files" — NOT "skip teardown"`), and the PR description confirms teardown now resolves from overlaid `config.json` files (not just `.superset/teardown.sh`). Please update the phase list so it no longer contradicts the detailed semantics or the actual implementation: change the teardown line to reflect config-based resolution and replace `skip if force` with `skip if skipTeardown`.</comment>
<file context>
@@ -142,14 +144,19 @@ export const workspaceCleanupRouter = router({
* still visible and delete can be retried instead of orphaning disk state.
*
- * Force semantics:
+ * Force semantics ("delete despite dirty files" — NOT "skip teardown"):
* - skips preflight (step 0)
- * - skips teardown (step 1)
</file context>
| @@ -0,0 +1,231 @@ | |||
| # Run project teardown scripts on the v2 workspace delete path | |||
There was a problem hiding this comment.
P3: The ExecPlan in plans/done/ contains two Open Questions that are already answered by Decisions D3 and D4 later in the same document. In a completed plan, these should be marked resolved or moved out of the Open Questions section so future readers don't re-escalate already-made product decisions.
Additionally, the Progress checklist leaves the "Manual marker-file scenario" item unchecked even though all other milestones are checked and the Outcomes section describes it as intentionally outstanding. For a living document that states its sections must be kept up to date, leaving this ambiguously unchecked in a done/ plan can suggest it was forgotten rather than deferred. Consider marking it [~] or [x] (deferred — automated coverage equivalent) to make intent explicit.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At plans/done/20260707-1351-v2-delete-teardown-resolution.md, line 25:
<comment>The ExecPlan in `plans/done/` contains two Open Questions that are already answered by Decisions D3 and D4 later in the same document. In a completed plan, these should be marked resolved or moved out of the Open Questions section so future readers don't re-escalate already-made product decisions.
Additionally, the Progress checklist leaves the "Manual marker-file scenario" item unchecked even though all other milestones are checked and the Outcomes section describes it as intentionally outstanding. For a living document that states its sections must be kept up to date, leaving this ambiguously unchecked in a `done/` plan can suggest it was forgotten rather than deferred. Consider marking it `[~]` or `[x] (deferred — automated coverage equivalent)` to make intent explicit.</comment>
<file context>
@@ -0,0 +1,231 @@
+- The 60-second teardown timeout (`TEARDOWN_TIMEOUT_MS` in `packages/shared/src/constants.ts:57`) stays as-is.
+- Backwards compatibility of the `destroy` input is required: existing callers pass only `{ workspaceId, deleteBranch, force }`, so the new `skipTeardown` field must default to `false`.
+
+## Open Questions
+
+- Should the legacy external `workspace.delete` procedure (CLI/SDK/MCP surface, `packages/host-service/src/trpc/router/workspace/workspace.ts:71-81`, which hard-codes `force: true`) now run teardown best-effort? This plan says yes (see Decision Log D3) — it makes SDK deletes take up to 60s longer if a teardown hangs, but skipping lifecycle scripts silently is the exact bug being fixed. If the product decision is "no", pass `skipTeardown: true` there instead and note it in the Decision Log. Impacts: Plan of Work step 4, Validation.
</file context>
…matching setup Review feedback: config-array commands were wrapped in exec bash -c, so commands authored for the user's shell (the contract setup uses) could fail at delete when re-parsed by non-interactive bash. Join with ' && ' and type into the login shell like setup does; a trailing argless 'exit' closes the hidden PTY and propagates the last status in bash/zsh/fish.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/host-service/src/runtime/teardown/teardown.test.ts (1)
68-76: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winSilent skip hides fish-propagation coverage when fish is absent.
if (!isFishAvailable()) return;makes the test report as passed without ever exercising the assertion when fish isn't installed (e.g., in some CI images). Since this specifically verifies the exit-status-propagation contract highlighted in the PR's commit message, a silent pass could mask a real regression on machines lacking fish.Consider using an explicit skip so it's visible in test output:
♻️ Proposed refactor using explicit skip
- test("config command exit propagates the last status under fish", () => { - if (!isFishAvailable()) return; - - const result = spawnSync("fish", [ + test.skipIf(!isFishAvailable())("config command exit propagates the last status under fish", () => { + const result = spawnSync("fish", [ "-c", buildTeardownCommandString(["sh -c 'exit 7'"]), ]); expect(result.status).toBe(7);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/host-service/src/runtime/teardown/teardown.test.ts` around lines 68 - 76, The fish exit-status propagation test is silently passing when fish is unavailable, which hides missing coverage. Update the test in teardown.test.ts around the isFishAvailable check to use an explicit skip or equivalent visible test skip mechanism instead of an early return, so the absence of fish is reported clearly while preserving the existing spawnSync and expect(result.status).toBe(7) assertion when fish is present.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/host-service/src/runtime/teardown/teardown.test.ts`:
- Around line 68-76: The fish exit-status propagation test is silently passing
when fish is unavailable, which hides missing coverage. Update the test in
teardown.test.ts around the isFishAvailable check to use an explicit skip or
equivalent visible test skip mechanism instead of an early return, so the
absence of fish is reported clearly while preserving the existing spawnSync and
expect(result.status).toBe(7) assertion when fish is present.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 4c6404bb-ed64-499e-b1be-7030058c98aa
📒 Files selected for processing (2)
packages/host-service/src/runtime/teardown/teardown.test.tspackages/host-service/src/runtime/teardown/teardown.ts
Problem
Deleting a workspace on the v2 delete path silently skips the project's teardown scripts in the two most common configurations:
teardowncommand arrays in.superset/config.jsonare never executed. The v2 destroy path only looks for a literal file at<worktree>/.superset/teardown.shand never reads config.json — even though the v2 project-settings Scripts editor writes config.json arrays, and the docs (setup-teardown-scripts.mdx: "Delete workspace → teardown commands run") promise they run. This is a regression: feat(desktop): add teardown script support for workspace deletion #178 added config-array teardown to the original delete path; the v2 unification in feat(v2): unify workspace delete through host-service #3443 dropped it, and feat(desktop): setup/teardown scripts editor for v2 projects #4090 upgraded only setup to read config while shipping the editor that writes teardown arrays nothing executes.force: trueskipped teardown entirely — every "Delete anyway" on a workspace with uncommitted/unpushed changes (run(hasWarnings)), and every CLI/SDK/MCP delete (workspace.deletehard-codesforce: true).forceconflated "delete despite dirty files" with "skip the teardown script".Both skips were silent: no log line, no warning, no result field.
Repro: a project with
"teardown": ["./scripts/worktree/teardown.sh"]in.superset/config.json(no.superset/teardown.shfile). Create a workspace, keep it clean, delete it → teardown never runs. Setup runs fine on creation.Fix
Teardown now resolves exactly like setup (
resolveInitialCommandinsetup-terminal.ts):teardowncommands from.superset/config.json(+~/.superset/projects/<id>/config.jsonoverride +config.local.jsonoverlay), joined with&&, run asexec bash -c '…'(same fish-safeexectrick as the existing script path)<worktree>/.superset/teardown.sh(unchanged behavior)<mainRepo>/.superset/teardown.sh— main repo is authoritative; worktrees skip gitignored files (parity with setup)forceno longer skips teardown. A newskipTeardowndestroy input (defaultfalse) is the only bypass, and the renderer sets it only on the TeardownFailedPane "Delete anyway" retry — where re-running the script that just failed/timed out would only stall the user again. Underforce, a teardown failure downgrades to awarningsentry instead of blocking; the non-forceTEARDOWN_FAILEDtyped-error contract is unchanged.Observability: skips are logged (
[teardown] Nothing to run …,[workspaceCleanup.destroy] teardown <status> …) and the destroy result gainsteardownStatus: "ok" | "skipped" | "failed" | "not-run".The legacy external
workspace.deletesurface keepsforce: trueand therefore now runs teardown best-effort (failures don't block SDK/CLI deletes).Testing
resolveTeardownCommand(config wins over worktree script; worktree → main-repo fallback; null when unconfigured; whitespace-only commands ignored; quoting) —bun test src/runtime/teardown: 8 passteardown,workspace-cleanup,workspace-create-delete): 27 pass; the create-delete run now visibly logsteardown skipped … (force=true, skipTeardown=false), showing forced deletes go through resolutionbun run typecheck(28/28 packages),bun run lintcleanExecPlan with the full investigation and decision log:
plans/done/20260707-1351-v2-delete-teardown-resolution.md.Summary by cubic
Ensure v2 workspace deletes run project teardown and only skip it on an explicit retry after a teardown failure. Teardown now resolves from
.superset/config.jsonand runs in the user's shell (like setup), with clear logs and ateardownStatusin the result.Bug Fixes
teardownfrom.superset/config.json(incl. user overrides), else<worktree>/.superset/teardown.sh, else<repo>/.superset/teardown.sh.&&and a trailingexitfor parity and correct exit codes across bash/zsh/fish.forceno longer skips teardown; newskipTeardowninput controls bypass and is only set on the TeardownFailedPane "Delete anyway" retry.force, teardown failures become warnings; non-force still throws theTEARDOWN_FAILEDerror.workspaceCleanup.destroyreturnsteardownStatus: "ok" | "skipped" | "failed" | "not-run".Migration
force: true) now run teardown best-effort and may take up to the timeout if teardown hangs.Written for commit de1edcd. Summary will update on new commits.
Summary by CodeRabbit
New Features
Bug Fixes