Skip to documentation content

Checkpoint

Mark a point in a conversation the work can return to, and restore it after a confirm step.

checkpoint-demo

Overview

Checkpoint marks a point in an agent's work that can be put back: the files, the plan, or whatever your app saves. It sits between messages as a hairline with a label and a time. Restore asks first, then shows Restoring and Restored.

CheckpointList shows several checkpoints in one panel, with the one the work is at now marked Current.

Saving and restoring are your app's work. The component shows the state and calls your handler.

Anatomy

Checkpoint
  • LabelWhat the checkpoint marks, and when it was made
  • DividerA hairline that sets it apart from the messages around it
  • RestoreA quiet button, when you handle restoring
  • ConfirmThe question, Cancel, and Restore, shown in place of the button
CheckpointList
  • TitleA heading for the panel
  • ItemA dot on a rail, the label, the time and a note, and Restore or Current

Installing checkpoint brings Button along as a registry dependency.

Behavior

Confirm step

Restore replaces itself with "Discard the changes made after this?", Cancel, and Restore. Focus moves to the confirming Restore, and back to the first one on Cancel or Escape. Nothing is called until the person confirms.

Restoring and restored

If onRestore returns a promise, the checkpoint shows Restoring until it settles. To control the state yourself, pass status: "available", "restoring", or "restored". A status you pass wins over the promise.

List

CheckpointList calls onRestore with the checkpoint's id. The checkpoint matching currentId shows Current instead of Restore.

Accessibility

Each checkpoint is a group named by its label. Restore is named with its checkpoint, such as "Restore: Before the rounding refactor", and the confirm step is a group with the same name. Times use the time element; pass dateTime for a machine-readable value. The icon and divider are decorative.

KeyAction
TabMove to Restore, or across Cancel and Restore while confirming
Enter or SpaceStart or confirm a restore
EscapeCancel the confirm step

Installation

npx honestui@latest add checkpoint

Usage

import { Checkpoint } from "@/components/ai/checkpoint"

<Checkpoint
  label={checkpoint.title}
  time={formatTime(checkpoint.createdAt)}
  dateTime={checkpoint.createdAt}
  onRestore={() => workspace.restore(checkpoint.id)}
/>

Examples

List

Several checkpoints in a panel. Restoring one makes it Current.

checkpoint-list

API reference

Checkpoint

Accepts native div props beyond those listed.

PropTypeDefaultDescription
labelstringRequiredWhat the checkpoint marks.
timestringNoneWhen it was made, already formatted.
dateTimestringNoneA machine-readable time for the time element.
onRestore() => void | Promise<unknown>NonePassing it shows Restore. A promise shows Restoring until it settles.
status"available" | "restoring" | "restored"From the promiseThe state to show.
labelsPartial<CheckpointLabels>EnglishButton text, the confirm question, and state words.

CheckpointList

Accepts native section props beyond those listed.

PropTypeDefaultDescription
checkpointsCheckpointItem[]RequiredThe checkpoints, in the order to show them.
currentIdstringNoneThe checkpoint the work is at now.
onRestore(id: string) => void | Promise<unknown>NonePassing it shows Restore on every other checkpoint.
titleReactNode"Checkpoints"The panel's heading.
labelsPartial<CheckpointLabels>EnglishAs for Checkpoint.

Types

ExportShape
CheckpointItemid, label, and optional time, dateTime, description, status
CheckpointStatus"available", "restoring", or "restored"