fix(host): recreating a destroyed workspace's branch silently no-ops
Closed
KI
3mo ago+6+6+0123456789-1-1-0123456789
Summary
workspaces.create's idempotency lookup (findExistingWorkspaceByBranch) matched archived tombstones, so creating a workspace on a branch whose previous workspace was destroyed returned the invisible archived row withalreadyExists: true— no worktree created, nothing appears in the sidebar. One-line filter, matching what the adopt path already does.
Why / Context
Since tombstones (#6296), destroyed workspaces keep their row forever with archived_at set. The create-path idempotency lookup predates that and never learned to skip them. Any user who deletes a workspace and later recreates the same branch hits a silent no-op.
Found while re-running lineage e2e scenes (#6562) that reuse branch names; reproduced directly against a dev host: create → workspaceCleanup.destroy → create returned the archived row's id with alreadyExists: true.
Testing
bunx tsc --noEmiton host-service — clean- Manual repro before the fix (create-after-destroy returns tombstone id); host-service dev verification of the fixed path pending a host restart — the archived-row repro is deterministic
- Not run locally: host-service
*.node-test.ts(ABI seesaw; relying on CI)
Notes
- Independent of #6562/#6564 — based on main; those branches will pick it up on their next rebase.
Summary by cubic
Recreating a destroyed workspace’s branch now creates a new workspace and worktree. Previously, workspaces.create matched archived tombstones in its idempotency check, returned alreadyExists=true, and silently no-oped.
Review notes
- Add
archivedAt IS NULLfilter tofindExistingWorkspaceByBranchto ignore tombstones (parity with the adopt path). - Scope: only affects branch-based creation idempotency; active workspaces still de-dup correctly.
- No API or schema changes; no migration required.
Summary by CodeRabbit
- Bug Fixes
- Prevented archived workspaces from being incorrectly returned during workspace creation or lookup.
- Improved handling of workspace records that have been archived.