Repository navigation
fix(shell): preserve the Canvas root component when the active catalog supports Canvas - #255
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the surface partitioning logic to preserve the Canvas component as the root of the extracted Canvas surface when the active renderer catalog supports it, rather than always unwrapping its children. It also integrates CatalogManagement into A2aChatView to dynamically re-partition existing messages once the active catalog resolves. Feedback is provided regarding a logical bug in shouldPreserveCanvas where a resolved catalog without a components property would incorrectly fall back to the flat component check, along with a suggested fix.
⚡ A2UI Composer PR PreviewYour automated preview is successfully live (commit
|
efa6c6d to
7ff4a4c
Compare
7ff4a4c to
cf26afc
Compare
…g supports Canvas When the surface partitioner extracts a Canvas whose root has several top-level children, it drops the Canvas node and synthesizes a `Column` as the surface root. Renderers whose catalog defines its own `Canvas` container component (and may not register a generic `Column` at all) then reject the synthetic root as an unknown component, and the Canvas panel stays blank. `partitionA2uiSurfacePayload` now takes the active catalog. When that catalog defines a `Canvas` component (or, before the catalog handshake has settled, when the incoming flat v0.9 node already uses the `Canvas` component type), the Canvas node is kept as the surface root, normalized to `id: 'root'` with a flat component type and a `children` ID list, and its subtree follows unchanged. Catalogs without a `Canvas` component are unwrapped into a single child or a `Column` exactly as before. Because surfaces can arrive before `CatalogManagement` has resolved the renderer's catalog, `A2aChatView` re-partitions the existing messages once the active catalog changes and refreshes the open side-canvas payload if its surface was re-partitioned, so the Canvas picks up the right root without reloading the conversation.
…served A resolved catalog without a components map fell through to the pre-handshake heuristic and preserved flat Canvas nodes. Once a catalog is known it decides on its own; the flat-type fallback only applies while no catalog is resolved.
CatalogManagement re-runs the catalog handshake on every RENDERER_READY and sets activeCatalog to a freshly parsed object each time, so with several frames open the re-partition effect fired on every canvas open and every new turn's inline frame. Each run rebuilt every message's inline payload as a new array, which made every RenderedFrame re-send content that had not changed. The partitioner reads exactly one property of the catalog, whether it defines a Canvas component. That bit is now a computed, and the effect depends on the computed rather than on the catalog object, so a catalog re-resolved with the same answer does not notify it. The first resolution and a genuine change (for example a renderer switch to a catalog without Canvas) still re-partition. The spec resolves the same catalog twice and checks the inline and canvas payload references are unchanged, then resolves a catalog without Canvas and checks the surface is unwrapped again.
cf26afc to
33552e6
Compare
When the surface partitioner extracts a Canvas whose root has several top-level children, it drops the agent's
Canvasnode and synthesizes a bare{component: 'Column', children}as the surface root, so the renderer never receives the component the agent sent. With the Gemini Enterprise composite catalog, whoseCanvasis a real component (a flex column that fills the side panel, applies the node'sstyle, and logs an impression), the panel renders a genericColumnwith the Canvas props dropped, and Composer shows a different tree than Gemini Enterprise does for the same payload.partitionA2uiSurfacePayloadnow takes the active catalog. When that catalog defines aCanvascomponent (or, before the catalog handshake has settled, when the incoming flat v0.9 node already uses theCanvascomponent type), the Canvas node is kept as the surface root, normalized toid: 'root'with a flat component type and achildrenID list, and its subtree follows unchanged. Catalogs without aCanvascomponent are unwrapped into a single child or aColumnexactly as before.Because surfaces can arrive before
CatalogManagementhas resolved the renderer's catalog,A2aChatViewre-partitions the existing messages once the active catalog changes and refreshes the open side-canvas payload if its surface was re-partitioned, so the Canvas picks up the right root without reloading the conversation.The re-partition is keyed on a
catalogPreservesCanvascomputed (the one bit of the catalog the partitioner reads) rather than on the catalog object itself.CatalogManagementpublishes a fresh catalog object on everyRENDERER_READY/A2UI_CATALOGround trip, i.e. each time any preview iframe (re)loads, so keying on the object would re-partition every message and swap the inline and side-canvas payload references on each handshake even though nothing changed. With the computed, a re-resolved catalog with the same Canvas support leaves the partitioned payloads untouched.Verification
surface-partitioner.spec.ts(24 specs): Canvas kept as root when the catalog definesCanvas, flat v0.9 Canvas kept before the catalog resolves, unwrapped intoColumnwhen the catalog lacksCanvasor declares no components at all, multiple Canvases still split into separate artifacts.a2a-chat-view.spec.ts(37 specs): messages re-partitioned when the catalog's Canvas support changes, open side canvas refreshed, and a re-resolved catalog with the same Canvas support leaves the inline and side-canvas payload references unchanged.prettier --check,eslint, andtsc -p tsconfig.json --noEmitclean inshell/.