Playground Output Components#
Three components handle generation output rendering in the Playground UI: GenerationCompletionRow (completion/non-chat outputs), GenerationChatRow / GenerationChatRowOutput (chat history outputs), and SharedEditor (the shared display/edit shell used by both). They live under web/oss/src/components/Playground/Components/.
GenerationCompletionRow#
GenerationCompletionRow handles output for non-chat (completion) variants in the Playground. It is the primary row component for single-input runs.
Key behaviors:
- Reads run state (
__runs[variantId].__result,__isRunning) fromusePlaygroundvia a scopedstateSelector. - Resolves the result lazily via
getResponseLazy(resultHash), keeping renders decoupled from raw state. - Renders different output states:
"Running..."text whileisRunningis true- Placeholder
"Click run to generate output"when there is no result - Error state β a read-only
SharedEditorwitherrorprop set and an inlineGenerationResultUtilsfooter - Tool call array response β one
SharedEditorper message withcodeOnlymode, showing parsed function name/call ID in the header - Plain / JSON response β a single
SharedEditor; JSON content is detected viaJSON5.parseand displayed incodeOnlymode
- Auto-scrolls to the bottom of the page after new results arrive in chat mode via
autoScrollToBottom. - In
singleview mode (notfocus), wraps its own run/cancel buttons alongside the output area. In comparison/focus modes the layout is handled by the parent . - Props:
variantId?,rowId,inputOnly?,view?, plus HTML div props .
Entry point: GenerationCompletionRow/index.tsx
GenerationChatRow and GenerationChatRowOutput#
Both are exported from GenerationChatRow/index.tsx and together manage chat-mode generation output.
GenerationChatRowOutput#
GenerationChatRowOutput renders a single chat turn (one history item).
- When
isRunningis true, shows a "Generating responseβ¦" placeholder viaTextControl. - Hidden messages (
__hidden === true) are skipped entirely . - Delegates to
PromptMessageConfigfor the actual message display (role label, content editor, delete/re-run actions). SetserroronPromptMessageConfigwhen the resolvedmessageResulthas an error . - Appends
GenerationResultUtils(token count, latency, cost) as thefooterwhen a result is present .
GenerationChatRow#
GenerationChatRow manages the full history loop and run/add controls.
- Reads chat history from
usePlayground, resolving per-variant run results viahistoryItem.__runs[variantId]. - Maps over
historyItemsand renders aGenerationChatRowOutputfor each, computing acanRerunpredicate per turn . - Tool messages (role
"tool") are never re-runnable . - Comparison view collapses gaps between messages (
!gap-0) . - When
withControlsis true, renders Run/Cancel and "Add Message" buttons below the history . - Uses
next/dynamicforGenerationResultUtilsto avoid SSR issues .
Entry point: GenerationChatRow/index.tsx
SharedEditor#
SharedEditor is a thin, styled wrapper around the Lexical-based EditorWrapper (or an Ant Design Input when useAntdInput is true). It provides a consistent visual shell used throughout the Playground for both editable and read-only content.
Key behaviors:
- Debounces value changes (300 ms) via
useDebounceInputbefore callinghandleChange. - Accepts optional
headerandfooterslots for surrounding content (e.g., function-call metadata header,GenerationResultUtilsfooter) . - Two border styles via
editorType:"border"(visible border) or"borderless"(border transparent until hover/focus) . - Error state (
error={true}) renders all text in red . codeOnlymode (passed througheditorProps) adjusts layout for code blocks and disables token interpolation .- A stable
editorIdis memoized from a UUID +codeOnlyflag; changingcodeOnlyremounts the Lexical editor instance .
Props summary (from SharedEditor/types.d.ts):
| Prop | Type | Notes |
|---|---|---|
initialValue | any | Seeded into the Lexical editor on mount |
handleChange | (value: string) => void | Called after 300 ms debounce |
editorType | "border" | "borderless" | Visual shell style |
state | "default" | "filled" | "disabled" | "readOnly" | ... | Controls pointer events and background |
header / footer | ReactNode | Slots above/below the editor |
editorProps | EditorProps | Passed through to the Lexical Editor |
error | boolean | Renders content in red |
useAntdInput | boolean | Swaps Lexical for Ant Design Input |
Entry point: SharedEditor/index.tsx
Supporting Components#
| Component | Role |
|---|---|
GenerationResultUtils | Footer showing token counts, latency, cost, and a trace drawer button |
GenerationOutputText | Ant Design Typography.Text wrapper with placeholder styling |
PromptMessageConfig | Full message editor (role, content, delete/re-run) β used inside GenerationChatRowOutput |
PlaygroundVariantPropertyControl | Renders per-variable input fields within GenerationCompletionRow |
Component Hierarchy#
Playground view
βββ GenerationCompletionRow β completion (non-chat) output row
β βββ PlaygroundVariantPropertyControl β variable inputs
β βββ RunButton / cancel
β βββ SharedEditor β output display (plain / JSON / tool call / error)
β βββ GenerationResultUtils (footer)
β
βββ GenerationChatRow β chat output history loop
βββ GenerationChatRowOutput β single chat turn
βββ PromptMessageConfig β message editor
βββ GenerationResultUtils (footer)