fc7dbb0ac0
Server: drop ntfy publishing (stage hooks, run outbox, chat attention, chat tool notify, auto-switch and schedule notices), the chat push outbox (its table is dropped at startup), ntfy status/endpoints and PIPELINES_NTFY_*. The app_notifications stream, subscribe/clear and kinds are unchanged. Notification settings keep run_finished/chat_needs_you/chat_reply_finished; ntfy_enabled is accepted and ignored and its stored row is never read. Stage type=ntfy is rejected: "ntfy stages were removed; notifications go to the Pipelines apps — use the stage notify hook". The notify hook remains. Installer: no ntfy build, accounts, config or supervisor child; manifest gets top-level "mode" (legacy ntfy.mode still read). Reinstall retires an old ntfy (safe PID-file stop, deletes binary, config, data dir, token, log, with a note in logs/install.log); uninstall cleans leftovers. App: ntfy settings section replaced by "Notification events"; texts updated. Docs: docs/ntfy.md folded into docs/notifications.md; install, docker, cli, author skill references updated; security review M1 marked resolved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
239 lines
12 KiB
Markdown
239 lines
12 KiB
Markdown
# Notifications
|
||
|
||
The server records every notification once, in its `app_notifications` table,
|
||
and streams it over the app's own connection (`/connect`) to every signed-in
|
||
Pipelines client, which posts it as a system notification:
|
||
|
||
- **Web** (each tab and installed web app window): a browser `Notification`,
|
||
while the page is open and the browser allows it. Closed-browser web push is
|
||
not implemented.
|
||
- **Android**: the **Receive notifications in Pipelines** background service
|
||
(keeps its own connection, also with the app closed), or the in-app bridge
|
||
while the app runs.
|
||
- **iOS and macOS**: the in-app bridge while the app runs.
|
||
|
||
No other app, server or account is involved. (Earlier versions also published
|
||
to a self-hosted ntfy server; that was removed. See
|
||
[Upgrading from ntfy](#upgrading-from-ntfy).)
|
||
|
||
## What notifies
|
||
|
||
| Event | When |
|
||
| --- | --- |
|
||
| Run needs your decision | a run reaches a human decision stage (runs not set to Silent) |
|
||
| Run failed / succeeded | runs started with **Notify me** (`--notify on`), or every run when **Notify when any run ends** is on; unexpected failures always |
|
||
| Stage hook | a stage's own `notify` block fires ([below](#stage-notify-hooks)) |
|
||
| Chat needs you | a chat asks a question or requests approval |
|
||
| Chat replied | an assistant turn ends (off by default) |
|
||
| Agent notification | a chat's agent calls its `notify` tool (always on; a turn that notified sends no separate "Chat replied") |
|
||
| Schedule delayed / skipped | a scheduled run could not start on time (low priority) |
|
||
|
||
Each event notifies once, on every signed-in device. Opening the chat or run,
|
||
tapping the notification, or dismissing it in the app or the Android
|
||
notification shade clears it on every device (see
|
||
[Clearing notifications across devices](#clearing-notifications-across-devices)).
|
||
|
||
Chat events do not need the chat to be open. When the last app or browser
|
||
leaves a chat whose turn is still running, or which has an unanswered question
|
||
or approval, the server keeps watching it until the turn ends and nothing is
|
||
left to answer, so "Chat needs you" and "Chat replied" still arrive with the
|
||
app closed. A client that reopens the chat meanwhile joins the same watch, so
|
||
nothing is announced twice. Idle chats are not watched.
|
||
|
||
Limits:
|
||
|
||
- At most 16 chats are watched with no client attached; a further one is not
|
||
(queued messages are always delivered regardless).
|
||
- A turn that never reports its end stops being watched after 6 hours.
|
||
- After a server restart, the 32 most recently used open chats (used in the last
|
||
24 hours) are asked whether a turn is still running, and those that are are
|
||
watched again. This works for OpenCode and Codex, which keep running across a
|
||
Pipelines restart. A Claude Code turn runs inside the server process and ends
|
||
with it, so there is nothing to resume.
|
||
|
||
## Settings
|
||
|
||
In the app, **Settings**:
|
||
|
||
**Notifications** asks for the platform's notification permission.
|
||
|
||
**Notifications in Pipelines** (Android only):
|
||
|
||
- **Receive notifications in Pipelines**: starts a background service that
|
||
keeps its own connection to the server and posts notifications. Android shows
|
||
a quiet "Pipelines is connected" notification while it runs. It restarts
|
||
after a reboot or an app update.
|
||
- **Status**: the service's connection state.
|
||
- **Allow notifications**: shown when Android is blocking Pipelines
|
||
notifications.
|
||
- **Allow background delivery**: asks Android to exempt Pipelines from battery
|
||
optimisation so delivery stays instant while the phone is idle. Grant it.
|
||
|
||
**Notification events** (stored on the server, shared by every device):
|
||
|
||
| Setting | Key | Default | Effect |
|
||
| --- | --- | --- | --- |
|
||
| Notify when any run ends | `run_finished` | off | every **auto**-mode run that fails or succeeds notifies; otherwise only runs started with **Notify me** announce their end |
|
||
| Chat needs your answer or approval | `chat_needs_you` | on | chat questions/forms and approval requests notify |
|
||
| Chat reply finished | `chat_reply_finished` | off | each finished assistant turn notifies |
|
||
|
||
They are stored in the server database (`server_settings`, keys `notify.*`) and
|
||
survive restarts. Per-stage `notify` hooks are not affected by them. 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 every
|
||
key. Unknown keys and non-boolean values are refused with an `error` reply and
|
||
nothing is written. The removed `ntfy_enabled` key is accepted and ignored, so an
|
||
older app's switch does not fail; a stored `notify.ntfy_enabled` row is never
|
||
read.
|
||
|
||
`run_finished` changed meaning once: it meant "auto runs announce success" and
|
||
defaulted on. It is stored under `notify.any_run_ended`, so a value saved under
|
||
the old meaning (`notify.run_finished`) is ignored.
|
||
|
||
Per run, choose **Notify me**, the default (auto), or **Silent** when starting
|
||
it. From the CLI: `pipelines run … --notify on|auto|off`.
|
||
|
||
## Run notifications
|
||
|
||
Independently of any `notify` block, the server records one run-level
|
||
notification when a run needs a person or ends and was marked to notify:
|
||
|
||
| Run notify mode | Enters `waiting` | Fails / succeeds |
|
||
| --- | --- | --- |
|
||
| **on** ("Notify me", `--notify on`) | `Run needs your decision` | `Run failed` / `Run succeeded` |
|
||
| **auto** (default) | `Run needs your decision` | unexpected failure or interruption; success only when **Notify when any run ends** is on |
|
||
| **off** ("Silent") | silent | silent |
|
||
|
||
A deliberate route to `#failure` with its reason is an expected failure: it does
|
||
not notify in auto mode. Queued, running and canceled runs are silent. The
|
||
setting is read in the same transaction that records the run's final state.
|
||
|
||
Run events go through a durable outbox (`run_notifications`): the event is
|
||
queued with the run's state change and recorded on the app stream at once; a
|
||
crash before it is recorded is recovered after a restart. A run that stays
|
||
`waiting` is not announced again on a read or restart, and a stage `notify` hook
|
||
that already covered the same event (`on=waiting`, or a failure hook)
|
||
suppresses the run-level one, so one event means one notification. A
|
||
notification problem is logged and never changes the run.
|
||
|
||
A tap opens `pipelines://run/<id>` in the app (the web app opens the same run).
|
||
|
||
## Stage notify hooks
|
||
|
||
Every stage can have an optional `notify` block:
|
||
|
||
````markdown
|
||
# stage compose
|
||
|
||
```notify
|
||
on=success,failure
|
||
open=*.md
|
||
link=standup-link.txt
|
||
```
|
||
````
|
||
|
||
- `on` is `success`, `failure`, `waiting`, or a comma list. A failure is an
|
||
execution error, the `error` outcome, or a route to `#failure`; any other
|
||
completed stage is a success. It reports the stage's result, not the run's.
|
||
- For a sequential workflow whose error routes go to `#failure`, add
|
||
`on=failure` to intermediate stages and `on=success,failure` to the final
|
||
stage: one notification on every normal terminal path, without progress
|
||
alerts.
|
||
- `open=<pattern>` attaches one file from the run's shared `public/` directory
|
||
to the notification (with a short text preview) and makes a tap open it. The
|
||
pattern is a relative glob without absolute paths, `..` or hidden segments;
|
||
the most recently modified match wins. Without `open=`, exactly one regular
|
||
file in `public/` is attached automatically; zero or several attach nothing.
|
||
- `link=<pattern>` makes a tap open a URL the stage produced (for example a
|
||
published doc): the matched `public/` file's first non-empty line must be an
|
||
absolute http(s) URL without credentials or fragment. The run stays reachable
|
||
from the notification's run action. A missing file or invalid URL keeps the
|
||
usual tap target and is noted on the stage's notification receipt.
|
||
- `artifacts=` and `destination=` lines from older definitions still parse but
|
||
do nothing: they configured ntfy attachments and connections.
|
||
|
||
Hooks run after the stage completes and before the run's final status is saved.
|
||
They are not a finalizer for cancellation, crashes or runtime limits, and loops
|
||
can notify more than once. The receipt (recorded or not) appears in the stage's
|
||
**Metadata**; it never changes routing.
|
||
|
||
The former `type=ntfy` delivery stage was removed. A definition that still uses
|
||
it is refused by validation with: "ntfy stages were removed; notifications go
|
||
to the Pipelines apps — use the stage notify hook".
|
||
|
||
## Clearing notifications across devices
|
||
|
||
The app's attention state is shared through the server: dismissing an entry or
|
||
using **Clear all** in the Needs-you sheet, and opening a chat (which clears its
|
||
**New** badge), clears it on every connected browser and phone at once, and on a
|
||
disconnected device when it next connects. The protocol is
|
||
`{"type":"attention_acks"}` (read the whole set) and
|
||
`{"type":"ack_attention","attention_acks":{"dismissed":["42:Failed"],"chat_seen":{"ses_x":1730000000000}}}`
|
||
(add to it). Both reply `attention_acks`, and every other connection receives an
|
||
`attention_acks_changed` frame. Acknowledgements for deleted runs or sessions,
|
||
or older than 30 days, are pruned.
|
||
|
||
Every client removes its system notification when the clear reaches it:
|
||
|
||
- **Web**: the page closes the browser `Notification` with that tag and tells
|
||
the origin's other tabs to close theirs over a `BroadcastChannel`. A click
|
||
sends `clear_notifications`. A browser *close* event is not reported back
|
||
(browsers raise it for timeouts and same-tag replacements too).
|
||
- **Android with Receive notifications in Pipelines**: the background service
|
||
cancels it; a tap or a swipe sends `clear_notifications`.
|
||
- **Android without the service, iOS and macOS** (the in-app bridge while the
|
||
app runs): it is removed by its tag; a tap clears it. A swipe is not reported.
|
||
|
||
## App notification stream (protocol)
|
||
|
||
```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),
|
||
`chat:<session>:<form|permission|reply|notify|auto-switch>:<id>` or
|
||
`schedule:<id>:<due>:<event>`. `kind` is one of `run_waiting`, `run_failed`,
|
||
`run_succeeded`, `stage_failed`, `stage_succeeded`, `chat_question`,
|
||
`chat_approval`, `chat_reply`, `chat_notify`, `schedule`. `group` is
|
||
`run:<id>`, `chat:<id>` or `schedule:<id>`.
|
||
- `priority` is 1–5 (3 default). Schedule notices and the Claude account
|
||
auto-switch notice are 2; an agent's `notify` uses the tool's priority (`low`
|
||
2, `default` 3, `high` 4).
|
||
- A stage hook notification may carry `artifact` (the `open=` file) and
|
||
`preview`; with a `link=` its `click` is the link and `run_click` the run.
|
||
- The subscribe reply holds the active (uncleared) notifications newer than the
|
||
`after` cursor, oldest first, at most 100; an empty, unknown or pruned cursor
|
||
replays them all. Its `ids` lists notifications cleared within the 7-day
|
||
retention (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` 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).
|
||
- Notifications are also cleared, with a push, by `ack_attention` from any
|
||
client, by a run leaving `waiting`, by deleting a run, and by an answered or
|
||
cancelled chat question or approval.
|
||
|
||
## Upgrading from ntfy
|
||
|
||
Installs made before the removal ran a bundled ntfy server on port 8090. The
|
||
installer retires it on reinstall and `./uninstall` removes any leftover (see
|
||
[Install](install.md)). Phones that subscribed in the ntfy app keep the old
|
||
subscription but receive nothing further: remove the Pipelines server from the
|
||
ntfy app, and turn on **Receive notifications in Pipelines** in the Android app
|
||
instead. Old stored settings keep their meaning; the `ntfy_enabled` choice and
|
||
the old chat push outbox (`chat_notifications`, dropped at startup) are ignored.
|