Skip to content
TuffTasks, docs and chat for teams and AI agents

Planning & Execution

Plan Editor

The agent's plan before it runs — drag steps into order, switch them off, edit them, set Ask first, and watch totals update. Run plan turns the same rows into live progress.

1 variantMIT

Preview

Plan · Stripe webhooks to v2

Proposed by the agent · not started

Draft

Here's how I'd move the webhooks to v2. Switch off or reorder anything before I start.

  • ~15s · 2.1k
  • ~50s · 6.8k
  • ~25s · 3.4k
  • ~40s · 4.2k
  • ~20s · 1.6k
  • ~10s · 900

6steps ·~3 min·~19.0ktokens

Installation

Copies the component into components/ui and installs its dependencies and theme tokens.

pnpm dlx shadcn@latest add https://tuffui.com/r/plan-editor.json

Usage

Pass your own data and wire the callbacks to your agent runtime.

import { PlanEditor, type PlanStep } from "@/components/ui/plan-editor";

export function PlanBeforeRun({ proposal }: { proposal: AgentPlan }) {
  const [steps, setSteps] = useState<PlanStep[]>(
    proposal.steps.map((s) => ({
      id: s.id,
      text: s.title,
      mode: s.needsApproval ? "ask" : "auto",
      estimate: { seconds: s.estSeconds, tokens: s.estTokens },
    })),
  );
  const run = useAgentRun(); // streams step status, tool calls and usage

  return (
    <PlanEditor
      title="Plan · Stripe webhooks to v2"
      note="Here's how I'd move the webhooks to v2. Switch off or reorder anything before I start."
      // While running, merge live status into the same rows.
      steps={run.active ? run.merge(steps) : steps}
      onStepsChange={setSteps}
      phase={run.done ? "done" : run.active ? "running" : "editing"}
      onRun={(enabled) => run.start(enabled)} // only steps that are on, in order
      onStop={() => run.stop()}
      onApprove={(id) => run.approve(id)}
      onSkip={(id) => run.skip(id)}
    />
  );
}

Props

PropTypeDefaultDescription
stepsPlanStep[]—Controlled steps, in order. While running, set each step's `status`, `tools`, `elapsedMs` and `tokens`.
defaultStepsPlanStep[][]Starting steps when uncontrolled.
onStepsChange(steps: PlanStep[]) => void—Called on every edit: a step switched on or off, dragged or moved with the arrow keys on its handle, its text edited, its mode changed, or a step added.
phase"editing" | "running" | "done""editing"The same rows morph between phases: handles and checkboxes become step numbers and status, the mode toggle a label, and the running step opens its tool calls.
onRun(steps: PlanStep[]) => void—Shows Run plan, the primary action. Gets only the steps that are on, in order. Disabled while a step's text is being edited.
onStop() => void—Shows Stop while running.
onApprove(stepId: string) => void—Shows Approve on a step whose status is `waiting`, e.g. an Ask first step.
onSkip(stepId: string) => void—Shows Skip next to Approve.
noteReactNode—The agent's line above the steps. A new string slides in and is announced.
newStepEstimate{ seconds: number; tokens: number }{ seconds: 20, tokens: 2000 }Estimate for a step added with Add step. A new step opens for typing; left empty, it goes away.
titleReactNode"Plan"Header title.
subtitleReactNode—Line under the title.
iconIconListChecksPhosphor icon in the header tile.
formatEstimate(seconds: number) => string—Formats estimates. Defaults to "~25s" and "~2 min".
formatElapsed(ms: number) => string—Formats actual time while running. Defaults to "38s" and "1m 04s".
formatTokens(tokens: number) => string—Formats token counts. Defaults to "3.4k".
classNamestring—Extra classes for the root element.
type PlanStep = {
  id: string;
  text: string;
  enabled?: boolean;              // off: out of the totals, skipped on run
  mode?: "auto" | "ask";          // ask: waits for approval before the step
  estimate: { seconds: number; tokens: number };
  status?: "pending" | "running" | "waiting" | "done" | "failed";
  tools?: PlanToolCall[];         // nested under the step while it runs
  elapsedMs?: number;             // actuals while running and after
  tokens?: number;
};

type PlanToolCall = {
  id: string;
  name: string;                   // "read_file"
  detail?: string;                // "services/billing/webhooks.ts"
  status: "running" | "done" | "failed";
  durationMs?: number;
};