Skip to main content
The Tauri backend for the Palyra Desktop application acts as a process supervisor and local control plane. It manages the lifecycle of the core daemon (palyrad) and the browser automation daemon (palyra-browserd) as sidecar processes, handles local state persistence, and provides an IPC bridge for the React-based frontend.

Supervisor Architecture

The core of the backend is the ControlCenter apps/desktop/src-tauri/src/supervisor.rs#201-218, which maintains the runtime state of managed services and coordinates diagnostics. It runs a supervisor loop that ticks every 500ms apps/desktop/src-tauri/src/lib.rs#1 to ensure required processes are healthy.

Managed Services

Services are defined by the ServiceKind enum apps/desktop/src-tauri/src/supervisor.rs#30-33: Each service is wrapped in a ManagedService struct apps/desktop/src-tauri/src/supervisor.rs#97-107 which tracks:

Data Flow: Supervisor to Frontend

The supervisor collects internal metrics and service status into a unified snapshot.
ComponentCode EntityResponsibility
State HolderControlCenterHolds PIDs, ports, and process handles.
Snapshot LogicSnapshotBuildInputsAggregates data from supervisor and external probes.
IPC Commandget_snapshotTauri command that serializes state for the UI.
Log StreamLogEventMPSC channel that routes stdout/stderr to internal buffers.

Process Management Lifecycle

The following diagram illustrates how the ControlCenter manages sidecar processes. Sidecar Process Lifecycle Sources: apps/desktop/src-tauri/src/supervisor.rs#97-137, apps/desktop/src-tauri/src/lib.rs#1-4, apps/desktop/src-tauri/src/snapshot.rs#173-182

Tauri IPC Commands

The commands.rs file defines the interface between the Rust backend and the TypeScript frontend. These commands are registered in the Tauri builder and use DesktopAppState apps/desktop/src-tauri/src/commands.rs#49-51 to access the shared ControlCenter.

Key Command Groups

Sources: apps/desktop/src-tauri/src/commands.rs#1-181

Desktop State & Persistence

The application persists local settings and onboarding progress in a state.json file, managed via DesktopStateFile apps/desktop/src-tauri/src/desktop_state.rs#222-240.

State Components

  1. Onboarding Progress: Tracks the current step (e.g., Welcome, Environment, Completion) apps/desktop/src-tauri/src/desktop_state.rs#209-219.
  2. Companion State: Stores UI-specific data like the active_section, notifications, and offline_drafts apps/desktop/src-tauri/src/desktop_state.rs#90-101.
  3. Secrets: Sensitive tokens (Admin and Browser Auth) are stored using DesktopSecretStore, which utilizes palyra-vault apps/desktop/src-tauri/src/desktop_state.rs#15-17.
State Persistence Mapping Sources: apps/desktop/src-tauri/src/desktop_state.rs#1-101, apps/desktop/src-tauri/src/supervisor.rs#221-233

Onboarding & Snapshots

The onboarding system uses a “Preflight” mechanism to ensure the environment is ready for the daemons to run.

Preflight Checks

The build_onboarding_status function apps/desktop/src-tauri/src/onboarding.rs#156-160 executes several checks:

Snapshot Generation

The ControlCenterSnapshot apps/desktop/src-tauri/src/snapshot.rs#173-182 is the primary data structure for the “Cockpit” view. It aggregates: Sources: apps/desktop/src-tauri/src/onboarding.rs#120-153, apps/desktop/src-tauri/src/snapshot.rs#1-182

Companion Architecture

The “Companion” is a lightweight interface within the desktop app that communicates with the palyrad gateway. Sources: apps/desktop/src-tauri/src/companion.rs#7-15, apps/desktop/src-tauri/src/desktop_state.rs#41-57