# Task plan

An agent's plan on a legal pad. Finished steps are ticked in ink, the current one is underlined in red pen, the rest are still in pencil.

- Category: Agents
- Docs: https://bevel-ui.vercel.app/components/task-plan
- Import from: `@/components/ui/task-plan`

## Install

```bash
npx shadcn@latest add @bevel/task-plan
```

npm dependencies (installed by the CLI): `@base-ui/react`, `cn`.

## Anatomy

```tsx
<TaskPlan>
  <TaskPlanHeader>
    <TaskPlanTitle />
    <TaskPlanProgress value={2} max={5} />
  </TaskPlanHeader>
  <TaskPlanSteps>
    <TaskPlanStep status="done" />
    <TaskPlanStep status="current" />
  </TaskPlanSteps>
</TaskPlan>
```

## Parts

| Part | Renders | Description |
| --- | --- | --- |
| `TaskPlan` | div | The pad. Every row sits on a rule. |
| `TaskPlanProgress` | Progress | value and max. Read as “2 of 5 done”; children replace the visible text. |
| `TaskPlanSteps` | ol | The steps, in order. |
| `TaskPlanStep` | li | status: done, current, pending, error or skipped, spoken before the step. The current step is marked aria-current. The tick draws itself when a step finishes. |

## Example: An agent at work

The plan advances on its own. Each step is ticked in ink as it finishes.

```tsx
"use client"

import * as React from "react"
import {
  TaskPlan,
  TaskPlanHeader,
  TaskPlanProgress,
  TaskPlanStep,
  TaskPlanSteps,
  TaskPlanTitle,
  type TaskPlanStatus,
} from "@/components/ui/task-plan"

const steps = [
  "Read the lease and schedules",
  "List every notice clause",
  "Check notice periods against the playbook",
  "Draft a redline",
  "Summarise for Priya",
]

/** An agent working down its plan. Each step is ticked in ink as it finishes. */
export function TaskPlanAgent() {
  const [done, setDone] = React.useState(1)

  React.useEffect(() => {
    if (done >= steps.length) return
    const timer = setTimeout(() => setDone((d) => d + 1), 1600)
    return () => clearTimeout(timer)
  }, [done])

  const statusOf = (i: number): TaskPlanStatus => (i < done ? "done" : i === done ? "current" : "pending")

  return (
    <div className="flex flex-col items-center gap-4">
      <TaskPlan>
        <TaskPlanHeader>
          <TaskPlanTitle>Review the Harbor Street lease</TaskPlanTitle>
          <TaskPlanProgress value={done} max={steps.length} />
        </TaskPlanHeader>
        <TaskPlanSteps>
          {steps.map((step, i) => (
            <TaskPlanStep key={step} status={statusOf(i)}>
              {step}
            </TaskPlanStep>
          ))}
        </TaskPlanSteps>
      </TaskPlan>
      <button
        type="button"
        disabled={done < steps.length}
        onClick={() => setDone(0)}
        className="h-9 rounded-md border px-3 text-sm font-medium hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none disabled:opacity-50"
      >
        Run again
      </button>
    </div>
  )
}
```
