Add per-edit undo: revert one change before it ships - #21
Open
samschwartzfh wants to merge 1 commit into
Open
Conversation
Every edit row in the sidebar gets an undo button while the change is still undoable: the SDK keeps a per-document registry (element refs, detached nodes, original positions) keyed by a per-block cid, reverts the DOM in-place preserving element identity, and the row is dropped server-side only after the frame confirms. Deleting a block also offers an immediate 'Deleted X — Undo' toast. - edit rows carry a durable server id and the block's cid; dedup is cid-first with a boot-timestamp-gated label+kind fallback, so two live blocks sharing a label stay separate rows while reloads keep one row - DELETE /api/page/:key/edit/:id undoes a single row - undo is offered only for rows the live frame advertises as revertible (eh:undoable), never while a batch is pending; on feedback-only pages (markdown, localhost, self-rendering) undo is row-removal - strict transaction order (purge queue -> revert -> save -> remove row) so a debounced flush can never resurrect an undone row - agent-facing batches are unchanged Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
This looks great! Can one also edit individual comments? That's my biggest wishlist item. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Reviewing a long page, it's easy to make several changes between sends and then want just one of them back. Today the only recovery is Revert all, and Ctrl+Z can't see a chip-deleted block (it's removed via JS, outside the browser's undo stack). This PR adds per-edit undo, plus an immediate "Deleted ⟨block⟩ — Undo" toast for the most common accident.
What it does
Design notes
eh:undoable); the chrome renders ↩ only for those (rows persisted from before a reload just don't get a button), and never while a batch is sent/pending — undoing a row the agent already holds would desync the two.eh:undone), so the 500ms edit flush can never resurrect an undone row.idand the block'scid. Dedup is cid-first with a boot-timestamp-gated label+kind fallback: two live blocks that share a label stay separate rows, while a reloaded frame's fresh cid still merges into the block's existing row.collectPagesships the same fields as before (there's a test asserting noid/cidleak).Testing
test/undo.test.js: store ids, cid dedup semantics,DELETE /api/page/:key/edit/:id, agent-contract cleanliness — all green alongside the existing suite.🤖 Generated with Claude Code