import type { NodeName, RunEndEvent } from '../lib/events' import { NODE_LABELS, NODE_ORDER } from '../lib/events' const NODE_BAR: Record = { gatekeeper: 'bg-sky-400', planner: 'bg-violet-400', tool_executor: 'bg-amber-400', auditor: 'bg-rose-400', synthesizer: 'bg-emerald-400', } /** * Per-node wall time for the run. The point is to make the expensive node * obvious at a glance — "the Auditor is 40% of latency" is only actionable if * you can see it without reading logs. */ export function LatencyBreakdown({ summary }: { summary: RunEndEvent }) { const total = summary.duration_ms || 1 const nodes = NODE_ORDER.filter((node) => (summary.node_timings_ms[node] ?? 0) > 0) return (

Latency breakdown

{(summary.duration_ms / 1000).toFixed(1)}s
{nodes.map((node) => (
))}
    {nodes .slice() .sort((a, b) => (summary.node_timings_ms[b] ?? 0) - (summary.node_timings_ms[a] ?? 0)) .map((node) => { const ms = summary.node_timings_ms[node] ?? 0 return (
  • {NODE_LABELS[node]} {(ms / 1000).toFixed(1)}s {Math.round((ms / total) * 100)}%
  • ) })}
{[ ['LLM calls', summary.llm_calls], ['Out tokens', summary.output_tokens], ['Replans', summary.replans], ].map(([label, value]) => (
{label}
{value}
))}
) }