pub fn encode_event(event: &UiEvent) -> StringExpand description
Encode one UiEvent as a single JSON object (no trailing newline —
the stream writer adds \n). Encoding cannot realistically fail for
our derived Serialize; if it ever does, fall back to an error line
so the stream stays valid JSONL.