Skip to main content
The Palyra Desktop application is a Tauri-based companion that manages the lifecycle of the core daemon (palyrad) and the browser automation service (palyra-browserd). It provides a React-based interface for initial setup (onboarding), real-time process monitoring, and a “Companion Shell” for interacting with agent sessions, managing approvals, and handling offline drafts.

Onboarding Wizard Flow

The onboarding process is a multi-step state machine managed by the ControlCenter supervisor. It transitions through several phases to ensure the local environment is prepared, the daemon is initialized, and model providers are configured.

Onboarding Steps

The flow is defined by the DesktopOnboardingStep enum apps/desktop/src-tauri/src/desktop_state.rs#209-219:
  1. Welcome: Initial landing and acknowledgement.
  2. Environment: Validation of system requirements and paths.
  3. State Root: Selection and confirmation of the data directory apps/desktop/src-tauri/src/commands.rs#135-151.
  4. Gateway Init: Bootstrapping the palyra.toml configuration and internal database.
  5. Operator Auth: Generating and securing the administrative tokens.
  6. OpenAI/Discord Connect: Optional steps for connecting external providers and communication channels.
  7. Dashboard Handoff: Transitioning the user to the full Web Console.

Data Flow: Onboarding Status

The UI polls the onboarding state via the get_onboarding_status Tauri command, which aggregates data into an OnboardingStatusSnapshot apps/desktop/src-tauri/src/onboarding.rs#78-110. Onboarding State Transitions
FunctionPurposeFile Reference
set_onboarding_state_root_commandSets the runtime_root where all data is stored.apps/desktop/src-tauri/src/commands.rs#135-151
acknowledge_onboarding_welcomeMarks the initial step as complete in DesktopStateFile.apps/desktop/src-tauri/src/commands.rs#126-132
build_onboarding_statusComputes progress based on persisted state and connectivity.apps/desktop/src-tauri/src/onboarding.rs#156-160
Sources: apps/desktop/src-tauri/src/desktop_state.rs, apps/desktop/src-tauri/src/onboarding.rs, apps/desktop/src-tauri/src/commands.rs

Desktop UI Architecture

The frontend is a React application built with Vite and Tailwind CSS, utilizing @heroui/react for UI components. It communicates with the Rust backend via Tauri’s invoke API.

Key UI Components

UI-to-Code Mapping

The following diagram maps UI concepts to the underlying Rust implementation structures. UI Entity to Code Mapping Sources: apps/desktop/ui/src/App.tsx, apps/desktop/src-tauri/src/commands.rs, apps/desktop/src-tauri/src/supervisor.rs

Companion Shell Features

The Companion Shell provides advanced desktop integration features that extend the capabilities of the headless daemon.

Offline Drafts

When the daemon is unreachable or the user wants to queue a message for later, the Desktop UI stores “Offline Drafts” in the DesktopStateFile apps/desktop/src-tauri/src/desktop_state.rs#60-66.

Desktop Notifications

The supervisor monitors the daemon’s event stream and pushes notifications to the OS.

Handoff and Session Management

The Desktop UI can “handoff” a session to the full Web Console by generating a signed URL using the admin_token. Sources: apps/desktop/src-tauri/src/desktop_state.rs, apps/desktop/src-tauri/src/companion.rs, apps/desktop/ui/src/App.tsx

Platform Considerations

The Desktop app handles several OS-specific requirements, particularly regarding process management and path resolution.

Process Supervision (Windows vs. macOS/Linux)

The ControlCenter uses tokio::process::Command to manage sidecars. On Windows, it applies specific flags to prevent console windows from appearing.

State and Secret Storage

Sources: apps/desktop/src-tauri/src/lib.rs, apps/desktop/src-tauri/src/supervisor.rs, apps/desktop/src-tauri/src/desktop_state.rs

Implementation Detail: Supervisor Logic

The ControlCenter is the heart of the desktop application, responsible for process health and log aggregation. Process Lifecycle & Log Flow

Key Functions

FunctionDescription
ControlCenter::new()Initializes the state file, secret store, and creates the log channels apps/desktop/src-tauri/src/supervisor.rs#221-233.
ManagedService::running()Checks if the child process handle exists and is active apps/desktop/src-tauri/src/supervisor.rs#124-126.
sanitize_log_lineRedacts sensitive information (tokens, keys) from process logs before they are sent to the UI apps/desktop/src-tauri/src/snapshot.rs#31-33.
Sources: apps/desktop/src-tauri/src/supervisor.rs, apps/desktop/src-tauri/src/snapshot.rs