Skip to content

fix(shell): preserve the Canvas root component when the active catalog supports Canvas - #255

Merged
mikzat merged 3 commits into
a2ui-project:mainfrom
mikzat:fix/preserve-canvas-root
Oct 12, 2026
Merged

mikzat merged 3 commits into
a2ui-project:mainfrom
mikzat:fix/preserve-canvas-root

Conversation

@mikzat

@mikzat mikzat commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

When the surface partitioner extracts a Canvas whose root has several top-level children, it drops the agent's Canvas node 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, whose Canvas is a real component (a flex column that fills the side panel, applies the node's style, and logs an impression), the panel renders a generic Column with the Canvas props dropped, and Composer shows a different tree than Gemini Enterprise does for the same payload.

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.

The re-partition is keyed on a catalogPreservesCanvas computed (the one bit of the catalog the partitioner reads) rather than on the catalog object itself. CatalogManagement publishes a fresh catalog object on every RENDERER_READY/A2UI_CATALOG round 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 defines Canvas, flat v0.9 Canvas kept before the catalog resolves, unwrapped into Column when the catalog lacks Canvas or 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, and tsc -p tsconfig.json --noEmit clean in shell/.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

⚡ A2UI Composer PR Preview

Your automated preview is successfully live (commit 33552e6):
👉 Launch PR Preview

Note: This environment will be wiped automatically when the PR is merged or closed.

@mikzat
mikzat force-pushed the fix/preserve-canvas-root branch from efa6c6d to 7ff4a4c Compare October 8, 2026 17:11
@mikzat
mikzat marked this pull request as ready for review October 8, 2026 17:24
@mikzat
mikzat force-pushed the fix/preserve-canvas-root branch from 7ff4a4c to cf26afc Compare October 8, 2026 22:26
…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.
@mikzat
mikzat force-pushed the fix/preserve-canvas-root branch from cf26afc to 33552e6 Compare October 12, 2026 20:40
@mikzat
mikzat merged commit 97575df into a2ui-project:main Oct 12, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants