Repository navigation
fix(shell): render an inline A2UI surface above the message text when the agent sent it first - #256
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces changes to preserve the order of inline surfaces and text in agent chat messages. It adds an inlineSurfaceLeadsText property to track whether an inline surface arrived before any text, allowing the UI to render the surface above or below the text accordingly. This behavior is supported by updates to the stream event parser, chat message component, and corresponding unit tests. I have no feedback to provide as there are no review comments.
⚡ A2UI Composer PR PreviewYour automated preview is successfully live (commit
|
… the agent sent it first An agent can lead a message with a small UI header (for example an avatar-and-name row) followed by its prose, relying on the order of the A2A parts. The chat view accumulates text and A2UI payloads into separate fields and the message template always rendered the text before the inline surface, so the header ended up below the paragraph it was meant to introduce. `A2aStreamEventParser` now records whether an event's A2UI items all preceded its text parts (`a2uiPrecedesText`). `A2aChatView` latches that onto the message (`inlineSurfaceLeadsText`) the first time visible content arrives, so prose streamed afterwards cannot demote a header that already rendered above it, and the message template places the inline surface before or after the text accordingly. Messages whose text comes first, or whose surfaces surround the text, render exactly as before.
A Playwright journey drives the A2A chat against a mock agent that answers one turn with the surface part before the text and another with the text first, and checks the real inline frame renders in each bubble above or below the text to match the wire order. Also states the a2uiPrecedesText update as "held so far and no text yet" rather than through a negated comparison.
be2224a to
0bd327a
Compare
jgindin
left a comment
There was a problem hiding this comment.
Seems like this would be a good candidate for a visual
…ve the message text a2ui-project#256 made the inline surface card follow the order the agent sent its parts, so a surface that arrives before the text now renders above it. The unit specs cover the ordering, but nothing checks what the bubble actually looks like, and jgindin flagged it as a good candidate for a visual test. The new test drives the mock agent through two turns, surface-then-text and text-then-surface, waits for both guest frames to draw, and snapshots each agent bubble on its own so the first one is not cropped by the history's scroll-to-bottom.
…ve the message text (#261) * test(shell): add a visual baseline for an inline surface rendered above the message text #256 made the inline surface card follow the order the agent sent its parts, so a surface that arrives before the text now renders above it. The unit specs cover the ordering, but nothing checks what the bubble actually looks like, and jgindin flagged it as a good candidate for a visual test. The new test drives the mock agent through two turns, surface-then-text and text-then-surface, waits for both guest frames to draw, and snapshots each agent bubble on its own so the first one is not cropped by the history's scroll-to-bottom. * test(shell): commit the workflow-generated visual baselines Adds the two new baselines from the visual_baselines workflow run and takes the six existing ones it regenerated along with them. Five of those differ only in wall-clock timestamps and antialiasing (well under the 2% threshold). a2a-full-chat-view.png also drops the New Session and share buttons from the toolbar: #232 hides them on non-workspace routes such as /a2a, and that baseline had not been regenerated since, so this catches it up with what the shell renders today. * test(shell): send the inline surface with the canonical A2UI MIME type * test(shell): fix the clock in the visual specs that show inspector timestamps The inspector drawer baseline and the full chat view baseline both contain the inspector's event timestamps, so they changed on every regeneration. The validation-errors spec already pins the clock with page.clock.setFixedTime, which keeps timers and the stream running; do the same in the other two. * test(shell): keep the baselines that only differed by antialiasing Four regenerated baselines differed from main by at most 0.05% of pixels with nothing above the antialiasing noise floor, well under the 2% threshold, so leave them as they are on main. * test(shell): regenerate the two inspector baselines with the fixed clock Workflow output; both now show 11:24:22 AM and will stay that way. * test(shell): regenerate the inspector baselines after the rebase onto main Only the two baselines whose specs pin the clock change; the rest came back different by antialiasing noise alone and stay as they are on main.
An agent can lead a message with a small UI header (for example an avatar-and-name row) followed by its prose, relying on the order of the A2A parts. The chat view accumulates text and A2UI payloads into separate fields and the message template always rendered the text before the inline surface, so the header ended up below the paragraph it was meant to introduce.
A2aStreamEventParsernow records whether an event's A2UI items all preceded its text parts (a2uiPrecedesText).A2aChatViewlatches that onto the message (inlineSurfaceLeadsText) the first time visible content arrives, so prose streamed afterwards cannot demote a header that already rendered above it, and the message template places the inline surface before or after the text accordingly. Messages whose text comes first, or whose surfaces surround the text, render exactly as before.Scope: a message still accumulates into one text block and one inline surface frame, so the fix decides only which of the two comes first. An agent that interleaves A2UI and text more than once (
a2ui, text, a2ui, text, ...) keeps rendering as before, text above the merged surfaces (the flag is only true while every A2UI part preceded any text). Reproducing a finer interleaving in the bubble would need the message model to hold an ordered list of text and surface blocks, which is a separate change.Verification
a2a-stream-event-parser.service.spec.ts:a2uiPrecedesTextis true when the A2UI items precede the text parts, false when they follow the text or surround it.a2a-chat-view.spec.ts: the message keeps the inline surface above the text when the agent sent it first and below it when the text came first, across streamed chunks.chat-message.spec.ts: the inline surface renders above the text when the surface led the message.e2e/a2a-inline-surface-order.e2e.tsdrives the A2A chat against a mock agent whose first turn sends the surface part before the text and whose second turn sends the text first, and checks that the real inline frame renders in each bubble above or below the text to match. It fails onmain's template with the surface below the text.prettier --check,eslint, andtsc -p tsconfig.json --noEmitclean inshell/.