Skip to content

feat(studio): undo/redo and dirty-state indicator#38

Merged
LeadcodeDev merged 1 commit into
mainfrom
feat/studio-undo
Jul 18, 2026
Merged

feat(studio): undo/redo and dirty-state indicator#38
LeadcodeDev merged 1 commit into
mainfrom
feat/studio-undo

Conversation

@LeadcodeDev

Copy link
Copy Markdown
Owner

Closes #14.

Goal: studio edits become recoverable and unsaved state visible.

  • History: pure bounded stacks (64) of whole-file snapshots — uniform JSON/HTML — recorded only on effective post-debounce disk writes (perform_write now reports whether it wrote); JSON annotation writes join the linear history; new edits clear redo
  • Reload-proof: stacks live in an app-global slot (export-slot pattern); the watcher replaces the model, never the slot; lazy reset on file switch; reloads never push, so an undo-induced reload isn't captured as an edit
  • Undo/redo = disk rewrite with PR fix(studio): surface write/reload errors, restore debounce, avoid mutex poisoning #30 guarantees; a failed write rolls the stacks back exactly
  • Keyboard: Cmd/Ctrl+Z, Shift+Cmd/Ctrl+Z on the focused root; the inspector subtree stops propagation so inputs/textareas keep native text undo; topbar Undo/Redo buttons (disabled on empty stacks) + "Saving…" indicator during the debounce window
  • Known v1 limits (documented in code/report): HTML annotation sidecar writes are not undoable; an undo raced against a pending 250ms debounced write can be overwritten by it

Tests: 8 new (TDD): cap/eviction, redo invalidation, empty-stack no-ops, roundtrip, path-switch reset, plus model-level integration on temp files (undo rewrites file, redo restores). 198 total, all green.

Verify: cargo check -p rustmotion-studio ✓ · cargo test --workspace → 198 passed ✓ · cargo fmt --check ✓ · clippy 0 warnings ✓

- History: bounded (64) undo/redo stacks of whole-file snapshots
  (uniform for JSON and HTML sources), captured on effective disk
  writes only (post-debounce; no-op writes excluded); new edits clear
  the redo stack
- App-global slot survives watcher reloads (the model is replaced,
  the slot is not); lazy reset on file switch; reloads never push
- Undo/redo rewrite the source file and let the watcher reload; a
  failed write rolls the stacks back exactly and surfaces write_error
- Cmd/Ctrl+Z and Shift+Cmd/Ctrl+Z at the StudioApp root; the
  inspector subtree stops propagation so text fields keep their
  native undo; topbar gains Undo/Redo buttons and a Saving indicator
@LeadcodeDev
LeadcodeDev merged commit 56c5fc7 into main Jul 18, 2026
@LeadcodeDev
LeadcodeDev deleted the feat/studio-undo branch July 18, 2026 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(studio): undo/redo and dirty-state indicator

1 participant