import { useState } from 'react'; import { ChevronDown, ChevronRight, Copy, Check } from 'lucide-react'; import { toast } from 'sonner'; import type { Message } from '@/api/types'; import { MarkdownRenderer } from '@/components/MarkdownRenderer'; // v1.11 anchored rolling summary. Inserted by services/compaction.ts as a // role='assistant', summary=true row. Distinct from legacy CompactCard // (which renders the kind='compact' system rows produced by v1.10 /compact). // Collapsed by default; header shows the timestamp; body renders the // summary markdown when expanded. Copy button matches CompactCard's affordance. export function SummaryCard({ message }: { message: Message }) { const [expanded, setExpanded] = useState(false); const [copied, setCopied] = useState(false); // Use finished_at when available (that's when the summary actually landed); // fall back to created_at for any row missing it. Both are ISO strings. const ts = message.finished_at ?? message.created_at; const headerTs = ts ? new Date(ts).toLocaleString() : ''; async function handleCopy() { try { await navigator.clipboard.writeText(message.content); setCopied(true); setTimeout(() => setCopied(false), 1200); toast.success('Summary copied to clipboard'); } catch { toast.error('Copy failed'); } } return (
{expanded && (
)}
); }