Skip to main content
This page documents the persistence layer, the multi-step onboarding state machine, and the React-based Companion Shell of the Palyra Desktop application. The Desktop application serves as both a process supervisor for the core daemon and a local-first operator interface.

Dual-Layer Persistence Model

Palyra Desktop utilizes a two-tier storage strategy to balance ease of migration with secure credential handling.

1. Unencrypted State (state.json)

General application configuration, window preferences, and non-sensitive status are stored in a versioned JSON file located at <state_root>/desktop-control-center/state.json apps/desktop/src-tauri/src/supervisor.rs#209-210.

2. Encrypted Secret Store (palyra-vault)

Sensitive tokens required for daemon orchestration are managed via the DesktopSecretStore, which wraps the palyra-vault crate apps/desktop/src-tauri/src/desktop_state.rs#8.
Persistence ComponentFile/PathLogic Entity
Public Statestate.jsonDesktopStateFile
Secret VaultPlatform SpecificDesktopSecretStore
Profile Catalogcli/profiles.tomlDesktopProfileCatalog
Sources: apps/desktop/src-tauri/src/lib.rs#9-12, apps/desktop/src-tauri/src/desktop_state.rs#8-103, apps/desktop/src-tauri/src/supervisor.rs#203-215.

Desktop Onboarding State Machine

The onboarding process is managed as a linear state machine defined by the DesktopOnboardingStep enum apps/desktop/src-tauri/src/desktop_state.rs#205-215.

State Transition Flow

The ControlCenter tracks the current step in the persisted state and exposes it via get_onboarding_status apps/desktop/src-tauri/src/commands.rs#84-93.
  1. Welcome: Initial splash screen acknowledgement apps/desktop/src-tauri/src/desktop_state.rs#206.
  2. Environment: Validates binary paths for palyrad and palyra-browserd apps/desktop/src-tauri/src/desktop_state.rs#207.
  3. StateRoot: Operator confirms or overrides the directory for logs, databases, and keys apps/desktop/src-tauri/src/desktop_state.rs#208.
  4. GatewayInit: Desktop triggers the initial startup of the sidecar daemon apps/desktop/src-tauri/src/desktop_state.rs#209.
  5. OperatorAuthBootstrap: Generates the initial admin credentials apps/desktop/src-tauri/src/desktop_state.rs#210.
  6. Provider Connect (OpenAI/Discord): Optional steps for configuring model providers and connectors apps/desktop/src-tauri/src/desktop_state.rs#211-212.
  7. DashboardHandoff: Final step where the operator is transitioned to the full Web Console apps/desktop/src-tauri/src/desktop_state.rs#213.

Implementation Diagram: Onboarding Logic

Sources: apps/desktop/src-tauri/src/commands.rs#84-150, apps/desktop/src-tauri/src/onboarding.rs#78-112, apps/desktop/src-tauri/src/desktop_state.rs#205-215.

Companion Shell and Offline Drafts

The Companion Shell is a React-based UI (apps/desktop/ui) that communicates with the Tauri backend to provide a lightweight interface for chat and approvals.

Offline Draft System

To prevent data loss during daemon restarts or network instability, the desktop app implements an offline draft queue.

Dashboard Handoff

The Desktop app facilitates a “Handoff” to the more powerful Web Console by generating short-lived tokens.

System Integration Diagram

Sources: apps/desktop/ui/src/App.tsx#21-43, apps/desktop/src-tauri/src/companion.rs#153-176, apps/desktop/src-tauri/src/desktop_state.rs#175-201.

Technical Details: Companion Snapshots

The UI is driven by a comprehensive snapshot fetched via get_desktop_companion_snapshot apps/desktop/src-tauri/src/commands.rs#109-122.

DesktopCompanionSnapshot Structure

This object aggregates data from multiple sources:
FunctionRoleFile Reference
build_companion_snapshotAggregates all data into the snapshot structapps/desktop/src-tauri/src/companion.rs#80-101
reconcile_companion_snapshotUpdates local preferences based on remote dataapps/desktop/src-tauri/src/supervisor.rs#226-235
fetch_companion_transcriptRetrieves the message history for a specific sessionapps/desktop/src-tauri/src/companion.rs#9
Sources: apps/desktop/src-tauri/src/companion.rs#80-101, apps/desktop/src-tauri/src/commands.rs#109-122, apps/desktop/ui/src/lib/desktopApi.ts#255-273.