---
title: "Checkpoint"
description: "Restore a saved point in a local conversation."
---

# Checkpoint

Restore a saved point in a local conversation.

## Usage

Restore the conversation to the named checkpoint, then continue the sample conversation.

## Example

```contract
use uiFontFamily, ButtonAI as ButtonContent from "@rightui/ui"
use BubbleFrame from "@rightui/ui"

component Demo
  props
    width: number
    reduced: bool
  inject
    uiFont: string
  state restored = false
  action restore
    restored = true
  action proceed
    restored = false
  view
    column width="100%" max-width="24rem" min-height=288 gap="ui.space-16" padding="ui.space-24 ui.space-0" font-size="ui.text-sm"
      BubbleFrame(id="ai-checkpoint-user", align="end", variant="muted")
        text "Rename the button component to action." font-family=uiFontFamily(uiFont) data-rightui-font="body"
      text "Renamed Button to Action in components/ui/button.tsx." font-family=uiFontFamily(uiFont) data-rightui-font="body"
      row gap="ui.space-8" align-items="center" color="ui.muted-foreground"
        view flex=1 height="ui.border-width" background-color="ui.border"
        text "Button renamed" font-size="ui.text-xs" font-family=uiFontFamily(uiFont) data-rightui-font="body"
        if not restored
          ButtonContent(id="ai-checkpoint-restore", label="Restore to Button renamed", variant="outline", size="xs", disabled=false, press=restore)
            text "Restore" font-family=uiFontFamily(uiFont) data-rightui-font="body"
        view flex=1 height="ui.border-width" background-color="ui.border"
      if not restored
        BubbleFrame(id="ai-checkpoint-docs", align="end", variant="muted")
          text "Update the docs to match." font-family=uiFontFamily(uiFont) data-rightui-font="body"
        text "Updated the Button page to say Action." font-family=uiFontFamily(uiFont) data-rightui-font="body"
      else
        row margin-top="auto"
          ButtonContent(id="ai-checkpoint-continue", label="Continue", variant="outline", size="sm", disabled=false, press=proceed)
            text "Continue" font-family=uiFontFamily(uiFont) data-rightui-font="body"

```

## Keyboard

Tab to controls; Enter or Space to activate buttons.

## Demo runtime

Timed examples use an injected clock. Add these members to your root component. Replace the scripted state with events from your TypeScript or Rust data source when connecting a model.

```contract
use defaultFontWeights from "@rightui/ui"
  state demoTime = 0
  state demoUntil = 0
  provide
    uiFont = "theme"
    uiWeights = defaultFontWeights()
    rightuiDemoTime = demoTime
    rightuiRunDemo = runDemo
  action runDemo(duration: number)
    demoUntil = max(demoUntil, demoTime + duration)
  action tickDemo
    demoTime = min(demoUntil, demoTime + 32)
  task demoClock when demoTime < demoUntil
    every(32, tickDemo)
```

## Source

File: patterns/ai-elements/checkpoint.contract

```contract
use uiFontFamily, ButtonAI as ButtonContent from "@rightui/ui"
use BubbleFrame from "@rightui/ui"

component Demo
  props
    width: number
    reduced: bool
  inject
    uiFont: string
  state restored = false
  action restore
    restored = true
  action proceed
    restored = false
  view
    column width="100%" max-width="24rem" min-height=288 gap="ui.space-16" padding="ui.space-24 ui.space-0" font-size="ui.text-sm"
      BubbleFrame(id="ai-checkpoint-user", align="end", variant="muted")
        text "Rename the button component to action." font-family=uiFontFamily(uiFont) data-rightui-font="body"
      text "Renamed Button to Action in components/ui/button.tsx." font-family=uiFontFamily(uiFont) data-rightui-font="body"
      row gap="ui.space-8" align-items="center" color="ui.muted-foreground"
        view flex=1 height="ui.border-width" background-color="ui.border"
        text "Button renamed" font-size="ui.text-xs" font-family=uiFontFamily(uiFont) data-rightui-font="body"
        if not restored
          ButtonContent(id="ai-checkpoint-restore", label="Restore to Button renamed", variant="outline", size="xs", disabled=false, press=restore)
            text "Restore" font-family=uiFontFamily(uiFont) data-rightui-font="body"
        view flex=1 height="ui.border-width" background-color="ui.border"
      if not restored
        BubbleFrame(id="ai-checkpoint-docs", align="end", variant="muted")
          text "Update the docs to match." font-family=uiFontFamily(uiFont) data-rightui-font="body"
        text "Updated the Button page to say Action." font-family=uiFontFamily(uiFont) data-rightui-font="body"
      else
        row margin-top="auto"
          ButtonContent(id="ai-checkpoint-continue", label="Continue", variant="outline", size="sm", disabled=false, press=proceed)
            text "Continue" font-family=uiFontFamily(uiFont) data-rightui-font="body"

```
