Repository navigation
Description
Summary
workspaceCleanup.destroy's force parameter conflates two independent concerns into one boolean:
- "discard/override the dirty-worktree check" — the thing a user is actually consenting to when they click "Delete anyway" on a workspace with uncommitted changes or unpushed commits.
- "skip the project's own
.superset/config.jsonteardownscript entirely" — a separate safety mechanism a project can define (e.g. a check that refuses to delete a workspace while a process is still running inside its worktree).
Because both are gated by the same force flag, there is currently no way to say "yes, discard my uncommitted changes" without also implicitly saying "and skip whatever safety check my project's teardown script does" — and two real call paths end up setting force: true far more often than users likely intend.
Where this surfaced
We (WowMakers, a Superset user) added a custom teardown script to a repo's .superset/config.json specifically to guard against workspace deletion while an active process still has files open in the worktree (a real gap: git's own dirty-tree check doesn't see live processes, only uncommitted/untracked file state). While reasoning about when that guard actually runs, we found it's reachable only through a narrow slice of "the GUI" — not through the CLI at all, and not through the GUI's own first-click path whenever the workspace happens to be dirty. Full context (not required to evaluate this issue, just background): pradtv/wowmakers#578.
The three places this shows up
1. force gates both preflight and teardown, as one flag — packages/host-service/src/trpc/router/workspace-cleanup/workspace-cleanup.ts:
* Force semantics:
* - skips preflight (step 0)
* - skips teardown (step 1)and concretely, both steps are gated by the exact same input.force check (L211, L232):
if (!input.force && local && project) { // step 0: dirty-worktree preflight
...
}
if (!input.force && local && project) { // step 1: run .superset/config.json teardown
...
}There's no independent way to skip one without the other.
2. The desktop GUI's own confirm button already sends force: true on a dirty/unpushed workspace's first click, not only on retry — DashboardSidebarDeleteDialog.tsx:
const hasWarnings = hasChanges || hasUnpushedCommits;
const confirmLabel = hasWarnings ? "Delete anyway" : "Delete";
...
onConfirm={() => run(hasWarnings)}A workspace with uncommitted changes or unpushed commits — a very common state, and one a project's own setup script can produce with zero user action (e.g. a package manager rewriting a lockfile during provisioning) — gets force: true the moment the user clicks the only button available, silently skipping the project's teardown script along with the dirty-tree override. The user is consenting to "delete despite my changes," not to "skip my project's safety hook," but both happen together.
3. The CLI/SDK/MCP delete path hardcodes force: true, deleteBranch: false unconditionally, on every call, for every workspace regardless of its state — packages/host-service/src/trpc/router/workspace/workspace.ts:
delete: protectedProcedure
.input(z.object({ id: z.string() }))
.mutation(async ({ ctx, input }) => {
// Legacy external surface used by CLI/SDK/MCP. Preserve its
// non-interactive contract while reusing the v2 cleanup path.
return destroyWorkspace(ctx, {
workspaceId: input.id,
deleteBranch: false,
force: true,
});
}),This means every superset workspaces delete, every SDK .workspaces.delete(), and every MCP delete tool call skips a project's .superset/config.json teardown script entirely, structurally, with no way to opt out — even for a perfectly clean workspace where the dirty-tree override was never needed in the first place. Confirmed via packages/cli/src/commands/workspaces/delete/command.ts → packages/sdk/src/resources/workspaces.ts (hostMutation(hostId, "workspace.delete", { id })) → the hardcoded call above.
Impact
A project author can write a teardown script in .superset/config.json believing it runs as a safety gate before workspace deletion (that's its documented purpose), but in practice:
- It never runs via CLI/SDK/MCP delete, unconditionally (Bump react from 18.3.1 to 19.2.0 #3 above).
- It only runs via the desktop GUI, and only when the workspace is clean with no unpushed commits (Bump lucide-react from 0.468.0 to 0.546.0 #2 above) — any dirty state, at all, skips it on the very first click.
- Retrying after a conflict or a teardown failure also forces (
onForceDelete: () => run(true)in the same dialog file), compounding the same issue.
So the effective guarantee a teardown script can offer today is much narrower than "runs before this workspace is deleted" — it's closer to "runs only for a clean GUI delete that has never hit a retry," which isn't obvious from the config surface or docs.
Suggested fix
Split force into two independently-settable inputs on workspaceCleanup.destroy, e.g.:
force(oroverrideDirtyCheck) — skip the git dirty-worktree/unpushed-commits preflight only.- A separate flag (e.g.
skipTeardown) — skip the project's teardown script only.
Then:
- The GUI's "Delete anyway" button should set only the dirty-check override, not also skip teardown — teardown should still get a chance to run (and itself decide, via its own exit code, whether to block) even on a dirty workspace.
- The CLI/SDK/MCP
workspace.deletepath (workspace.ts:159-169) shouldn't hardcode teardown-skipping — it has no state-based reason to, since it isn't reacting to a dirty-tree conflict the way the GUI's forced retry is.
Happy to help verify a fix against a real teardown script if useful — we have one in place (pradtv/wowmakers's .superset/config.json) that already distinguishes "active process in worktree" from "clean, safe to remove" via an lsof-based guard, so it'd exercise the split cleanly.
Activity