palyrad (the core daemon) and palyra-browserd (the browser automation daemon).
Supervisor Architecture
TheControlCenter 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 theServiceKind 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 localDesktopSecretStore:
desktop_admin_token: Used for administrative control of thepalyradgateway apps/desktop/src-tauri/src/lib.rs#11-11.desktop_browser_auth_token: Used to authenticate the connection between the gateway and the browser daemon apps/desktop/src-tauri/src/lib.rs#12-12.
Data Flow: Sidecar Supervision
The following diagram illustrates how the TauriControlCenter 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
TheControlCenterSnapshot is the primary data structure sent to the React frontend. It aggregates:
- Quick Facts: Versioning, uptime, and connectivity status for Discord and Browser services apps/desktop/src-tauri/src/snapshot.rs#88-96.
- Diagnostics: Aggregated errors and observability metrics (failure rates, queue depths) apps/desktop/src-tauri/src/snapshot.rs#99-104.
- Process Snapshots: Detailed PID and liveness info for both sidecars apps/desktop/src-tauri/src/snapshot.rs#178-179.
- Log Buffers: A rolling window of the last 400 log lines per service apps/desktop/src-tauri/src/lib.rs#2-2.
Implementation Entities
| Entity | Role | Source |
|---|---|---|
ControlCenter | Main supervisor struct holding process handles and state. | apps/desktop/src-tauri/src/supervisor.rs#201 |
ManagedService | State container for a single sidecar process. | apps/desktop/src-tauri/src/supervisor.rs#97 |
DesktopStateFile | JSON-persisted state (onboarding progress, preferences). | apps/desktop/src-tauri/src/desktop_state.rs#236 |
build_snapshot_from_inputs | Function that transforms raw supervisor state into a UI-ready snapshot. | apps/desktop/src-tauri/src/snapshot.rs#204 |
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
TheDesktopCompanionState 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
- Offline Drafts: If the gateway is unreachable, the desktop app can queue “Offline Drafts” apps/desktop/src-tauri/src/desktop_state.rs#60-66. These are persisted locally and can be retried once connectivity is restored.
- Notifications: The supervisor generates notifications for events like pending approvals or trust state changes apps/desktop/src-tauri/src/desktop_state.rs#50-57.
Exposed Tauri Commands
The frontend communicates with the supervisor via a set of async Tauri commands defined incommands.rs.
Primary Commands
get_snapshot: Returns the fullControlCenterSnapshotapps/desktop/src-tauri/src/commands.rs#54-62.get_desktop_companion_snapshot: Returns a snapshot tailored for the companion UI, including session catalogs and inventory apps/desktop/src-tauri/src/commands.rs#108-123.set_browser_service_enabled: Toggles the desired state of thepalyra-browserdsidecar apps/desktop/src-tauri/src/commands.rs#154-162.send_companion_chat_message: Routes a message to the gateway or queues it as an offline draft apps/desktop/src-tauri/src/commands.rs#205-214.decide_companion_approval: Submits an approval/denial decision for a pending tool call apps/desktop/src-tauri/src/commands.rs#217-225.
Diagnostics & Recovery
The supervisor exposes commands for system health:run_support_bundle_export: Triggers the CLI’s support bundle logic to collect logs and state for debugging apps/desktop/src-tauri/src/commands.rs#242-248.get_onboarding_status: Provides detailed progress of the initial setup wizard apps/desktop/src-tauri/src/commands.rs#83-92.