palyrad and palyra-browserd), managing persistent local state, and providing a secure bridge between the system and the React-based user interface.
ControlCenter Supervisor
TheControlCenter 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 theServiceKind enum:
- Gateway (
palyrad): The core daemon providing the gRPC and HTTP API. - Browserd (
palyra-browserd): The headless browser automation service.
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 sidecarstdout 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.
- Capacity: Up to 400 lines per service are retained apps/desktop/src-tauri/src/lib.rs#2-2.
- Sanitization: Log lines are passed through
sanitize_log_lineto redact sensitive information like tokens or local paths before being sent to the UI apps/desktop/src-tauri/src/snapshot.rs#33-33.
Process Lifecycle Diagram
This diagram illustrates the relationship between theControlCenter 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
TheDesktopStateFile is a JSON-backed persistence layer located in the user’s app data directory. It stores:
- Onboarding Progress: Tracks the current
DesktopOnboardingStepapps/desktop/src-tauri/src/desktop_state.rs#209-219. - Companion Preferences: Stores the active UI section, last selected session ID, and device ID apps/desktop/src-tauri/src/desktop_state.rs#90-101.
- Notifications & Drafts: Local history of desktop notifications and offline message drafts apps/desktop/src-tauri/src/desktop_state.rs#98-99.
DesktopSecretStore
Sensitive tokens are managed viaDesktopSecretStore, which leverages the palyra-vault crate for secure storage apps/desktop/src-tauri/src/desktop_state.rs#8-8.
- Admin Token: Used by the desktop app to authenticate against the local
palyradadmin API apps/desktop/src-tauri/src/lib.rs#11-11. - Browser Auth Token: Used for securing the connection to
palyra-browserdapps/desktop/src-tauri/src/lib.rs#12-12.
Snapshot and Diagnostics
The backend provides a unifiedControlCenterSnapshot 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 thepalyrad 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
TheDiagnosticsSnapshot includes:
- Error Tracking: A collection of the last 25 system errors apps/desktop/src-tauri/src/lib.rs#4-4.
- Observability Metrics: Success/failure rates for provider auth, connector uploads, and browser relays apps/desktop/src-tauri/src/snapshot.rs#107-115.
- Dropped Events: Counter for log events dropped due to channel saturation apps/desktop/src-tauri/src/snapshot.rs#102-102.
Tauri Command Interface
The bridge between the React frontend and the Rust backend is defined incommands.rs. These functions are exposed to the UI via the desktopApi.ts wrapper.
| Command | Purpose | Implementation |
|---|---|---|
get_snapshot | Returns the full system status snapshot. | apps/desktop/src-tauri/src/commands.rs#54 |
get_onboarding_status | Returns the current onboarding phase and step. | apps/desktop/src-tauri/src/commands.rs#83 |
set_browser_service_enabled | Toggles the palyra-browserd sidecar. | apps/desktop/src-tauri/src/commands.rs#154 |
update_desktop_companion_preferences | Persists UI state (active tab, etc.) to disk. | apps/desktop/src-tauri/src/commands.rs#165 |
run_support_bundle_export | Generates a diagnostic ZIP for troubleshooting. | apps/desktop/src-tauri/src/commands.rs#31 |