affectUI › Components › Agents

Critical Path

An agent run's spans on a timeline, one lane per agent, with thin arrows from every span to the ones waiting for it. The chain that decides when the run ends is the critical path – its spans in full tint, its arrows solid, the rest fades back, and a quiet line says how much of the run it is. Drag the end of any span to try a what-if: everything that waits for it slides along, the end of the run moves, and the path hops to another chain when that one now ends last; a pill says how much earlier or later the run ends. Drag a span onto another lane to run it on that agent. Click a span for its card – the duration before and after, its slack, and what it waits for and unblocks; Reset brings the run back.

Part of affectUI Pro. Install: npx shadcn@latest add https://www.affectui.com/r/critical-path.json · Import from @/components/ui/critical-path

When to use

  • Showing what decided when an agent run ended – the chain of spans the run waited on, across agents
  • Asking what-if: would the run end sooner if this step were faster, or if it ran on another agent?
  • Finding where to optimize – spans with slack can get slower for free, spans on the critical path can't

When not to use

  • Every span nested under its parent with tokens and cost – use Trace Waterfall or Agent Flame Graph
  • Who hands work to whom while a run is live – use Handoff Swimlanes
  • How the run went against the plan – use Plan vs Actual

Usage

import { CriticalPath, type CriticalLane, type CriticalSpan } from "@/components/ui/critical-path";

const lanes: CriticalLane[] = [
  { id: "planner", name: "Planner", model: "Opus 5.5", logo: <ClaudeLogo /> },
  { id: "coder", name: "Coder", model: "Sonnet 5", logo: <ClaudeLogo /> },
  { id: "tests", name: "Test Runner", model: "GPT-5 mini", logo: <OpenAILogo /> },
];

const spans: CriticalSpan[] = [
  { id: "plan", name: "plan", lane: "planner", kind: "llm", start: 0, duration: 9200 },
  { id: "fix", name: "write fix", lane: "coder", kind: "llm", start: 12000, duration: 34500, deps: ["plan"] },
  { id: "tests", name: "run tests", lane: "tests", kind: "tool", logo: <TerminalIcon />, start: 47000, duration: 24800, deps: ["fix"] },
];

export function Run() {
  return <CriticalPath title="Ship v2.4" lanes={lanes} spans={spans} />;
}

Props

NameTypeDefaultDescription
lanesCriticalLane[]One per agent, top to bottom – { id, name, model?, logo?, color?, person? }
spansCriticalSpan[]{ id, name, lane, kind, duration, start?, deps?, logo?, detail?, failed? } – durations and starts in ms from the start of the run
kind"llm" | "tool" | "agent"The bar's tint – indigo, teal or gray; failed: true tints it red
depsstring[]The spans it waits for – it starts when the last of them ends. A lane runs its spans one after another on top of that
startnumberWhen it really started – a wait after it could have started is kept in every what-if; leave it out to start as soon as possible
titlestringThe run's name in the head – "Agent run" by default
stepnumberHow much ⇧← / ⇧→ change a span, in ms – 500 by default
hintReactNode | falseA quiet line under the timeline until the first edit – false hides it
onChange(whatIf) => voidAfter every edit and on reset – { durations, lanes, end, baseEnd, critical }
formatDuration(ms) => stringFormats every duration – "3.4 s", "1m 42s" by default
classNamestringAn extra class on the root

Accessibility

  • The spans are one tab stop: ← and → move along a lane, ↑ and ↓ to the nearest span on the next lane, Home and End to the first and last on a lane
  • Enter or Space opens and closes the focused span's card; Esc closes it and focus stays on the span
  • ⇧← and ⇧→ shorten and lengthen the focused span in steps – the keyboard's way to drag its end; ⌥↑ and ⌥↓ move it to the lane above or below
  • R on a span resets the what-if; the Reset button does too and hands focus to the timeline when it turns off
  • Every span reads as its name, agent, duration, what it was before and its slack – "translate, Translator, 20 s, was 22 s, 0.4 s slack"
  • What an edit did is announced once it lands – "Run ends 1.6 s earlier. Critical path: plan, search_code, …"
  • A focus ring shows only for the keyboard – clicks and drags never leave one, and a drag never selects

Responsive

  • Fills its container's width – the time scale fits it, so it never scrolls sideways
  • Below 520px the lanes keep only their pixel marks and the hint steps aside
  • On touch screens the end of a bar has a wider handle; a finger on a bar scrolls the page and a tap opens its card
  • Names that don't fit end in … – a bar that is too small shows only its logo, then nothing; the card has them in full
  • Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"

Requirements

  • React 19

Related

  • Trace Waterfall – Where the time and money of an agent run go – every LLM call, tool call and sub-agent as a bar on a live timeline, with tokens and cost per step, the slowest call marked and branches that fold into their parent
  • Agent Flame Graph – A multi-agent run's call stack as a flame graph – the orchestrator on top, its subagents under it, then their LLM and tool calls, every block as wide as it took. Switch to Tokens or Cost and every block glides to its new width; click one and it slides out to the full width, with a breadcrumb back. Search lights up the matching blocks and says how much of the run they took; a failed call's card offers Retry. Agents carry their pixel mark, LLM and tool calls their maker's logo, and a live run keeps growing at its right edge
  • Tool Calls Network – Every LLM and tool call of an agent run as rows, like the Network tab of the browser's developer tools – status, name with the tool's logo, the agent that made it, size and time, and a small waterfall where each call is a bar on the run's timeline, split into queued, waiting for the first token, streaming and tool execution. New calls stream in at the bottom while running bars grow at the "now" edge; drag across the overview strip for a stretch of time, filter by LLM, tools, errors or retries, sort like DevTools, and open a call for its request and response as pretty JSON, its timing phase by phase and every retry
  • Handoff Swimlanes – Who does what in an agent run, and where the work changes hands – a process diagram with a lane for you, every agent and every tool. Each task is a box in the lane of whoever does it, a handoff an arrow to the next one, an approval a diamond; done boxes are quiet, the running one shimmers in its agent's color, waiting is amber, failed is red, and a light runs along every handoff that's happening now. Click a box, a diamond or a lane and its card opens – an approval waiting for you can be approved right there
  • Plan vs Actual – An agent's plan against what really happens – every step's bar grows over its dashed planned ghost, overruns turn amber, the steps after it slide right, and the expected finish moves away from the planned one