You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Workflow redo does not apply an empty-graph snapshot (deleted last node reappears) #45442
Undo/redo skips history snapshots that contain an empty graph. If you delete the last node, undo, and then redo, the node stays on the canvas even though the history pointer has moved forward.
Where
web/app/components/workflow/hooks/use-nodes-interactions.ts (verified on main at fbc33cae43):
handleHistoryForward (~L2363-2375): calls redo(), then if (edges.length === 0 && nodes.length === 0) return before setEdges/setNodes.
handleHistoryBack (~L2341-2353) has the same guard after undo().
Steps to reproduce
Create a workflow whose canvas has a single deletable node, for example only the Start node.
Select the node and delete it. The canvas is now empty.
Undo (Ctrl/Cmd+Z). The node comes back, as expected.
Redo (Ctrl+Y / Cmd+Shift+Z).
Expected
The redo re-applies the delete and the canvas is empty again.
Actual
The history store moves forward to the empty snapshot, but the early return means the canvas is never updated, so the node is still shown. Canvas and history are now out of sync, and the next undo/redo steps operate on the wrong baseline. The same guard in handleHistoryBack probably prevents undoing back to an empty-graph snapshot as well.
Suggested fix
Remove the empty-graph early return, or use a distinct sentinel for "no snapshot" so that a real empty graph is still applied (including the collaboration broadcast).
How this was found
This came up during the web test cleanup (#44381), when web/app/components/workflow/shortcuts/__tests__/workflow-canvas.spec.tsx was rewritten to assert the live canvas after undo/redo instead of only the history store. The regression in that spec keeps an unrelated node on the canvas to avoid this case. A test for the empty-graph redo should be added together with the fix.
One detail for the regression test: history capture is debounced by 500 ms, so wait for the deletion snapshot to reach history before issuing undo. The existing canvas spec already does this by waiting for pastStates to have length 1. That avoids testing a pending history write instead of the empty-snapshot behavior. [1][2]
A complementary case would start empty, add a node, then undo back to empty. That exercises handleHistoryBack independently of the reported redo sequence, since both handlers contain the same guard. [3]
Activity
dosubot commentedon Nov 3, 2026
One detail for the regression test: history capture is debounced by 500 ms, so wait for the deletion snapshot to reach history before issuing undo. The existing canvas spec already does this by waiting for
pastStatesto have length 1. That avoids testing a pending history write instead of the empty-snapshot behavior. [1] [2]A complementary case would start empty, add a node, then undo back to empty. That exercises
handleHistoryBackindependently of the reported redo sequence, since both handlers contain the same guard. [3]To reply, just mention @dosu.
Share context across your team and agents. Try Dosu.