Skip to main content
The Chat Interface is the primary operational surface of the Palyra Web Console. It manages the lifecycle of agent interactions, including message composition, real-time streaming transcripts, tool approval workflows, and session branching.

Architecture and Data Flow

The chat system is built around the ChatConsolePanel which orchestrates several specialized hooks and components to maintain a high-fidelity view of the agent’s state.

Component Hierarchy

State Orchestration

The system uses useChatRunStream to handle NDJSON streaming from the daemon’s GatewayService. This hook manages the “live” transcript and active run state apps/web/src/chat/ChatConsolePanel.tsx#147-153. Session-level metadata and history are managed by useChatSessions apps/web/src/chat/ChatConsolePanel.tsx#110-115.

ChatComposer and Input Management

The ChatComposer is a sophisticated input area supporting rich context preparation before a message is dispatched to the LLM.

Slash Commands

The composer implements a “Slash Command” system for operational shortcuts. Commands are parsed using parseSlashCommand apps/web/src/chat/chatShared.tsx#165-168.
CommandAction
/newCreates a fresh session apps/web/src/chat/chatShared.tsx#84-88
/branchCreates a child session from the current run apps/web/src/chat/chatShared.tsx#102-106
/queueAppends a follow-up message without interrupting the current run apps/web/src/chat/chatShared.tsx#108-112
/compactTriggers transcript compaction to reduce context window usage apps/web/src/chat/chatShared.tsx#145-150

Context Budget and Previews

To prevent context window overflow, the composer calculates a ContextBudgetSummary apps/web/src/chat/chatShared.tsx#54-65.

Drag-and-Drop Attachments

Files dropped into the composer are processed via uploadComposerAttachments. This converts files to base64 and registers them with the daemon’s MediaArtifactStore apps/web/src/chat/chatConsoleUtils.ts#164-186.

ChatTranscript and Entry Kinds

The transcript renders a list of TranscriptEntry objects. To keep the UI performant, it limits rendered items to the latest 120 entries apps/web/src/chat/ChatTranscript.tsx#46-51.

Entry Types

The system supports multiple TranscriptEntryKind values apps/web/src/chat/chatShared.tsx#171-184:
  • assistant: Standard text output from the model.
  • tool: Execution logs for plugin calls.
  • approval_request: Interactive UI for authorizing sensitive operations.
  • a2ui / canvas: Protocol-specific frames for rich UI rendering.

Tool Payload Inspection

Large tool payloads are moved out of the main transcript flow to avoid clutter. Users click “Inspect payload” to view the raw JSON in the ChatInspectorColumn apps/web/src/chat/ChatTranscript.test.tsx#93-117.

Approval Request Controls

When a tool is marked as sensitive, the daemon emits an approval_request. The console renders ApprovalRequestControls inline within the transcript apps/web/src/chat/ChatTranscript.tsx#17-18.

Rich Rendering: A2UI and Canvas

Palyra supports two methods for agents to render complex UIs:

A2UI (Agent-to-UI)

The A2uiRenderer processes specialized documents published by plugins. It supports incremental updates and security-sandboxed rendering apps/web/src/chat/ChatTranscript.tsx#2.

Canvas Rendering

The canvas entry kind renders an <iframe> pointing to /canvas/v1/frame/.... These frames are strictly sandboxed with sandbox="allow-scripts" to prevent cross-site scripting from agent-generated content apps/web/src/chat/ChatTranscript.test.tsx#202-205.

System Interaction Diagram

The following diagram illustrates how user actions in the Web Console transition into the daemon’s internal state. Title: Chat Interaction Flow Sources: apps/web/src/chat/ChatComposer.tsx#124-130, apps/web/src/chat/useChatRunStream.ts#147-153, apps/web/src/chat/ChatTranscript.tsx#160-165.

Data Mapping: UI to Code Entities

This diagram maps the visual components of the Chat Interface to the underlying TypeScript interfaces and Rust models. Title: Chat Entity Mapping Sources: apps/web/src/chat/chatShared.tsx#38-52, apps/web/src/chat/chatShared.tsx#186-203, apps/web/src/chat/ChatInspectorColumn.tsx#38-44, apps/web/src/chat/chatConsoleUtils.ts#32-39.

Transcript Tools and Recall Preview

The ChatInspectorColumn provides utility for managing long-running sessions: Sources:
  • apps/web/src/chat/ChatConsolePanel.tsx
  • apps/web/src/chat/chatShared.tsx
  • apps/web/src/chat/ChatComposer.tsx
  • apps/web/src/chat/ChatTranscript.tsx
  • apps/web/src/chat/ChatInspectorColumn.tsx
  • apps/web/src/chat/chatConsoleUtils.ts
  • apps/web/src/chat/chatSessionActions.ts
  • apps/web/src/chat/useChatRunStream.ts