Skip to main content
The Palyra Chat Interface is the primary operator surface for interacting with autonomous agents. It is designed to handle high-density information, including streaming transcripts, tool execution payloads, context budget visualizations, and rich UI components (A2UI).

Chat Architecture Overview

The chat interface is implemented as a multi-column workspace. It separates the primary conversation from diagnostic “signals” to maintain readability while providing full transparency into agent operations.

Key Components

Data Flow: Chat Stream and Sessions

The interface relies on two primary hooks for data synchronization:
  1. useChatSessions: Manages the session catalog, allowing users to create, rename, archive, and switch between conversations apps/web/src/chat/useChatSessions.ts#37-42.
  2. useChatRunStream: Connects to the daemon’s gRPC/NDJSON gateway to handle live message streaming, tool updates, and run lifecycle events apps/web/src/chat/ChatConsolePanel.tsx#132-168.

Chat Interface Logic Flow

This diagram bridges the React component space with the underlying streaming and command logic. Sources: apps/web/src/chat/ChatComposer.tsx, apps/web/src/chat/chatCommandRegistry.ts, apps/web/src/chat/useChatRunStream.ts, apps/web/src/chat/useChatContextBudget.ts

Slash Commands and Palette

Palyra uses a shared command registry defined in chatCommandRegistry.json apps/web/src/chat/chatCommandRegistry.json#1-133. This ensures parity between the Web Console and the TUI apps/web/src/chat/chatCommandRegistry.ts#33-36.

Command Execution

Commands are categorized by their execution target:

The Slash Palette

The useChatSlashPalette hook provides real-time suggestions as the user types. It filters the registry based on keywords and surface compatibility (web vs tui) apps/web/src/chat/chatCommandRegistry.ts#38-42.
CommandSynopsisPurpose
new/new [label]Create a fresh session apps/web/src/chat/chatCommandRegistry.json#27.
branch/branch [label]Fork the current session into a new lineage apps/web/src/chat/chatCommandRegistry.json#196.
undo/undo [id]Revert to a previous ChatCheckpointRecord apps/web/src/chat/chatCommandRegistry.json#147.
interrupt/interruptForce stop a running agent apps/web/src/chat/chatCommandRegistry.json#159.
Sources: apps/web/src/chat/chatCommandRegistry.ts, apps/web/src/chat/chatCommandRegistry.json

Context Budget and Compaction

To prevent context window overflow, the UI provides real-time visibility into token usage via useChatContextBudget.

Budget Calculation

The system calculates a ContextBudgetSummary including: The UI displays a “tone” (default, warning, danger) based on soft (12,000) and hard (16,000) limits apps/web/src/chat/chatShared.tsx#29-30.

Session Compaction and Branching

When a session nears its limit, users can trigger Compaction:
  1. Preview: The server plans which messages to summarize or prune apps/web/src/console/sections/SessionsSection.tsx#156-183.
  2. Apply: The server generates a ChatCompactionArtifactRecord and updates the session tape apps/web/src/console/sections/SessionsSection.tsx#185-202.
Branching allows an operator to create a “child” session from any point in the transcript, preserving the parent’s history up to that point without affecting the original session apps/web/src/chat/chatSessionActions.ts#49. Sources: apps/web/src/chat/chatShared.tsx, apps/web/src/chat/useChatContextBudget.ts, apps/web/src/console/sections/SessionsSection.tsx

A2UI: Agent-to-User Interface

A2UI is a protocol for agents to push structured interactive elements to the console. These are rendered via the A2uiRenderer.

Supported Components

The renderer handles several component types defined in A2uiComponent apps/web/src/a2ui/types.ts:

Canvas Rendering

A2UI documents can be designated as “Canvas” surfaces. The ChatConsolePanel tracks these via a2uiDocuments and provides a dedicated view for long-lived UI state that persists across multiple turns apps/web/src/chat/ChatConsolePanel.tsx#147.

A2UI Component Mapping

This diagram maps the A2UI JSON protocol to the React rendering logic. Sources: apps/web/src/a2ui/renderer.tsx, apps/web/src/a2ui/types.ts To maintain performance, the UI implements a sliding window for the rendered transcript:

Search and Pinning

Operators can search the session history using searchChatTranscript apps/web/src/chat/chatConsoleOperations.ts#25. Important events (like specific tool outputs or assistant conclusions) can be pinned using pinChatTranscriptRecord, which creates a ChatPinRecord for quick access in the inspector sidebar apps/web/src/chat/ChatConsolePanel.tsx#22. Sources: apps/web/src/chat/chatShared.tsx, apps/web/src/chat/ChatConsolePanel.tsx, apps/web/src/chat/chatConsoleOperations.ts