Workspace Architecture
The chat interface is orchestrated byChatConsolePanel apps/web/src/chat/ChatConsolePanel.tsx#81-88, which coordinates several specialized hooks and components to manage state across the transcript, composer, and inspector.
Key Components
| Component | Responsibility |
|---|---|
ChatConsolePanel | Top-level orchestrator for the chat workspace apps/web/src/chat/ChatConsolePanel.tsx#81. |
ChatConsoleWorkspaceView | Layout definition for the three-column view (Sessions, Conversation, Inspector) apps/web/src/chat/ChatConsoleWorkspaceView.tsx#50. |
ChatComposer | Multi-functional input field with support for slash commands, attachments, and budget previews apps/web/src/chat/ChatComposer.tsx#66. |
ChatTranscript | High-performance renderer for conversational entries and tool outputs apps/web/src/chat/ChatTranscript.tsx#9. |
ChatInspectorColumn | Sidebar for out-of-band data: A2UI surfaces, background tasks, and run tapes apps/web/src/chat/ChatInspectorColumn.tsx#109. |
Data Flow: Chat Workspace
The following diagram illustrates how user input and server events flow through the React component tree. Chat Workspace Data Flow Sources: apps/web/src/chat/ChatConsolePanel.tsx#125-168, apps/web/src/chat/ChatConsoleWorkspaceView.tsx#142-190, apps/web/src/chat/useChatRunStream.ts#59Slash Command Pipeline
Palyra uses a unified slash command system shared between the Web UI and the TUI apps/web/src/chat/chatCommandRegistry.ts#3-18. Commands can be executed locally in the browser or dispatched to the server.Command Resolution
- Parsing:
parseSlashCommandextracts the command name and arguments apps/web/src/chat/chatShared.tsx#76-79. - Suggestions:
buildSlashSuggestionsprovides autocomplete for commands and entities (sessions, objectives, profiles) apps/web/src/chat/chatCommandSuggestions.ts#60-98. - Execution:
executeChatSlashCommandroutes the command to specific handlers likebranchCurrentSessionActionorcreateUndoCheckpointapps/web/src/chat/chatSlashActions.ts#147-186.
Session and Run Management
Session Branching
Branching allows an operator to fork a conversation into a new session from a specific point in the lineage. This is handled bybranchCurrentSessionAction apps/web/src/chat/chatSessionActions.ts#153-167, which calls the api.branchSession endpoint.
Run Streaming and Interruption
Runs are managed viauseChatRunStream apps/web/src/chat/useChatRunStream.ts#59, which handles the NDJSON event stream from the gateway.
- Interruption: Operators can trigger a “Soft” or “Force” interrupt via the
/interruptcommand or the UI button apps/web/src/chat/chatSlashActions.ts#58-79. - Undo Checkpoints: Before potentially destructive actions (like retry or redirect), the system automatically creates an “undo_safe” checkpoint apps/web/src/chat/chatSlashActions.ts#17-38.
Context Budget System
The interface tracks the “Context Budget” to prevent LLM context window overflows. TheuseChatContextBudget hook calculates tokens for the baseline history, current draft, and active attachments apps/web/src/chat/chatShared.tsx#61-72.
- Soft Limit: 12,000 tokens apps/web/src/chat/chatShared.tsx#29.
- Hard Limit: 16,000 tokens apps/web/src/chat/chatShared.tsx#30.
Media and Artifact Pipeline
The chat interface supports a sophisticated pipeline for handling files and derived artifacts.Attachment Handling
useChatAttachmentUploadHandler manages the lifecycle of uploading files to the session apps/web/src/chat/chatInspectorActions.ts#35. Attachments are represented as ComposerAttachment objects containing metadata and preview URLs apps/web/src/chat/chatShared.tsx#45-59.
Compaction and Checkpoints
To manage long transcripts, the system supports:- Compaction: Reducing the transcript size while preserving key information apps/web/src/chat/chatConsoleOperations.ts#24.
- Checkpoints: Point-in-time snapshots of the session state that can be restored apps/web/src/chat/ChatInspectorColumn.tsx#83-85.
Inspector and A2UI
TheChatInspectorColumn apps/web/src/chat/ChatInspectorColumn.tsx#109 serves as a secondary display for non-conversational data:
- A2UI Surfaces: Documents published by the agent for the user to interact with apps/web/src/chat/ChatInspectorColumn.tsx#161-182.
- Run Tapes: Detailed execution logs of tool calls and internal thoughts apps/web/src/chat/ChatRunDrawer.tsx#10.
- Background Tasks: Long-running operations that exist outside the main chat loop apps/web/src/chat/ChatInspectorColumn.tsx#87-92.