import { Check, Circle, Loader2, MinusCircle } from 'lucide-react' import { useEffect, useState } from 'react' import { STEPS } from '@/lib/content' import { seconds } from '@/lib/format' import type { RunState, StepView } from '@/lib/run' import type { StepDetail } from '@/lib/types' import { cn } from '@/lib/utils' /** The run as it happens: C's graph node by node (with what each found), or A/B's steps * as one call. The running step shows a live timer from when the last event came. */ export function Progress({ run, since }: { run: RunState; since: number }) { const now = useNow(run.phase === 'running') return (
System {run.system?.toUpperCase()} runs these steps in one call: no progress until the answer.
)}{STEPS[s.name]?.what}
{s.status === 'done' && s.detail &&{detail.candidates} candidate passages
case 'judge': case 'judge_new': return ({(detail.queries ?? []).map((q) => `"${q}"`).join(', ')} → {detail.new_candidates} new passages
) case 'select': return ({detail.kept} passages kept, {detail.expansions} cited sections added {detail.fallback ? ' (the judge kept none: the top search results are used)' : ''}
) case 'verify': return ({detail.checked} citations checked {detail.retried ? `, ${detail.failed_first?.length ?? 0} failed the first time: the answer was retried` : ', all passed'} {detail.dropped ? `, ${detail.dropped} still failing and dropped` : ''}
) default: return null } } /** The current time, ticking every 100 ms while `on`. */ function useNow(on: boolean): number { const [now, setNow] = useState(() => Date.now()) useEffect(() => { if (!on) return const timer = setInterval(() => setNow(Date.now()), 100) return () => clearInterval(timer) }, [on]) return now }