# Agent timeline layout

A long running agent's thread as a timeline, with honest gaps between steps and a composer that steers without stopping the run.

> chatcn Pro: needs a Pro license (https://chatcn.dev/pro). Install from the `@chatcn-pro` registry with your license token; setup at https://chatcn.dev/docs/chatcn-pro.

Example: Agent timeline layout. An overnight helpdesk migration as a timeline: an approval, a human reply, a pause at dawn, and the finish while you watch. Preview: https://chatcn.dev/preview/agent-timeline-layout-demo

## Installation

```bash
npx shadcn@latest add @chatcn-pro/agent-timeline-layout
```

## Usage

```tsx
import { AgentTimelineLayout } from "@/components/ui/chatcn/pro/agent-timeline-layout"

<AgentTimelineLayout
  title="Helpdesk migration"
  events={events}
  status={run.status}
  startedAt={run.startedAt}
  onSend={steer}
  onStop={run.stop}
/>
```

Agents that run for hours do not fit a chat transcript. Here each step sits on a rail with its time and a mark for its kind (an update, a tool, a wait for someone, a human reply, a milestone, an error) in the kit's status colors. Time is honest: when more than `gapMs` passes between two steps, the rail turns dashed and says how long, so a run that took a night reads like one; a new day gets a label. While the run is going, the latest step shows as in progress and the header counts how long it has been running. Waits can carry actions inline, such as Approve. The composer always sends, so steering never stops the run; Stop is its own button in the header.

## Examples

### States

Example: States. Waiting on a person with actions inline, running, and a failed step with the fix. Preview: https://chatcn.dev/preview/agent-timeline-layout-states

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `events` | `TimelineEvent[]` | `{ id, at, kind, title, detail?, state?, actions? }`; `kind` is `"update" | "tool" | "wait" | "human" | "milestone" | "error"` |
| `title` | `ReactNode` | The run's name |
| `status` | `LayoutChatStatus` | `streaming` or `submitted` while the agent works |
| `startedAt` | `Date | string | number` | For the elapsed time in the header |
| `gapMs` | `number` | Longer gaps show as dashed stretches. Default 20 minutes |
| `onSend`, `onStop` | `(text) => void`, `() => void` | Steer, and stop the run |
| `now`, `timeZone`, `locale` |  | A fixed clock and formatting, for previews |
| `value`, `onValueChange` | `string` | The draft, controlled or not |
| `labels` | `Partial<AgentTimelineLabels>` | Every string, for translation |

## Keyboard

| Key | Action |
| --- | --- |
| Enter, Shift Enter | Send a steer, new line |
| Tab | Reach actions on a waiting step, then Stop run |

## Accessibility

- The timeline is an ordered list; each step's time is a time element with the full date.
- Status is shown by color, an icon and the words in the step, never color alone.
- Gaps are written out (3 h later), not only drawn.

## Motion

A new step enters with a short rise at the bottom of the list, which stays scrolled to the latest step unless the reader has scrolled up. Under reduced motion steps appear in place.

Source: https://chatcn.dev/docs/components/agent-timeline-layout