Event delivery and notifications
Pipedash turns changes in pipeline and provider state into events that reach connected clients and, when needed, user notifications. The system uses one event stream for live application updates, then applies user and device preferences before it shows a notification locally or sends it through the push relay.
Event distribution
The event system separates application changes from user-facing notification decisions. Core services publish typed events, while each delivery path chooses how to represent those events for its client or device.
Core event stream
home/…/event.rs defines the shared event vocabulary for pipeline changes, provider health, device changes, and notification observations. Services publish these events through an event bus. The web server and desktop app attach their own delivery layer to that bus.
Pipeline and provider checks turn state changes into notification observations. Pipeline notices cover failures, degraded state, finished runs, recovery, and runs that take longer than usual. The notification state keeps a baseline so an unchanged state does not create a new alert. It also lets event-driven updates and later scans describe the same change only once.
NotificationObserved is the bridge between state change and user alert. The alert recorder watches relevant pipeline and provider events, stores a short recent history, and emits an observed notification with an ordered ID. A delivery path can then filter that observation without changing the source event.
References: crates/…/event.rs• L35-90 crates/…/event.rs• L138-145 crates/…/pipelines.rs• L16-70 crates/…/overdue.rs• L143-170
Delivery paths
The main paths share the same event source but serve different user states:
| Path | Purpose | User-visible result |
|---|---|---|
| WebSocket | Keep an open client current | Live data events and admitted notifications |
| Desktop event bus | Connect the core to the Tauri webview and native app | In-app notification history and system alerts |
| Mobile local notifications | Notify a device while the app can run locally | Local or background device notification |
| Push relay | Reach an iOS device when the app is not active | APNs notification delivered by the relay |
The paths are complementary. Realtime delivery supports an active client, while push delivery provides an out-of-process path for selected alerts.
This diagram shows how one application event can reach active clients and registered mobile devices through separate branches.
flowchart LR
A[Core state change] --> B[Core event bus]
B --> C[Notification observation]
B --> D[Realtime event stream]
C --> E[Preference admission]
E --> F[Web client]
E --> G[Desktop app]
C --> H[Server push notifier]
H --> I[Push relay]
I --> J[APNs and mobile device]
References: crates/…/ws.rs• L118-160 crates/…/tauri_event_bus.rs• L63-116 crates/…/push.rs• L317-339 crates/…/push.rs• L420-443 crates/…/alerts.rs• L119-140
Realtime transport
The WebSocket transport carries both ordinary application updates and admitted notifications to connected clients. It also gives clients a way to send preferences and request notifications that arrived after the last notification they processed.
WebSocket sessions
Each session authenticates as an operator or paired device before it receives the event stream. After authentication, the server forwards typed event frames and treats notification observations as a special frame whose payload is already filtered for that session.
The client reconnects after a lost connection and sends its last notification ID with its current preferences. The server replays newer observations from its recent buffer. A client that falls too far behind is closed instead of receiving an incomplete stream, so it can reconnect and recover from a known point.
References: crates/…/ws.rs• L256-323 crates/…/ws.rs• L486-549 crates/…/ws.rs• L551-577 src/…/websocket.ts• L127-175 src/…/websocket.ts• L281-293
Notification admission
Notification admission means deciding whether an observed notification should be shown to one user or device. The decision uses alert kind, provider scope, pipeline scope, and watched-run settings. The same observed notification can therefore be shown to one device and omitted from another.
The server applies preferences for WebSocket sessions and paired devices. The desktop event bus applies the local app copy before it sends a notification to the webview or native desktop layer. This keeps filtering close to each delivery boundary and avoids exposing a muted alert as a user-visible event.
The client gives each pipeline one active policy: follow general settings, notify for the current or next finish, watch every run, or mute the pipeline. A separate missed-run alert can notify the user when a learned pipeline schedule is overdue. These choices change the preference state only after the host saves them, so a failed change keeps the prior choice visible and lets the user try again.
For the client-side controls and display rules, see Client notification behavior.
References: crates/…/pipelines.rs• L23-62 crates/…/tests.rs• L320-359 crates/…/ws.rs• L522-547 crates/…/tauri_event_bus.rs• L35-57 crates/…/local_notifications.rs• L150-172 src/…/useNotifyItems.tsx• L94-165 src/…/PipelineNotifyMenu.tsx• L17-57 src/…/PipelineNotifyPolicy.tsx• L14-74 src/…/watchControls.test.tsx• L103-194 src/…/watchControls.test.tsx• L317-333
Desktop and mobile integrations
The application adapts the shared notification model to the runtime that owns the user interface. Desktop uses the Tauri bridge and native system notifications, while mobile uses local notification state and a push registration when background delivery is needed.
Desktop notifications
The desktop path records admitted notifications in a small notification history and publishes changes to the webview. It can also submit a system notification with a target that lets a click open the related pipeline, provider, run, or notification detail.
Remote server notifications use the same desktop history as local core notifications. The desktop app keeps the history, read state, and system switch separate from the live event transport, so a user can review an alert after the original event has passed.
For the client-side controls and display rules, see Client notification behavior.
References: crates/…/tauri_event_bus.rs• L63-100 crates/…/notifications.rs• L126-218 src/…/desktop.ts• L7-32 src/…/systemNotifications.ts• L13-85
Mobile push integration
Mobile notification delivery has two stages. The device registers its platform token with the relay and stores the returned subscription with its Pipedash host. Later, the host sends an alert to that subscription when a matching recorded alert occurs.
The mobile app can also use local notification handling when it has access to the host and its saved authorization. Push delivery covers the case where the app is not active. On iOS, the notification service can fetch alert details from the host before presenting the final content.
References: crates/…/relay.rs• L16-70 crates/…/mod.rs• L130-192 ios/…/NotificationService.swift• L17-91 crates/…/local_notifications.rs• L191-231
Push relay delivery
The push relay is a small service between a Pipedash host and Apple Push Notification service (APNs). It keeps device-token data at the relay, gives the host an opaque subscription ID, and accepts notification requests without making the host talk to APNs directly.
Host-to-relay delivery
The host registers mobile subscriptions and stores the relay-facing identity needed for later delivery. Its push service can turn failed or degraded pipelines into bounded alerts with pipeline, provider, branch, run, and thread context. It looks up recent failed-run data when available, then fans the alert out to registered subscriptions. A missing relay configuration or an empty subscription list produces no delivery attempt.
The host also watches recorded alerts and checks device preferences before sending the matching alert. A successful relay response updates the subscription activity. A gone response removes the stale registration.
The host sends two broad alert forms:
- A pipeline alert contains display text and optional pipeline, provider, run, and thread context.
- A recorded device alert contains an alert ID that the mobile service can resolve through the host.
The relay service validates subscriptions, limits request rates, and forwards the request to APNs for the correct sandbox or production environment. APNs results determine whether the relay keeps the subscription or reports that the device token is no longer valid.
For the relay API, APNs handoff, and relay-specific failure handling, see Push-relay delivery.
References: crates/…/alerts.rs• L21-78 crates/…/alerts.rs• L81-140 crates/…/push.rs• L74-90 crates/…/push.rs• L213-253 crates/…/push.rs• L377-417 crates/…/routes.rs• L103-179 crates/…/apns.rs• L124-220
Delivery outcomes
The host treats relay responses as delivery state rather than as a retry queue. A delivered request records success. A missing or expired subscription is removed. Rate limits and other relay errors remain failures for the current attempt and do not silently delete the device registration.
This boundary keeps stale device records from growing while avoiding destructive changes when the relay is busy or unavailable. It also means push delivery is best viewed as a time-bound alert path, not as a durable replacement for the notification history.
References: crates/…/push.rs• L45-60 crates/…/push.rs• L213-233 crates/…/push.rs• L216-254 crates/…/apns.rs• L124-143
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the event name and payload shape aligned between crates/…/event.rs, crates/…/ws.rs, and src/…/events.ts.
- Preserve notification IDs and the replay boundary when changing the recent-notification store or WebSocket reconnect flow.
- Keep notification state transitions aligned between event observation and background scans so one pipeline change creates one alert.
- Keep preference admission consistent between WebSocket clients, desktop local events, and host push filtering.
- Keep pipeline policy changes aligned between the client controls and the preference-change contract used by the host.
- Keep push alert length limits and context fields aligned with the relay payload and mobile deep-link handling.
- Keep relay subscription lifecycle changes aligned across mobile registration, host subscription storage, and relay registration or rotation.
- Keep APNs destination metadata aligned with desktop and mobile deep-link targets when alert payloads change.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A WebSocket client falls behind the event broadcast | The connection closes and the client must reconnect | Replay from the last notification ID |
| Event observation and a later provider scan see the same pipeline change | The user may receive duplicate alerts | Persist the pipeline baseline and compare status, run, and overdue markers |
| A device or user preference rejects an alert | That delivery path shows no notification | Apply admission at the delivery boundary |
| A pipeline policy save fails | The client must not confirm the new policy | Keep the old choice and allow another attempt |
| A failed-run lookup times out or fails | The push still sends without run-specific context | Use the pipeline state and provider context as the fallback |
| A push alert exceeds relay limits | The relay may reject or truncate an invalid request | Bound title and body length before fan-out |
| The push relay returns 404 or 410 | The host removes the stale subscription | Treat the registration as gone |
| The push relay returns 429 or an upstream error | The current push is not delivered | Keep the registration and report the failed attempt |
| APNs reports an unregistered device token | The relay marks the subscription as unusable | Classify the APNs result as unregistered |
Key files
| File | Why to read it |
|---|---|
| crates/…/event.rs | Shared event names and payload model |
| crates/…/pipelines.rs | Pipeline state changes that become user alerts |
| crates/…/overdue.rs | Background checks for long-running pipelines |
| crates/…/tests.rs | Guarantees for baselines, deduplication, recovery, and overdue alerts |
| crates/…/ws.rs | Authenticated realtime transport, filtering, and replay |
| src/…/websocket.ts | Client reconnect and notification cursor behavior |
| src/…/useNotifyItems.tsx | Client policy choices and preference changes for pipeline alerts |
| src/…/PipelineNotifyMenu.tsx | Compact pipeline notification controls |
| src/…/PipelineNotifyPolicy.tsx | Full pipeline policy dialog and save behavior |
| crates/…/tauri_event_bus.rs | Desktop bridge from core events to the Tauri webview |
| crates/…/notifications.rs | Desktop history and native alert handoff |
| crates/…/alerts.rs | Pipeline alert content and host fan-out |
| crates/…/push.rs | Host-side push selection and relay delivery |
| crates/…/push.rs | Host push subscription and relay settings interface |
| crates/…/routes.rs | Relay registration and notification interface |
| crates/…/apns.rs | Relay-to-APNs delivery model |