Repository navigation
feat(narratives): render interleaved text and chart blocks in the UI - #577
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the Narratives UI to support streaming and rendering answers as structured blocks (text and charts) rather than raw text chunks. It introduces a coordinated text reveal mechanism across sequential blocks, waits for charts to settle before displaying the answer, and adds support for composite citation markers (e.g., [1, 2]). Feedback on these changes includes a warning to replace relative parent imports with project path aliases in panel_answer.tsx to align with the repository style guide, and a suggestion to wrap the text reveal schedule calculation in useMemo to prevent unnecessary recalculations on render.
juliawu
left a comment
There was a problem hiding this comment.
Overall looks good! Leaving some gemini comments below.
Overview
#576 switched the server's SSE
contentframe payload from{text}and{chart_config}to{block}. This PR updates the React UI to accumulate those blocks and render text and charts interleaved in the order they were emitted.{block}frames in order and joins text blocks with a blank line, so the answer text matches the server's signed transcript.[N, M]markers render as separate citation chips in prose and in Markdown tables.The core files to review are
ui/src/hooks/use_sse_chat.ts,ui/src/components/panel_answer.tsx, andui/src/components/tile_chart.tsx.Related Issues
This is the seventeenth step in the continued agent loop update sequence, following #547, #549, #550, #558, #559, #562, #563, #564, #565, #566, #568, #569, #570, #571, #572, #574, and #576.
Changes Made
[1]) and multi-source ([1, 2]) citation markers, used by both prose citation chips and Markdown tables.{block}frames instead of{text}and{chart_config}and drops malformed blocks; a turn with charts but no answer text shows only its error, as before #576. The answer panel renders blocks in emission order and keeps the existing word-by-word reveal, now spread across text blocks; the rendering path for{text}and{chart_config}turns is removed because nothing produces those turns anymore. The chart tile maps the new chart options onto the web components and reports when its charts have drawn, the chart settle poll reports when it stops watching a chart, the turn view holds the answer invisibly behind the skeleton until its charts settle, the Markdown card drops its unused streaming badge, the word-reveal plugin accepts a start offset, and the debug provenance inspector reads charts from blocks.Testing Done
pnpm test:ui(vitest run): 32 files, 349 passed (28 files, 304 passed onmain).pnpm lint:ui(tsc --noEmitandbiome check): passed across 58 checked files (53 onmain).pnpm test:agent(uv run pytest): 1,706 passed.pnpm lint:agent(ruff format --check . ../deploy,ruff check . ../deploy, andmypy --strict): passed across all 124 source files.pnpm build: passed.pnpm run lint:shell,pnpm run lint:docker, andterraform fmt -check -recursive deploy/terraform-custom-datacommons/: passed (terraform validatefails locally with a pre-existing backend configuration error onmain; nodeploy/files were modified).pnpm test:ui.Checklist:
Manual
Ran the server's synthesis, block splitting, and turn signing on a stubbed turn and fed the resulting SSE bytes through the UI's stream parser and components, rendered in a DOM test environment:
[1, 2]markers render as two citation chips in prose and move onto table column headers.Risk & Rollback
There are no live instances of this application yet. This PR completes the SSE
{block}contract migration started in #576: until it merges,mainstreams{block}frames that the UI does not render. Rollback is reverting this PR together with #576.Follow-ups
Checklist
AGENTS.mdand followedCODING_GUIDELINES.md, plusFRONTEND.mdfor UI changes.Note: Only Maintainers can approve and merge PRs. Expected initial review time: 3 business days.