Application hosts and native runtime
Pipedash exposes its core pipeline and provider capabilities through a native desktop app and a web service. Each host owns the core session and adapts the same product surface to its access path. The desktop host adds operating-system features, while the web host supports browsers and paired devices.
Host model
The host is the boundary between the user interface and the core layer. The interface uses native commands in standalone desktop mode and HTTP or WebSocket access in web or remote mode. The frontend keeps these choices behind one service contract, so product actions do not depend on where the core runs.
The hosts coordinate the core session rather than replace it. The core owns product behavior and persistence; the hosts provide the access path and the platform boundary. See Core domain and persistence for the core responsibilities.
The following diagram shows the local, standalone, and shared paths.
flowchart LR
UI[Pipedash interface]
UI --> Select{Connection mode}
Select -->|Standalone desktop| Native[Native command bridge]
Select -->|Web or remote client| Network[HTTP and WebSocket API]
Native --> Desktop[Desktop host]
Network --> Web[Web host]
Desktop --> Core[Core layer]
Web --> Core
Desktop -. optional sharing .-> Shared[Shared web host]
Shared --> Client[Paired client]
Client --> Core
The connection state distinguishes standalone, client, and unset modes. Service selection and event transport selection change together when that state changes. src/…/service.ts and src/…/connection.ts define this frontend boundary.
References: src/…/service.ts• L1-60 src/…/connection.ts• L6-58 crates/…/lib.rs• L49-85
Desktop host
The desktop host packages the web interface with a Tauri process and gives it access to a local core. It prepares configuration and storage before core work starts. It also owns desktop state such as the main window, tray, menus, notifications, app locking, sharing, and updates.
The host supports these operating modes:
- Standalone: the desktop owns the core and local data.
- Client: the interface connects to another Pipedash host.
- Setup or locked: the interface can show status and configuration work while core-dependent actions wait.
Setup can create the first session or replace storage settings. During a reconfiguration, the desktop clears its current projection before it attaches the new core. This prevents menus and tray data from showing the previous storage session.
When the desktop acts as a client, it is ready only while the remote connection is active. A change to the remote host or connection mode clears old pins, notices, and other projected data before new data arrives. This keeps local desktop actions tied to the current host rather than to a previous session.
The desktop runtime also projects core and server changes into menus, tray state, notification history, and the interface. A remote connection can supply the projection when the desktop is acting as a client. The desktop command boundary also reads and updates general settings through the core, then starts notification synchronization when those settings change. See Desktop runtime composition for the detailed desktop lifecycle.
The desktop host also coordinates native build watching. It allows one active watch session at a time and ties that session to the current provider and core generation. A provider change, core replacement, or native end signal stops only the matching session, so a new watch cannot be cancelled by stale state.
References: crates/…/setup.rs• L39-112 crates/…/pipelines.rs• L25-180 crates/…/settings.rs• L17-38 crates/…/session.rs• L21-205 crates/…/native.rs• L38-124 crates/…/tests.rs• L127-344 crates/…/desktop.rs• L37-146 crates/…/state.rs• L89-184 crates/…/projection.rs• L31-121 crates/…/tests.rs• L297-354 crates/…/tests.rs• L194-226 crates/…/tests.rs• L147-353 crates/…/lib.rs• L84-250
Web host
The web host runs Pipedash as a network service. It loads or reports configuration, prepares storage, creates the core session, and then serves the product API. It can serve the built interface from the same process or accept an external frontend.
The service has a clear startup path:
- Inspect configuration and choose setup, configuration-error, or normal mode.
- Create storage and the core session when configuration is usable.
- Warm the token store and start background work when the vault is unlocked.
- Bind the configured address and serve HTTP and WebSocket traffic.
Health reporting makes these host states visible without requiring the core to be ready. It distinguishes setup, configuration errors, initialization, normal operation, and database failure. A database probe returns an unavailable status when its query cannot complete, while releasing the host state lock before it waits for the database.
The service can run under a validated base path. Its embedded frontend is built for release packages and uses a safe placeholder during non-release or incomplete builds, so a missing frontend asset does not silently become a broken package state.
Setup and vault routes let a host move from configuration or locked state to a usable core session. Locking removes the active session and tells connected clients that the vault is locked. General settings and pipeline views remain web-accessible through the API when their owning core session is ready. See Web service endpoints for the endpoint groups and transport contract.
References: crates/…/main.rs• L33-110 crates/…/main.rs• L113-271 crates/…/health.rs• L13-101 crates/…/tests.rs• L63-121 crates/…/setup.rs• L54-190 crates/…/settings.rs• L16-45 crates/…/vault.rs• L50-217 crates/…/tests.rs• L156-426 crates/…/build.rs• L4-56
Shared capability boundary
The desktop command bridge and web API expose the same high-level product surface. Provider management, pipeline actions, run history, logs, metrics, views, settings, storage, vault state, and device access can therefore use one frontend service contract even when the transport differs.
Live state follows the same boundary. The local desktop uses Tauri events, while network clients use WebSocket events. The web event channel carries product updates and controls access before a client can issue requests. A client that falls behind is closed so it can reconnect and rebuild its state instead of using an incomplete event stream.
Desktop pipeline commands first require an active core session. They then pass pipeline reads and actions to the core service, which keeps the native command boundary separate from pipeline rules. The web host exposes the same relationship for pipeline views, memberships, pins, navigation, and the menu snapshot used by desktop state.
Web failures use a stable JSON shape with a code, message, and optional details. Core errors map to HTTP status classes such as unauthorized, forbidden, conflict, rate limited, unavailable, timeout, and bad gateway. This gives browser and remote clients a common way to handle failures.
References: src/…/service.ts• L7-60 src/…/api.ts• L73-271 src/…/tauri.ts• L88-127 crates/…/pipelines.rs• L25-180 crates/…/settings.rs• L17-38 crates/…/settings.rs• L16-45 crates/…/tests.rs• L258-360 crates/…/error.rs• L12-114 crates/…/tests.rs• L127-239
Native runtime bridge
The native runtime connects product actions to operating-system behavior that a browser cannot provide. It supports native notifications, deep links, appearance, accessibility, haptics, badges, settings, privacy cover behavior, and platform-specific lifecycle actions.
Desktop settings control tray visibility, background behavior, system notifications, and automatic update checks. Background mode depends on the tray being enabled. Settings changes are serialized and retried when a save or tray update fails, so the interface can show the pending preference instead of silently losing it. A general settings update also schedules local notification synchronization so provider and alert state follows the new core settings. Update checks publish a status that moves from checking to available or current, then through download and install when the user accepts an update. An installed update restarts the app.
Credentials use the platform keyring on desktop and native keyring stores on mobile. The host serializes keyring access and can migrate older provider entries into the current token store. This keeps provider secrets outside ordinary application settings while preserving access across host versions.
On mobile, local background notifications use the native runtime even when the main interface is not active. The host keeps authorized provider access, alert observations, notification preferences, and the alert-host cursor in protected local storage. It refreshes provider state and hosted alerts within a time budget, then delivers only the notifications allowed by the current preferences. A one-time watch is marked as used after its matching run finishes, so a later preference sync cannot fire it again.
Native intents remain available until the interface reads and acknowledges them. This protects links and notification actions that arrive during startup or while the app window is inactive. Platform support differs by target, so desktop-only sharing and updater features do not define the mobile host.
Native build-watch state follows the same bridge. The host exposes support, availability, and the current watch to the interface, while native status changes can end an in-flight core operation. A watch that is unavailable or no longer owned by this host is removed from the visible status instead of being retained as active state.
References: crates/…/settings.rs• L33-117 crates/…/settings.rs• L121-253 crates/…/settings.rs• L261-359 crates/…/settings.rs• L28-38 crates/…/state.rs• L63-157 crates/…/tests.rs• L89-210 crates/…/tests.rs• L32-44 crates/…/tests.rs• L97-267 crates/…/updater.rs• L33-55 crates/…/updater.rs• L165-326 crates/…/settings.rs• L36-110 crates/…/settings.rs• L189-305 crates/…/store.rs• L24-77 crates/…/store.rs• L113-217 crates/…/tests.rs• L13-159 crates/…/tests.rs• L46-153 crates/…/wake.rs• L63-232 crates/…/keyring_store.rs• L23-55 crates/…/native.rs• L27-67 crates/…/session.rs• L122-205 crates/…/tests.rs• L95-125 crates/…/lib.rs• L49-82 crates/…/tauri.conf.json• L2-22
Sharing host
The desktop sharing host makes a local desktop core available to paired devices on the local network. It reuses the web host’s HTTP and WebSocket behavior, but marks the service as desktop-hosted. Remote clients can use product capabilities without taking ownership of storage, vault, setup, or other machine-level settings.
Sharing starts only when enabled and when the desktop has a usable network address. Pairing gives a device a credential that the shared service checks on later connections. When the desktop core is replaced or stops, the shared host and its client connections must follow that lifecycle so clients do not use stale state.
References: crates/…/mod.rs• L81-103 crates/…/mod.rs• L222-405 crates/…/vault.rs• L57-81 crates/…/tests.rs• L82-162 crates/…/tests.rs• L263-302
Access boundaries
The hosts protect state at both the transport and host levels. Authentication and pairing protect requests from unknown clients. Host ownership keeps machine-level changes on the process that owns the core and its storage.
Setup, health, and vault status remain available when the core is not ready. Core-dependent work reports a service-unavailable or host-locked state instead of pretending that the session is usable. The web host rejects cross-origin writes and WebSocket upgrades by default unless its configuration explicitly allows them.
The web host keeps API authentication active across vault lock and failed unlock attempts. A paired device can use product routes but cannot use host-managed routes such as storage changes, factory reset, or server vault control. Health reports host readiness separately from API authorization, so monitoring can inspect setup and database state without gaining product access.
The web host reports failures through the same structured response shape for normal HTTP requests and WebSocket request responses. A locked or broken host can therefore reject clients without losing paired-device records or hiding the reason for the rejection.
References: crates/…/error.rs• L41-104 crates/…/health.rs• L30-100 crates/…/tests.rs• L63-121 crates/…/main.rs• L243-271 crates/…/tests.rs• L60-110 crates/…/tests.rs• L218-324 crates/…/tests.rs• L207-239 crates/…/tests.rs• L425-461 crates/…/tests.rs• L768-796
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the frontend service contract aligned between Tauri command names, HTTP route shapes, WebSocket request rules, and shared domain response types.
- When core startup, replacement, or vault locking changes, update desktop projections, shared-host state, background work, and client event behavior together.
- When the web base path or embedded frontend mode changes, check both static asset serving and API or WebSocket paths.
- When health state changes, keep setup, configuration, initialization, database, and HTTP status reporting consistent for monitoring clients.
- When a route changes ownership, review authentication and host-managed route guards together.
- When general settings change, preserve the desktop notification synchronization trigger and the web response contract.
- When desktop settings change, preserve the dependency between tray visibility and background mode, plus the updater wake-up behavior.
- When a native intent or event changes, keep its event name, pending state, parser, and frontend acknowledgement flow aligned.
- When build watching changes, keep the native status, session identity, provider or core-generation binding, interruption queue, and selected-run link aligned.
- When background notifications change, keep native authorization, protected records, preference merging, alert cursors, push state, and active-session checks aligned.
- When a client or server switch changes, invalidate projected pins, notices, and in-flight replies from the old host.
- When error mappings change, preserve the HTTP status and error-code contract for both HTTP and WebSocket clients.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Desktop sharing starts without a usable network address | The shared host does not run and remote pairing cannot start | Report the sharing failure and keep the host stopped |
| A desktop core is locked, replaced, or not ready | Local projections or remote requests can use stale or unavailable data | Clear the projection, stop dependent work, and report the current host state |
| A client or server switch leaves old projected data active | Pins, notices, or replies from the old host appear in the new session | Change the session ticket and clear old projections before accepting new data |
| The web service starts with invalid or missing configuration | Users reach setup or an error state instead of a usable core | Keep setup and configuration status routes available and block normal core work |
| A health query cannot reach the database | Monitoring sees an unavailable service even if the process is running | Return a database-error health state with a service-unavailable status |
| A client connects before authentication or with an invalid device token | The request is rejected and the socket closes | Require operator or paired-device authentication before requests |
| A paired device calls a machine-owned operation | A remote device could change the computer that owns the data | Apply host ownership checks and return a host-managed error |
| A WebSocket client falls behind the event stream | The client may miss state changes and show stale data | Close the lagging socket so the client reconnects and resynchronizes |
| The embedded frontend asset is missing during packaging | The service could ship without a usable page | Build it for release or create an explicit placeholder that reports the missing build |
| Background notification authorization belongs to an old host or session | The mobile host can show alerts for the wrong server or stale provider data | Match saved host identity and core instance before saving or using background state |
| Background notification work is disabled or replaced while a refresh is running | An old task can continue or cancel a newer refresh | Gate refresh start on enabled state and cancel only the matching task |
| A build-watch session is replaced or receives a stale native end signal | A new watch could stop or display state from an older watch | Match cancellation and status changes by session identity and clear unavailable watches |
Key files
| File | Why to read it |
|---|---|
| crates/…/lib.rs | Desktop entry point, native plugins, command boundary, and run lifecycle |
| crates/…/tauri.conf.json | Desktop web asset, development server, security policy, and update package settings |
| crates/…/setup.rs | Desktop setup, reconfiguration, and core bootstrap boundary |
| crates/…/pipelines.rs | Desktop pipeline command boundary and core-session guard |
| crates/…/settings.rs | Desktop general-settings bridge and notification synchronization trigger |
| crates/…/session.rs | Build-watch session ownership, cancellation, and replacement rules |
| crates/…/native.rs | Native build-watch status, stop requests, and interruption handling |
| crates/…/tests.rs | Guarantees for watch replacement, cancellation, native links, and interruption handling |
| crates/…/desktop.rs | Desktop state, window behavior, menus, tray, and shutdown behavior |
| crates/…/state.rs | Readiness, session identity, projected state, and the desktop status contract |
| crates/…/projection.rs | Projection of local or remote core state into desktop UI state |
| crates/…/settings.rs | Desktop preferences and their effect on tray, background mode, notifications, and updates |
| crates/…/tests.rs | Guarantees for locked, client, pinned-pipeline, notification, and route behavior |
| crates/…/tests.rs | Guarantees for tray status, client readiness, notification counts, and build-watch state |
| crates/…/updater.rs | Desktop update lifecycle and user-visible update status |
| crates/…/settings.rs | Notification authorization, core synchronization, host detachment, and mobile background state |
| crates/…/store.rs | Protected records for notification authorization, preferences, observations, and alert-host cursors |
| crates/…/wake.rs | Provider and hosted-alert refresh flow for background notifications |
| crates/…/keyring_store.rs | Platform credential storage boundary for provider tokens |
| crates/…/main.rs | Web service startup, configuration, frontend serving, and network binding |
| crates/…/health.rs | Readiness and database health contract for service monitoring |
| crates/…/setup.rs | Transition from setup or configuration error to an active core session |
| crates/…/settings.rs | Web general-settings API boundary |
| crates/…/tests.rs | HTTP guarantees for views, memberships, pins, navigation, and desktop menu data |
| crates/…/vault.rs | Web vault state, unlock, lock, and session replacement |
| crates/…/error.rs | HTTP error contract shared by web clients |
| crates/…/tests.rs | Guarantees for authentication, pairing, host ownership, vault state, and readiness errors |
| crates/…/tests.rs | WebSocket authentication, pairing, event delivery, backpressure, and shutdown behavior |
| crates/…/build.rs | Embedded frontend build and missing-asset behavior |