Expand description
dayscript recording (docs/dayscript.md “Recording”, DESIGN §14.6): install a recorder that
captures the user’s taps, edits, selections, and navigation into a replayable dayscript.
day::record::{start, start_into, start_to_file, stop, is_recording, recording_signal, script, steps, save, clear, exclude_prefix}. A recorder also arms headlessly from day launch --record <file> (the DAY_RECORD env, honored inside day_script::init). What it records is an ordinary
dayscript, so it replays cross-toolkit through play_script or day launch -p <target> --script <file>.
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.