Closed general

Toast onClick with a prefixed verb (hd_api) fails at click time: Unknown hd command

John Lauer · 1mo ago ·closed by John Lauer

What happens

A toast armed with onClick: {"command": "hd_api", "args": {...}} is accepted: notify_user answers clickBehavior: "runs-onclick-verb". But when the user clicks it, nothing happens. notify_response shows why:

"response": {
  "action": "onClick",
  "command": "hd_api",
  "ok": false,
  "error": "Unknown hd command: hd_api. Known: status, eval, iframe_eval, log, open_url, browser_profiles, screenshot, reload_vscode, container_exec, build, build_frontend, build_rust, build_status, build_log, build_tail, launch, stop, restart."
}

Seen on ab 2.1.162 (winvm, 2026-09-30) with Hydrogen 1.0.510's "Hydrogen is still running" toast.

Why

hd_api is the CLI spelling. The CLI and the direct API strip the hd_ prefix before dispatch, so inside the hd app the verb is api (hd_bridge.rs, handle_hd_command: "api" => hd_api(...)).

The toast-click path does not strip it. In lib.rs (the notify-click handler), when the armer gives no app, it calls direct_api::infer_app(&act.command, ...), which maps the hd_ prefix to app hd, and then sends command: act.command unchanged. So the hd app receives hd_api and rejects it. The same happens for any prefixed verb whose app strips the prefix (hd_status, hd_launch, and so on).

Workaround (what Hydrogen now does)

Name the app and the unprefixed verb explicitly:

"onClick": {"app": "hd", "command": "api", "args": {"method": "POST", "path": "/window/show"}}

Verified working on winvm: the click reached Hydrogen's POST /window/show.

Suggested fix

When onClick has no app, route it exactly as the direct API routes the same verb, prefix stripping included, so {"command": "hd_api"} behaves the same from a toast as from adom-bridge hd_api. Failing that, reject it at arm time (in notify_user) with the correct {app, command} form, instead of accepting it and failing only when the user clicks, where nobody sees the error.

1 Reply

John Lauer · 1mo ago

Fixed in 2.1.163 (insiders now).

The Hydrogen handler now accepts both spellings of its verbs, hd_api and api, so a toast onClick of {"command": "hd_api", "args": {...}} runs the same verb as adom-bridge hd_api. The fix is in the handler itself, not the click path, so every route that forgets to strip the prefix (a toast click, a local API call with no app) behaves the same.

Checked on arav-rog (2.1.163): a local API call with the raw name {"command": "hd_status"} and no app, the exact route the click uses, now returns Hydrogen's status instead of "Unknown hd command". The unknown-verb error also lists every verb and says either spelling works.

On a box still below 2.1.163, the workaround ({"app": "hd", "command": "api", ...}) keeps working.

John Lauer closed this · 1mo ago

Log in to reply.