Issue #166: snapshot --script exits non-zero when a scripted request fails

`fn snapshot` wrote every reply but never looked at `ok`, so a script with a
bad `ui.set`, an unknown command or a failed `ui.screenshot` exited 0 while
the PNG showed the wrong view or was never written. The run now counts
replies with `"ok": false`, keeps going (every reply still reaches stdout and
the final `-o` screenshot is still written — continue-and-report, like
`run --keep-going`) and returns `N scripted request(s) failed` afterwards,
which `main` turns into exit 1. Usage text and docs/control-protocol.md
"Headless rendering" state the contract.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
wstock
2026-10-08 10:46:29 +00:00
co-authored by Claude Fable 5.1
parent 629e39380e
commit ee0b0ef67e
3 changed files with 46 additions and 2 deletions
+4 -1
View File
@@ -86,7 +86,10 @@ lightcraft-cli snapshot --library DIR --script tour.jsonl -o shot.png
`tour.jsonl` holds one request per line (`#` comments allowed), e.g.
`{"method": "ui.set", "params": {"view": "detail", "right": "edit", "openSections": ["optics"]}}`
then `{"method": "ui.screenshot"}`. Replies are printed to stdout. A `ui.screenshot` without
then `{"method": "ui.screenshot"}`. Replies are printed to stdout. A failed request
(`"ok": false`) does not stop the script — the remaining lines and the final screenshot still
run — but the exit status is non-zero when any request failed, as with `run --keep-going`, so
CI and nightly runs can judge a snapshot by its exit status. A `ui.screenshot` without
`path` writes `-o` (then `OUT-2.png`, `OUT-3.png`, …); `ui.settle {timeoutMs?}` waits until no
renders are in flight. Each request runs frames until it is answered and its injected input
(clicks, keys, drags) has played out. Widget ids for `ui.clickWidget` come from `ui.widgets`