Skip to content

Allow account owners to delete workspaces - #208

Open
paulocastellano wants to merge 15 commits into
mainfrom
fix/207-delete-workspace
Open

Allow account owners to delete workspaces#208
paulocastellano wants to merge 15 commits into
mainfrom
fix/207-delete-workspace

Conversation

@paulocastellano

@paulocastellano paulocastellano commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds a workspace settings danger zone so account owners can delete a workspace after typing its name
  • SaaS blocks deleting the last workspace (links to billing / delete account); self-hosted allows it and skips Stripe quantity sync
  • Delete is account-owner only (same as create/billing) so workspace admins cannot change Stripe quantity
  • Stranded members are rehomed to a personal account (EnsurePersonalAccount); owner account delete does the same for remaining members
  • Enforces authorize('create') so members/admins cannot create billable workspaces on the shared account

Closes #207

Test plan

  • As account owner with 2+ workspaces (SaaS): Workspace settings → Danger zone → confirm name → workspace deleted and billing quantity drops
  • As workspace admin/member/viewer: no danger zone; delete returns 403
  • As member: cannot open create workspace / store returns 403
  • Delete workspace with a member who only had that shared workspace: member is rehomed to a personal account
  • Delete workspace with a member who still has another workspace on the account: member stays on the shared account
  • Delete workspace when member still has a personal workspace membership: member is rehomed (account-scoped), not left on the owner’s account
  • As SaaS with only 1 workspace: delete blocked; owner sees billing + delete account links
  • As self-hosted with only 1 workspace: delete still allowed; copy has no billing mention
  • Owner deletes account: Stripe cancelNow (if subscribed), members rehomed, account wiped

paulocastellano and others added 15 commits July 26, 2026 12:51
Expose a danger zone with name confirmation, sync Stripe quantity on SaaS, and skip billing constraints in self-hosted mode.

Co-authored-by: Cursor <cursoragent@cursor.com>
The settings page is already gated by update (owner/admin), which matches delete.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Enforce owner-only workspace creation, rehome stranded members to a personal account, warn about member access loss, and clarify the only-workspace SaaS exit paths.

Co-authored-by: Cursor <cursoragent@cursor.com>
…ehome.

Restrict delete to account owners, rehome stranded members transactionally with account-scoped fallbacks, and clean up the danger-zone UI/copy.

Co-authored-by: Cursor <cursoragent@cursor.com>
Prune pending invites and media on delete, lock the account for the
last-workspace guard, fall back to account-owned workspaces for owners,
redirect self-hosted last deletes to create, cancel Stripe after local
cleanup, align personal-account trials, and gate Index create for owners.

Co-authored-by: Paulo Castellano <hello@paulocastellano.com>
Stop invite accept from demoting existing roles, expire dead invites on
show, preserve flash by avoiding calendar bounces, move media file I/O
outside locked delete transactions, and finish account deletion even if
Stripe cancel fails.

Co-authored-by: Paulo Castellano <hello@paulocastellano.com>
Distinguish already-accepted invites from gone workspaces, rehome
members removed from their last shared workspace, capture media paths
inside the delete lock, extract orphaned-file cleanup, and use Wayfinder
for the expired-invite home link.

Co-authored-by: Paulo Castellano <hello@paulocastellano.com>
Switch invitees onto an invite-account workspace when accepting, prefer
same-account fallbacks when removing members, abort account deletion if
Stripe cancel fails, and clear avatar media on profile delete.

Co-authored-by: Paulo Castellano <hello@paulocastellano.com>
Flush workspace media files before billing cancel can abort account
delete, and rehome stranded non-owners before picking an invite redirect
fallback so current workspace never points across accounts.

Co-authored-by: Paulo Castellano <hello@paulocastellano.com>
Keep RemoveMember and account-delete member fallbacks same-account
only, clarify the billing-failure flash that workspaces were already
removed, and assert storage deletion in media cleanup tests.

Co-authored-by: Paulo Castellano <hello@paulocastellano.com>
After local workspaces are wiped, a stuck cancelNow must still drop
seat quantity so the subscription cannot keep billing the old count.

Co-authored-by: Paulo Castellano <hello@paulocastellano.com>
Pending and accepted invites are removed with the workspaces so a
Stripe cancel failure cannot leave unique email/account rows that block
re-invites to a gutted account.

Co-authored-by: Paulo Castellano <hello@paulocastellano.com>
@cursor cursor Bot changed the title Allow users to delete workspaces Allow account owners to delete workspaces Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Users cannot delete workspace

2 participants