Skip to main content
The Desktop application serves as the primary orchestration layer for the Palyra ecosystem on user workstations. It manages the lifecycle of the core daemon (palyrad), handles profile-specific isolation of data, and provides a “Companion Shell” for ambient interactions such as push-to-talk, offline message queuing, and system notifications.

Onboarding State Machine

The onboarding process is governed by the DesktopOnboardingStep state machine. This flow ensures that the local environment is correctly configured before the daemon is allowed to perform high-risk operations.

Onboarding Steps

The state machine progresses through several distinct phases:
  1. Welcome: Initial landing and acknowledgement apps/desktop/src-tauri/src/desktop_state.rs#210-210.
  2. Environment: Preflight checks for system dependencies apps/desktop/src-tauri/src/desktop_state.rs#211-211.
  3. StateRoot: Selection and validation of the runtime_root where all daemon data (Journal, Vault, etc.) is stored apps/desktop/src-tauri/src/desktop_state.rs#212-212.
  4. Operator: Authentication of the local user and generation of the admin_token apps/desktop/src-tauri/src/desktop_state.rs#213-213.
  5. Providers: Configuration of model providers (e.g., OpenAI) apps/desktop/src-tauri/src/desktop_state.rs#214-214.
  6. Connectors: Setup of external communication channels like Discord apps/desktop/src-tauri/src/desktop_state.rs#215-215.
  7. Completion: Finalization and handoff to the main dashboard apps/desktop/src-tauri/src/desktop_state.rs#216-216.

Preflight and Validation

Before transitioning steps, the ControlCenter executes build_onboarding_status, which aggregates results from probe_dashboard_reachability and port availability checks apps/desktop/src-tauri/src/onboarding.rs#161-165.
ComponentCheckSource
PortsValidates 7142, 7443, 7444 are freeapps/desktop/src-tauri/src/lib.rs#16-18
StateRootEnsures path is writable and not inside a system dirapps/desktop/src-tauri/src/desktop_state.rs#38-41
OperatorVerifies admin_token presence in DesktopSecretStoreapps/desktop/src-tauri/src/lib.rs#11-11
Sources: apps/desktop/src-tauri/src/desktop_state.rs#209-217, apps/desktop/src-tauri/src/onboarding.rs#125-139, apps/desktop/src-tauri/src/lib.rs#16-20

Profile Isolation and Runtime Switching

Palyra Desktop supports multiple isolated profiles. Each profile maps to a specific runtime_root, allowing users to switch between different agent identities, journal histories, and security contexts.

Profile Registry

Profiles are managed via the DesktopProfileCatalog apps/desktop/src-tauri/src/supervisor.rs#223-223. If no profile is explicitly selected, the system defaults to desktop-local apps/desktop/src-tauri/src/desktop_state.rs#23-23.

Runtime Root Switching

When a user switches profiles via switchDesktopCompanionProfile apps/desktop/ui/src/lib/desktopApi.ts#38-38, the ControlCenter performs the following:
  1. Shutdown: Stops all managed services (palyrad, browserd) apps/desktop/src-tauri/src/supervisor.rs#227-229.
  2. Re-resolve: Calls resolve_desktop_state_root to locate the new profile’s data directory apps/desktop/src-tauri/src/desktop_state.rs#38-38.
  3. Migration: If legacy secrets exist in the state.json file, they are migrated into the palyra-vault via migrate_legacy_runtime_secrets_from_state_file apps/desktop/src-tauri/src/desktop_state.rs#37-37.
  4. Restart: Re-initializes the supervisor with the new paths and restarts services apps/desktop/src-tauri/src/commands.rs#147-163.

Onboarding and Profile Entity Mapping

The following diagram illustrates how the natural language concept of “Onboarding” maps to the underlying code entities. Diagram: Onboarding Entity Map Sources: apps/desktop/src-tauri/src/desktop_state.rs#209-217, apps/desktop/src-tauri/src/onboarding.rs#161-165, apps/desktop/src-tauri/src/supervisor.rs#223-223

Companion Shell and React Frontend

The “Companion Shell” is the React-based frontend (apps/desktop/ui) hosted within Tauri. It provides a lightweight interface for agent interaction without requiring the full Console UI.

Key Features

Data Flow: Message Dispatch

The following diagram shows the flow of a message from the UI through the Desktop bridge to the daemon. Diagram: Message Dispatch Flow Sources: apps/desktop/ui/src/App.tsx#34-34, apps/desktop/src-tauri/src/commands.rs#12-12, apps/desktop/src-tauri/src/companion.rs#157-180, apps/desktop/src-tauri/src/desktop_state.rs#179-200

Secret Management and Migration

The Desktop app manages a set of “Runtime Secrets” separate from the daemon’s internal vault. These include the desktop_admin_token used for authenticating the UI to the daemon and the desktop_browser_auth_token for the browser extension apps/desktop/src-tauri/src/lib.rs#11-12.

DesktopSecretStore

Secrets are stored in an encrypted SQLite backend provided by palyra-vault. The DesktopSecretStore manages access to these tokens using the admin:desktop-control-center principal apps/desktop/src-tauri/src/lib.rs#7-7.

Legacy Migration

During the transition to palyra-vault, the function migrate_legacy_runtime_secrets_from_state_file handles the extraction of plaintext tokens from the old state.json file and their insertion into the secure vault apps/desktop/src-tauri/src/desktop_state.rs#37-37. This is a critical path during the StateRoot onboarding step. Sources: apps/desktop/src-tauri/src/lib.rs#7-12, apps/desktop/src-tauri/src/desktop_state.rs#36-41, apps/desktop/src-tauri/src/supervisor.rs#25-27