# Checkpoints and restore

Let a person go back to an earlier point in a run, knowing what going back does and doesn't undo.

For: Anyone whose agent changed files or data and got it wrong.

Web page: https://candor.themethodic.com/screens/checkpoints-and-restore

## Layouts

### Points in the thread

Pick it when: Coding or editing agents: each turn is a point the person can return to.

Layout: A thread with a restore point marked beside each turn and the current one highlighted.

Items:

- **Checkpoint list** (`checkpoint-list`, Pro; https://candor.themethodic.com/docs/checkpoint-list.md): Restore points in a run, one per turn, with what each holds and where the person is now.
- **Thread divider** (`thread-divider`, free; https://candor.themethodic.com/docs/thread-divider.md): A rule across the thread labelling a point.
- **Restore dialog** (`restore-dialog`, Pro; https://candor.themethodic.com/docs/restore-dialog.md): Restores code, the conversation or both, and says what a restore doesn't undo.

```bash
npx candor-ui add checkpoint-list thread-divider restore-dialog
```

### List in a side panel

Pick it when: Long runs with many points, where a list with search and detail is easier than the thread.

Layout: The thread on the left and a side panel with a list of restore points on the right.

Items:

- **Side panel** (`side-panel`, Pro; https://candor.themethodic.com/docs/side-panel.md): One tab per open item, each closable.
- **Checkpoint list** (`checkpoint-list`, Pro; https://candor.themethodic.com/docs/checkpoint-list.md): The points.
- **Version history** (`version-history`, Pro; https://candor.themethodic.com/docs/version-history.md): The same idea for something editable, such as an agent's settings.

```bash
npx candor-ui add side-panel checkpoint-list version-history
```

### Confirm in a dialog

Pick it when: Always, before the restore happens: it names what comes back and what stays.

Layout: A dialog over the thread with two choices (code, conversation) and a restore button that waits to be held.

Items:

- **Restore dialog** (`restore-dialog`, Pro; https://candor.themethodic.com/docs/restore-dialog.md): What a restore undoes and what it doesn't, and what the app can check afterwards.
- **Hold to confirm** (`hold-to-confirm`, Pro; https://candor.themethodic.com/docs/hold-to-confirm.md): For a restore that discards work.
- **Undo window** (`undo-window`, Pro; https://candor.themethodic.com/docs/undo-window.md): Undo, for as long as it can honestly be offered.

```bash
npx candor-ui add restore-dialog hold-to-confirm undo-window
```

## Rules that matter most here

- **Say what can and can't be undone** (https://candor.themethodic.com/principles#say-what-can-be-undone): The restore dialog lists what a restore does not undo, such as an email already sent.
- **Unknown stays unknown** (https://candor.themethodic.com/principles#unknown-stays-unknown): After a restore, what couldn't be checked is shown as not checked, not as restored.
- **Nothing is pre-selected in a decision** (https://candor.themethodic.com/principles#nothing-preselected): Code, conversation or both starts unchosen.

## Brief for a coding agent

Paste this to the agent that builds the screen.

```text
Build checkpoints and restore with Candor UI: a person can go back to an earlier turn of a run.
List the points with CheckpointList, one per turn, saying what each holds and which one the person is at now.
Restore through RestoreDialog: the person chooses code, conversation or both (unchosen to start), and the dialog says what a restore doesn't undo.
After the restore show RestoreResult with what the app checked; anything it couldn't check says "not checked".
For a restore that throws work away, use HoldToConfirm; offer UndoWindow only for as long as your server allows an undo.
Restoring files is your server's job; the components show the choice and the outcome.

Start from the "Points in the thread" layout: A thread with a restore point marked beside each turn and the current one highlighted.
Candor items: checkpoint-list (https://candor.themethodic.com/docs/checkpoint-list.md), thread-divider (https://candor.themethodic.com/docs/thread-divider.md), restore-dialog (https://candor.themethodic.com/docs/restore-dialog.md).
Install: npx candor-ui add checkpoint-list thread-divider restore-dialog
Read each item's docs before using it and take its props from there; don't guess them. Pro and Premium items need the person's licence key, which they add with `npx candor-ui key <key>`; don't ask for it.
```
