From 1e0c3c5a7dfc5740bc678a7c0215e778ed87b5d7 Mon Sep 17 00:00:00 2001 From: JasonOA888 Date: Mon, 9 Mar 2026 17:35:19 +0800 Subject: [PATCH] fix(frontend): block deletion of an app's last revision When a user tries to delete the last revision of an app from Playground, the UI now prevents this action instead of leaving the app in a broken state. Changes: - Add isLastRevision check that counts total visible revisions - Disable delete button when deleting would remove all revisions - Show helpful message: Cannot delete the only revision. Delete the app instead. Fixes #3892 --- .../Modals/DeleteVariantModal/Content.tsx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/web/oss/src/components/Playground/Components/Modals/DeleteVariantModal/Content.tsx b/web/oss/src/components/Playground/Components/Modals/DeleteVariantModal/Content.tsx index 06f83f1967..f9ab30fa79 100644 --- a/web/oss/src/components/Playground/Components/Modals/DeleteVariantModal/Content.tsx +++ b/web/oss/src/components/Playground/Components/Modals/DeleteVariantModal/Content.tsx @@ -174,6 +174,17 @@ const DeleteVariantContent = ({revisionIds, forceVariantIds = [], onClose}: Prop const totalSelectedCount = uniqueRevisionIds.length const isBulkDelete = deletionPlan.variants.length > 0 || totalSelectedCount > 1 + // Check if this would delete the last revision of the app + const isLastRevision = useMemo(() => { + // Count total visible revisions across all variants + let totalRevisions = 0 + Object.values(variantGroups).forEach((group) => { + totalRevisions += group.totalIds.length + }) + // If we're deleting all revisions, this is the last one + return totalRevisions > 0 && totalSelectedCount >= totalRevisions + }, [variantGroups, totalSelectedCount]) + const onDeleteVariant = useCallback(async () => { setIsMutating(true) try { @@ -277,13 +288,19 @@ const DeleteVariantContent = ({revisionIds, forceVariantIds = [], onClose}: Prop type="primary" danger loading={isMutating} - disabled={isMutating || totalSelectedCount === 0} + disabled={isMutating || totalSelectedCount === 0 || isLastRevision} icon={} onClick={onDeleteVariant} + title={isLastRevision ? "Cannot delete the only revision. Delete the app instead." : undefined} > {isBulkDelete ? "Delete selected" : "Delete"} + {isLastRevision && ( + + Cannot delete the only revision. Delete the app instead. + + )} ) }