/* Copyright 2026 Marimo. All rights reserved. */ import { AlertTriangleIcon } from "lucide-react"; import React from "react"; import { FocusScope } from "react-aria"; import { formatElapsedTime } from "@/components/editor/cell/CellStatus"; import { CellLink } from "@/components/editor/links/cell-link"; import { Button } from "@/components/ui/button"; import type { CellId } from "@/core/cells/ids"; import { usePendingDelete } from "@/core/cells/pending-delete-service"; import { cn } from "@/utils/cn"; export const PendingDeleteConfirmation: React.FC<{ cellId: CellId }> = ({ cellId, }) => { const pendingDelete = usePendingDelete(cellId); if (!pendingDelete.isPending) { return null; } // Non-primary handlers in multi-delete just show pending state if (pendingDelete.type === "simple") { return (
Pending deletion
); } const hasExpensiveExecution = pendingDelete.executionDurationMs !== undefined; const hasDependencies = pendingDelete.defs.size > 0; const formattedTime = formatElapsedTime( pendingDelete.executionDurationMs ?? 0, ); let warningMessage = "Pending deletion"; if (hasExpensiveExecution && hasDependencies) { warningMessage = `This cell took ${formattedTime} to run and contains variables referenced by other cells.`; } else if (hasExpensiveExecution) { warningMessage = `This cell took ${formattedTime} to run.`; } else if (hasDependencies) { warningMessage = "This cell contains variables referenced by other cells."; } return (

{warningMessage}

{hasDependencies && [...pendingDelete.defs.entries()].map(([varName, cells]) => (

'{varName}' is referenced by:

    {cells.map((id) => (
  • ))}
))}
{/* Only show buttons for single cell - multi-cell uses toast */} {pendingDelete.shouldConfirmDelete && ( <>

Are you sure you want to delete?

{ // Stop propagation to prevent Cell's resumeCompletionHandler e.stopPropagation(); }} >
)}
); };