From 48d2b46a6534f524675bdacafed0e095f84ca11b Mon Sep 17 00:00:00 2001 From: Guilhem Date: Wed, 2 Dec 2026 19:50:39 +0100 Subject: [PATCH] feat: require typing the workspace ID to archive or delete a root workspace (#12821) * feat: require typing the workspace ID to archive or delete a root workspace Co-Authored-By: Claude Opus 5.5 * fix: say only an instance superadmin can unarchive a workspace Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Claude Opus 5.5 --- .../(logged)/workspace_settings/+page.svelte | 121 +++++++++++++----- 1 file changed, 88 insertions(+), 33 deletions(-) diff --git a/frontend/src/routes/(root)/(logged)/workspace_settings/+page.svelte b/frontend/src/routes/(root)/(logged)/workspace_settings/+page.svelte index c6171b96e7..308d46d89a 100644 --- a/frontend/src/routes/(root)/(logged)/workspace_settings/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/workspace_settings/+page.svelte @@ -111,6 +111,7 @@ reconcileAfterWorkspaceChange } from '$lib/components/sessions/sessionState.svelte' import TextInput from '$lib/components/text_input/TextInput.svelte' + import { workspaceIsFork } from '$lib/utils/workspaceHierarchy' import CollapseLink from '$lib/components/CollapseLink.svelte' import SlackAppSetup from '$lib/components/common/slack/SlackAppSetup.svelte' import { validateWebhookUrl, validateEncryptionKey } from '$lib/validators/workspaceSettings' @@ -139,13 +140,18 @@ let archiveConfirmOpen = $state(false) let deleteConfirmOpen = $state(false) let affectedSessionCount = $state(0) + // A root workspace has no parent to fall back on, so archiving or deleting it asks for its + // ID typed out; a fork is disposable and keeps the one-click confirm. + let typedWorkspaceId = $state('') async function openArchiveConfirm() { affectedSessionCount = await countSessionsForWorkspace($workspaceStore ?? '') + typedWorkspaceId = '' archiveConfirmOpen = true } async function openDeleteConfirm() { affectedSessionCount = await countSessionsForWorkspace($workspaceStore ?? '') + typedWorkspaceId = '' deleteConfirmOpen = true } async function doArchiveWorkspace() { @@ -503,6 +509,14 @@ } }) const currentWorkspace = $derived($userWorkspaces.find((w) => w.id === $workspaceStore)) + // A dev workspace has a parent too but is long-lived, so only a plain fork skips typing the ID. + const requiresTypedWorkspaceId = $derived( + !workspaceIsFork($workspaceStore, $userWorkspaces) || !!currentWorkspace?.is_dev_workspace + ) + const typedWorkspaceIdMatches = $derived( + !requiresTypedWorkspaceId || typedWorkspaceId.trim() === ($workspaceStore ?? '') + ) + const isSpecialWorkspace = $derived($workspaceStore === 'admins' || $workspaceStore === 'starter') // The deploy filters configure what may be promoted into the parent, so they only mean // something for a fork. A root workspace deploys nowhere by lineage. @@ -2145,46 +2159,84 @@
- Delete workspace - {#if !$superadmin} -

- Only instance superadmins can delete a workspace. -

- {/if} - {#if $workspaceStore === 'admins' || $workspaceStore === 'starter'} -

- This workspace cannot be deleted as it has a special function. Consult the - documentation for more information. -

- {/if} -
- - - {#if $superadmin} - +
+ Archive workspace + + Hides {$workspaceStore} from its members and archives + its AI sessions. An instance superadmin can unarchive it from the workspaces + page. + +
+ +
+
+
+ Delete workspace + + Permanently deletes {$workspaceStore} with + its scripts, flows, apps, resources, variables, schedules, run history and + AI sessions. This cannot be undone.{#if !$superadmin} + Only instance superadmins can delete a workspace.{/if} + +
+ +
+ + + + {#snippet typeWorkspaceIdToConfirm()} + {#if requiresTypedWorkspaceId} +
+ + Type {$workspaceStore} to confirm. + + +
{/if} - + {/snippet} { archiveConfirmOpen = false await doArchiveWorkspace() @@ -2197,6 +2249,7 @@ ? ` (${affectedSessionCount})` : ''}. Unarchiving the workspace restores them. + {@render typeWorkspaceIdToConfirm()} @@ -2204,6 +2257,7 @@ open={deleteConfirmOpen} title="Delete workspace" confirmationText="Delete" + confirmDisabled={!typedWorkspaceIdMatches} onConfirmed={async () => { deleteConfirmOpen = false await doDeleteWorkspace() @@ -2217,6 +2271,7 @@ ? ` (${affectedSessionCount})` : ''}. This cannot be undone. + {@render typeWorkspaceIdToConfirm()} {:else if tab == 'webhook'}