fix: remove skipHistoryRef that silently drops history entry after undo/redo

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>
This commit is contained in:
Devin AI
2026-04-18 17:41:32 +00:00
parent ce481fd2c1
commit 81506c63ec

View File

@@ -104,17 +104,13 @@ export default function App() {
const [historyState, dispatchHistory] = useReducer(historyReducer, { entries: [{ nodes: [], edges: [] }], index: 0 });
const history = historyState.entries;
const historyIndex = historyState.index;
const skipHistoryRef = useRef(false);
const pushHistory = useCallback((n: Node[], e: Edge[]) => {
if (skipHistoryRef.current) { skipHistoryRef.current = false; return; }
dispatchHistory({ type: 'push', nodes: n, edges: e });
}, []);
const undo = useCallback(() => {
const entry = historyState.entries[historyState.index - 1];
if (!entry || historyState.index <= 0) return;
skipHistoryRef.current = true;
dispatchHistory({ type: 'undo' });
setNodes(JSON.parse(JSON.stringify(entry.nodes)));
setEdges(JSON.parse(JSON.stringify(entry.edges)));
@@ -123,7 +119,6 @@ export default function App() {
const redo = useCallback(() => {
const entry = historyState.entries[historyState.index + 1];
if (!entry || historyState.index >= historyState.entries.length - 1) return;
skipHistoryRef.current = true;
dispatchHistory({ type: 'redo' });
setNodes(JSON.parse(JSON.stringify(entry.nodes)));
setEdges(JSON.parse(JSON.stringify(entry.edges)));