Concatenated forwardOps of every undo-stack entry, in order. Snapshot of "what changes are currently applied via this history" — useful for Journal.commit to flush to a parent, and for any caller that wants to diff against a baseline.
Optionallabel: stringOpen a scoped sub-history. All apply/undo/redo on the returned Journal affect the same adapter; on commit, the Journal's net forward ops are flushed to this History as one entry. See spec docs/superpowers/specs/ 2026-05-24-modality-design.md for the full lifecycle.
The id that will be assigned to the next pushed entry. Stable monotonic counter; callers use it to tag a fork point (see Journal).
Snapshot of the current undo + redo stacks. undo is oldest→newest
(i.e. the last element is what undo() would pop next); redo is
also oldest→newest from the user's perspective (i.e. the first
element is what redo() would pop next — see implementation note).
Callers should treat the arrays as immutable.
Monotonic counter bumped on every push/undo/redo/clear/coalesce. Cheap to read; callers use it as a React dep to detect changes.
Walk the history forward/back until exactly n entries are on the
undo stack (0 ≤ n ≤ entries().undo.length + entries().redo.length).
Equivalent to repeated undo()/redo() calls but doesn't bother
rebuilding entry snapshots between steps. No-op if already at n.
Push an entry whose ops have already been applied to the adapter.
Unlike applyOps, does NOT call op.apply(). Used by Journal.commit
to flush a session's net forward ops to the parent as one entry without
re-mutating the scene.
Number of entries on the redo stack (O(1)).
Replace the current undo + redo stacks with the deserialized contents
of snapshot. Ops are rebuilt via the rebuildOp option when
provided, then the global registry; unknown names become no-op
placeholders so stack ordering survives across kit-version skew.
Bumps version and notifies subscribers exactly once.
Re-activate a suspended journal. Throws if the journal was committed or
cancelled (those are terminal). Staleness checking is the caller's
responsibility — consult journal.forkedAtEntryId against
currentEntryId() and your own op-semantic rules to decide whether
to resume or discard before calling this.
Snapshot the undo + redo stacks in a structured-clone-safe form.
Entries whose ops aren't all kit-registered (i.e. any op missing a
name) are dropped from the snapshot with a debug-level log — they
can't round-trip, so we omit them rather than emit a half-restorable
entry. The in-memory stacks aren't modified.
Subscribe to history changes. Fires after every push/undo/redo/ clear/coalesce. Returns an unsubscribe fn.
Number of entries on the undo stack (O(1); entries().undo.length
without materializing the views).
Op-batched undo/redo controller returned by
createHistory.