Chat UI Components
Relevant source files
The following files were used as context for generating this wiki page:
The Chat UI in KnowledgeVault is a sophisticated, multi-zone workspace designed for high-fidelity RAG (Retrieval-Augmented Generation) interactions. It utilizes a three-zone layout to manage session history, active conversation transcripts, and detailed evidence attribution across documents, memories, and compiled wiki knowledge.
Sources: README.md:522-540, redesign/INTEGRATION_GUIDE.md:8-12
Workspace Architecture
The system implements a responsive three-zone workspace layout that adapts to both desktop and mobile viewports. On desktop, this is primarily a two-pane layout with an optional third zone (Session Rail).
Primary Layout Zones
| Zone | Component | Purpose |
|---|---|---|
| Zone 1 (Left) | SessionRail | Browse and manage chat sessions, search history, and pin important conversations. |
| Zone 2 (Center) | TranscriptPane | The main interaction area containing MarkdownMessage lists and the Composer. |
| Zone 3 (Right) | RightPane | The "Evidence" panel displaying SourceCards, WikiCards, and KMSCards. |
Sources: README.md:522-540, frontend/src/components/chat/RightPane.tsx:442-450
Transcript and Message Components
The TranscriptPane is the core of the chat experience, handling real-time streaming responses and complex markdown rendering.
Rendering Pipeline
The application uses a unified rendering pipeline to ensure consistent display of AI responses. Key components include:
- MarkdownMessage: Handles GFM tables, lists, and blockquotes with
rehype-sanitizefor security. - Shiki Integration: Provides lazy-loaded syntax highlighting for fenced code blocks.
- Citation Handling: Distinct namespaces for different evidence types:
[S#]: Document sources.[M#]: Memory records.[W#]: Wiki claims (compiled knowledge).[K#]: Knowledge Management (KMS) entries.
Sources: specs/chat-ui-ux-premiumization/SPEC.md:78-95, specs/wire-wiki-chat/SPEC.md:120-130, frontend/src/lib/api.ts:503-520
The Composer
The Composer is a specialized input component featuring:
- Auto-growing Textarea: Expands based on content.
- IME Composition Guard: Prevents premature submission during CJK input.
- File Attachment Tray: Supports drag-and-drop and paste for document uploads directly into the active vault.
Sources: specs/chat-ui-ux-premiumization/SPEC.md:112-124
Right Evidence Pane (Canvas)
The RightPane (often referred to as the Evidence Pane or Canvas) serves as a resizable area for deep-diving into the retrieved context used by the LLM.
The diagram shows how the RightPane consumes data from the last completed assistant message to populate specialized tabs.
Sources: frontend/src/components/chat/RightPane.tsx:455-520
Evidence Classification and Preview
The RightPane handles various data types:
- Source Preview: Uses
getChunkContextto fetch surrounding context for a specific chunk or loads the raw document bytes for a fullPdfPreview. - Relevance Scoring: Maps scores to descriptive labels (e.g., "Relevant", "Marginal", "Tangential") based on the
score_type(Distance, Rerank, or RRF). - Extracted Tab: Automatically parses code blocks and tables from the assistant message into a structured view for easy review.
Sources: frontend/src/components/chat/RightPane.tsx:162-230, specs/fix-ui-chat-layout/SPEC.md:50-65
State Management and Data Flow
The Chat UI relies on a normalized Zustand store to prevent unnecessary re-renders during high-frequency token streaming.
Normalized Store Structure
Instead of a flat array of messages, the store uses a messagesById record and a messageIds array. This allows appendToMessage to mutate only the specific message receiving a chunk.
The sequence diagram illustrates the streaming flow where granular updates ensure performance.
Sources: specs/chat-ui-ux-premiumization/SPEC.md:65-75, frontend/src/lib/api.ts:750-800
Interaction Logic: Jump to Answer
A specialized interaction exists between the RightPane and TranscriptPane. Clicking a citation in the transcript triggers a scroll-into-view in the RightPane, while clicking "Jump to answer" in a source preview triggers an evidence:jump-to-answer custom event to highlight the citation in the transcript.
Sources: frontend/src/components/chat/RightPane.tsx:325-335, specs/fix-ui-chat-layout/SPEC.md:45-55
UI/UX Feature Table
| Feature | Description | Relevant Files |
|---|---|---|
| Virtualization | useVirtualizer used for lists with >20 sources to maintain performance. | RightPane.tsx |
| Delete Undo | Toast-based undo for session deletion. | SPEC.md |
| Parent Window | Context expansion around specific chunks in preview. | api.ts, README.md |
| Mobile Adaption | Right pane converts to a bottom sheet (75vh/95vh) on mobile devices. | README.md, ChatShell.tsx |
| Theme System | Support for Light/Dark/System modes via next-themes. | INTEGRATION_GUIDE.md |
Sources: frontend/src/components/chat/RightPane.tsx:490, README.md:545-555, specs/chat-ui-ux-premiumization/SPEC.md:145
The Chat UI Components form a robust system that prioritizes transparency and performance, ensuring users can verify AI claims through multiple layers of citation and evidence visualization.