From e29e7dfad1281a5954058819815a2676019f20ab Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Fri, 27 Feb 2026 11:48:45 +0100 Subject: [PATCH] Add capture-in-progress guard to prevent duplicate snapshots Concurrent captureSnapshot calls (e.g. manual Ctrl+S overlapping a debounced auto-capture) could both pass the hash check before either sets the hash, creating duplicates. A simple boolean flag now ensures only one capture runs at a time. Co-Authored-By: Claude Opus 4.6 --- js/snapshot_manager.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/js/snapshot_manager.js b/js/snapshot_manager.js index 1c4b80b..b23c845 100644 --- a/js/snapshot_manager.js +++ b/js/snapshot_manager.js @@ -1411,8 +1411,16 @@ async function showPreviewModal(record) { // ─── Snapshot Capture ──────────────────────────────────────────────── +let captureInProgress = false; + async function captureSnapshot(label = "Auto") { if (restoreLock) return false; + if (captureInProgress) return false; + captureInProgress = true; + try { return await _captureSnapshotInner(label); } finally { captureInProgress = false; } +} + +async function _captureSnapshotInner(label) { const graphData = getGraphData(); if (!graphData) return false;