Chat Message Components#
Agenta uses a layered set of React components to render chat messages across three distinct surfaces: the Playground (prompt configuration and live generation), Evaluations, and general-purpose chat input/display. The components share a common ChatMessage / ChatRole type contract but differ significantly in their responsibilities — from simple readonly display to fully interactive message editing with state-driven playground integration.
Core Types#
ChatMessage and ChatRole (defined in web/oss/src/lib/Types.ts) are the shared primitives used throughout all chat message components:
ChatRoleenum:system,user,assistant,functionChatMessage:{ role: ChatRole, content: string, id?: string }
Component Overview#
| Component | Location | Context |
|---|---|---|
ChatInputs | web/oss/src/components/ChatInputs/ChatInputs.tsx | General-purpose editable/readonly message list |
EvaluationChatResponse | web/oss/src/components/Evaluations/EvaluationCardView/EvaluationChatResponse.tsx | Read-only evaluation result display |
PromptMessageConfig | web/oss/src/components/Playground/Components/PromptMessageConfig/ | Full message editor for prompt configuration |
GenerationChatRow | web/oss/src/components/Playground/Components/PlaygroundGenerations/assets/GenerationChatRow/index.tsx | Live generation output in playground |
ChatInputs#
ChatInputs is the lowest-level reusable component. It renders a list of ChatMessage objects as role-selector + textarea pairs, with +/− controls to add/remove messages. Key behaviors:
- Supports both controlled (
value) and uncontrolled (defaultValue) usage - The
readonlyprop disables all editing controls (role selector, content area, add/remove buttons) simultaneously - Error state: messages whose content starts with
❌receive a distinct red background - A copy button floats over the last assistant message
- Exported helper
getDefaultNewMessage()generates a fresh user message with a UUID
Used as the rendering primitive by EvaluationChatResponse.
EvaluationChatResponse#
EvaluationChatResponse wraps ChatInputs in read-only mode to display a single variant's chat output inside the Evaluation Card view. It:
- Parses
outputTextwithsafeParseto extract.contentfrom a JSON-encoded assistant message - Renders a
VariantAlphabetbadge and color-coded variant name with the revision number - Passes a single hardcoded
assistantrole message toChatInputswithreadonly
Props: variant, outputText, index, showVariantName, evaluation.
PromptMessageConfig#
PromptMessageConfig is the richest of the chat message components. It is the per-message editor inside the Playground's prompt configuration panel and supports three rendering modes based on message type :
- Standard message — role dropdown + Lexical-based
SharedEditorfor message content - Tool/function call — displays function name input and JSON argument editor
- Function output — renders function call results
It consumes the usePlayground hook for bidirectional state synchronization, meaning edits are propagated into centralized playground state without manual prop threading . The component is wrapped by PromptMessageConfigWrapper, which sets up the Lexical editor provider and handles JSON vs. plain-text content detection.
Prop types extend BaseContainerProps and SharedEditorProps , and expose callbacks for deleteMessage, rerunMessage, and handleChange .
GenerationChatRow / GenerationChatRowOutput#
GenerationChatRow manages the chat conversation history for live generation runs in the Playground. It reads history items from centralized state via usePlayground and renders each turn using GenerationChatRowOutput, which in turn delegates to PromptMessageConfig for message display.
Notable behaviors:
- Supports both single and comparison view modes — comparison view collapses gaps between messages
- Handles per-variant run results via
__runs[variantId]on history items - Tool messages (role
tool) are not re-runnable - The
withControlsprop enables run/cancel and "Add Message" buttons below the history - Uses dynamic import for
GenerationResultUtilsto avoid SSR issues
Component Hierarchy#
ChatInputs ← standalone editable/readonly list
└── used by EvaluationChatResponse ← readonly evaluation display
PromptMessageConfig ← Lexical editor, playground state
└── used by GenerationChatRowOutput
└── used by GenerationChatRow ← history loop + run controls
└── used by Playground views
Related Components#
PromptMessageContentOptions— action menu (delete, re-run, minimize) integrated insidePromptMessageConfigVariantAlphabet— color-coded letter badge used in evaluation displayGenerationResultUtils— token/latency metadata rendered as a footer insideGenerationChatRowOutput