Transcript playground
Role-labelled message history with collapsible traces, rich body rendering and scroll following.
Preview
Example controls
State matrix
| Variant | Default |
|---|---|
| Sample |
Published example
API reference'use client'
import { useState } from 'react'
import { Button, EmptyState, LoadingState } from '@ancrel/ui'
import { SimpleMarkdown } from '@ancrel/workspace/markdown'
import { Transcript, type TranscriptMessage } from '@ancrel/workspace/transcript'
import '@ancrel/tokens/css'
import '@ancrel/ui/styles.css'
import '@ancrel/workspace/styles.css'
export default function App() {
const [phase, setPhase] = useState<'empty' | 'streaming' | 'done'>('empty')
const messages: TranscriptMessage[] = [
{ id: 'q', role: 'Reader', content: 'What changed?' },
{ id: 'trace', role: 'trace', content: 'Compared two revisions.' },
{ id: 'reply', role: 'Editor', content: phase === 'done' ? '**Added** an index.' : 'Comparing…' },
]
return <>
<Button disabled={phase === 'done'} onClick={() => setPhase(phase === 'empty' ? 'streaming' : 'done')}>
{phase === 'empty' ? 'Start review' : 'Finish review'}
</Button>
{phase === 'empty' ? <EmptyState title="Start a review to see the conversation" /> :
<Transcript label="Review conversation" messages={messages} renderMessage={message =>
typeof message.content === 'string'
? <SimpleMarkdown source={message.content} streaming={phase === 'streaming' && message.id === 'reply'} />
: message.content} />}
{phase === 'streaming' && <LoadingState label="Receiving reply" inline />}
</>
}