import { useCallback, useRef, useState, type JSX, type ReactNode } from "react"; import { Check, ChevronDown, ChevronUp, Copy, ListChecks } from "lucide-react"; import { translate } from "../../../i18n/index"; const COLLAPSED_MAX_HEIGHT_PX = 220; /** * Shared collapsible plan card used by both providers' plan proposals so the * codex plan item and the claude-code ExitPlanMode plan render identically: * a framed card with a title, a copy action, and a collapse/expand affordance * (long plans default to collapsed with an "expand plan" overlay). */ export function AgentPlanCard({ title, copyText, children, defaultCollapsed = true }: { title?: string; copyText: string; children: ReactNode; defaultCollapsed?: boolean; }): JSX.Element { "use memo"; const [collapsed, setCollapsed] = useState(defaultCollapsed); const [copied, setCopied] = useState(false); const copyResetRef = useRef | null>(null); const handleCopy = useCallback(() => { void navigator.clipboard?.writeText(copyText).then(() => { setCopied(true); if (copyResetRef.current) { clearTimeout(copyResetRef.current); } copyResetRef.current = setTimeout(() => setCopied(false), 1500); }); }, [copyText]); return (
{children}
{collapsed ? (
) : null}
); }