aiellie

Search

Find a component, template or page

GitHub
Components

Plan Review

The plan an agent proposes, to reorder, rewrite, trim and add to before it runs, or send back with a note. It reports exactly what changed.

Press arrow up or arrow down to move the step.

Proposed plan

Nothing runs until you approve

4 steps
  1. 1
  2. 2
  3. 3
  4. 4
as proposed
Open full screen
fig. 01 · open it full screen from the corner

Installation

npx shadcn@latest add "@aiellie/plan-review"

shadcn needs the @aiellie registry in components.json first. npx aiellie add plan-review adds it on its first run, then installs the same way.

Plan Review shows the plan an agent proposes before it runs anything, and lets you shape it first. Drag a step by its handle, or focus the handle and use the arrow keys. Press a step to rewrite it, remove or restore it, or add one of your own. Then run the plan, or send it back with a note saying what should change.

What comes back is a PlanDecision: the steps to run, in order, plus exactly what you changed. A step counts as moved only if it left the order the others kept, so dragging one step down doesn't mark every step it passed. The newest change flashes on a muted fill and settles. Once you decide, the controls give way to a line saying what was decided.

Getting started

  1. Show the plan

    Keep the state and the decision, so the card can show what was decided.

    components/agent-plan.tsx
    "use client"
    
    import * as React from "react"
    
    import {
      PlanReview,
      type PlanDecision,
      type PlanReviewState,
      type PlanStep,
    } from "@/components/aiellie/plan-review"
    
    export function AgentPlan({
      steps,
      onDecide,
    }: {
      steps: PlanStep[]
      onDecide: (decision: PlanDecision, note?: string) => void
    }) {
      const [state, setState] = React.useState<PlanReviewState>("review")
      const [note, setNote] = React.useState("")
    
      return (
        <PlanReview
          steps={steps}
          state={state}
          note={note}
          onApprove={(decision) => {
            setState("approved")
            onDecide(decision)
          }}
          onRevise={(text, decision) => {
            setNote(text)
            setState("revising")
            onDecide(decision, text)
          }}
        />
      )
    }
  2. Hand the decision back to the agent

    Send decision.steps as the plan to run. decision.edits lists the ids that were moved, rewritten, added or removed, if the agent should hear about them.

Anatomy

<div data-slot="plan-review" data-state="review" role="group">
  <div data-slot="plan-review-header" />
  <ol>
    <li data-slot="plan-review-step" data-removed data-dragging data-flashing>
      {/* handle, number, label, tag, remove */}
    </li>
  </ol>
  {/* Add step, then the edit count with Keep planning and Run plan */}
  <div data-slot="plan-review-receipt" role="status" /> {/* once decided */}
</div>

The handle is a button that the arrow keys, Home and End move, and each move is read out. Steps glide to their new place unless motion is reduced.

Removed steps stay listed, struck through, until you decide, so you can restore them. A step you added and then removed simply goes.

Examples

From a stored decision

Pass the saved decision with its state to show it again after a reload.

Press arrow up or arrow down to move the step.

Proposed plan

Nothing runs until you approve

2 steps
  1. 1Add a migration for the new column
  2. 2Backfill it in batches of 1,000edited
  3. –Drop the old columnremoved
Approved with 2 edits1 rewritten · 1 removed

API reference

PlanReview

PropTypeDefaultDescription
stepsPlanStep[]requiredThe plan as proposed.
state"review" | "approved" | "revising""review"
onApprove(decision: PlanDecision) => voidAdds Run plan.
onRevise(note: string, decision: PlanDecision) => voidAdds Keep planning, which asks for a note.
decisionPlanDecisionA stored decision to show.
notestringThe note shown once sent back.
draft, onDraftChangePlanDraftStep[]Controls the edits.
readOnlybooleanfalseShows the plan without editing.
titlestring"Proposed plan"
subtitlestring"Nothing runs until you approve"
approveLabelstring"Run plan"
reviseLabelstring"Keep planning"

All other div props are forwarded.

PlanDecision

FieldTypeDefaultDescription
stepsPlanStep[]What to run, in order.
removedPlanStep[]Proposed steps that were taken out.
edits{ moved, rewritten, added, removed }The ids each change touched.

A PlanStep is { id, label }. decidePlan(steps, draft) works out a decision yourself.