Skip to main content
The Palyra Web Dashboard is a React-based Single Page Application (SPA) that serves as the primary operator interface for the daemon. It relies on a centralized ConsoleApiClient for all communication with the palyrad HTTP surface and uses a unified application state hook to manage domain-specific data, authentication, and the boot lifecycle.

ConsoleApiClient

The ConsoleApiClient class in apps/web/src/consoleApi.ts is the low-level transport layer for the dashboard. It encapsulates session management, CSRF protection, and specialized handling for streaming responses.

CSRF and Session Management

The client maintains an internal ConsoleSession object containing a csrf_token.

NDJSON Streaming

The client supports streaming runs and logs using Newline Delimited JSON (NDJSON).

Data Flow: API Request Lifecycle

The following diagram illustrates how the ConsoleApiClient interacts with the browser’s fetch API and the daemon’s middleware. Console API Request Flow Sources: apps/web/src/consoleApi.ts#1591-1635, apps/web/src/consoleApi.test.ts#44-90

Application State and useConsoleAppState

The useConsoleAppState hook is the central state manager for the dashboard, located in apps/web/src/console/useConsoleAppState.tsx. It orchestrates the lifecycle of the application from boot to logout.

Domain Separation

To maintain maintainability, the state is split into logical domains, each managed by a specialized hook:

Auto-Refresh Logic

The dashboard implements a TTL-based auto-refresh strategy for different sections. The shouldAutoRefreshSection function checks if a section’s data is stale based on defined intervals apps/web/src/console/useConsoleAppState.tsx#42-54.
  • Overview/Auth: 10 seconds.
  • Channels: 8 seconds.
  • Config/Secrets: 15 seconds.
Sources: apps/web/src/console/useConsoleAppState.tsx#164-240

Boot Lifecycle and Handoff Flow

The application follows a strict boot sequence to ensure the operator is authenticated before any domain data is fetched.

Boot Sequence

  1. booting state: Initially true. The App component renders ConsoleBootScreen apps/web/src/App.tsx#16-18.
  2. Handoff Check: The app checks for a desktop_handoff_token in the URL query parameters apps/web/src/console/useConsoleAppState.tsx#133-143.
  3. Session Recovery:
  4. Transition: Once a session is acquired, booting is set to false. If no session is found, the user is redirected to ConsoleAuthScreen apps/web/src/App.tsx#20-30.

Desktop Handoff Token Flow

The “Desktop Handoff” is the primary mechanism for the Palyra Desktop app to open the web dashboard without requiring manual password entry. Handoff Token Exchange Sources: apps/web/src/console/useConsoleAppState.tsx#109-123, apps/web/src/App.test.tsx#69-107, apps/web/src/console/useConsoleAppState.tsx#145-153

Key Entities and Types

EntityDescriptionFile
ConsoleSessionRepresents an active operator session, including principal, device, and CSRF token.apps/web/src/consoleApi.ts#280-288
SessionCatalogRecordDetailed metadata for a chat session, including token counts and approval status.apps/web/src/consoleApi.ts#29-49
UsageSummaryEnvelopeContainer for usage metrics, cost estimates, and timeline buckets.apps/web/src/consoleApi.ts#124-130
ControlPlaneApiErrorCustom error class for handling non-2xx responses from the daemon.apps/web/src/consoleApi.ts#1568-1582
Sources: apps/web/src/consoleApi.ts#1-280