Plan
Present a draftable, reorderable agent plan that locks on approval into a live executing checklist with progress, activity substeps, failure recovery, and a completion summary.
import { AgentPlan } from '@uthereal/ui/agent-plan'Agent plan playground
Plan5 steps
Claude Sonnet 5.5Add rate limiting to the public API
Overview
AgentPlan displays the multi-step plan an AI agent proposes before it edits code, runs commands, or modifies production state. While in the draft phase, the user can rename steps inline, reorder them by dragging or with the keyboard, remove steps, add new steps, or request another suggestion with Keep planning. Selecting Approve plan locks the list into a live checklist with a header progress bar, shimmering active step, activity substeps, pause and resume controls, failure recovery, and a final completion summary.
Use AgentPlan when the user reviews and edits an ordered plan up front, then tracks execution on the same surface. For a multi-agent execution timeline with handoffs and token metrics, use Agent timeline. For individual tool call inputs, outputs, and single-action approvals, use Tool call. For a formatted, cited final response, use Answer.
Usage
'use client'
import { AgentPlan, type AgentPlanStep } from '@uthereal/ui/agent-plan'
export function ReleasePlan({
steps,
status,
summary,
onUpdateDraft,
onSuggestStep,
onStartRun,
onPauseChange,
onStepAction,
}: {
steps: AgentPlanStep[]
status: 'draft' | 'running' | 'paused' | 'done'
summary?: string
onUpdateDraft: (steps: AgentPlanStep[]) => void
onSuggestStep: () => void
onStartRun: (steps: AgentPlanStep[]) => void
onPauseChange: (paused: boolean) => void
onStepAction: (action: {
type: 'retry' | 'skip'
step: AgentPlanStep
}) => void
}) {
return (
<AgentPlan
goal="Add rate limiting to the public API"
modelName="Claude Sonnet 5.5"
modelBrand="anthropic"
status={status}
steps={steps}
summary={summary}
onChange={onUpdateDraft}
onKeepPlanning={onSuggestStep}
onApprove={onStartRun}
onPauseChange={onPauseChange}
onStepAction={onStepAction}
/>
)
}Pass status to drive the plan deterministically from your agent host; the component never mutates status on its own and reports every user interaction through React callbacks or named onAction events. Omit status to render the interactive draft with a built-in simulated run after approval.
Examples
Live execution and agent-inserted steps
Drive status="running" or status="paused" from the host to track active progress. Completed steps settle to secondary text with their duration on the trailing edge and expand on click to inspect past substeps. Steps added mid-run display an attribution note with the model mark.
Plan3 steps
2 of 3Add rate limiting to the public API
- Done:21s
- In progress:Fall back to in-memory counters when Redis is down
Added by agent
- Read lib/redis.ts
- Edited middleware/rate-limit.ts
- Pending:Return 429 with Retry-After and RateLimit headers
Failure recovery and completion summary
Set a step's state to "failed" with an error message to pause execution and show inline Retry and Skip controls. When all steps settle and status="done", the footer sums completed durations and displays the summary.
Plan3 steps
2 of 3Add rate limiting to the public API
- Done:42s
- Failed:Write tests for limits, bursts and window resets
- Created rate-limit.test.ts
- Ran 12 tests
Failed 2 of 12 tests failed: the window resets one second late
- Pending:Document the limits in the API reference
Plan3 steps
3 of 3Add rate limiting to the public API
- Done:21s
- Done:48s
- Skipped:Run optional k6 load test against staging
Done in 1m 09s.
Step lifecycle and substeps
Each step uses a distinct geometric glyph so status never relies on color alone.
| State | Glyph | Behavior |
|---|---|---|
pending | Open ring | Queued work waiting to start. |
active | Spinning arc | Title shimmers and activity substeps stay open. Shows pause bars when status="paused". |
done | Filled check disc | Draws its check stroke, settles to secondary text, shows durationSec, and toggles substeps on click when present. |
failed | Exclamation disc | Shows error detail with Retry and Skip buttons and keeps substeps visible. |
skipped | Dashed ring | Muted title with Skipped label in the trailing column. |
Substep lines automatically choose an icon from their leading past-tense verb:
| Leading verb | Icon |
|---|---|
Read | file-text |
Edited, Updated | pencil |
Created, Wrote, Added | file |
Searched, Found | search |
Ran | terminal |
Measured | signal-high |
| Other verbs | circle-dot |
API reference
These serializable arguments and defaults come directly from the component schema.
| Argument | Type / default | Description |
|---|---|---|
goal | stringDefault: "Add rate limiting to the public API" | Short statement of what the plan accomplishes, shown beneath the header and used in the accessible section name. |
modelName | stringDefault: "Claude Sonnet 5.5" | Model name displayed in the header during the draft phase and included in the section label. |
modelBrand | anthropic | openai | google | mistral | xai | customDefault: "anthropic" | Provider brand mark rendered in the header and beside agent-inserted step notes. |
status | draft | running | paused | done— | Controlled plan phase (draft, running, paused, done). Pass to drive execution from your agent; omit to run interactive draft editing and a built-in simulation. |
defaultStatus | draft | running | paused | doneDefault: "draft" | Initial phase when status is omitted; edits do not reset a mounted instance. |
steps | AgentPlanStep[]Default: [{"id":"map","title":"Map the public routes under api/v1","state":"pending","substeps":[]},{"id":"limiter","title":"Add a sliding window limiter to the API middleware","state":"pending","substeps":[]},{"id":"store","title":"Keep request counters in Redis with a 60 second TTL","state":"pending","substeps":[]},{"id":"headers","title":"Return 429 with Retry-After and RateLimit headers","state":"pending","substeps":[]},{"id":"tests","title":"Write tests for limits, bursts and window resets","state":"pending","substeps":[]},{"id":"docs","title":"Document the limits in the API reference","state":"pending","substeps":[]}] | Ordered plan steps with unique IDs, states, optional activity substeps, notes, error reasons, and durations in seconds; arrays replace on edit. |
summary | string— | One-line completion summary shown after the summed duration when status is done. |
editable | booleanDefault: true | Allow inline renaming, dragging or keyboard reordering, removing, adding steps, and Keep planning while in draft phase. |
approveAction | string— | Registered host action requested when Approve plan is pressed. |
keepPlanningAction | string— | Registered host action requested when Keep planning is pressed. |
pauseAction | string— | Registered host action requested when Pause is pressed. |
resumeAction | string— | Registered host action requested when Resume is pressed. |
retryAction | string— | Registered host action requested with the step ID when Retry is pressed on a failed step. |
skipAction | string— | Registered host action requested with the step ID when Skip is pressed on a failed step. |
locale | string— | BCP 47 locale for duration and numeric formatting; inherited when omitted. |
recipe | studio | softDefault: "studio" | Visual treatment. Both recipes preserve interaction behavior. |
theme | AgentPlanThemeDefault: {} | Color mode, accent, and typed semantic token overrides. |
motion | none | subtle | expressiveDefault: "subtle" | Animation preset. System reduced-motion preferences take precedence. |
motionOptions | AgentPlanMotionOptionsDefault: {} | Row glide spring and streamed text chunk timing overrides in milliseconds. |
dir | ltr | rtl— | Reading direction; inherited from the page when omitted. |
AgentPlanStep accepts { id, title, state?, substeps?, note?, error?, durationSec? }.
React integration
| Prop | Purpose |
|---|---|
onChange(steps) | Called after each draft edit: rename, reorder, remove, add, or completed suggestion stream. |
onApprove(steps) | Called by Approve plan with trimmed, non-empty steps in their final order. |
onKeepPlanning() | Called when Keep planning is pressed. |
onPauseChange(paused) | Called by Pause (true) and Resume (false). |
onStepAction({ type, step }) | Called when Retry or Skip is pressed on a failed step. |
onAction(action, stepId?) | Called for registered host actions (approveAction, keepPlanningAction, pauseAction, resumeAction, retryAction, skipAction). |
renderModelMark() | Custom 16px decorative model mark replacing the built-in modelBrand mark. |
preset | Application defaults overridden by explicit instance arguments. |
tokens | CSS variables applied after the typed theme. |
ref, className, style | Applied to the root <section> element. |
| Native attributes | id, aria-*, data-*, and remaining <section> props forwarded to the root. |
Keyboard & accessibility
| Key | Action |
|---|---|
Tab | Moves across step grips, editable titles, remove buttons, Add step, and footer controls. |
Alt + ArrowUp / ArrowDown | Reorders the focused step up or down inside its title field while preserving the caret. |
ArrowUp / ArrowDown | Reorders the step up or down when focused on its drag grip button. |
Enter | Commits a draft title edit without leaving the field. |
Escape | Reverts the draft title to its value before focus. |
Backspace | Removes an empty draft step and moves focus to the preceding step. |
The root renders a <section> labelled by modelName and goal, and steps render inside an ordered <ol> list. Each non-draft step announces its state word (Pending, In progress, Done, Failed, Skipped) before its title. A polite role="status" live region announces draft edits, approval, inserted steps, failures, pause state, and completion. Focus follows every action: moved steps retain focus, removed steps hand focus to a neighbour, and Approve plan, Retry, and Skip hand focus to the execution control. The header rule acts as a role="progressbar" with aria-valuetext once approved. Logical CSS properties keep alignment consistent in RTL (dir="rtl"), and forced-colors: active maps progress fills, status discs, and focus outlines to system colors.
Motion and theming
Step inserts, removals, reorders, substep lists, and footer height changes move on a critically damped 260ms spring with no overshoot. Fixed lead (20px) and trail (48px) grid tracks prevent step titles from reflowing when switching from draft to execution. Completing a step draws its checkmark stroke over 220ms, the active step runs a light shimmer that pauses when offscreen or hidden, agent-inserted rows fade out a faint accent wash over 1.8s, and header counters roll in place with tabular digits. prefers-reduced-motion: reduce drops spatial travel, spinning arcs, check stroke draws, shimmer sweeps, and washes while preserving short opacity crossfades; motion="none" makes every state transition immediate (0ms).
theme accepts a mode, an accent, and semantic tokens for surfaces, borders, text, accent, success, danger, radii, elevation, and control heights. An application-wide UtherealProvider supplies defaults.
Composition
In an agent composition, AgentPlan is a leaf. Supply status and steps from host state so the card renders deterministically without running local timers. approveAction, keepPlanningAction, pauseAction, resumeAction, retryAction, and skipAction must name registered host actions. See Building with agents.
{
"type": "AgentPlan",
"props": {
"goal": "Add rate limiting to the public API",
"modelName": "Claude Sonnet 5.5",
"modelBrand": "anthropic",
"status": "draft",
"approveAction": "approve_plan",
"keepPlanningAction": "suggest_plan_step",
"steps": [
{ "id": "map", "title": "Map the public routes under api/v1" },
{
"id": "limiter",
"title": "Add a sliding window limiter to the API middleware"
},
{
"id": "tests",
"title": "Write tests for limits, bursts and window resets"
}
]
},
"children": []
}