import { useState, type ReactNode } from 'react'; import { motion, useReducedMotion } from 'framer-motion'; import { ChevronDown, ListChecks } from 'lucide-react'; import { cn } from '@/lib/utils'; import { SPRING } from '@/lib/motion/tokens'; import { DotLive } from './DotLive'; import { ProvenanceLine } from './ProvenanceLine'; import type { WarmTone } from './tones'; export interface ActivityStep { tone?: WarmTone; text: ReactNode; /** Provenance for the step — rendered only when real source data exists. */ provenance?: { source: string; when?: string; onClick?: () => void }; /** * Surprise-recall bloom (Pillar 3.2): when true, the step row blooms honey on * mount — a SPRING.micro scale pop + a ~600ms honey glow that fades, drawing the * eye to the "it remembered" moment. Set only for the memory-recall step of the * ACTIVE turn; reduced-motion renders a plain row (no bloom). */ bloom?: boolean; } interface ActivityStreamProps { /** e.g. "Worked across memory, web & files". */ summary: string; durationMs?: number; steps: ActivityStep[]; /** Default-open on the active turn; collapsed on prior turns. */ defaultOpen?: boolean; className?: string; } /** * The Chat "activity stream" — a collapsible card that reveals the agent's * steps (each with a tone dot and optional provenance pill). The header shows a * summary + step count + duration. Violet checklist icon = the agent's work steps. */ export function ActivityStream({ summary, durationMs, steps, defaultOpen = false, className, }: ActivityStreamProps) { const [open, setOpen] = useState(defaultOpen); const reduce = useReducedMotion(); const seconds = durationMs != null ? `${Math.max(1, Math.round(durationMs / 1000))}s` : null; const meta = [`${steps.length} step${steps.length === 1 ? '' : 's'}`, seconds].filter(Boolean).join(' · '); return (