Agent task

Slant / People & chat

One step an agent took: its status, what it did, and its output.

Demo

Usage

@tuttn/slant
import { AgentTask, CodeBlock } from '@tuttn/slant'

// The status draws the mark and is read after the title: "Run the tests, Running".
<AgentTask title="Run the tests" status="running" detail="npm test" />

// steps: what it did along the way, as a Timeline.
<AgentTask title="Patch the rounding bug" status="done" detail="src/cart/total.ts" steps={[
  { id: 'trace', title: 'Followed the total', done: true },
  { id: 'edit', title: 'Rounded once at the end', meta: '+3 −5', done: true },
]} />

// subtasks: the tool calls it made, nested, folded under "Subtasks, 2 of 3 done"
// (counted over the whole tree). They start open while the task runs or fails.
<AgentTask title="Run the tests" status="running" subtasks={[
  { id: 'install', title: 'Bash · npm ci', status: 'done', detail: '1.2s' },
  { id: 'test', title: 'Bash · npm test', status: 'running', subtasks: [
    { id: 'unit', title: 'Unit tests', status: 'done', detail: '41 passed' },
  ] },
]} />

// children: the output, folded under "Output". A failed task's starts open.
<AgentTask title="Run the tests" status="failed" detail="npm test · 3.1s">
  <CodeBlock language="sh" code={log} />
</AgentTask>

// Controlled output and subtasks, with the title in the page's outline.
<AgentTask title="Deploy" status="done" heading="h4" open={open} onOpenChange={setOpen}
  subtasks={calls} subtasksOpen={callsOpen} onSubtasksOpenChange={setCallsOpen}>{log}</AgentTask>

Props

PropTypeDefaultDescription
titleReactNode—What the step does: "Run the tests". A string title is also what the finish announcement says.
statusAgentTaskStatus—Where it stands: pending, running, done or failed. Drawn as a mark, read after the title (`messages.taskStatus`), and rendered as `data-status`. A change to done or failed is announced politely, when the title is a string.
detailReactNode—A detail line: the command, the file, how long it took.
stepsTimelineItem[]—What it did along the way, as a Timeline: `{ id, title, meta?, time?, done? }`.
subtasksreadonly AgentSubtask[]—The tool calls the task made, nested: `{ id, title, status, detail?, subtasks? }`. Shown after the steps and before the output, folded under a toggle that counts them over the whole tree (`messages.taskSubtasks(done, total)`).
subtasksOpenboolean—Whether the subtasks are open. Pass it with onSubtasksOpenChange to control it; leave it out and it keeps its own state.
defaultSubtasksOpenbooleantrue while the task is running or failed, else false (read when the subtasks first appear)Whether the subtasks start open, when uncontrolled.
onSubtasksOpenChange(open: boolean) => void—Called with the requested state when the subtasks' toggle is pressed.
childrenReactNode—The step's output, folded under a toggle named `messages.taskOutput`. Pass plain text, Text or a CodeBlock.
openboolean—Whether the output is open. Pass it with onOpenChange to control it; leave it out and it keeps its own state.
defaultOpenbooleantrue for a failed task, else false (read when the output first appears)Whether the output starts open, when uncontrolled.
onOpenChange(open: boolean) => void—Called with the requested state when the output's toggle is pressed.
heading'h3' | 'h4' | 'div''div'The element wrapping the title, so the step sits in the page's outline.
TimelineItem{ id: string; title: ReactNode; meta?: ReactNode; time?: ReactNode; done?: boolean }—One entry of steps, as in Timeline.
AgentSubtask{ id: string; title: ReactNode; status: AgentTaskStatus; detail?: ReactNode; subtasks?: readonly AgentSubtask[] }—One entry of subtasks: a tool call, with its own subtasks nested one level deeper. id is unique among its siblings.
…restHTMLAttributes<HTMLDivElement>—className, style, the ref and other attributes go on the root <div>, which carries data-status.

Keyboard

Tabfocuses the Subtasks toggle, then the Output toggle
Enter / Spaceopens or folds the subtasks or the output

Accessibility

  • The status mark is hidden from screen readers; the status is read after the title instead, in the root’s messages.taskStatus (“Run the tests, Running”).
  • When status changes to done or failed, the root’s announcer says “Run the tests, Done” politely. Only a string title is spoken; a task that mounts finished says nothing.
  • The output toggle is a Disclosure button named messages.taskOutput (“Output”), with aria-expanded, aria-controls on its panel, and the task’s title as its description, so each task’s toggle can be told apart.
  • The steps are a Timeline, an ordered list named by the title.
  • The subtasks toggle is a Disclosure button named by messages.taskSubtasks(done, total) (“Subtasks, 2 of 6 done”, counted over the whole tree) and described by the title, like the output’s.
  • The subtasks are a list named by the title, with each level nested inside its parent’s list item. Each row reads its title then its status (“Read package.json, Done”); the marks are hidden. A subtask’s change of status is not announced: only the task’s own is.

Uncontrolled, the output starts open for a failed task and folded otherwise, unless defaultOpen says. That is read when the output first appears, so a task whose log arrives as it fails opens on it. Pass open and onOpenChange to decide yourself.

Subtasks

subtasks are the tool calls a task made, or the tasks an agent handed off, each with a status, a muted detail and its own subtasks. They sit after the steps and before the output, folded under a toggle that counts the done ones over the whole tree. Uncontrolled, they start open while the task is running or failed and folded otherwise, unless defaultSubtasksOpen says, read when they first appear; pass subtasksOpen and onSubtasksOpenChange to decide yourself. Each level below the first steps in under a hairline guide down its inline start.

While running, the mark is a small Spinner, which rests on one frame under prefers-reduced-motion. Under dir="rtl" the mark, the timeline, the subtasks’ guides and the toggles mirror.