Open ntfy notifications in the app and notify chats that need the operator
Run notifications now always click through to pipelines://run/<id>; a valid PIPELINES_WEB_PUBLIC_URL adds an "Open in browser" ntfy view action instead of replacing the click. Queued rows derive links from the run id at delivery, so legacy rows holding a web URL still open the app. Unresolved chat questions/forms and permission requests publish one async, bounded notification to the system destination (pipelines://chat/<id> plus the browser action), deduplicated per form/request id across reconnects and replays. stage.PublishNtfy gains optional, strictly validated view actions. Server tests now clear the operator's real ntfy environment.
This commit is contained in:
@@ -113,6 +113,38 @@ ordered by importance — a run waiting for a decision, then a failed run, then
|
||||
run that finished since the operator last looked — derived from the run events the
|
||||
server already pushes, so it needs no refresh and starts nothing.
|
||||
|
||||
## Tapping a notification
|
||||
|
||||
Run notifications (stage hooks and run-level waiting/failed/succeeded alerts)
|
||||
set the ntfy `Click` to the app deep link `pipelines://run/<id>`, so a tap on the
|
||||
phone opens the native Pipelines app at that run. When `PIPELINES_WEB_PUBLIC_URL`
|
||||
is set to a valid HTTP(S) origin (no credentials, path, query or fragment), each
|
||||
notification also gets one ntfy `view` action, **Open in browser**, pointing at
|
||||
`<web>/runs/<id>`. Without it, or with an invalid value, only the app link is
|
||||
sent. Queued run notifications derive both links from the run id at delivery,
|
||||
so rows queued by older servers (which stored a web URL) also open the app.
|
||||
|
||||
## Chats that need you
|
||||
|
||||
When a chat asks the operator something — an unresolved question/form or a
|
||||
permission (approval) request — the server publishes one notification to the
|
||||
`system` destination: title `<chat title> needs your answer` (or `... needs your
|
||||
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.
|
||||
|
||||
- Each form/request id notifies at most once per server process: duplicate
|
||||
events, reconnects and replays of a still-pending question are deduplicated in
|
||||
memory, and a form first seen already resolved or cancelled never notifies.
|
||||
The record is not persisted, so a request still pending across a server
|
||||
restart can notify once more.
|
||||
- The server only observes a chat while at least one client is subscribed to
|
||||
it, so questions raised while no client watches the session are not seen.
|
||||
- Publishing is asynchronous within the same 30-second budget, never blocks or
|
||||
fails chat handling, and failures are only logged. Nothing is sent when
|
||||
`PIPELINES_NTFY_URL` is not configured.
|
||||
|
||||
## Explicit delivery stage (optional)
|
||||
|
||||
The preceding stage must output three nonempty UTF-8 strings: `title`, `summary`,
|
||||
|
||||
Reference in New Issue
Block a user