themeocean

Agent Run Timeline

AI chats

About

A live timeline of an AI agent's run. Each thinking, tool and message step shows its status, duration, input and output, and updates as you change the steps prop.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Agent Run Timeline to your project and fits it to your theme.

Code

How Agent Run Timeline is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

// This is a file with a demo for your component
// That's what users will see in the preview
// Create new files in this directory to add more demos

"use client";

import * as React from "react";
import { Play, TriangleAlert } from "lucide-react";
import { Component, type AgentStep } from "@/components/ui/agent-run-timeline";



/* ------------------------------------------------------------------ */
/* A pretend agent run, so you can watch the timeline update           */
/* ------------------------------------------------------------------ */

interface ScriptStep extends Omit<AgentStep, "status" | "durationMs"> {
  /** How long the pretend step takes, in milliseconds. */
  takes: number;
  /** Text shown when this step fails in the "with error" run. */
  failure?: string;
}

const SCRIPT: ScriptStep[] = [
  {
    id: "plan",
    type: "thinking",
    title: "Planning the task",
    takes: 900,
    description: "The customer asks for a refund on order A-1042. I need to check the policy, load the order, then write a reply.",
  },
  {
    id: "docs",
    type: "tool",
    toolName: "search_docs",
    title: "Searching the help docs",
    takes: 1400,
    input: '{\n  "query": "refund policy",\n  "limit": 3\n}',
    output: "Found 3 pages. Top result: “Refunds within 30 days of delivery”.",
  },
  {
    id: "order",
    type: "tool",
    toolName: "get_order",
    title: "Loading the order",
    takes: 1100,
    input: '{ "order_id": "A-1042" }',
    output: '{\n  "status": "delivered",\n  "delivered_days_ago": 12,\n  "total": 84.0\n}',
    failure: "Order service timed out after 10 s (503).",
  },
  {
    id: "refund",
    type: "tool",
    toolName: "create_refund",
    title: "Issuing the refund",
    takes: 1300,
    input: '{ "order_id": "A-1042", "amount": 84.0 }',
    output: '{ "refund_id": "RF-7731", "state": "queued" }',
  },
  {
    id: "reply",
    type: "message",
    title: "Writing the reply",
    takes: 1000,
    description: "Your refund of $84.00 has been issued and should reach you in 3 to 5 business days.",
  },
];

// Outputs stay hidden until a step finishes, like in a real run
const initialSteps = (): AgentStep[] => SCRIPT.map(({ takes, failure, output, ...step }) => ({ ...step, status: "pending" as const }));

export default function DemoOne() {
  const [steps, setSteps] = React.useState<AgentStep[]>(initialSteps);
  const [busy, setBusy] = React.useState(false);

  // Each run gets a number, so an older run stops writing when a new one starts
  const runId = React.useRef(0);
  React.useEffect(() => () => void (runId.current += 1), []);

  const play = async (withError: boolean) => {
    const id = ++runId.current;
    const alive = () => runId.current === id;
    const patch = (stepId: string, change: Partial<AgentStep>) => setSteps((all) => all.map((s) => (s.id === stepId ? { ...s, ...change } : s)));

    setBusy(true);
    setSteps(initialSteps());
    await new Promise((r) => setTimeout(r, 400));

    for (const step of SCRIPT) {
      if (!alive()) return;
      patch(step.id, { status: "running" });
      await new Promise((r) => setTimeout(r, step.takes));
      if (!alive()) return;

      // In the error run, the order step fails and the rest never start
      if (withError && step.failure) {
        patch(step.id, { status: "error", durationMs: step.takes, output: step.failure });
        setBusy(false);
        return;
      }
      patch(step.id, { status: "success", durationMs: step.takes, output: step.output });
    }
    setBusy(false);
  };

  return (
    <div className="flex min-h-[640px] w-full flex-col items-center justify-center gap-5 bg-background px-4 py-10 text-foreground">
      <Component title="Support agent" steps={steps} defaultOpenIds={[]} />

      <div className="flex flex-wrap items-center justify-center gap-2">
        <button
          type="button"
          onClick={() => play(false)}
          disabled={busy}
          className="inline-flex h-10 items-center gap-2 rounded-full bg-primary px-5 text-sm font-semibold text-primary-foreground shadow-md shadow-primary/25 transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50"
        >
          <Play className="size-4" aria-hidden="true" />
          Run agent
        </button>
        <button
          type="button"
          onClick={() => play(true)}
          disabled={busy}
          className="inline-flex h-10 items-center gap-2 rounded-full border border-border bg-card px-5 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"
        >
          <TriangleAlert className="size-4" aria-hidden="true" />
          Run with an error
        </button>
      </div>
    </div>
  );
}

Dependencies

More by themeocean

View all
  • Interactive Tech Stack Bento Grid with Hover Effects

    Interactive Tech Stack Bento Grid with Hover Effects

    780
  • Floating Glassmorphic Navbar with Morphing Pill Indicator

    Floating Glassmorphic Navbar with Morphing Pill Indicator

    87
  • Mac-Style Floating Dock

    Mac-Style Floating Dock

    79
  • Nexus 3D Animated Login - Futuristic Authentication UI

    Nexus 3D Animated Login - Futuristic Authentication UI

    72
  • Animated 3D Perspective Hero with Floating Glass Layers

    Animated 3D Perspective Hero with Floating Glass Layers

    51
  • Interactive AI Agent Workflow Node Card

    Interactive AI Agent Workflow Node Card

    38
  • Interactive LLM Token & Context Window Visualizer

    Interactive LLM Token & Context Window Visualizer

    31
  • Interactive AI Voice Assistant Audio Visualizer

    Interactive AI Voice Assistant Audio Visualizer

    24

More in AI chats

View all
  • Agent Chat

    Agent Chat

    21
  • AI Suggestions

    AI Suggestions

    27
  • AI Actions

    AI Actions

    372
  • Aquarium Prompt

    Aquarium Prompt

    223
  • Message Parts

    Message Parts

    11
  • AI SaaS Workflow Hero

    AI SaaS Workflow Hero

    37
  • AI Chat Composer

    AI Chat Composer

    22
  • Tool Memory

    Tool Memory

    10