import { useQuery } from '@tanstack/react-query'; import { Link, useSearchParams } from 'react-router-dom'; import { ReportHero, ReportPanel, SignalMetric, reportActionPrimary } from '../components/report/ReportPrimitives'; import { TraceExplorer } from '../components/trace/TraceExplorer'; import { StatusBadge } from '../components/ui/Card'; import { api, type HarnessRunRecord } from '../lib/api'; const integer = (value: number): string => new Intl.NumberFormat('en-US').format(value); export function Runs() { const { data, isLoading, isError } = useQuery({ queryKey: ['runs'], queryFn: () => api.runs(100) }); const [searchParams, setSearchParams] = useSearchParams(); const selectedTrace = searchParams.get('trace') ?? ''; const runs = data?.runs ?? []; const failures = runs.filter((run) => run.status === 'failed').length; const attributedCost = runs.filter((run) => run.cost_estimate != null).length; const latencyValues = runs.map((run) => Number(run.latency_ms)).filter((value) => Number.isFinite(value) && value > 0); const averageLatency = latencyValues.length > 0 ? Math.round(latencyValues.reduce((sum, value) => sum + value, 0) / latencyValues.length) : null; return (
0 ? 'attention' : data ? 'operational' : undefined} meta={data ? ( <> {data.count} records in current registry {failures} failures {attributedCost}/{runs.length} cost-attributed ) : Loading governed run registry…} actions={Open H6 dossier} /> {selectedTrace && setSearchParams({})} />} {isLoading && (
{Array.from({ length: 4 }, (_, index) =>
)}
)} {isError &&
The governed run registry could not be loaded.
} {data && ( <>
0 ? 'danger' : 'success'} /> 0 ? 'success' : 'warning'} />
{data.count} total records} >
{runs.map((run: HarnessRunRecord, index: number) => ( ))} {runs.length === 0 && ( )}
Observed at Lifecycle step Verdict Latency Tokens Cost Evidence
{run.timestamp?.replace('T', ' ').replace('Z', ' UTC') ?? 'Unavailable'} {run.step ?? run.harness} {run.latency_ms == null ? 'Unavailable' : `${integer(Number(run.latency_ms))} ms`} {run.total_tokens ?? 'Unavailable'} {run.cost_estimate == null ? Unavailable : `$${Number(run.cost_estimate).toFixed(5)}`} {run.trace_id ? ( ) : —}
No governed run has been recorded yet.
)}
); }