CockpitInteractionRecorder class final
Session engine for in-app interaction recording.
Owns the phase machine (idle → recording ⇄ paused → stopped), the
recorded step list, and the segment stack. The capture layer feeds
observed interactions through recordInteractionStep; the exclusion
registry it consults lives at exclusions. export converts the
recorded steps through CockpitRecordedFlowConverter and
CockpitTestDocumentYamlWriter; verifyReplay re-dispatches the
actionable steps through the live automation path with capture
suppressed.
Step-stamping contract: the capture layer builds a
CockpitInteractionStep with placeholder values for stepId (any
non-empty string, e.g. pending), phase, and segments, plus a
settledAfterMs of null. recordInteractionStep re-stamps those
fields with the authoritative engine state — monotonic s<n> id, the
recording phase, and the segment stack open at record time — so step
ids are always engine-assigned and steps always carry the context that
was active when they were captured.
- Inheritance
-
- Object
- ChangeNotifier
- CockpitInteractionRecorder
Constructors
- CockpitInteractionRecorder({DateTime now()?, CockpitTargetRegistry? registry, CockpitReplayIdleWaiter? waitForIdle, CockpitReplayGesturePerformer? gesturePerformer, String? routeNameProvider()?, CockpitViewportGeometryProvider? viewportGeometryProvider, int maxRecordedSteps = _defaultMaxRecordedSteps})
-
Creates a recorder. Pass
nowto inject a clock; defaults to the system wall clock.
Properties
- activeSession → CockpitInteractionRecordingSession?
-
The current session, or
nullbefore the first start. Kept after stop so the finished session stays inspectable until the next start replaces it.no setter - beforeStopHook ↔ void Function()?
-
Hook invoked at the top of stop, while the session is still in the
recordingorpausedphase — so a hook's recordInteractionStep calls land in the returned result. The text capture uses this to flush a still-focused field. A single slot: setting a new hook replaces the previous one,nullclears it.getter/setter pair - exclusions → CockpitRecorderExclusionRegistry
-
Subtree exclusion registry the capture layer consults per event.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- isReplaying → bool
-
Whether a verify-replay pass is currently executing. Capture feeds
must drop events while this is true — a replay must not re-record
itself.
no setter
-
openSegments
→ List<
String> -
The currently open segment labels, stack order (bottom first).
no setter
- phase → CockpitRecorderPhase
-
Current phase of the recording state machine.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sessionName → String?
-
Name of the current session, from the start request. The session
model carries no name, so the engine keeps it.
no setter
-
steps
→ List<
CockpitInteractionStep> -
The recorded steps of the current session, oldest first.
no setter
- stepsTruncated → bool
-
Whether the session hit
maxRecordedStepsand stopped accepting new steps. A truncated session is still replayable — the recorded prefix is intact — but later interactions were dropped rather than recorded.no setter
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
annotate(
String stepId, String note) → void -
Replaces CockpitInteractionStep.annotation on a recorded step.
Throws StateError for an unknown
stepId. -
beginSegment(
String label) → void -
Opens a segment label. Legal only while
recording. Segments nest; concurrent duplicate labels are allowed and each stays on the stack until its own endSegment pops it. Steps record the open labels in stack order, bottom first. -
discardLastStep(
) → void - Removes the most recently recorded step. Throws StateError when no step has been recorded.
-
dispose(
) → void -
Discards any resources used by the object.
inherited
-
endSegment(
) → void - Closes the most recently opened segment. Throws StateError when no segment is open.
-
export(
) → CockpitRecordedFlowBundle -
Builds the export bundle of the current session: the recorded steps,
the converted case document, and its YAML rendering. Legal while
recording,paused, andstopped— steps are retained until the next start. The case id derives from the engine-generated session id (recorded-r1,recorded-r2, …), which always satisfies the case id pattern by construction; the human-facing session name goes to the casename, not the id. -
markStepSettled(
String stepId, int settledAfterMs) → void -
Back-fills the settle time of a recorded step. Legal while
recordingorpaused(a settle watch started before a pause may complete after it). Throws StateError for an unknownstepIdor a step that is already settled. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
pause(
) → void -
Pauses the running session. Legal only while
recording. Capture is suppressed while paused;pausedAtrecords the latest pause. -
recordInteractionStep(
CockpitInteractionStep step) → void - Ingests a step captured by the capture layer.
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
resume(
) → void - Resumes a paused session.
-
sessionSnapshot(
) → CockpitInteractionRecordingSession -
A fresh CockpitInteractionRecordingSession view of the engine state
with recomputed
stepCountandunresolvedCount. -
start(
[CockpitInteractionRecordingRequest? request]) → void -
Starts a new session. Legal from
idleandstopped; resets the step list, step ids, and the segment stack. Session ids (r1,r2, …) stay monotonic across the recorder's lifetime. -
stop(
) → CockpitInteractionRecordingResult -
Stops the session. Legal while
recordingorpaused;stoppedis terminal until the next start. Returns the finished result. -
toString(
) → String -
A string representation of this object.
inherited
-
verifyReplay(
) → Future< List< CockpitReplayReport> > - Replays the actionable recorded steps in-process and reports the per-step outcome.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
isActionable(
CockpitInteractionStep step) → bool -
Whether
stepis replayable in-process: an actionable kind (tap,longPress,scroll,text) that resolved to at least one locator candidate. Everything else — non-actionable kinds and unresolved noise — reportsskippedduring verifyReplay. Public so the panel can derive its replay affordance from the same rule the engine enforces.