Repository navigation
fix(host-service): don't reuse a tombstoned workspace on same-branch create - #6552
Conversation
…create Since ParadevAI#6296 turned workspace deletes into tombstones (archivedAt), the create flow's branch-idempotency lookup still matched archived rows, so recreating a deleted workspace's name returned the dead row: no worktree was created, the call reported alreadyExists, and the desktop navigated to an id the workspace list filters out — landing on "Workspace not found" (ParadevAI#6383, ParadevAI#6380). Filter tombstones out of findExistingWorkspaceByBranch, matching the isNull(archivedAt) convention every sibling lookup already follows, and add an integration regression test for the delete → same-branch recreate flow.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughWorkspace branch idempotency lookup now excludes archived workspace rows. Integration coverage verifies that deleting and recreating a workspace on the same branch creates a new active workspace and worktree while preserving the original archive metadata. ChangesWorkspace branch reuse
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This change prevents deleted workspace records from being reused during same-branch creation and adds regression coverage; no actionable merge-blocking risk remains after normal checks and review. 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 |
|
hey @Kitenite |
…potency filter Folds in the clearer rationale from the duplicate PR ParadevAI#6605: matching a tombstone returns the archived row with alreadyExists: true and silently skips the create, and the adopt path already filters archived rows.
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
What & why
Fixes #6383, refs #6380.
Since #6296 turned workspace deletes into tombstones (
archivedAt+archiveReason, row kept for the board's Merged/Deleted history), the create flow's branch-idempotency lookupfindExistingWorkspaceByBranchstill matched on(projectId, branch)with no archived filter — the one consumer #6296's "consumers updated" pass missed. Recreating a deleted workspace's name therefore "reused" the tombstone: exit 0,alreadyExists: true, no worktree created, and the desktop redirected to the dead row's id, whichworkspace.listfilters out — landing users on the "Workspace not found" screen. CLI/SDK/MCP callers got a success response for a workspace that doesn't exist (the automation-fleet failure described in #6383).This PR adds the
isNull(workspaces.archivedAt)guard to the lookup, matching the convention every sibling lookup already follows (adopt-existing-worktree.ts,workspace.list, session folder dedupe). #6296 explicitly planned for re-creating a workspace on a tombstoned branch ("Tombstones aren't phantoms — same-branch history must survive re-creating a workspace on that branch"); this makes that path reachable.Note: #6384 proposes the same guard — happy to defer to it if it lands first; this PR adds an independent regression test and desktop-flow verification.
How I tested it
workspace-create-delete.integration.test.ts): create → delete (assert tombstone) → create on the same branch → asserts a fresh live row with a real worktree on disk,alreadyExists: false, and the tombstone's history untouched. Watched it fail onmain(alreadyExistscame backtrue) before the fix.main— each recreate left zero new rows, no worktree, no branch, and the renderer sat on the tombstone's id showing "Workspace not found" (screenshots below). With the fix, repeated create → delete → recreate cycles on the same name each produced a fresh live workspace coexisting with its tombstone, verified inhost.dband on disk.bun run lint(clean — no warnings),bun run typecheck, full@superset/host-servicesuite: 1112 pass / 0 fail.Known limitation (deliberately out of scope): a create that lands while a destroy of the same branch is still mid-pipeline (archive-first, worktree removed last) can adopt the dying worktree; that window predates this change and is better handled by serializing create/destroy separately.
Checklist
type(scope): subject)bun run lintandbun run typecheckpass (CI fails on lint warnings too)Summary by cubic
Prevents workspace.create from reusing a tombstoned workspace on the same branch, fixing “Workspace not found” after recreate. Previously the idempotency lookup matched archived rows, returned alreadyExists: true, and created no worktree; now it ignores tombstones and inserts a fresh live workspace with a real worktree.
@superset/host-service.Written for commit 9dd093e. Summary will update on new commits.
Summary by CodeRabbit
Bug Fixes
Tests