Portal Community

Tracked Action List

ActionSnapshot CapturesUndo Restores
addNodenodes before addNode is removed
removeNodenodes + edges before removeNode + connected edges restored
moveNodenode position before moveNode returns to previous position
renameNode (via updateNode)node label before renameLabel reverts
addEdgeedges before addEdge is removed
removeEdgeedges before removeEdge is restored

Composite Operations

Some user actions result in multiple store mutations — these are grouped into a single history entry:

// removeNode: removes the node AND all its connected edges atomically
// This is a single history entry — one Ctrl+Z restores both the node and its edges

removeNode: (id) => {
    get().historyAction(() => {
        set(state => ({
            nodes: state.nodes.filter(n => n.id !== id),
            edges: state.edges.filter(e => e.source !== id && e.target !== id)
        }));
        // nodes AND edges updated in one set() call → one history entry
    });
}

What a Snapshot Contains

// History snapshots capture only nodes and edges — not viewport or selection
type HistorySnapshot = {
    nodes: WorkflowNode[];  // Deep copy (JSON.parse(JSON.stringify(...)))
    edges: WorkflowEdge[];  // Deep copy
};

// Viewport and selectedNodes are NOT captured:
// - Viewport changes are not undoable
// - Selection is a transient UI state — restoring it after undo would be confusing
updateNode is not globally tracked. Only the rename operation (updating node label) pushes to history. Config field changes (actorId, timeoutDuration, etc.) are auto-saved directly and do not enter the undo stack — they go through the persistence middleware, not historyAction.