Honor bread.command.help.open via breadhelp listen
All checks were successful
dev release / build (push) Successful in 39s

This commit is contained in:
Breadway 2026-08-15 23:11:28 +08:00
parent f021473269
commit d9012c8e72
4 changed files with 124 additions and 9 deletions

View file

@ -9,14 +9,17 @@ follows.
App id: **`help`**. Transport: `bread-utils`'s `bread_client` module
(feature `bread-client`) — breadhelp links it directly. Each `emit` is
its own short-lived connection. There is no long-running command
subscription.
its own short-lived connection. Command verbs are only received while
`breadhelp listen` is running — that process holds the
`bread.command.help.**` subscription open.
## Events published (`bread.help.*`)
| Event | Data | When |
|-------|------|------|
| `bread.help.opened` | `{ "autostart": bool }` | The main help window is presented (`ApplicationWindow::present`). `autostart` is `true` when that invocation was launched with `--autostart`. |
| `bread.help.open.done` | `{}` | `bread.command.help.open` was received and `breadhelp` was spawned. This is the command confirmation, not proof the window mapped — the spawned process is the same no-args invocation as SUPER+/. |
| `bread.help.open.failed` | `{ "error": "<message>" }` | `bread.command.help.open` was received but this binary could not be started. |
Not emitted when:
@ -29,14 +32,36 @@ Not emitted when:
## Commands honored (`bread.command.help.*`)
None. Opening the help center, starting the tour, and applying one-click
fixes already exist as local CLI / UI paths. There is no command
subscription, and no verb is stubbed as a no-op. If breadhelp later grows
a bus verb that maps to real behavior, add it then.
These are only received while `breadhelp listen` is running. Publishing a
command with no subscriber is a silent no-op — that is the documented
bread convention, not a breadhelp bug.
| Verb | Data | Effect |
|------|------|--------|
| `open` | none | Same as running `breadhelp` with no flags: present the main help window (GApplication forwards to an already-running primary instance). Emits `bread.help.open.done` / `.failed`. |
```lua
bread.spawn(function()
bread.emit("bread.command.help.open")
bread.wait("bread.help.open.done", { timeout = 5000 })
end)
```
### Not implemented: extra verbs
There is no `onboard` / `tour` / `suggest` command verb. Those already
exist as local CLI flags (`--onboard`, `--tour-event`, `--suggest`).
If/when a bus verb maps to real extra behavior, add it then — do not
stub one as a no-op ahead of it.
## Fail-safe behavior
- If breadd isn't installed or isn't running, `emit` is a silent no-op
(`BreadClient::emit` never blocks or errors the caller) — the help
(`BreadClient::emit` never blocks or errors the caller) and the
command subscription simply never receives anything — the help
center, tour, and screenshots are entirely unaffected.
- There is no command subscription to reconnect.
- If breadd restarts, the command subscription reconnects automatically
(`BreadClient::subscribe`'s background thread has its own backoff
loop); no restart of `breadhelp listen` is needed.
- If `breadhelp listen` is not running, commands are a graceful no-op at
the bus (no subscriber). The CLI still works.