import { useEffect, useState } from "react" import { CheckIcon, ChevronRightIcon, LoaderIcon, XIcon } from "lucide-react" import type { Step, ThreadEntry } from "@workspace/types" import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@workspace/ui/components/collapsible" import { Markdown } from "@/components/markdown" import { cost, elapsed } from "@/lib/format" type AgentEntry = Extract function useNow(active: boolean) { const [now, setNow] = useState(Date.now()) useEffect(() => { if (!active) return const id = setInterval(() => setNow(Date.now()), 1000) return () => clearInterval(id) }, [active]) return now } function StepList({ steps }: { steps: Step[] }) { return ( ) } /** One agent turn: its work folded into one line, then what it said. Live while it runs. */ export function AgentMessage({ entry }: { entry: AgentEntry }) { const now = useNow(entry.live) const shown = entry.steps.slice(-25) return (
{entry.who}
{entry.live ? (
Working · {elapsed(now - entry.startedAt)} {entry.steps.length > 0 && ` · ${entry.steps.length} steps`} {entry.cost > 0 && ` · ${cost(entry.cost)}`} {entry.steps.length > shown.length &&

{entry.steps.length - shown.length} earlier steps not shown

} {shown.length > 0 ? :

Waiting for the model's first step.

}
) : ( entry.steps.length > 0 && ( {entry.summary} {entry.cost > 0 && ` · ${cost(entry.cost)}`} ) )} {entry.text && (entry.live ? (

{entry.text.slice(-800)}

) : (
{entry.text}
))}
) }