Epicenter
Local-first, open source apps
Button renamed
Checkpoint is a point in the conversation you can return to. It is a Marker after a turn, with a Restore button. Restore keeps that turn and drops every message after it.
Installation
Checkpoint is built with the Marker and Button components.
Usage
Render a marker after the turn, with a button that restores it.
<Marker.Root variant="separator">
<Marker.Content class="inline-flex items-center gap-2">
{label}
<Button size="xs" variant="outline" onclick={restore}>Restore</Button>
</Marker.Content>
</Marker.Root> See Marker.
AI SDK
Restore replaces the thread with the messages up to and including that turn. Every later turn is removed. Send a new message to continue from there.
const index = chat.messages.findIndex((message) => message.id === messageId);
chat.messages = chat.messages.slice(0, index + 1); AI SDK Helper
To script a checkpoint with createChat, write it as a data part on the agent's turn. Send the same id again only when you mean to update that checkpoint.
const chat = createChat()
.user("Rename the button component to action.")
.assistant(({ writer }) => {
writer.text("Renamed Button to Action in components/ui/button.tsx.");
writer.data({
type: "data-checkpoint",
id: "rename",
data: { label: "Button renamed" },
});
})
.user("Update the docs to match.")
.assistant(({ writer }) => {
writer.text("Updated the Button page to say Action.");
});