Expand description
The dayscript recorder and in-process playback (§14.6): capture the events an app
receives back into a replayable dayscript, and replay one against the live UI. See
record::start/record::play.
The dayscript recorder (DESIGN.md §14.6): the inverse of playback. Where the engine turns a
script into synthesized Day events, the recorder turns the events an app actually receives back
into a script. It rides one seam — [day_core::set_event_observer], the single point EVERY
backend funnels its native events through ([day_core::enqueue_events]) — so it needs no
per-toolkit code, and it emits an ordinary dayscript that replays cross-toolkit through the same
executor as any hand-written one.
Scope is deliberately narrow: actions only, and only where the step is portable. A tap, a
text edit, a selection/toggle, a navigation, a back — the id-addressed things a walkthrough is
made of. Positional taps, gestures, slider drags, and native OS chrome are dropped (see
[event_to_step]); the resulting script is a starting point to edit, not a pixel-exact replay.
Everything here is main-thread state (the observer only ever runs on the main thread, where
day-core dispatches). On wasm there is no in-process playback (play) — the WebSocket
transport drives the page instead (docs/web.md).
Functions§
- annotate_
yaml - Like
steps_to_yaml, but each step’s identifying line carries a trailing# "label"comment naming the control it came from (§14.6) — its accessibility label, or its visible text. The comment sits on theid:line for a tap/input/select and theroute:line for a navigate, so a reader seesroute: focus # "Focus". Comments are ordinary YAML, so an annotated script parses and replays exactly as the bare one does; this is the form the recorder streams and saves. - clear
- Discard the recorded steps (recording, if live, continues from empty). Mirrors the emptied script into any live sink.
- exclude_
prefix - Skip events whose element id starts with
prefix— set it to the id prefix an app gives its own record/stop/play controls so they never record themselves. Set beforestart*. - is_
playable - Whether
yamlis a non-empty, parseable script — what a Play button binds its enabled state to. - is_
recording - Whether a recording is currently live.
- play
- Play a dayscript in-process (§14.6): parse
yamland run each step through the SAME executor the socket runner uses ([crate::run_step_with_wait]), on a spawned thread that dispatches each step to the main thread and awaits its reply — mirroring the engine’s connection loop. Returns as soon as the run is dispatched (the steps then run asynchronously against the live UI). Refuses while a recording is live, so a replay never records itself. - play_
with_ delay - Play with an artificial pause (seconds) between each step — a slow-motion replay for watching a
script drive the UI. Returns
ErrWITHOUT spawning when the script is empty or does not parse, so a UI can call it to validate (seeis_playable) and to run from one path. - recording_
signal - The reactive recording flag:
truewhile recording. Bind a control’s label/style to it (the showcase’s Record↔Stop button does). The same global handle every call, so reads from any page track the one signal. - save
- Write the recorded script to
path. - script
- The recorded script as canonical dayscript YAML (
steps_to_yaml);flow: []when empty. - start
- Start recording into memory only (read it back with
script/steps/save). - start_
into - Start recording, mirroring the script text into
sigon every event — the streaming, editable buffer an app binds atext_areato. Called again while already recording, it re-targets the stream atsig(keeping the recording so far) rather than restarting — what a page needs after it was disposed and rebuilt mid-recording. - start_
to_ file - Start recording, continuously flushing the script to
path— howDAY_RECORD/day launch --recordcapture headlessly. Crash-resilient: the file holds everything up to the last event even if the app is killed. - steps
- The recorded steps, cloned.
- steps_
from_ yaml - Parse the canonical on-disk dayscript form back into steps — the inverse of
steps_to_yaml. - steps_
to_ yaml - Serialize steps to the canonical on-disk dayscript form — a
flow:document of- <op>: { <params> }entries (§14.1), byte-compatible with the file day-cli’sparse_flowreads. EachStepserializes to its internal-op-tag map ({op: tap, id: inc, …}); this lifts theopout to become the entry key and drops null-valued optional params, then serde_norway renders the whole{flow: […]}document as YAML. - stop
- Stop recording and remove the observer. The captured script is kept (read it with
script/steps/save, or resume with astart*). - version
- A counter that increments each time a step is recorded (or the recording is cleared). A UI can watch it to react to recording progress — a live step count, say — without owning the mirrored buffer signal. Global-scoped, so it survives page rebuilds.