Skip to content

Add option to delete a realm#4173

Draft
jurgenwerk wants to merge 7 commits intomainfrom
cs-10333-add-option-to-delete-a-realm
Draft

Add option to delete a realm#4173
jurgenwerk wants to merge 7 commits intomainfrom
cs-10333-add-option-to-delete-a-realm

Conversation

@jurgenwerk
Copy link
Contributor

@jurgenwerk jurgenwerk commented Mar 12, 2026

Screen.Recording.2026-03-12.at.13.19.09.mov

Summary

  • add a workspace chooser context menu action to delete user-owned realms and show a richer destructive confirmation
  • add a realm-server delete endpoint that removes source realms, published copies, related permissions, and soft-deletes claimed domains
  • add host acceptance coverage and targeted realm-server endpoint coverage for the delete flow

Testing

  • pnpm ember test --path dist --filter "workspace-chooser-delete"
  • TEST_MODULE=server-endpoints/delete-realm-test.ts pnpm test-module
  • pnpm lint (packages/host)
  • pnpm lint (packages/realm-server)

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds end-to-end “delete realm/workspace” support, spanning host UI (workspace chooser action + destructive confirmation), realm-server endpoint implementation, and test coverage to validate both server-side deletion behavior and the host flow.

Changes:

  • Added DELETE /_delete-realm realm-server endpoint and wired it into routing.
  • Introduced shared realm destruction utilities and refactored unpublish to use them.
  • Added realm-server endpoint tests, host acceptance tests, and CI inclusion for the new test module.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/realm-server/tests/server-endpoints/delete-realm-test.ts New endpoint coverage for deleting source realms, published copies, permissions, and domain-claim soft deletion.
packages/realm-server/tests/index.ts Registers the new delete-realm endpoint test.
packages/realm-server/routes.ts Adds DELETE /_delete-realm route with JWT middleware.
packages/realm-server/handlers/realm-destruction-utils.ts New shared helper for deleting realm contents + unmounting.
packages/realm-server/handlers/handle-unpublish-realm.ts Refactors published realm removal to use the new shared helper.
packages/realm-server/handlers/handle-delete-realm.ts New handler implementing the server-side realm deletion flow.
packages/host/tests/helpers/realm-server-mock/routes.ts Adds mock realm-server route for /_delete-realm used by host acceptance tests.
packages/host/tests/acceptance/workspace-chooser-delete-test.gts Adds acceptance coverage for enabling/disabling delete and for the delete confirmation UI content.
packages/host/app/services/realm.ts Adds removeRealm() to evict a realm resource locally after deletion.
packages/host/app/services/realm-server.ts Adds deleteRealm() client method calling the new realm-server endpoint.
packages/host/app/services/matrix-service.ts Adds helper to remove a realm URL from Matrix account data.
packages/host/app/components/operator-mode/workspace-chooser/workspace.gts Adds workspace context menu + delete confirmation modal and deletion workflow.
packages/host/app/components/operator-mode/workspace-chooser/index.gts Enables the workspace menu in the chooser list.
packages/host/app/components/operator-mode/delete-modal.gts Makes delete modal content more flexible and adds size override support.
.github/workflows/ci.yaml Ensures the new realm-server endpoint test is included in CI’s test-module list.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link

Preview deployments

@github-actions
Copy link

github-actions bot commented Mar 12, 2026

Host Test Results

    1 files  ± 0      1 suites  ±0   2h 36m 11s ⏱️ + 13m 10s
2 025 tests +15  2 009 ✅ +14  15 💤 ±0  0 ❌ ±0  1 🔥 +1 
2 040 runs  +15  2 023 ✅ +13  15 💤 ±0  1 ❌ +1  1 🔥 +1 

For more details on these errors, see this check.

Results for commit 804b4dc. ± Comparison against base commit 3665973.

This pull request removes 1 and adds 16 tests. Note that renamed tests count towards both.
Chrome ‑ Integration | operator-mode | card catalog: Show only preserves scroll position of the focused section
Chrome ‑ Acceptance | AI Assistant tests: LLM select footer hides "Restore default" when default system card is active
Chrome ‑ Acceptance | AI Assistant tests: LLM select footer shows "Go to current system card" action
Chrome ‑ Acceptance | AI Assistant tests: LLM select footer shows "Restore default" when non-default system card is active
Chrome ‑ Acceptance | AI Assistant tests: duplicate model IDs render as distinct menu items with correct state
Chrome ‑ Acceptance | workspace-chooser-delete: can delete a workspace created by the current user from the chooser
Chrome ‑ Acceptance | workspace-chooser-delete: delete workspace is enabled only for a workspace created by the current user
Chrome ‑ Integration | Command | host command schema generation test > command schema generation: getInputJsonSchema for GetUserSystemCardCommand
Chrome ‑ Integration | Command | host command schema generation test > command schema generation: getInputJsonSchema for SyncOpenRouterModelsCommand
Chrome ‑ Integration | commands | get-user-system-card: returns the active system card ID when one is set
Chrome ‑ Integration | commands | get-user-system-card: returns undefined cardId when no system card is set
…

♻️ This comment has been updated with latest results.

@jurgenwerk
Copy link
Contributor Author

I had no design for this so I vibed it. I'll show it to the design people and get feedback. In the meanwhile this is ready for review.

@jurgenwerk jurgenwerk marked this pull request as ready for review March 12, 2026 13:11
@jurgenwerk jurgenwerk requested review from a team and habdelra March 12, 2026 13:12
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ec5b945584

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +548 to +550
await this.realmServer.deleteRealm(this.args.realmURL);
await this.matrixService.removeRealmFromAccountData(this.args.realmURL);
this.recentFilesService.removeRecentFilesForRealmURL(this.args.realmURL);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Recover from matrix update failures after realm deletion

The delete flow performs deleteRealm first and only then updates Matrix account data, but all subsequent cleanup is inside the same try. If removeRealmFromAccountData fails (for example, a transient Matrix API error), the catch path skips local cleanup and leaves the just-deleted workspace in account data/recent UI state; a retry then hits _delete-realm with a 404 because the realm is already gone. This creates a hard-to-recover partial-failure state for end users.

Useful? React with 👍 / 👎.

Comment on lines +539 to +543
let isActiveWorkspace =
this.operatorModeStateService.realmURL === this.args.realmURL ||
this.operatorModeStateService
.getOpenCardIds()
.some((cardId) => cardId.startsWith(this.args.realmURL)) ||

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include published realm URLs in active-workspace detection

The active-workspace check only looks for the source realm URL, but deleting a workspace also deletes its published realms on the server. If a user currently has stack items or code paths under one of those published URLs, this condition stays false and the stacks are not cleared, leaving open references to resources that were just removed and causing follow-on load/edit failures.

Useful? React with 👍 / 👎.

@habdelra
Copy link
Contributor

are there any odd behaviors if you have an existing chat with AI that has artifacts from a deleted realm?

@jurgenwerk
Copy link
Contributor Author

jurgenwerk commented Mar 12, 2026

Yeah the assistant will show errors for attached cards that used to work but are now deleted. Perhaps we can adjust this to say the cards/files are not found

image

@habdelra
Copy link
Contributor

habdelra commented Mar 13, 2026

@IanCal this is the PR that we can use for removing a realm for teh software factory so that realms become more disposable. probably a good next step is to make a command and skill for this (and prob refactor the menu logic here to call the command)

return response.body.data.id as string;
}

test('DELETE /_delete-realm removes a created realm, its published copies, and related domain claims', async function (assert) {
Copy link
Contributor

@habdelra habdelra Mar 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think there is more cleanup. we should delete all items for the deleted realm in the realm_versions, boxel_index, boxel_working_index, and modules tables and add assertions our tests for that. Also probably we should delete any pending jobs in the jobs table that are tied to the deleted realm's concurrency group (indexing:<realm_url>)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe also ask AI to think of any other tables that might need cleanup

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a way to detect this is to dump the database and look for any mentions of the should-have-been-deleted realm name

@jurgenwerk jurgenwerk marked this pull request as draft March 13, 2026 11:12
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.

4 participants