Skip to main content
The Desktop UI, also known as the Companion Shell, is the primary graphical interface for the Palyra desktop application. It is a Vite-based React frontend hosted within a Tauri container, providing users with a “Control Center” to manage local daemons, handle agent approvals, and conduct chat sessions.

Architecture and Data Flow

The Desktop UI follows a reactive state-management pattern where the frontend periodically polls the Tauri backend for a unified system snapshot.

Implementation Overview

Data Flow Diagram

The following diagram illustrates how the UI synchronizes with the underlying Rust services. Sources: apps/desktop/ui/src/hooks/useDesktopCompanion.ts#18-101, apps/desktop/ui/src/lib/desktopApi.ts#50-51, apps/desktop/src-tauri/src/companion.rs#51-67

Core Entities and Types

The frontend interacts with several key data structures defined in the desktopApi.ts bridge, which mirror the Rust structs in companion.rs.
Code Entity (TypeScript)Source FileDescription
DesktopCompanionSnapshotapps/desktop/ui/src/lib/desktopApi.ts#227-243The root state object containing metrics, sessions, and status.
SessionCatalogRecordapps/desktop/ui/src/lib/desktopApi.ts#62-81Represents an agent session with token counts and last intent.
DesktopCompanionNotificationapps/desktop/ui/src/lib/desktopApi.ts#19-26System notifications (approvals, connections, runs).
InventoryDeviceRecordapps/desktop/ui/src/lib/desktopApi.ts#147-175Details about paired devices and their trust states.
Sources: apps/desktop/ui/src/lib/desktopApi.ts#1-243, apps/desktop/src-tauri/src/companion.rs#30-67

Key Frontend Components

1. useDesktopCompanion Hook

This hook is the engine of the UI. It implements a polling loop that adjusts its frequency based on the connection state:

2. Main Shell (App.tsx)

The App component manages navigation between sections: home, chat, approvals, access, and onboarding apps/desktop/ui/src/App.tsx#44-50. It also handles:

3. IPC Bridge (desktopApi.ts)

This file abstracts Tauri’s invoke calls into asynchronous TypeScript functions. Key functions include: Sources: apps/desktop/ui/src/App.tsx#52-195, apps/desktop/ui/src/hooks/useDesktopCompanion.ts#18-68, apps/desktop/ui/src/lib/desktopApi.ts#1-42

Onboarding and Discord Setup

The onboarding wizard is a specialized flow within the Companion Shell that guides the user through initial configuration.

Implementation Details

Sources: apps/desktop/ui/src/lib/desktopApi.ts#197-208, apps/desktop/src-tauri/src/companion.rs#11-15

Control Center and Launcher

The “Home” section acts as a Control Center, providing a high-level view of system health and process status.

System Monitoring

The UI displays the status of sidecar processes (like palyrad and palyra-browserd) using the ServiceProcessSnapshot apps/desktop/ui/src/lib/desktopApi.ts#268-272.

Visual Mapping: UI to Code

Sources: apps/desktop/ui/src/App.tsx#4-9, apps/desktop/ui/src/lib/desktopApi.ts#3-10, apps/desktop/ui/src/lib/desktopApi.ts#217-272