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 theControlCenter 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 theServiceKind enum apps/desktop/src-tauri/src/supervisor.rs#30-33:
- Gateway: The
palyraddaemon apps/desktop/src-tauri/src/supervisor.rs#45. - Browserd: The
palyra-browserdautomation service apps/desktop/src-tauri/src/supervisor.rs#46.
ManagedService struct apps/desktop/src-tauri/src/supervisor.rs#97-107 which tracks:
child: The actual OS process handle apps/desktop/src-tauri/src/supervisor.rs#99.restart_attempt: Counter for exponential backoff logic apps/desktop/src-tauri/src/supervisor.rs#102.logs: AVecDequecontaining the last 400 lines of output apps/desktop/src-tauri/src/lib.rs#2.
Data Flow: Supervisor to Frontend
The supervisor collects internal metrics and service status into a unified snapshot.| Component | Code Entity | Responsibility |
|---|---|---|
| State Holder | ControlCenter | Holds PIDs, ports, and process handles. |
| Snapshot Logic | SnapshotBuildInputs | Aggregates data from supervisor and external probes. |
| IPC Command | get_snapshot | Tauri command that serializes state for the UI. |
| Log Stream | LogEvent | MPSC channel that routes stdout/stderr to internal buffers. |
Process Management Lifecycle
The following diagram illustrates how theControlCenter 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
Thecommands.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
- System Control:
get_snapshotapps/desktop/src-tauri/src/commands.rs#54-62 andget_settingsapps/desktop/src-tauri/src/commands.rs#75-80 provide the UI with real-time status. - Onboarding: Commands like
acknowledge_onboarding_welcomeapps/desktop/src-tauri/src/commands.rs#126-132 andset_onboarding_state_root_commandapps/desktop/src-tauri/src/commands.rs#135-151 manage the initial setup wizard. - Companion Shell: Functions such as
send_companion_chat_messageapps/desktop/src-tauri/src/commands.rs#9 bridge the UI to the underlying gRPC gateway.
Desktop State & Persistence
The application persists local settings and onboarding progress in astate.json file, managed via DesktopStateFile apps/desktop/src-tauri/src/desktop_state.rs#222-240.
State Components
- Onboarding Progress: Tracks the current step (e.g.,
Welcome,Environment,Completion) apps/desktop/src-tauri/src/desktop_state.rs#209-219. - Companion State: Stores UI-specific data like the
active_section,notifications, andoffline_draftsapps/desktop/src-tauri/src/desktop_state.rs#90-101. - Secrets: Sensitive tokens (Admin and Browser Auth) are stored using
DesktopSecretStore, which utilizespalyra-vaultapps/desktop/src-tauri/src/desktop_state.rs#15-17.
Onboarding & Snapshots
The onboarding system uses a “Preflight” mechanism to ensure the environment is ready for the daemons to run.Preflight Checks
Thebuild_onboarding_status function apps/desktop/src-tauri/src/onboarding.rs#156-160 executes several checks:
- Port Availability: Checks if ports like
7142(Admin) or7443(gRPC) are blocked apps/desktop/src-tauri/src/lib.rs#16-20. - Binary Resolution: Locates the sidecar executables on the host filesystem apps/desktop/src-tauri/src/supervisor.rs#50-60.
- State Root Validation: Ensures the directory for logs and databases is writable apps/desktop/src-tauri/src/desktop_state.rs#36-37.
Snapshot Generation
TheControlCenterSnapshot apps/desktop/src-tauri/src/snapshot.rs#173-182 is the primary data structure for the “Cockpit” view. It aggregates:
QuickFactsSnapshot: Version info and dashboard URLs apps/desktop/src-tauri/src/snapshot.rs#88-96.DiagnosticsSnapshot: Error counts and observability metrics apps/desktop/src-tauri/src/snapshot.rs#99-104.ServiceProcessSnapshot: Detailed PID and uptime info for each sidecar apps/desktop/src-tauri/src/supervisor.rs#179-190.
Companion Architecture
The “Companion” is a lightweight interface within the desktop app that communicates with thepalyrad gateway.
- Session Resolution: Uses
resolve_companion_chat_sessionapps/desktop/src-tauri/src/commands.rs#9 to link the desktop UI to an active orchestration run. - Handoff: Generates signed URLs via
build_companion_handoff_urlapps/desktop/src-tauri/src/commands.rs#8 to transition the user from the desktop app to the full Web Console. - Notifications: Manages local OS notifications for human-in-the-loop approvals using the
DesktopCompanionNotificationstruct apps/desktop/src-tauri/src/desktop_state.rs#50-57.