Add server notification settings with app checkboxes
Persist three global ntfy switches in server_settings: run_finished (default on: auto-mode runs notify on success, read inside the transition transaction; on/off modes unchanged), chat_needs_you (default on: gates chat question/approval alerts) and chat_reply_finished (default off: one alert per finished assistant turn). Expose notification_settings / set_notification_settings over the websocket protocol, add a Phone notifications section with Material and Cupertino checkboxes in Settings, document the settings, and keep the cli, tui, stage and pipeline test packages from inheriting a real ntfy configuration.
This commit is contained in:
+42
-5
@@ -73,10 +73,15 @@ artifacts=markdown,files
|
||||
|
||||
Independently of any `notify` block, the server publishes one run-level
|
||||
notification to the `system` destination when a run needs a person: when it enters
|
||||
`waiting` (a human stage asked for a decision) and when it fails. Nothing else
|
||||
notifies by default — queued, running, canceled and interrupted runs are silent.
|
||||
Runs explicitly started with notifications **on** also notify on success.
|
||||
The payload names the run and its pipeline. Run notifications and stage hooks
|
||||
`waiting` (a human stage asked for a decision), when it fails, and — while the
|
||||
**Run finished** setting (`run_finished`, on by default) is enabled — when it
|
||||
succeeds (`Run succeeded`). Queued, running, canceled and interrupted runs are
|
||||
silent. The run's own notify mode still wins: a run started with notifications
|
||||
**on** always notifies on success, a run started with notifications **off**
|
||||
never notifies anything, and the default **auto** mode follows `run_finished`
|
||||
for success (waiting/failed always notify). The setting is read in the same
|
||||
transaction that records the run's final state, so a change applies to runs
|
||||
finishing after it. The payload names the run and its pipeline. Run notifications and stage hooks
|
||||
use the configured web run link described below.
|
||||
|
||||
### Open notifications in the web app
|
||||
@@ -132,7 +137,18 @@ permission (approval) request — the server publishes one notification to the
|
||||
approval` for permissions; `Chat` when the session has no title), the question or
|
||||
permission text as the body, `Click` `pipelines://chat/<session id>`, and the
|
||||
**Open in browser** action to `<web>/chat/<session id>` when
|
||||
`PIPELINES_WEB_PUBLIC_URL` is set. Ordinary finished replies do not notify.
|
||||
`PIPELINES_WEB_PUBLIC_URL` is set. These are controlled by the **Chat needs your
|
||||
answer or approval** setting (`chat_needs_you`, on by default).
|
||||
|
||||
Finished replies notify only when **Chat reply finished**
|
||||
(`chat_reply_finished`) is turned on (off by default): when an assistant turn
|
||||
ends (the authoritative, non-intermediate step end), the server publishes
|
||||
`<chat title> replied` (`Chat replied` without a title) with the first ~200
|
||||
characters of the turn's final assistant text as the body, or `The agent
|
||||
finished its reply.` when no text was retained, plus the same click and browser
|
||||
action. Each turn notifies once: a repeated or replayed end with no turn
|
||||
observed in between, or a turn id already announced, publishes nothing, and
|
||||
reading history never publishes.
|
||||
|
||||
- Each form/request id notifies at most once per server process: duplicate
|
||||
events, reconnects and replays of a still-pending question are deduplicated in
|
||||
@@ -145,6 +161,27 @@ permission text as the body, `Click` `pipelines://chat/<session id>`, and the
|
||||
fails chat handling, and failures are only logged. Nothing is sent when
|
||||
`PIPELINES_NTFY_URL` is not configured.
|
||||
|
||||
## Notification settings
|
||||
|
||||
Three global, server-side switches choose which of these events are published.
|
||||
They are stored in the server database (`server_settings`), survive restarts and
|
||||
apply to every device subscribed to the topic. Per-stage `notify` hooks and
|
||||
explicit `type=ntfy` stages are not affected.
|
||||
|
||||
| Setting | Default | Effect |
|
||||
| --- | --- | --- |
|
||||
| `run_finished` — Run finished | on | an **auto**-mode run that succeeds notifies `Run succeeded` |
|
||||
| `chat_needs_you` — Chat needs your answer or approval | on | chat question/form and approval requests notify |
|
||||
| `chat_reply_finished` — Chat reply finished | off | each finished assistant turn in a chat notifies |
|
||||
|
||||
Change them in the app under **Settings → Phone notifications** (checkboxes; a
|
||||
refused change reverts and shows the server's reason). Over the websocket
|
||||
protocol, `{"type":"notification_settings"}` reads them and
|
||||
`{"type":"set_notification_settings","notification_settings":{"chat_reply_finished":true}}`
|
||||
changes any subset; both reply with type `notification_settings` carrying all
|
||||
three keys. Unknown keys and non-boolean values are refused with an `error`
|
||||
reply and nothing is written.
|
||||
|
||||
## Explicit delivery stage (optional)
|
||||
|
||||
The preceding stage must output three nonempty UTF-8 strings: `title`, `summary`,
|
||||
|
||||
Reference in New Issue
Block a user