1. Per-tab history: Changed reducer from single HistoryState to
Record<string, HistoryState> keyed by tab ID. Undo/redo now
only affects the active tab. Creating a new tab initializes
its own history; closing a tab cleans up its history.
2. Stale closure fix: onDropComponent, onConnect, deleteSelectedNodes,
and duplicateSelectedNodes now use setTransactionTabs directly to
read both nodes and edges from the same state snapshot, preventing
inconsistent history entries.
3. Zoom animation: handleZoomIn/handleZoomOut now use .then() on the
zoomIn()/zoomOut() promises to read the zoom level after animation
completes, preventing stale zoom display.
Co-Authored-By: Nakamoto, S <defi@defi-oracle.io>
skipHistoryRef was set to true in undo/redo but never consumed during
those operations (setNodes/setEdges update transactionTabs directly
without calling pushHistory). The ref stayed true indefinitely, causing
the next user action's pushHistory call to silently skip recording,
breaking the undo chain.
Since pushHistory is never called during undo/redo operations, the
skip guard serves no purpose. Removed entirely.
Co-Authored-By: Nakamoto, S <defi@defi-oracle.io>
Fixes two bugs identified by Devin Review on PR #1:
1. History index goes out of bounds (50) when entries exceed the
50-entry cap, causing the first undo to be a silent no-op.
The shift() removed an entry but the index still incremented
past the array bounds.
2. pushHistory uses stale historyIndex closure value inside
setHistory's functional updater, causing entries to be silently
dropped when multiple pushHistory calls are batched by React.
Fix: Combine history entries and index into a single useReducer
state so both are always updated atomically. Add 'reset' action
for new transaction tab creation.
Co-Authored-By: Nakamoto, S <defi@defi-oracle.io>