Undo Stack
Per-document undo / redo stack used by the editor's master-pane operations (Add, Clone, Remove, Reorder, Enable/Disable, Rename per scenario workflow §6 — and any other reversible action). Bounded by limit (default 20 per §6); pushing past the cap discards the oldest entry.
The stack is caller-applies: the editor performs the user's change first, then pushes an operation that knows how to undo and redo it. This keeps the stack decoupled from the editor's data model — any reversible change shape works, not just scenarios-list ops.
Calling push clears the redo branch — a new edit after some undo invalidates the future the user diverged from. Calling clear empties both stacks (typically on document close).
Thread-safety: the underlying MutableStateFlow is safe for concurrent reads, but mutating methods are not synchronised. In practice the editor view-model is the sole mutator and lives on the Swing EDT.
Properties
Functions
Records operation on the undo stack. The caller is expected to have already applied the change. Pushing always clears the redo branch. If the stack is at limit, the oldest entry is dropped to make room.