Agent plan

Slant / People & chat

The steps an agent intends to take, and how far it has got.

Demo

Usage

@tuttn/slant
import { AgentPlan, Button } from '@tuttn/slant'

const steps = [
  { name: 'Read the failing test', detail: 'src/checkout.test.ts' },
  { name: 'Patch the rounding bug' },
  { name: 'Run the suite', detail: 'npm test' },
]

// Proposed: current -1 leaves every step upcoming; actions asks for the go-ahead.
<AgentPlan title="Fix the checkout total" description="About five minutes."
  steps={steps} current={-1}
  actions={<>
    <Button variant="primary" size="sm" onClick={approve}>Approve</Button>
    <Button variant="ghost" size="sm" onClick={edit}>Edit</Button>
  </>} />

// Running: steps before current are done, and current is aria-current="step".
<AgentPlan title="Fix the checkout total" steps={steps} current={1} />

// Done: current at steps.length. heading puts the title in the page's outline.
<AgentPlan title="Fix the checkout total" steps={steps} current={steps.length} heading="h2" />

Props

PropTypeDefaultDescription
titleReactNode—The plan's heading. It also names the section and its list of steps.
descriptionReactNode—A line under the heading: what the plan is for, or how long it should take.
stepsStepperStep[]—The steps the agent intends to take, in order: `{ name, detail? }`.
currentnumber—Index of the step under way: earlier steps are done. -1 before the plan starts, `steps.length` once every step is done. Rendered as `data-state`: `proposed` below 0, `done` from `steps.length`, `running` between.
actionsReactNode—Buttons under the steps, such as Approve and Edit, in a wrapping row.
heading'h2' | 'h3' | 'h4''h3'The heading's element, so the plan sits in the page's outline.
StepperStep{ name: ReactNode; detail?: ReactNode }—One entry of steps: its name, and an optional line under it, as in Stepper.
…restHTMLAttributes<HTMLElement>—className, style, the ref and other attributes go on the <section>. An aria-labelledby or aria-label of yours replaces the heading as its name.

Keyboard

Tabmoves through the buttons in actions; the plan itself takes no focus

Accessibility

  • The plan is a <section> named by its heading through aria-labelledby, so it is a region screen readers can jump to. The Stepper inside is a list named by the same heading.
  • Each step reads its state after its name (“Run the suite, current”) in the root’s messages.stepComplete, stepCurrent and stepUpcoming, and the current one carries aria-current="step".
  • The progress line is messages.planProgress(done, total) (“1 of 4 done”), with done counted from current and kept between 0 and the number of steps.
  • The plan is not a live region and announces nothing as it advances. Speak progress yourself, or show each step as an AgentTask, which announces when it finishes.

The root carries data-state: proposed while current is below 0, done once it reaches steps.length, and running between. The progress line sits at the end of the title’s row and drops under it when the row runs out of room.

Under dir="rtl" the layout mirrors: the title starts on the right, and the step marks and their connector move to the right edge.