Skip to main content

Module record

Module record 

Source
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 the id: line for a tap/input/select and the route: line for a navigate, so a reader sees route: 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 before start*.
is_playable
Whether yaml is 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 yaml and 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 Err WITHOUT spawning when the script is empty or does not parse, so a UI can call it to validate (see is_playable) and to run from one path.
recording_signal
The reactive recording flag: true while 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 sig on every event — the streaming, editable buffer an app binds a text_area to. Called again while already recording, it re-targets the stream at sig (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 — how DAY_RECORD / day launch --record capture 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’s parse_flow reads. Each Step serializes to its internal-op-tag map ({op: tap, id: inc, …}); this lifts the op out 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 a start*).
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.
Day API ↩ Guides· daybrite.dev