From 73cde5ade100451da6134c0a2cfd3b5e0fa40c10 Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Wed, 25 Feb 2026 00:46:38 +0100 Subject: [PATCH] Skip redundant auto-save when browsing between snapshots MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When activeSnapshotId is set, the current graph state is already a saved snapshot. Swapping to another one no longer creates a duplicate "Current" entry — the auto-save only fires on the first swap away from an unsaved graph state. Co-Authored-By: Claude Opus 4.6 --- js/snapshot_manager.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/js/snapshot_manager.js b/js/snapshot_manager.js index fa50440..9059c80 100644 --- a/js/snapshot_manager.js +++ b/js/snapshot_manager.js @@ -544,11 +544,13 @@ async function restoreSnapshot(record) { } async function swapSnapshot(record) { - // Auto-save current state before swapping (so user can get back) + // Auto-save current state before swapping (so user can get back), + // but skip if the graph is already a saved snapshot (browsing between old ones) const prevCurrentId = currentSnapshotId; - const capturedId = await captureSnapshot("Current"); - // captureSnapshot clears currentSnapshotId; restore or update it - currentSnapshotId = capturedId || prevCurrentId; + if (!activeSnapshotId) { + const capturedId = await captureSnapshot("Current"); + currentSnapshotId = capturedId || prevCurrentId; + } await withRestoreLock(async () => { if (!validateSnapshotData(record.graphData)) {