Elements

Elements · Agents

Checkpoints

Points you can fall back to, with what each one would give back.

Checkpoints
Before the converter change09:41 · 0 files
Converter guarded09:58 · 2 files
Tests added10:12 · 4 filescurrent
Formatting sweep10:20 · 31 files
fig. 01

Installation

npx shadcn@latest add "@assistant-ui/elements-checkpoint-history"
First time? Set up a runtime

Runtime components read their state from an assistant-ui runtime. Add one to an existing project:

npx assistant-ui@latest init

Then wrap your app in a runtime provider:

import { AssistantRuntimeProvider } from "@assistant-ui/react";
import { useChatRuntime, AssistantChatTransport } from "@assistant-ui/ai-sdk";

export default function App() {
  const runtime = useChatRuntime({
    transport: new AssistantChatTransport({ api: "/api/chat" }),
  });

  return (
    <AssistantRuntimeProvider runtime={runtime}>
      {/* your components */}
    </AssistantRuntimeProvider>
  );
}

The installation guide covers new projects, templates, and API routes.

A checkpoint list shows the points you could restore to: a label, when it was taken, and how much it touched. It is a plain list with one entry marked current; restoring is a callback you wire up yourself.

Getting started

Anatomy

<div data-slot="checkpoint-history">
  <span>Checkpoints</span>
  <div>
    {/* one row per checkpoint */}
    <span>{/* dot: solid blue = current, hollow ring = ahead, solid gray = behind */}</span>
    <span>{label}</span>
    <span>{/* at · N files */}</span>
    <span>{/* "current" label, or a Restore button */}</span>
  </div>
</div>

The current row is found by matching currentId against checkpoints. Rows that come after it in the array are "ahead": they render at reduced opacity with a hollow dot, since they are only reachable by moving forward again. Rows at or before it are "behind": full opacity, solid gray dot. The current row itself gets a highlighted background and shows the word "current" instead of a button; every other row, ahead or behind, shows a Restore button that only appears on hover or focus. If currentId matches nothing in checkpoints, no row is current: every row reads as behind and every row shows a Restore button. An empty checkpoints array renders only the "Checkpoints" label.

Examples

Checkpoints ahead of the current one

Passing a currentId earlier in the array than the list's end leaves the later entries visible but dimmed, showing what moving forward would give back:

<CheckpointHistory checkpoints={checkpoints} currentId="2" onRestore={onRestore} />

An unrecognized current id

Useful right after a checkpoint is deleted server-side, before the caller has picked a new current one:

<CheckpointHistory checkpoints={checkpoints} currentId="" onRestore={onRestore} />

Restyle the list

The root uses the shared paper surface; the timestamp and file count use mono.

<CheckpointHistory className="max-w-md rounded-3xl" {...rest} />

API reference