Skip redundant auto-save when browsing between snapshots

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 <noreply@anthropic.com>
This commit is contained in:
2026-02-25 00:46:38 +01:00
parent e554dc9973
commit 73cde5ade1

View File

@@ -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;
if (!activeSnapshotId) {
const capturedId = await captureSnapshot("Current");
// captureSnapshot clears currentSnapshotId; restore or update it
currentSnapshotId = capturedId || prevCurrentId;
}
await withRestoreLock(async () => {
if (!validateSnapshotData(record.graphData)) {