Skip to content

v0.3.1 — Preview mode with commit ✓ and cancel ↺

Choose a tag to compare

@dgutierrezd dgutierrezd released this 05 Apr 02:27

Every style edit made on a selected component is now held in a server-side preview buffer until you explicitly commit or cancel. Experiment freely — no more polluted undo history or accidental git diffs.

New preview flow

Button Action
Commit Consolidates all preview edits into a single undo entry labeled "preview (N edits)", then re-arms the buffer for the next round
Cancel Writes the original file content back to disk verbatim — as if nothing ever happened. No undo stack pollution.

A lime "Preview" pill badge appears next to the component name while the buffer has unsaved edits. The buttons replace the regular ↶ ↷ undo/redo pair only while a preview is pending.

Safety rails

  • Switching components auto-commits the current preview so edits survive.
  • Closing the panel or toggling the bubble off auto-commits.
  • Disconnecting (app reload, server restart) auto-cancels any in-flight preview so a stale buffer can never leak across sessions.

Why this matters

Preview writes still hit the disk so Metro Fast Refresh can visually show the change. But because the edit is held OUT of the undo stack until commit:

  • If you cancel, your file is pristine. No entry to clean up.
  • If you commit, you get ONE consolidated undo entry covering all the tweaks you made in that session — not 20 separate ones.
  • Your git diff stays clean across experimentation.

Install

```bash
npm install rn-studio@0.3.1
```

Tested end-to-end with four scenarios:

  • Cancel after 3 edits → file reverts exactly, undo stack untouched ✓
  • Commit after 3 edits → single "preview (3 edits)" entry ✓
  • Undo committed preview → all 3 edits reverted in one go ✓
  • Empty commit → no-op, no entry created ✓