# AI undo history

> A line in the project’s history for every machine proposal a person used: what changed, from what, who accepted it, and Undo.

Source: https://kwark.space/designSystem/components/ai-undo-entry

## Usage

### What it is
Kwark already keeps work recoverable: the screenplay saves a snapshot of the writer’s version before loading a newer one, and characters keep a history. The AI undo entry is the line that history shows for a machine proposal someone used: the change in plain words, the provenance (*Suggested · from your outline, Act 2*), who used it and when, and two actions: **See changes** (reopens the [review](https://kwark.space/designSystem/components/ai-review.md) read-only) and **Undo**.

### Undo
Undo restores exactly what was there before the accepted changes, and itself becomes a history line (*Undid 3 scene headings*). If later edits touched the same words, Undo shows the review first so the person chooses what to restore.

### When to use
- For every machine proposal a person used, in the module’s history and the project’s.

### When not to use
- For dismissed or rejected proposals: they never touched the work, so they leave no entry.

### Writing
Past tense, the object, the count: *3 scene headings added*. Then provenance, the person, the time.

## Style

### Anatomy

1. **Entry**: 12px 0, 1px `--k-line` between entries.
2. **Mark column**: 16px; an asterisk in `--k-rev` on `--k-rev-bg` for AI entries, empty for people’s.
3. **Text**: 14px 500 summary; 12px `--k-text-2` provenance line.
4. **Actions**: *See changes* as a text button, *Undo* small secondary.

### Tokens

| Token | Light | Dark |
|---|---|---|
| `--k-line` | #e2e8f0 | rgba(255, 255, 255, .1) |
| `--k-text` | #0f172a | #e3e3e3 |
| `--k-text-2` | #5b6779 | #9ca3af |
| `--k-rev` | #346a58 | #9fd4bf |
| `--k-rev-bg` | #e4f1eb | #1b2b25 |
| `--k-fs-body` | 14px |  |
| `--k-fs-meta` | 12px |  |

## Code

### React

Use the HTML below with `kwark.css`. The example shows the markup and styling. Supply any application behavior described on this page.

### HTML and CSS

Works anywhere with `kwark.css`.

```html
<ol class="kw-history" aria-label="History of Scene 12">
  <li class="kw-history__entry kw-history__entry--ai"><span class="kw-history__mark" aria-hidden="true">*</span><span class="kw-history__text"><b>3 scene headings added</b><small>Suggested · from your outline, Act 2 · used by Mira · 16 Nov, 14:20</small></span><span class="kw-history__acts"><button class="kw-text-button" type="button"><span>See changes</span></button><button class="kw-button kw-button--sm" type="button"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 14 4 9l5-5"/><path d="M4 9h10.5a5.5 5.5 0 0 1 0 11H11"/></svg> Undo</button></span></li>
  <li class="kw-history__entry"><span class="kw-history__mark" aria-hidden="true"></span><span class="kw-history__text"><b>Scene 12 edited</b><small>Mira · 16 Nov, 13:05</small></span></li>
</ol>
```

## Accessibility

### Keyboard
| Key | Does |
|---|---|
| Tab | See changes, then Undo, for each AI entry. |
| Enter | Runs it. |

### ARIA
- An ordered list named for its scope. The asterisk is `aria-hidden`; the provenance text says *Suggested from your outline*.
- After Undo, announce *Undone. 3 scene headings removed.*

## For agents

### Rules

- **Must** record every used machine proposal with its source, who used it and when.
- **Must** offer Undo that restores the exact prior text, and record the Undo itself.
- **Never** record rejected or dismissed proposals as changes.
- **Always** show the review before an Undo that would overwrite later edits.

### AI readiness test

**Task:** Let Mira undo yesterday's prop tags that Kwark found in the script and she added after she has edited two of them.

**Give the agent:** This page, AI result review, Decision 0013.

**Constraint:** Two of the six tags were edited by Mira after acceptance.

**A reliable answer:**
- Opens the review first, showing the two edited tags separately
- Restores only what Mira chooses
- Records "Undid 4 prop tags" in history
