Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions packages/genui/a2ui-playground/src/pages/PlaybackPage.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
border-bottom: 1px solid var(--geist-border);
background: var(--geist-background);
flex-shrink: 0;
flex-wrap: wrap;
}

.playbackPanelTitle {
Expand All @@ -45,6 +46,22 @@
text-transform: uppercase;
}

.playbackScenarioSelect {
font-size: 12px;
padding: 3px 6px;
border-radius: 6px;
border: 1px solid var(--geist-border);
background: var(--geist-background);
color: var(--geist-foreground);
cursor: pointer;
max-width: 200px;
}

.playbackScenarioSelect:focus {
outline: none;
border-color: var(--geist-foreground);
}

.playbackControls {
display: flex;
align-items: center;
Expand Down Expand Up @@ -199,3 +216,36 @@
text-transform: uppercase;
letter-spacing: 0.06em;
}

/* ── Responsive ── */
@media (max-width: 980px) {
.playbackPage {
flex-direction: column;
}

.playbackStreamPanel {
flex: 0 0 auto;
min-height: 260px;
max-height: 340px;
border-right: none;
border-bottom: 1px solid var(--geist-border);
}

.playbackScenarioSelect {
max-width: 100%;
width: 100%;
}

.playbackPreviewPanel {
width: 100%;
flex: 1;
border-left: none;
border-top: 1px solid var(--geist-border);
min-height: 480px;
}

.playbackControls {
flex-wrap: wrap;
gap: 6px;
}
}
44 changes: 19 additions & 25 deletions packages/genui/a2ui-playground/src/pages/PlaybackPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';

import './PlaybackPage.css';

import { PLAYBACK_SCENARIOS } from '../demos.js';
import { DYNAMIC_PRESETS, STATIC_DEMOS } from '../demos.js';
import { DEFAULT_A2UI_DEMO_URL } from '../utils/demoUrl.js';
import type { Protocol } from '../utils/protocol.js';

type PlayState = 'idle' | 'playing' | 'paused' | 'done';

const STREAM_DELAY_MS = 800;

const ALL_SCENARIOS = [
...STATIC_DEMOS,
...DYNAMIC_PRESETS,
];

function formatChunk(msg: unknown): string {
return JSON.stringify(msg, null, 2);
}
Expand All @@ -21,7 +26,7 @@ export function PlaybackPage(props: { protocol: Protocol }) {
const { protocol } = props;

const [scenarioId, setScenarioId] = useState<string>(
PLAYBACK_SCENARIOS[0]?.id ?? '',
ALL_SCENARIOS[0]?.id ?? '',
);
const [playState, setPlayState] = useState<PlayState>('idle');
const [currentIndex, setCurrentIndex] = useState(-1);
Expand All @@ -36,8 +41,8 @@ export function PlaybackPage(props: { protocol: Protocol }) {
null,
);

const currentScenario = PLAYBACK_SCENARIOS.find((s) => s.id === scenarioId)
?? PLAYBACK_SCENARIOS[0];
const currentScenario = ALL_SCENARIOS.find((s) => s.id === scenarioId)
?? ALL_SCENARIOS[0];
const messages = Array.isArray(currentScenario?.messages)
? currentScenario.messages
: [];
Expand Down Expand Up @@ -150,30 +155,19 @@ export function PlaybackPage(props: { protocol: Protocol }) {

return (
<div className='playbackPage'>
<aside className='sidebar'>
<div className='sidebarSection'>
<div className='sidebarHeading'>Scenarios</div>
<div className='scenarioList'>
{PLAYBACK_SCENARIOS.map((s) => (
<button
key={s.id}
type='button'
className={s.id === scenarioId
? 'scenarioItem active'
: 'scenarioItem'}
onClick={() => handleSelectScenario(s.id)}
>
<span className='scenarioName'>{s.title}</span>
</button>
))}
</div>
</div>
</aside>

<div className='playbackStreamPanel'>
<div className='playbackPanelHeader'>
<span className='playbackPanelTitle'>JSONL Stream</span>
<span className='playbackPanelTitle'>Message Stream</span>
<span className='playbackPanelBadge'>JSONL</span>
<select
className='playbackScenarioSelect'
value={scenarioId}
onChange={(e) => handleSelectScenario(e.target.value)}
>
{ALL_SCENARIOS.map((s) => (
<option key={s.id} value={s.id}>{s.title}</option>
))}
</select>
<div className='spacer' />
<div className='playbackControls'>
<label className='simSpeedLabel' htmlFor='pbSpeedSlider'>
Expand Down
Loading