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:
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user