Spaces:
Sleeping
Sleeping
Download web/src/components/chat/Trace.tsx from TBM99/CoverageCheck: direct link, hf CLI and curl.
- Browser
- Download file 2.39 kB
-
https://huggingface.co/spaces/TBM99/CoverageCheck/resolve/main/web/src/components/chat/Trace.tsx
- Command line
-
hf download hf://spaces/TBM99/CoverageCheck/web/src/components/chat/Trace.tsx
-
curl -L -o Trace.tsx https://huggingface.co/spaces/TBM99/CoverageCheck/resolve/main/web/src/components/chat/Trace.tsx
2.39 kB
| import { ChevronRight, Loader2 } from 'lucide-react' | |
| import { useState } from 'react' | |
| import { EvidenceList } from './EvidenceList' | |
| import { Progress } from './Progress' | |
| import { STEPS } from '@/lib/content' | |
| import { seconds } from '@/lib/format' | |
| import { running, type RunState } from '@/lib/run' | |
| /** How the answer was made, like Claude's "thinking": open while the system works (each | |
| * step ticks off with what it found), then folded to one line ("Worked 19 s · 6 steps") | |
| * that opens again on click. The passages the model read are inside it. */ | |
| export function Trace({ run, lastEventAt }: { run: RunState; lastEventAt: number }) { | |
| const [opened, setOpened] = useState<boolean | null>(null) // null: follow the run | |
| const working = run.phase === 'running' | |
| const open = opened ?? working | |
| const done = run.steps.filter((s) => s.status === 'done').length | |
| const step = running(run) | |
| const total = run.answer?.latency_ms | |
| let summary: string | |
| if (working) summary = step && run.live ? `${STEPS[step.name]?.title ?? step.name}…` : 'Searching and answering…' | |
| else if (run.live) summary = `Worked ${seconds(total)} · ${done} step${done === 1 ? '' : 's'}` | |
| else summary = `Worked ${seconds(total)} · one search and one model call` | |
| if (run.phase === 'error') summary = 'Stopped before an answer' | |
| return ( | |
| <div className="text-sm"> | |
| <button | |
| type="button" | |
| onClick={() => setOpened(!open)} | |
| aria-expanded={open} | |
| className="inline-flex items-center gap-1.5 rounded-md py-1 text-muted-foreground hover:text-foreground" | |
| > | |
| {working ? <Loader2 className="size-3.5 animate-spin text-primary" /> : <ChevronRight className={`size-3.5 transition-transform ${open ? 'rotate-90' : ''}`} />} | |
| <span>{summary}</span> | |
| </button> | |
| {open && ( | |
| <div className="mt-1 ml-1.5 space-y-3 border-l pl-4"> | |
| <Progress run={run} since={lastEventAt} /> | |
| {run.evidence && ( | |
| <details className="group"> | |
| <summary className="cursor-pointer text-xs font-medium text-muted-foreground hover:text-foreground"> | |
| Read {run.evidence.length} passages | |
| </summary> | |
| <div className="mt-1"> | |
| <EvidenceList passages={run.evidence} /> | |
| </div> | |
| </details> | |
| )} | |
| </div> | |
| )} | |
| </div> | |
| ) | |
| } | |