zgx

Recipes and safety

Common sequences, and what serving devtools costs and exposes.

Recipes

  • Send a chat message and read the reply: type '#composer' 'hi', key Enter, wait '#message-m4' --text '.', tree '#message-m4'.
  • Find why a button does nothing: node '"Save"' (is it disabled? where was it made?), errors.
  • Check a state change took: click '"Add"', state count.
  • Reproduce in a test: the same targets work in TestApp (app.click("\"Add\""), app.type_text("#composer", "hi"), app.keys("Enter"), app.tree()).

Safety and cost

Devtools are built only with zgx-run’s inspect feature (on by default for development) or zgx-script’s inspect; an app built without it cannot be driven, whatever its environment says. Even when built in, nothing listens unless the host serves it: there is no thread, socket or bookkeeping until then. The socket belongs to the user who started the app: a Unix socket (mode 0600) in $TMPDIR/zgx-inspect-<uid> (0700); on Windows a loopback port that answers only requests carrying the token written beside it in %LOCALAPPDATA%\zgx-inspect.

A Rust host serves devtools with zgx_script::inspect::serve(Session::new(&cx.ui, handle, &host, Some(cx.inspector.clone())), "my app", |task| cx.tasks.spawn(task)), where handle is what cx.render(host.view()) returned.

Edit on GitHub