# Run History

> Every run of an automation, its status, and each step's result.

Page: https://uicontext.com/docs/components/run-history

Group: Agents.

## When to use

Every run of an automation, its status, and each step's result. Use [Activity Feed](https://uicontext.com/docs/components/activity-feed.md) instead when you show changes to a record, not runs.

## Usage

```ts
import { RunHistory } from "./ui/uicontext/components/Runs.ts"
import type { RunSummary } from "./ui/uicontext/components/Runs.ts"

const Message = UiSchema.TaggedEnum({
	OpenedRun: { id: Schema.String },
	ReplayedRuns: { ids: Schema.Array(Schema.String) },
})

export const InvoiceSyncRuns = (h: Html.H<typeof Message.Type>, runs: ReadonlyArray<RunSummary>, selected: string | null) =>
	RunHistory(h, {
		props: { label: "Invoice sync runs", status: "ready", runs, selected, timeZone: "Europe/London" },
		onEmit: {
			RequestedOpen: ({ id }) => Message.OpenedRun({ id }),
			RequestedReplay: ({ ids }) => Message.ReplayedRuns({ ids }),
			RequestedStop: () => undefined,
			RequestedDelete: () => undefined,
			RequestedMore: () => undefined,
		},
	})
```

## Examples

Each example is a complete file. Its imports point where the CLI installs the source.

### History

The example the page opens with: Run History in “History”.

```ts title="src/demo.ts" source="www/src/examples/run-history/demo.ts"
import { UiSchema } from "effect/ui"
import { Html } from "effect/ui/html"
import * as stylex from "@stylexjs/stylex"
import { Schema } from "effect"
import { RunHistory, type RunSummary } from "./ui/uicontext/components/Runs.ts"
import { sx } from "./ui/uicontext/components/Sx.ts"

const styles = stylex.create({
	frame: { inlineSize: "100%" },
})

const runs: ReadonlyArray<RunSummary> = [
	{
		id: "run-41",
		title: "New lead to CRM",
		status: "failed",
		reason: "The CRM refused the request: rate limit exceeded.",
		trigger: "Webhook",
		startedAt: "2026-11-29T15:02:00Z",
		durationMs: 4200,
		cost: { value: 2, unit: "tasks" },
		sideEffects: true,
		can: ["replay", "replayFromStart", "delete"],
	},
	{ id: "run-40", title: "New lead to CRM", status: "running", trigger: "Webhook", onBehalfOf: { id: "ada", name: "Ada Lovelace", kind: "person" }, startedAt: "2026-11-29T15:10:00Z", can: ["stop"] },
	{ id: "run-39", title: "Weekly digest", status: "succeeded", trigger: "Schedule", startedAt: "2026-11-28T09:00:00Z", durationMs: 2100, cost: { value: 3, unit: "tasks" }, can: ["replay", "delete"] },
	{ id: "run-38", title: "New lead to CRM", status: "skipped", reason: "Filtered: the lead has no email", trigger: "Webhook", startedAt: "2026-11-28T08:12:00Z", can: ["delete"] },
]

const Message = UiSchema.TaggedEnum({
	OpenedRun: { id: Schema.String },
	StoppedRun: { id: Schema.String },
	DeletedRuns: { ids: Schema.Array(Schema.String) },
})

export const AutomationRuns = Html.component({
	name: "AutomationRuns",
	model: Schema.Struct({ selected: Schema.NullOr(Schema.String), stopped: Schema.Array(Schema.String), deleted: Schema.Array(Schema.String) }),
	message: Message,
}).make({
	init: () => ({ selected: "run-41", stopped: [], deleted: [] }),
	update: {
		OpenedRun: ($, { id }) => $.evolve({ selected: id }),
		StoppedRun: ($, { id }) => $.evolve({ stopped: (s) => [...s, id] }),
		DeletedRuns: ($, { ids }) => $.evolve({ deleted: (d) => [...d, ...ids] }),
	},
	view: (h, { selected, stopped, deleted }) =>
		h.div.attrs(sx(styles.frame)).children(
			RunHistory(h, {
				props: {
					label: "Run history",
					status: "ready",
					timeZone: "Europe/London",
					selected,
					selectable: true,
					runs: runs
						.filter((run) => !deleted.includes(run.id))
						.map((run) => (stopped.includes(run.id) ? { ...run, status: "stopped", reason: "Stopped by you", can: ["replay", "delete"] } : run)),
				},
				onEmit: {
					RequestedOpen: ({ id }) => Message.OpenedRun({ id }),
					RequestedStop: ({ id }) => Message.StoppedRun({ id }),
					RequestedDelete: ({ ids }) => Message.DeletedRuns({ ids }),
					RequestedMore: () => undefined,
					RequestedReplay: () => undefined,
				},
			}),
		),
})
```

### A failed run

One run opened: each step with its input, output and the error that stopped it.

```ts title="src/run-detail.ts" source="www/src/examples/run-history/run-detail.ts"
import { Html } from "effect/ui/html"
import * as stylex from "@stylexjs/stylex"
import { Schema } from "effect"
import { RunDetail, type RunStep, type RunSummary } from "./ui/uicontext/components/Runs.ts"
import { sx } from "./ui/uicontext/components/Sx.ts"

const styles = stylex.create({
	frame: { inlineSize: "min(100%, 40rem)" },
})

const run: RunSummary = {
	id: "run-41",
	title: "New lead to CRM",
	status: "failed",
	reason: "The CRM refused the request: rate limit exceeded.",
	trigger: "Webhook",
	startedAt: "2026-11-29T15:02:00Z",
	durationMs: 4200,
	cost: { value: 2, unit: "tasks" },
	can: ["replay", "replayFromStart"],
}

const steps: ReadonlyArray<RunStep> = [
	{ id: "read", title: "Read the lead", status: "succeeded", durationMs: 300, output: '{ "name": "Grace Hopper", "email": "grace@example.com" }' },
	{ id: "enrich", title: "Look the company up on the web", status: "refused", reason: "Web access is off for this automation", reasonHref: "#settings" },
	{ id: "create", title: "Create the contact", status: "failed", reason: "Rate limit exceeded", durationMs: 3900 },
]

export const FailedRun = Html.component({
	name: "FailedRun",
	model: Schema.Struct({}),
	message: Schema.Never,
}).make({
	init: () => ({}),
	update: ($) => $.model,
	view: (h) =>
		h.div.attrs(sx(styles.frame)).children(
			RunDetail(h, {
				props: { run, steps, timeZone: "Europe/London" },
				onEmit: { RequestedReplay: () => undefined, RequestedReplayFromStep: () => undefined, RequestedFix: () => undefined, RequestedStop: () => undefined },
			}),
		),
})
```

### Fix a failed step

The failed step says what went wrong and offers its fix; replay from it, or pick any step to run again from.

```ts title="src/fix-a-step.ts" source="www/src/examples/run-history/fix-a-step.ts"
import { UiSchema } from "effect/ui"
import { Html } from "effect/ui/html"
import * as stylex from "@stylexjs/stylex"
import { Schema } from "effect"
import { RunDetail, type RunStep, type RunSummary } from "./ui/uicontext/components/Runs.ts"
import { sx } from "./ui/uicontext/components/Sx.ts"
import { color, font } from "./ui/uicontext/components/tokens.stylex.ts"

const styles = stylex.create({
	frame: { inlineSize: "min(100%, 40rem)", display: "flex", flexDirection: "column", gap: 12 },
	said: { margin: 0, fontSize: font.sm, color: color.muted },
})

const run: RunSummary = {
	id: "run-88",
	title: "New lead intake",
	status: "failed",
	reason: "Step 3B.1, Send email: the Mail account’s sign-in expired.",
	trigger: "Form response",
	startedAt: "2026-11-30T13:42:00Z",
	durationMs: 1610,
	version: "v3",
	sideEffects: true,
	can: ["replay", "replayFromStart", "replayFromStep", "delete"],
}

const steps: ReadonlyArray<RunStep> = [
	{ id: "form", title: "1. New form response", status: "succeeded", output: '{\n  "name": "Tomas Reyes",\n  "company_size": "38"\n}' },
	{ id: "filter", title: "2. Only continue if Email exists", status: "succeeded", output: '{ "passed": true }' },
	{ id: "size", title: "3. Split by company size", status: "succeeded", output: '{ "path": "Everyone else" }' },
	{
		id: "reply", title: "3B.1. Send email", status: "failed", reason: "Mail refused the request: the sign-in expired on Nov 24.",
		input: '{\n  "To": "tomas@reyes.example",\n  "Subject": "Thanks for getting in touch, Tomas Reyes"\n}', fix: { label: "Reconnect Mail" },
	},
	{ id: "log", title: "4. Add row", status: "skipped", reason: "An earlier step failed" },
]

const Message = UiSchema.TaggedEnum({ Said: { text: Schema.String } })

export const FixAStep = Html.component({
	name: "FixAStep",
	model: Schema.String,
	message: Message,
}).make({
	init: () => "",
	update: { Said: (_$, { text }) => text },
	view: (h, said) =>
		h.div.attrs(sx(styles.frame)).children(
			RunDetail(h, {
				props: { run, steps, timeZone: "Europe/London", agentId: "run-fix-demo" },
				onEmit: {
					RequestedFix: ({ step }) => Message.Said({ text: `The app reconnects the account for ${step}.` }),
					RequestedReplayFromStep: ({ step }) => Message.Said({ text: `The app replays from ${step}, reusing the steps before it.` }),
					RequestedReplay: ({ from }) => Message.Said({ text: `The app replays from ${from === "start" ? "the start" : "the failed step"}.` }),
					RequestedStop: () => undefined,
				},
			}),
			h.p.attrs({ role: "status", ...sx(styles.said) }).children(said),
		),
})
```

### Loading and empty

`status: "loading"` while the first page arrives, and an `empty` title and hint before anything has run.

```ts title="src/loading-and-empty.ts" source="www/src/examples/run-history/loading-and-empty.ts"
import type { Html } from "effect/ui/html"
import * as stylex from "@stylexjs/stylex"
import { RunHistory } from "./ui/uicontext/components/Runs.ts"
import { sx } from "./ui/uicontext/components/Sx.ts"

const styles = stylex.create({
	stack: { display: "grid", gap: 24, inlineSize: "100%" },
})

const ignore = { RequestedOpen: () => undefined, RequestedReplay: () => undefined, RequestedStop: () => undefined, RequestedDelete: () => undefined, RequestedMore: () => undefined }

export const RunsLoadingAndEmpty = <M>(h: Html.H<M>) =>
	h.div.attrs(sx(styles.stack)).children(
		// while the first page loads
		RunHistory(h, {
			key: "loading",
			props: { label: "Invoice sync runs", status: "loading", runs: [], timeZone: "UTC" },
			onEmit: ignore,
		}),
		// an automation that hasn't run yet says what will start it
		RunHistory(h, {
			key: "empty",
			props: {
				label: "Weekly digest runs",
				status: "ready",
				runs: [],
				timeZone: "UTC",
				hideColumns: ["cost"],
				empty: { title: "No runs yet", hint: "It runs every Monday at 9:00, or when you press Test." },
			},
			onEmit: ignore,
		}),
	)
```

## API reference

### RunHistory (component)

**Props**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `runs` (required) | `RunSummary[]` | — | The runs to list, newest first |
| `status` (required) | `"loading" \| "ready"` | — | `loading` shows placeholder rows |
| `label` (required) | `string` | — | What the list is of, for screen readers and agents: "Automation history" |
| `timeZone` (required) | `string` | — | The person's time zone (IANA) |
| `locale` | `string` | — | The locale dates and numbers are formatted in; the browser's by default |
| `selected` | `string \| null` | — | The run whose detail is open |
| `selectable` | `boolean` | — | Checkboxes and bulk replay or delete |
| `filters` | `boolean` | — | False hides the chips that filter by outcome, for a page that filters the runs itself |
| `hideColumns` | `("trigger" \| "duration" \| "cost")[]` | — | Metadata columns to omit from the history table when the product doesn't show them |
| `notice` | `Notice \| null` | — | A bulk outcome or a refusal: "2 of 5 runs couldn't be replayed: the automation is off." |
| `empty` | `{ title, hint }` | — | What an empty history says, with a hint at what to do next |
| `more` | `boolean` | — | Older runs exist beyond these: shows "Load older runs" |
| `loadingMore` | `boolean` | — | Older runs are loading |
| `agentId` | `string` | `runs:<label>` | The id agents know this list by; `runs:<label>` by default |

**Events**

| Event | Payload | Description |
| --- | --- | --- |
| `RequestedOpen` | `{ id: string }` | A row without an href was opened: show its detail |
| `RequestedReplay` | `{ ids: string[]; from: "failed" \| "start" }` | Run these runs again, from their failed step or from the start, after the person confirmed |
| `RequestedStop` | `{ id: string }` | Stop a run in progress |
| `RequestedDelete` | `{ ids: string[] }` | Delete these runs, after the person confirmed |
| `RequestedMore` | `{}` | Load the runs older than these |

**Agent actions**

| Action | Description |
| --- | --- |
| `ClickedRun` | Open a run's detail by id |
| `ToggledRun` | Tick or untick a run for a bulk action |
| `ClickedReplay` | Replay a run, from the failed step or from the start. With side effects this opens a confirmation. |
| `ClickedStop` | Stop a queued or running run |
| `ClickedDelete` | Ask to delete a run (opens the confirmation) |
| `ClickedReplayChecked` | Replay the ticked runs |
| `ClickedDeleteChecked` | Ask to delete the ticked runs |
| `ConfirmedAction` (asks first) | Confirm the replay or delete waiting for confirmation. Name it as your target. |

### RunDetail (component)

**Props**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `run` (required) | `RunSummary` | — | The run's status, trigger, start and duration |
| `steps` (required) | `RunStep[]` | — | Each step's status, input and output, in order |
| `streaming` | `boolean` | — | Steps are still arriving |
| `timeZone` (required) | `string` | — | The person's time zone (IANA) |
| `locale` | `string` | — | The locale dates and numbers are formatted in; the browser's by default |
| `agentId` | `string` | `run:<id>` | The id agents know this run by; `run:<id>` by default |

**Events**

| Event | Payload | Description |
| --- | --- | --- |
| `RequestedReplay` | `{ ids: string[]; from: "failed" \| "start" }` | Run this run again, from its failed step or from the start, after the person confirmed |
| `RequestedReplayFromStep` | `{ id: string; step: string }` | Run it again from this step, reusing what the steps before it returned |
| `RequestedFix` | `{ id: string; step: string }` | The person asked for a failed step's fix: open its setup, reconnect its account |
| `RequestedStop` | `{ id: string }` | Stop the run while it's in progress |

**Agent actions**

| Action | Description |
| --- | --- |
| `ClickedReplay` | Replay this run from the failed step or from the start. With side effects this opens a confirmation. |
| `PickedReplayFrom` | Replay this run from a step by id, reusing what the steps before it returned |
| `ClickedFix` | Open the fix for a failed step by id |
| `ClickedStop` | Stop this run |
| `ConfirmedReplay` (asks first) | Confirm the replay waiting for confirmation. Name it as your target. |

## Keyboard and accessibility

- The history is a captioned table with times in the reader's time zone.
- Replaying a run that has side effects, and deleting runs, ask first.
- Agents must name the runs they replay or delete.

## Installation

```sh
pnpm dlx shadcn@latest add checkfu/uicontext/run-history
```

With npm: `npx shadcn@latest add checkfu/uicontext/run-history`. With yarn: `yarn dlx shadcn@latest add checkfu/uicontext/run-history`. With bun: `bunx --bun shadcn@latest add checkfu/uicontext/run-history`.

It writes these files:

- `src/ui/uicontext/components/AgentPlan.ts`
- `src/ui/uicontext/components/Button.ts`
- `src/ui/uicontext/components/Callout.ts`
- `src/ui/uicontext/components/CopyButton.ts`
- `src/ui/uicontext/components/Dialog.ts`
- `src/ui/uicontext/components/Direction.ts`
- `src/ui/uicontext/components/Glyph.ts`
- `src/ui/uicontext/components/IconStroke.ts`
- `src/ui/uicontext/components/InlineNotice.ts`
- `src/ui/uicontext/components/Kbd.ts`
- `src/ui/uicontext/components/Menu.ts`
- `src/ui/uicontext/components/Motion.ts`
- `src/ui/uicontext/components/Runs.ts`
- `src/ui/uicontext/components/Skeleton.ts`
- `src/ui/uicontext/components/States.ts`
- `src/ui/uicontext/components/StatusBadge.ts`
- `src/ui/uicontext/components/Sx.ts`
- `src/ui/uicontext/components/agent/Agent.ts`
- `src/ui/uicontext/components/button.stylex.ts`
- `src/ui/uicontext/components/domain/Actor.ts`
- `src/ui/uicontext/components/domain/Format.ts`
- `src/ui/uicontext/components/domain/Glyph.ts`
- `src/ui/uicontext/components/domain/Notice.ts`
- `src/ui/uicontext/components/domain/Outcome.ts`
- `src/ui/uicontext/components/domain/Run.ts`
- `src/ui/uicontext/components/domain/Time.ts`
- `src/ui/uicontext/components/safeArea.stylex.ts`
- `src/ui/uicontext/components/tokens.stylex.ts`
- `src/ui/uicontext/components/touch.stylex.ts`
- `src/ui/uicontext/components/variants.ts`

And installs the npm packages `@stylexjs/stylex`, `effect`.

## Source

- [src/Runs.ts](https://github.com/checkfu/uicontext/blob/main/src/Runs.ts)

## Used in

- [Workflow builder](https://uicontext.com/blocks/automation-builder.md)
- [Automation runs](https://uicontext.com/blocks/automation-runs.md)

## Related

- [Agent Tools](https://uicontext.com/docs/components/agent-tools.md) (`agent-tools`): Lets agents in the browser read the page and act through the same controls people use.
- [Tool Confirmation](https://uicontext.com/docs/components/tool-confirmation.md) (`tool-confirmation`): Asks a person to confirm before an agent's action changes anything.
- [Prompt Template](https://uicontext.com/docs/components/prompt-template.md) (`prompt-template`): Write a prompt with {{variables}} the app fills in: they stand out, unknown ones are flagged, and a preview shows it with samples.
- [Agent Settings](https://uicontext.com/docs/components/agent-settings.md) (`agent-settings`): Edit an agent's name, instructions, tools and model.
- [Computer](https://uicontext.com/docs/components/computer.md) (`computer`): The machine an agent works on: a live view of its screen, full size or as a thumbnail with Take over, and its browser with tabs and an address bar.
- [Persona Avatar](https://uicontext.com/docs/components/persona-avatar.md) (`persona-avatar`): An agent's face: a shape and a color with eyes that move with what it's doing.
