/* Copyright 2026 Marimo. All rights reserved. */ import { AlertOctagonIcon, ChevronDownIcon, ChevronRightIcon, ChevronsUpDownIcon, Loader2Icon, RefreshCcw, } from "lucide-react"; import type React from "react"; import { memo } from "react"; import { Toolbar } from "@/components/layout/toolbar"; import { Button } from "@/components/ui/button"; import { Tooltip } from "@/components/ui/tooltip"; import { useNotebook } from "@/core/cells/cells"; import type { CellId } from "@/core/cells/ids"; import { getDescendantsStatus } from "@/core/cells/utils"; import { cn } from "@/utils/cn"; interface Props { isCollapsed: boolean; canCollapse: boolean; onClick: () => void; } export const CollapseToggle: React.FC = (props) => { // It could be collapsed, but the markdown headers were removed. // So we still want to be able to expand it, if it is collapsed. if (!props.canCollapse && !props.isCollapsed) { return null; } return ( ); }; const Arrow = ({ isCollapsed }: { isCollapsed: boolean }) => { return isCollapsed ? ( ) : ( ); }; export const CollapsedCellBanner: React.FC<{ onClick: () => void; cellId: CellId; count: number; }> = memo(({ onClick, count, cellId }) => { const notebook = useNotebook(); const states = getDescendantsStatus(notebook, cellId); return (
{count} {count === 1 ? "cell" : "cells"} collapsed } right={ <> {states.errored && ( )} {states.stale && ( )} {states.runningOrQueued && ( )} } />
); }); CollapsedCellBanner.displayName = "CollapsedCellBanner";