Bruno DelorenceBruno
Appearance
Appearance

Choose your reading theme.

Contact

Agent fleet

New

Every lead agent and its sub-agents in one view: live cost and time, elbow lines to the selected lead’s team, task lists and questions that wait for you.

agent-fleet/agent-fleet.tsx
Live · interactive

Fleet

4 agents / 14 sub-agents7 running1 needs you$4.08

The live component, numbered part by part. Every measurement is read from it as it is drawn. Point at a row to outline its part, or at a part to find its row.

The choices it offers, each value drawn live and the default marked, with how to pick one.

When to use

  • Several lead agents at work at once, each handing parts of its job to sub-agents, where the reader needs the whole tree in one view.
  • A fleet whose cost and running time matter while it works: every card counts both up live.
  • Sub-agents that stop to ask, where an Answer button on the card beats a separate inbox.
  • A panel or a page about 560 px wide or more; under 540 px the sub-agents stack under their lead.

When not to use

  • One agent with no sub-agents. Use a step list or a progress line in the chat.
  • Work over time, where when things happened matters more than who did them. Use a timeline or lanes.
  • Dozens of agents. The column gets long and the lines tangle: use a table with status and cost columns, and filters.
  • Approvals alone, with nothing else to watch. Use an approval card or an inbox.

Reading the fleet

  • Left is who leads, right is who they handed work to; a sub-agent’s own sub-agents hang under it.
  • The footer is the summary: a lead’s says what needs you first, then what failed, then how many of its sub-agents run.
  • Cost counts up while an agent runs; the header adds every card. A waiting agent keeps its time running but spends nothing.

Answers

A sub-agent that needs the reader shows Needs you and an Answer button. Its question opens over its task list: Approve takes what it proposes, Reject the other choice, and either way it runs again; onAnswer hears which. Ask for a choice the agent can’t make alone, and say in the question what Approve picks.

Each one drawn with the component itself, used well or badly.

Every card has three lines: who it is, what it does, where it stands.

  • Names are roles: Researcher, Release manager. The model goes on the line under it.
  • Tasks start with a verb and say what with: Reply to 19 questions about invoices.
  • Steps in the task list are shorter still: Tag them by product. A question is a step that starts with Ask:.
  • The question is one or two sentences: the choice, then what Approve does.

You can add this component with the shadcn CLI or by hand:

Into components/agent-fleet of any React project, with no setup:

Terminal
npx shadcn@latest add https://brunodelorence.com/r/agent-fleet.json

Either way it needs React 19 and a bundler that supports CSS Modules, such as Next.js or Vite. It has a dark colour scheme: it follows your page’s color-scheme, light unless the page sets one, or its colorScheme prop, with nothing to configure. Browsers without light-dark() show it light.

Usage

docs-fleet.tsx
'use client';import { AgentFleet, type Lead } from './agent-fleet';const leads: Lead[] = [  {    id: 'docs',    name: 'Docs lead',    model: 'Large · v5.5',    mark: 'petal',    status: 'running',    task: 'Update the guides for version 3',    tools: ['doc', 'chat'],    cost: 0.12,    rate: 0.001,    seconds: 380,    subs: [      {        id: 'editor',        name: 'Editor',        model: 'Medium · v5.5',        mark: 'petal',        status: 'needs',        task: 'Rewrite the install guide',        tools: ['doc'],        cost: 0.05,        seconds: 210,        ask: 'Drop the guide for version 1? Approve to remove it.',        steps: [          { label: 'Rewrite the steps', tool: 'doc', status: 'done', seconds: 160 },          { label: 'Ask: drop the old guide?', tool: 'chat', status: 'needs' },        ],      },    ],  },];export function DocsFleet() {  return (    <AgentFleet      leads={leads}      onAnswer={(sub, decision) => console.log(sub.id, decision)}      autoplay={false}    />  );}

Each state below is a live instance, locked so you can study it.

The pieces it is built from, each with its measurements read live.

A fleet of agents at work. Lead agents sit in a column, each with its model, status, task, the tools it uses and a footer that says what needs you, what failed or how many of its sub-agents run. Select a lead and elbow lines draw out to its sub-agents, while the other leads dim; a sub-agent’s own sub-agents hang under it. Hover or focus a sub-agent for its task list with each task’s time. One that needs you has an Answer button that opens its question with Reject and Approve. Cost and time count up live on every running card and in the header.

  • The fleet is live: a one-second interval, running only while it is on screen, adds a second and the agent’s rate in dollars to every running card; a card that needs you keeps counting time but not money. The header and each lead add up their sub-agents’ costs on render.
  • A price that changes fades its changed characters in from 30 % opacity over 0.7 s: the ticker compares the new string with the last one and gives only the changed characters a fresh key, so they remount and replay the animation.
  • The sub-agents’ column centres on its lead and is clamped inside the leads’ column: top = clamp(0, lead middle − column height / 2, leads height − column height). The lines are drawn from offsets (offsetLeft/offsetTop up to the board), never from boxes, so the cards’ 4 px entrance lift does not bend them.
  • Each line is one SVG path: out of the lead’s right edge at its task line, 25 px to a trunk halfway across the 50 px gap, a 6 px quadratic elbow, down to the sub-agent’s name line, another elbow and in. A sub-agent’s own sub-agents drop from its tile’s centre. Each path has pathLength 1 and draws in by its dash offset over 0.42 s.
  • On each selection the sub-agent cards remount: they fade and rise 4 px in 0.24 s, 55 ms apart, with cubic-bezier(0.2, 0.7, 0.3, 1). The leads that are not selected fade their faces to 50 %.
  • Under 540 px of width (a container query) the column goes absolute under its lead, 32 px in, and the lead after it gets a top margin as tall as the column, so the rest move down to make room.
  • The demo switches to the support lead, opens the triage task list, goes back, answers the writer’s question with Approve, then visits the other two leads. Any input of the reader’s stops it for good.
PropTypeDefaultDescription
leadsreadonly Lead[]FLEETThe lead agents: an id, name, model, mark (petal, rings, diamond), status, task, tools, its own cost and rate in dollars, its seconds of work, and its sub-agents. A sub-agent has the same fields plus its steps, an ask when it needs you, and sub-agents of its own.
titlestring'Fleet'The header’s title.
defaultSelectedstring—The lead selected on mount, by id; the first one without it.
livebooleantrueRunning agents count up their time and cost each second while on screen.
onAnswer(sub: SubAgent, decision: 'approve' | 'reject') => void—Called when the reader approves or rejects what a sub-agent asks.
defaultTasksstring—Opens with this sub-agent’s task list showing (its id); turns the demo off.
defaultAnswerstring—Opens with this sub-agent’s question showing (its id); turns the demo off.
autoplaybooleantrueWhile on screen and untouched, a demo pointer shows the fleet at work. Never under reduced motion; the first real input stops it.
colorScheme'light' | 'dark' | 'system'—Light or dark colours, or the reader’s; without it, the page’s color-scheme.
classNamestring—Classes for the stage.

Leads and sub-agents

  • Leads are vertical tabs in a tablist: one Tab stop, arrows move and select, Home and End go to the ends. The sub-agents are its tabpanel.
  • Each sub-agent is a button named by its name, model, status, task, cost, time and task count. Focus from the keyboard, hover or a tap shows its task list; Escape hides it.
  • Status is a word on every pill, never colour alone (WCAG 1.4.1).

Answers

  • Answer is a button named Answer Writer, with aria-haspopup="dialog" and aria-expanded.
  • The question opens as a non-modal dialog, named by its title and described by its text; opened by the reader, it moves focus to Approve. Escape closes it and gives focus back to Answer.
  • After a decision, focus goes back to the card and the outcome is read out in a polite live region (WCAG 4.1.3).

Motion

With reduced motion set, the running rings stop turning, the cards and lines appear without fading or drawing in, and a changed price does not fade. Time and cost still count up, as text. The demo pointer never plays under reduced motion, and the reader’s first input stops it for good (WCAG 2.2.2).

In this build

  • Leads are vertical tabs: one Tab stop, Up and Down (or Left and Right) move and select, Home and End jump to the ends. The sub-agents are the tab panel, labelled by the selected lead.
  • Each sub-agent is a button whose name reads its name, model, status, task, cost, time and task count. Keyboard focus, hover or a tap shows its task list; Escape hides it.
  • Answer has aria-haspopup="dialog" and aria-expanded. The question is a non-modal dialog named by its title and described by its text; opened by the reader, it takes focus on Approve, and Escape gives focus back to Answer.
  • Decisions are read out in a polite live region, and focus goes back to the sub-agent’s card.
  • Status is always a word on its pill, never colour alone. Focus shows a 2 px ring.
  • Under reduced motion, rings stop turning, cards and lines appear without motion and prices do not fade; the demo never plays.

The complete source behind this demo. Open source under the MIT license, © 2026 Bruno Delorence: copy it, change it, ship it.

agent-fleet.tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.'use client';import {  Fragment,  useCallback,  useEffect,  useEffectEvent,  useId,  useLayoutEffect,  useRef,  useState,  type KeyboardEvent as ReactKeyboardEvent,  type PointerEvent as ReactPointerEvent,} from 'react';import { FLEET, type AgentStatus, type Lead, type Step, type SubAgent } from './data';import { DemoPointer, runDemo, type Point } from './demo-pointer';import { AgentGlyph, Progress, Sparkle, StatusIcon, ToolGlyph } from './glyphs';import { useAutoplay } from './use-autoplay';import styles from './agent-fleet.module.css';/* * Agent fleet: every lead agent and the sub-agents it handed work to, in one view. Leads sit in
agent-fleet.module.css
/* Agent fleet (agent-fleet.tsx): a quiet grey stage with the fleet in its middle, or at night a   near-black one. The fleet is laid out for 560 px: a 262 px column of leads, 50 px for the   lines, then 218 px sub-agent cards (a sub-agent's own ones 29 px further in). At 540 px and   under, the sub-agents stack under their lead, 32 px in.   The script sets --offset (where the sub-agents start, in px from the board's top) and, when   stacked, --push (the room they take under their lead) on .board; the lines are an SVG drawn   from measured offsets.   Colours are the tokens below, light-dark(light, dark) where the two differ: the component takes   the color-scheme it inherits from the page (light unless the page says otherwise), or the one   its colorScheme prop sets (data-color-scheme). */.root {  /* The stage, the cards, their edge. */  --stage: #f7f7f7;  --card: #fff;  --card-dim: rgb(255 255 255 / 0.55);  --edge: #e8e8ea;  --edge-dim: #efeff0;  --card-shadow: rgb(0 0 0 / 0.04);  --card-hover: #fcfcfc;  /* Text: names, the task line, quiet counts. */  --ink: #111113;
data.ts
// Copyright (c) 2026 Bruno Delorence. MIT License./* * The shapes the fleet draws, and the fleet the lab shows: four lead agents, each with the * sub-agents it handed work to (one of them with a sub-agent of its own). Times are in seconds * of work so far and costs in dollars; while an agent runs, both grow, by one second and by its * rate, each second. *//** The tools an agent uses: a small glyph each, drawn in glyphs.tsx. */export type Tool =  'chat' | 'doc' | 'code' | 'design' | 'ticket' | 'search' | 'test' | 'ship' | 'mail';/** An agent's mark on its tile: one per model family. */export type AgentMark = 'petal' | 'rings' | 'diamond';/** Where an agent stands, on its status pill. */export type AgentStatus = 'running' | 'needs' | 'done' | 'queued' | 'failed';/** One task of a sub-agent, in its task list. */export type Step = {  label: string;  tool: Tool;  status: 'done' | 'running' | 'needs' | 'failed' | 'queued';
glyphs.tsx
// Copyright (c) 2026 Bruno Delorence. MIT License./* * The small drawings, on a 16-unit grid and sized by the stylesheet: a glyph for each tool, a * mark for each model family's tile, the header's sparkle and the status icons. Ink strokes * take --glyph-ink, so they turn light at night; the coloured ones keep their colour on both * schemes, which is what tells two tools apart at 11 px. */import type { AgentMark, AgentStatus, Tool } from './data';const INK = { stroke: 'var(--glyph-ink)' };const ROUND = { strokeLinecap: 'round', strokeLinejoin: 'round' } as const;function ToolPath({ tool }: { tool: Tool }) {  switch (tool) {    case 'chat':      return (        <path          d="M2.6 4.4c0-1 .8-1.8 1.8-1.8h7.2c1 0 1.8.8 1.8 1.8v4.8c0 1-.8 1.8-1.8 1.8H7.2l-3 2.4v-2.4h0c-.9-.1-1.6-.9-1.6-1.8z"          fill="#8a6cf2"        />      );    case 'doc':
demo-pointer.tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.'use client';import type { CSSProperties, Ref } from 'react';/* * The demo's pointer, and the steps that move it. A demo is a script of awaited steps: wait, or * glide the pointer somewhere. Stopping the demo (the reader takes over, or it scrolls away) ends * the step in progress at once: its promise rejects, which ends the script right there, and the * pointer fades out. * * Each glide is a curved flight played by the Web Animations API, so nothing runs frame by frame. * The points of the flight are handed to whoever wants to move along with it. The arrow and the * hand are HTML boxes * that swap by their visibility: a change of style inside an SVG would lay the SVG out again. */export type Point = { x: number; y: number };/** A glide's path and timing, for an animation that plays along with it. */export type Flight = { points: Point[]; timing: KeyframeAnimationOptions };export type Demo = {
use-autoplay.ts
// Copyright (c) 2026 Bruno Delorence. MIT License.'use client';import { useCallback, useEffect, useRef, useState } from 'react';/* * When a demo may play on its own: while part of it is on screen and the tab is visible, never * under reduced motion, and never again once the reader has used it. `take()` hands it to the * reader for good, until the component mounts again (WCAG 2.2.2). */export function useAutoplay<T extends HTMLElement>() {  const ref = useRef<T>(null);  const [visible, setVisible] = useState(false);  const [reduced, setReduced] = useState(true);  const [taken, setTaken] = useState(false);  useEffect(() => {    const element = ref.current;    if (!element) return;    let onScreen = false;    const update = () => setVisible(onScreen && !document.hidden);    const observer = new IntersectionObserver(      ([entry]) => {