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. + + )} ) }