Flow Studio
Stack Depth Limits
The undo stack is capped at HISTORY_STACK_SIZE entries (default: 50). When the cap is reached, the oldest entry is dropped. Each entry holds a deep copy of the nodes and edges arrays — memory cost scales with workflow size.
Stack Size Configuration
// historyMiddleware.ts
export const HISTORY_STACK_SIZE = 50; // configurable at build time
// Applied when pushing to the undo stack:
const newUndoStack = [snapshot, ...undoStack].slice(0, HISTORY_STACK_SIZE);
// When the stack reaches 50:
// Entry 51 causes entry 1 (oldest) to drop off the end
// Users cannot undo beyond 50 actions
Memory Implications
| Factor | Impact |
|---|---|
| Stack size | 50 entries max |
| Snapshot content | Deep copy of nodes[] + edges[] (JSON serializable) |
| Typical workflow | 20 nodes × ~2KB each × 50 entries ≈ 2MB (acceptable) |
| Large workflow (200 nodes) | 200 × ~2KB × 50 = ~20MB — monitor memory usage |
| Redo stack | Clears on new action — does not accumulate |
Adjusting Stack Size
// For memory-constrained environments or very large workflows:
// Reduce HISTORY_STACK_SIZE in historyMiddleware.ts
// For power users working on complex designs who need more history:
// Increase HISTORY_STACK_SIZE (be aware of memory usage)
// There is no runtime API to change stack size — it is a build-time constant
// A future enhancement could make it a user preference (stored in tenant settings)
History is Session-Only
The undo/redo stacks exist only in memory for the current browser session. Refreshing the page clears all history — the workflow loads from the server at the last saved state. This is intentional: cross-session history would require significant server-side storage and adds complexity around merge conflicts.
History also clears on loadWorkflow. When the user opens a different workflow or reloads the current one (e.g., discarding unsaved changes),
loadWorkflow calls deserializeWorkflow which resets the history stacks. The user starts fresh on each load.