Stream ntfy notifications to app clients over /connect
Record every notification published to ntfy (run outbox, stage notify hooks, chat question/approval/reply) in a persisted app_notifications outbox and stream it to subscribe_notifications clients with an after cursor; clear_notifications and ack_attention clear across devices, as do runs leaving waiting, deleted runs and answered chat questions. Add the notify.ntfy_enabled setting (default on) to stop only the ntfy publish.
This commit is contained in:
+6
-1
@@ -319,7 +319,12 @@ and matched field. `list_runs` also returns all-history `usage`
|
||||
aggregates. `attention_acks` reads and `ack_attention` adds to the operator's
|
||||
shared in-app acknowledgements (dismissed Needs-you entries and chat read
|
||||
watermarks; see [ntfy.md](ntfy.md#clearing-notifications-across-devices)); other
|
||||
connections receive an `attention_acks_changed` push.
|
||||
connections receive an `attention_acks_changed` push. `subscribe_notifications`
|
||||
(optional `after` cursor) streams the same notifications the server publishes to
|
||||
ntfy as `notification` pushes, `clear_notifications` (`ids`) clears them on every
|
||||
device, and `notifications_cleared` reports clears; `ntfy_enabled` in the
|
||||
notification settings turns the ntfy publish off without stopping the stream (see
|
||||
[ntfy.md](ntfy.md#app-notification-stream-no-ntfy-app-needed)).
|
||||
|
||||
Every run summary (`list_runs` rows, `get_run`, subscribe snapshots and terminal
|
||||
`run_event` frames) carries `size_bytes`: bytes on disk for the run (artifact tree
|
||||
|
||||
+51
-3
@@ -169,7 +169,7 @@ reading history never publishes.
|
||||
|
||||
## Notification settings
|
||||
|
||||
Three global, server-side switches choose which of these events are published.
|
||||
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.
|
||||
@@ -179,13 +179,14 @@ explicit `type=ntfy` stages are not affected.
|
||||
| `run_finished` — Notify when any run ends | off | every **auto**-mode run that fails or succeeds notifies; otherwise only runs started with **Notify me** (`on`) announce their end |
|
||||
| `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 |
|
||||
| `ntfy_enabled` — Publish to ntfy | on | when off, nothing is published to ntfy; the app notification stream (below) still delivers every notification |
|
||||
|
||||
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`
|
||||
changes any subset; both reply with type `notification_settings` carrying every
|
||||
key. Unknown keys and non-boolean values are refused with an `error`
|
||||
reply and nothing is written.
|
||||
|
||||
`run_finished` changed meaning: it once meant "auto runs announce success" and
|
||||
@@ -209,6 +210,53 @@ This does **not** reach notifications the ntfy app has already shown on a phone:
|
||||
once ntfy delivered a message, the server cannot retract it, so those must still
|
||||
be swiped away in the ntfy app (or the Android notification shade).
|
||||
|
||||
## App notification stream (no ntfy app needed)
|
||||
|
||||
Every notification the server publishes to ntfy — run waiting/failed/succeeded
|
||||
alerts from the run outbox, stage `notify` hook events, and chat
|
||||
question/approval/reply alerts — is first recorded in the `app_notifications`
|
||||
table (kept 7 days) and streamed over `/connect` to clients that subscribe, so
|
||||
the Pipelines app can post them itself. The same settings decide what is
|
||||
recorded, so the stream carries exactly the set ntfy gets, with the same title,
|
||||
message and `click` deep link. A stage hook with several attachments is one
|
||||
stream notification per step event; explicit `type=ntfy` stages are not
|
||||
streamed.
|
||||
|
||||
```text
|
||||
→ {"type":"subscribe_notifications","id":"1","after":"run:7:3:waiting"}
|
||||
← {"type":"notifications_subscribed","id":"1","notifications":[N...],"ids":["<cleared id>",...]}
|
||||
← {"type":"notification","notification":N} (push)
|
||||
← {"type":"notifications_cleared","ids":["run:7:3:waiting"]} (push)
|
||||
→ {"type":"clear_notifications","id":"2","ids":["run:7:3:waiting"]}
|
||||
← {"type":"notifications_cleared","id":"2","ids":[<ids it cleared>]}
|
||||
|
||||
N = {"id":"run:7:3:waiting","kind":"run_waiting","title":"Run needs your decision",
|
||||
"message":"Run #7 · release · waiting for a human decision at stage approve",
|
||||
"click":"pipelines://run/7","priority":3,"tags":[],
|
||||
"created_at":"2026-11-01T10:00:00Z","group":"run:7"}
|
||||
```
|
||||
|
||||
- `id` is stable: `run:<run>:<step>:<event>` (event `waiting`, `failed`,
|
||||
`succeeded`, or `success` for a mid-run stage hook) or
|
||||
`chat:<session>:<form|permission|reply>:<id>`. `kind` is one of `run_waiting`,
|
||||
`run_failed`, `run_succeeded`, `stage_failed`, `stage_succeeded`,
|
||||
`chat_question`, `chat_approval`, `chat_reply`. `group` is `run:<id>` or
|
||||
`chat:<id>`. `priority` is 3 and `tags` empty, matching what ntfy receives.
|
||||
- The subscribe reply holds the active (uncleared) notifications newer than the
|
||||
`after` cursor (the last id the client holds), oldest first, at most 100;
|
||||
an empty, unknown or pruned cursor replays them all. Its `ids` lists
|
||||
notifications cleared within the 7 days (newest first, at most 500) so a
|
||||
reconnecting device can dismiss ones it still shows. Pushes follow in order;
|
||||
subscribing again replaces the subscription.
|
||||
- `clear_notifications` (the app's dismiss or tap) has the same effect as the
|
||||
matching `ack_attention`: `run_waiting` dismisses `<run>:Decision`,
|
||||
`run_failed`/`stage_failed` `<run>:Failed`, and a chat notification marks the
|
||||
chat seen (clearing its other notifications too). Other subscribers receive
|
||||
`notifications_cleared`; connections receive `attention_acks_changed`.
|
||||
- Notifications are also cleared, with a push, by `ack_attention` from any
|
||||
client, by a run leaving `waiting` (its waiting notifications), by deleting a
|
||||
run, and by an answered or cancelled chat question or approval.
|
||||
|
||||
## Explicit delivery stage (optional)
|
||||
|
||||
The preceding stage must output three nonempty UTF-8 strings: `title`, `summary`,
|
||||
|
||||
Reference in New Issue
Block a user