From c8b401f5638e6fdc2e80c63173be4266a27d7eea Mon Sep 17 00:00:00 2001 From: Michael B Reiser Date: Mon, 1 Jun 2026 09:27:43 -0400 Subject: [PATCH] fix(v3): clear dirty flag when undo returns to a saved state (v0.19) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The undo/redo snapshots captured text + selection but not the `dirty` flag, so undoing the only edit left "● edited" showing even though the document matched what was loaded. Snapshot `dirty` too (pushUndo captures pre-mutation state, so the snapshot records the correct pre-edit value) and restore it in restoreSnapshot. Undo back to the loaded state now clears the indicator; redo re-asserts it; undoing one of several edits keeps it (edits remain). Footer v0.18 → v0.19. npm test green (arena 10 · v2 137 · v3 576); browser-verified the load/edit/undo/redo/partial-undo indicator states. Co-Authored-By: Claude Opus 4.8 (1M context) --- experiment_designer_v3.html | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/experiment_designer_v3.html b/experiment_designer_v3.html index b327de0..cfb16c4 100644 --- a/experiment_designer_v3.html +++ b/experiment_designer_v3.html @@ -1332,7 +1332,7 @@

v3 Experiment Designer

@@ -1457,7 +1457,11 @@

Import error

if (!experiment || !experiment._doc) return null; return { text: experiment._doc.toString(), - selection: selection ? JSON.parse(JSON.stringify(selection)) : null + selection: selection ? JSON.parse(JSON.stringify(selection)) : null, + // Capture the dirty flag too, so undoing back to the loaded state + // clears "● edited" (and redo re-asserts it). pushUndo snapshots + // BEFORE the mutation, so this records the pre-edit dirty value. + dirty: dirty }; } @@ -1479,6 +1483,7 @@

Import error

try { experiment = parseV3Protocol(snap.text); selection = snap.selection; + setDirty(!!snap.dirty); renderAll(); } catch (err) { showError('Undo/redo restore failed', err.message);