Skip to main content
The Tauri backend serves as the orchestration layer for the Palyra Desktop Companion. It is responsible for the lifecycle of sidecar processes (palyrad and palyra-browserd), managing persistent local state, and providing a secure bridge between the system and the React-based user interface.

ControlCenter Supervisor

The ControlCenter is the central supervisor struct that manages the runtime environment of the desktop application. It handles process monitoring, port allocation, and log aggregation.

Service Management

The supervisor manages two primary sidecar services defined by the ServiceKind enum:
  • Gateway (palyrad): The core daemon providing the gRPC and HTTP API.
  • Browserd (palyra-browserd): The headless browser automation service.
Each service is encapsulated in a ManagedService struct which tracks its PID, liveness status, and restart attempts apps/desktop/src-tauri/src/supervisor.rs#97-107. The supervisor runs a “tick” loop every 500ms to ensure desired services are running and to perform health checks apps/desktop/src-tauri/src/lib.rs#1-1.

Log Aggregation

Logs from sidecar stdout and stderr are captured via async pipes and funneled into a bounded VecDeque within the ManagedService apps/desktop/src-tauri/src/supervisor.rs#105-105.

Process Lifecycle Diagram

This diagram illustrates the relationship between the ControlCenter and the underlying OS processes. Title: ControlCenter Process Supervision Sources: apps/desktop/src-tauri/src/supervisor.rs#201-218, apps/desktop/src-tauri/src/supervisor.rs#30-33, apps/desktop/src-tauri/src/supervisor.rs#97-107

State and Persistence

Desktop state is split into two categories: non-sensitive configuration/history and sensitive credentials.

DesktopStateFile

The DesktopStateFile is a JSON-backed persistence layer located in the user’s app data directory. It stores:

DesktopSecretStore

Sensitive tokens are managed via DesktopSecretStore, which leverages the palyra-vault crate for secure storage apps/desktop/src-tauri/src/desktop_state.rs#8-8. Sources: apps/desktop/src-tauri/src/desktop_state.rs#222-240, apps/desktop/src-tauri/src/lib.rs#35-39

Snapshot and Diagnostics

The backend provides a unified ControlCenterSnapshot to the UI, aggregating data from the supervisor, the local state, and the active sidecar services.

Data Flow: Snapshot Collection

The snapshot process involves querying the local supervisor and making internal HTTP calls to the palyrad health and diagnostic endpoints. Title: Snapshot Data Aggregation Flow Sources: apps/desktop/src-tauri/src/commands.rs#54-62, apps/desktop/src-tauri/src/snapshot.rs#173-182, apps/desktop/src-tauri/src/onboarding.rs#137-154

Diagnostic Collection

The DiagnosticsSnapshot includes:

Tauri Command Interface

The bridge between the React frontend and the Rust backend is defined in commands.rs. These functions are exposed to the UI via the desktopApi.ts wrapper.
CommandPurposeImplementation
get_snapshotReturns the full system status snapshot.apps/desktop/src-tauri/src/commands.rs#54
get_onboarding_statusReturns the current onboarding phase and step.apps/desktop/src-tauri/src/commands.rs#83
set_browser_service_enabledToggles the palyra-browserd sidecar.apps/desktop/src-tauri/src/commands.rs#154
update_desktop_companion_preferencesPersists UI state (active tab, etc.) to disk.apps/desktop/src-tauri/src/commands.rs#165
run_support_bundle_exportGenerates a diagnostic ZIP for troubleshooting.apps/desktop/src-tauri/src/commands.rs#31
Sources: apps/desktop/src-tauri/src/commands.rs#1-38, apps/desktop/ui/src/lib/desktopApi.ts#1-2