I want the ability to delete workspaces
Delete workspace
ready…
Osebotfable-5-156d ago
Plan: owner-only workspace deletion
Mirroring the existing thread-delete flow (components/delete-thread.tsx + DELETE /api/threads/[id]):
lib/data.ts—deleteWorkspace(id): a singledb.delete(workspaces). Every child table already hasonDelete: "cascade"(members, invites, repos, threads → posts/jobs/embeddings/candidates, memory notes), so no manual fan-out and no migration.app/api/workspaces/[id]/route.ts(new) —DELETE, guarded withrequireMember(id, user, "owner"). Members get 403, non-members 404 (existing convention).components/workspace-forms.tsx—DeleteWorkspaceButton: same two-tap arm/confirm pattern asDeleteThreadButton, redirects to/workspaceson success.app/workspaces/[id]/page.tsx— a "Danger zone" card at the bottom, rendered for owners only, spelling out what gets removed.
Running jobs: if a workspace is deleted mid-run, the job row cascades away, the runner's callbacks start getting 401 from authJob, and the sandbox dies at its wall-clock timeout. That's identical to deleting a thread today — I'm not adding sandbox-killing here.
Osebotfable-5-156d ago
threadide@f7d94f5Done — owners can now delete workspaces. Pushed as f7d94f5 on thread/92313ff0 (tsc clean, no migration needed).
What changed
app/api/workspaces/[id]/route.ts(new) —DELETE. Owner-only viarequireMember(id, user, "owner"): members get 403, non-members 404, same as the other owner routes.lib/data.ts—deleteWorkspace(id): onedb.delete(workspaces). I verified indrizzle/*.sqlthat all 7workspace_idFKs and boththread_idFKs areON DELETE cascade, so members, invites, repos, threads → posts/jobs/embeddings/memory candidates, and memory notes all go with it.components/workspace-forms.tsx—DeleteWorkspaceButton, same two-tap arm/confirm pattern asDeleteThreadButton(turns red "really delete this workspace?", auto-disarms after 4s). Redirects to/workspaceson success, showsFailed: <status>inline otherwise.app/workspaces/[id]/page.tsx— "Danger zone" card at the bottom, owners only, stating the live thread/memory-note counts that will be removed and that nothing on GitHub is touched.
Screenshot attached: static mockup against the real globals.css at 390px, resting and armed states.
Worth knowing
- Running jobs. If a workspace is deleted mid-run, the job row cascades away, so the runner's callbacks start failing
authJob(401) and the sandbox exits at its wall-clock timeout (SANDBOX_TIMEOUT_MS, default 45 min). This is identical to deleting a thread today. If we ever want to actively kill the sandbox on delete,jobs.sandboxIdis already stored for that. - The members route's existing error — "owner can't leave; transfer or delete the workspace" — is now actually actionable. There's still no ownership transfer; that'd be a separate task.
- Non-owner members see no delete affordance at all; only the API enforces the 403.
Ready for a PR from thread/92313ff0 whenever you want it.
Pull requests:threadide #14
