Core 1.0.0-rc.1
Navigation Commit Logic
Source file: packages/core/src/journey-machine/navigation.ts
This file owns the actual snapshot commits for movement.
It does not choose which transition wins. That work lives in send.ts. Once a target is known, navigation turns
that decision into a new snapshot and the right lifecycle events.
How It Works
applyPreviousNavigation(...)moves the history pointer backward without destroying the existing timeline. It normalizes the requested step count, emitsstep.exit, commits the new snapshot with reason"navigation", emitsnavigation.previous, then emitsstep.enter.applyLastVisitedNavigation(...)jumps the pointer to the realized tail of the timeline. This is useful when a user inspected an older point and should return to the current tail.commitTerminalTransition(...)keeps the realized timeline up to the current pointer, updates status to"completed"or"terminated", and emitsjourney.completedorjourney.terminated.commitStepTransition(...)validates the target step, emitsstep.exitwhen the current step changes, commits the next snapshot, emitstransition.success, and finally emitsstep.enter.
Headless goToStepById(...) navigation also lands here. send.ts decides when a direct jump is allowed, then
delegates the actual snapshot write to commitStepTransition(...).
The key design is that history is a realized path plus a pointer, not just a current index into the authored step registry. That is what lets Journey model non-linear flows without losing what actually happened.
Recommended Reading
- Read Send Pipeline for transition selection and fallback rules.
- Read Helpers for
transitionSnapshot(...)and snapshot-building utilities. - Read History for the public explanation of the timeline model.
- Read Snapshot if you want the exact shape this file commits.