Skip to main content
The Palyra Desktop application, built on the Tauri framework, serves as a management hub and supervisor for the core Palyra engine. It is responsible for orchestrating the lifecycle of two critical sidecar processes: palyrad (the core daemon) and palyra-browserd (the browser automation daemon).

Supervisor Architecture

The ControlCenter is the central management entity within the Tauri backend. It maintains the desired state of the system, monitors process health, and handles the rotation of security tokens required for sidecar communication.

Process Lifecycle Management

The supervisor manages services defined by the ServiceKind enum: Gateway (palyrad) and Browserd (palyra-browserd) apps/desktop/src-tauri/src/supervisor.rs#30-33. Each service is wrapped in a ManagedService struct which tracks its PID, restart attempts, and bound ports apps/desktop/src-tauri/src/supervisor.rs#97-107. The supervisor runs a periodic “tick” every 500ms (SUPERVISOR_TICK_MS) to ensure the sidecars match their desired state apps/desktop/src-tauri/src/lib.rs#1-1.

Security & Token Management

The supervisor initializes and rotates two primary secrets stored in a local DesktopSecretStore:

Data Flow: Sidecar Supervision

The following diagram illustrates how the Tauri ControlCenter manages the lifecycle and communication of the sidecars. Sidecar Management & Token Distribution Sources: apps/desktop/src-tauri/src/supervisor.rs#201-218, apps/desktop/src-tauri/src/lib.rs#16-20, apps/desktop/src-tauri/src/desktop_state.rs#231-232

Snapshot & State Management

The Desktop application uses a “Snapshot” pattern to provide the UI with a consistent view of the entire system state.

Snapshot Aggregation

The ControlCenterSnapshot is the primary data structure sent to the React frontend. It aggregates:
  1. Quick Facts: Versioning, uptime, and connectivity status for Discord and Browser services apps/desktop/src-tauri/src/snapshot.rs#88-96.
  2. Diagnostics: Aggregated errors and observability metrics (failure rates, queue depths) apps/desktop/src-tauri/src/snapshot.rs#99-104.
  3. Process Snapshots: Detailed PID and liveness info for both sidecars apps/desktop/src-tauri/src/snapshot.rs#178-179.
  4. Log Buffers: A rolling window of the last 400 log lines per service apps/desktop/src-tauri/src/lib.rs#2-2.

Implementation Entities

EntityRoleSource
ControlCenterMain supervisor struct holding process handles and state.apps/desktop/src-tauri/src/supervisor.rs#201
ManagedServiceState container for a single sidecar process.apps/desktop/src-tauri/src/supervisor.rs#97
DesktopStateFileJSON-persisted state (onboarding progress, preferences).apps/desktop/src-tauri/src/desktop_state.rs#236
build_snapshot_from_inputsFunction that transforms raw supervisor state into a UI-ready snapshot.apps/desktop/src-tauri/src/snapshot.rs#204
Sources: apps/desktop/src-tauri/src/supervisor.rs#201-218, apps/desktop/src-tauri/src/snapshot.rs#173-182

Companion Architecture

The “Companion” refers to the desktop-integrated features that bridge the local OS and the Palyra engine. This includes offline drafts, desktop notifications, and a simplified chat/approval interface.

Companion State Machine

The DesktopCompanionState tracks the user’s current context within the desktop app, such as the active_session_id or active_section (Home, Chat, Approvals, etc.) apps/desktop/src-tauri/src/desktop_state.rs#90-101.

Offline Drafts & Notifications

Natural Language to Code Mapping: Companion Flow Sources: apps/desktop/src-tauri/src/companion.rs#119-130, apps/desktop/src-tauri/src/desktop_state.rs#139-161, apps/desktop/src-tauri/src/desktop_state.rs#177-200

Exposed Tauri Commands

The frontend communicates with the supervisor via a set of async Tauri commands defined in commands.rs.

Primary Commands

Diagnostics & Recovery

The supervisor exposes commands for system health: Sources: apps/desktop/src-tauri/src/commands.rs#53-248