Skip to content

feat(samples,shell): restore A2UI v0.9 alongside v1.0 - #334

Open
jgindin wants to merge 19 commits into
pr7-qa-cleanupfrom
pr8-restore-v0-9-renderers
Open

jgindin wants to merge 19 commits into
pr7-qa-cleanupfrom
pr8-restore-v0-9-renderers

Conversation

@jgindin

@jgindin jgindin commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Description

Summary

This PR reverses the earlier per-renderer single-version assumption from #324 (where basic sample renderers became v1.0-only and the shell assumed one active protocol version per renderer) so Composer's Angular, Lit, and React basic renderers and shell support A2UI v0.9 payloads alongside v1.0. Every renderer continues to default to v1.0 for new/blank sessions when it supports both versions, while single-version renderers (Mock V09, Mock V10, React Slack) strictly enforce their single announced version.

  • Renderer capability model (CatalogManagement, catalog-domain.ts, FakeCatalogManagement): Add ProtocolSupport (defaultVersion, versions, catalogsByVersion, announcedCatalogCount), resolveProtocolSupport, and selectCatalogsForVersion while keeping activeProtocolVersion(), activeCatalog(), activeCatalogs(), and mergedActiveCatalog() scoped strictly to defaultVersion so initial boot stays v1.0 for dual-version renderers. FakeCatalogManagement defaults announcedCatalogs to [activeCatalog()] when empty and activeCatalog() is set, matching CatalogManagement. Suppress a false watchdog timeout error for an unregistered secondary frame that was removed before answering once a live catalog has already been established for the current renderer URL — where "established" means a live A2UI_CATALOG handshake succeeded for the current renderer URL since the last URL change (an earlier failed handshake or a cache-only catalog does not count; cancelling the in-progress handshake directly on HostCommunication.unregisterIframe is left as a follow-up #335). This fixes a /demos flake where registering four catalogs in ng-basic-catalog slowed per-card GET_CATALOG answers and widened the pre-existing race window when Demos.reconcileMountedCards() evicted off-screen cards mid-handshake.
  • Per-payload resolution & multi-catalog gating (payload-protocol-resolution.ts, protocol-version-mismatch.ts, RawFrame, GuestFrame, Gallery): Replace validatePayloadProtocolVersion with shared scanPayloadVersion (inspectPayloadVersion + detectPayloadVersion), resolvePayloadProtocol, and gatePayloadDispatch. Add no v0_9/v0.9 catalogId substring heuristic while keeping the existing v1_0 check and A2A partitioner behavior unchanged; for indeterminate payloads, resolvePayloadProtocol resolves createSurface.catalogId via ProtocolSupport.catalogsByVersion. RawFrame checks the boolean return of HostCommunication.sendRenderA2UI (clearing the watchdog and returning false when CrossFrameValidator blocks a payload missing a valid wire "version": "v0.9" | "1.0"). Reject unknown catalogs across all createSurface.catalogId entries in a payload on multi-catalog renderers (announcedCatalogCount > 1) with UNSUPPORTED_CATALOG while letting single-catalog renderers pass through, and report wire versions ("v0.9" / "1.0") accurately in formatUnsupportedProtocolVersionMessage.
  • Draft-driven Monaco validation (MonacoEditor, V09MonacoSchemaStrategy, RawFrame, resolveStickyEditorProtocol): Select the JSON validation schema and versioned catalogs via VersionRegistry strategies and selectCatalogsForVersion so pasting a v0.9 payload into an Angular Basic workspace validates against the v0.9 schema without false "Value must be \"1.0\"." markers. Require version with const: 'v0.9' in V09MonacoSchemaStrategy, extract resolveStickyEditorProtocol (via linkedSignal) so unparseable JSON preserves the last supported editor protocol version and catalog (resetting to defaultVersion when cleared to empty, updating on valid supported drafts, and clearing to null when unsupported or when protocolSupport() drops the version), and filter PROTOCOL_MARKER_OWNER inside MonacoEditor.onDidChangeMarkers so clearing schema errors takes the immediate fast path.
  • Chat protocol decision & version-locked prompts (generation-protocol-selector.ts, ChatPromptFactory, PromptProtocolStrategy, ChatCoordinator, StateSync): Decide chat generation version in one pure function (selectGenerationVersion) sharing detectRawJsonDraftVersion with StateSync.sanitizeLayout for unparseable drafts: keep existing non-placeholder UI version unless explicitly asked to switch (replacing the draft when switching), treat a bare createSurface placeholder via isUntouchedBlankDraft as from-scratch (v1.0 default unless v0.9 is requested; dual-version mentions on an existing UI switch to the non-current version), match explicit version asks (v0.9/v1.0/v0_9/v1_0 on their own with STANDALONE_LEFT_BOUNDARY (?<![.$\w/=?&])(?<![a-zA-Z]-) blocking URLs/paths/query params/identifiers like icon-v1.0 while allowing digit-preceded ranges like v0.9-v1.0, or after a keyword — a2ui, version, protocol, spec, protected against preceding ., $, \w, ?, &, =, - — separated by whitespace or a colon: dotted/underscored versions with or without v, and dotless v09/v10), validate/heal LLM output against selectCatalogsForVersion, keep edited layout snapshots across switchRenderer version changes, mark local unsupported-version refusals with isRefusal so they stay visible in chatHistory while getConversationalMessages excludes them from later LLM requests, and move the switchRenderer trailing instruction into PromptProtocolStrategy (V09PromptStrategy / V10PromptStrategy) without duplicating draft-replacement wording.
  • Restored v0.9 basic samples & MCP recursive-ref fix (samples/ng-basic-catalog, samples/lit-basic-catalog, samples/react-basic-catalog, bridge/src/mcp/): Restore the v0.9 catalog builders and tests removed in #324 (231273eb) under both https://a2ui.org/specification/v0_9/basic_catalog.json and https://a2ui.org/specification/v0_9/catalogs/basic/catalog.json (using @a2ui/web_core/v0_9/basic_catalog in both Lit and React so Lit's catalogSchema exposes theme $defs and V09_SPEC_FUNCTIONS matching React and Angular), serving native Angular v0.9 (a2ui-v09-*) components alongside v1.0 custom elements via toNativeAngularEntries and memoizing/reusing BasicWithMcpCatalog's generated schema in BasicWithMcpNpmIdCatalog; wrap DynamicStringSchema/DynamicValueSchema in bridge/src/mcp/functions/common.ts with z.any().transform carrying REF:#/$defs/... markers so @a2ui/web_core 0.15.0 emits $ref: '#/$defs/DynamicString' for callMcpTool.name (with $defs.DynamicString present in the generated catalog schema) and zero recursive-reference warnings while keeping strict v0.9 runtime validation (and preserving nullable v1.0 helpers in v1-0-mcp-catalog.ts).

Tests Whose Expectations Changed / Were Inverted / Removed

  • shell/src/app/chat/chat-coordinator/chat-coordinator.spec.ts: Removed 'strips prototype pollution keys from mergedActiveCatalog()' because it only exercised the deleted local MockCatalogManagement stub from pr7-qa-cleanup (production mergeCatalogs never stripped keys; frame-boundary stripping remains covered in cross-frame-validator.spec.ts).
  • shell/e2e/v09-compat-regression.e2e.ts: Inverted 'switching between live v1.0 sample renderer...' into 'switching between live dual-version Angular sample renderer...' — switching to Angular Basic with an edited v0.9 draft now renders User Customised Car Booking via a2ui-v09-text and asserts mismatchCount === 0 (previously expected PROTOCOL_VERSION_MISMATCH and mismatchCount === 1).
  • shell/e2e/slack-renderer.e2e.ts: Updated the absent-error assertion from the old 'Payload protocol version' prefix to 'This renderer does not support A2UI'.
  • shell/src/app/preview/protocol-version-mismatch.spec.ts & shell/src/app/agent-chat/converters/surface-partitioner.spec.ts: Removed validatePayloadProtocolVersion assertions (superseded by resolvePayloadProtocol in payload-protocol-resolution.spec.ts), updated detectPayloadVersion/inspectPayloadVersion tests so v0_9/v0.9 catalogId substrings are not treated as version signals, and documented A2A surface-partitioner.ts pre-branch default ('v0.9') and v1_0 catalogId preservation.
  • shell/src/app/preview/guest-frame/guest-frame.spec.ts, shell/src/app/preview/raw/raw-frame.spec.ts, shell/src/app/gallery/gallery.spec.ts: Updated mismatch error string expectations to the updated formatUnsupportedProtocolVersionMessage wording, expanded mock protocolSupport, and added tests for v0.9 dispatch on a two-version renderer and UNSUPPORTED_CATALOG vs single-catalog pass-through.

Commits

4ffdac86 test(bridge): cover renderers with v0.9 and v1.0 catalogs
ed2145bc feat(shell): model the protocol versions a renderer supports
a4de833e feat(shell): resolve protocol version per payload
00541831 feat(shell): gate previews on supported versions and catalogs
e01f2777 feat(shell): pick editor schema from the draft's version
c4c5f446 feat(shell): decide the chat generation version in one function
5a4abcac feat(shell): use the decided version for chat prompts and payloads
2eadca8b feat(samples): restore v0.9 catalog code removed in #324
c187c6af feat(samples): serve v0.9 and v1.0 in the Lit and React samples
1793946c fix(bridge): avoid recursive schema refs in CallMcpToolApi
b63469c2 feat(samples): serve v0.9 natively in the Angular sample
eb5ae88f test(e2e): cover v0.9 and v1.0 on the basic renderers
43e42495 chore(shell): add license header to selector spec
96382f6b fix(shell): accept "version: 0.9" style version requests
f501d616 fix(shell): default FakeCatalogManagement announced list to primary
6161d0a6 fix(shell): align preview gates, v0.9 editor schema, and markers
78f773a6 fix(shell): refine chat refusals, switch prompts, and version matcher
56aaecb7 fix(samples): align Lit v0.9 catalog schema and React v0.9 action test
2dfa7517 test(e2e): route config.json directly in dual-version E2E

65 files changed, 8051 insertions(+), 655 deletions(-)

Stack

Stacked PR 8/9 — base: pr7-qa-cleanup → merge in order:

Verification

Run locally at 2dfa7517 (pr8-restore-v0-9-renderers tip):

  • corepack yarn workspace a2ui-bridge clean && corepack yarn build: exit 0
  • corepack yarn test: 3680/3680 passed (scripts: 48, a2ui-bridge: 338, lit-basic-catalog: 26, ng-basic-catalog: 34, react-basic-catalog: 26, react-slack-catalog: 197, a2ui-composer-shell: 3011)
  • corepack yarn lint, corepack yarn tsc, corepack yarn prettier:check, corepack yarn generate:demos:check (46 demos): all exit 0
  • From shell/, E2E_HEADLESS=true corepack yarn playwright test --project=e2e --workers=1 --retries=0 e2e/dual-version-renderers.e2e.ts e2e/v09-compat-regression.e2e.ts e2e/slack-renderer.e2e.ts e2e/slack-assistant.e2e.ts e2e/demos.e2e.ts: 60/60 passed (6.7m)
  • Full headless E2E suite (corepack yarn --cwd shell e2e-headless): 244/244 passed (8.7m)

Pre-launch Checklist

@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 introduces multi-version protocol support (v0.9 and v1.0) for A2UI, allowing renderers to support both versions simultaneously. It includes a protocol version selector for chat generation, updates to the Monaco editor to support version-specific schema validation and protocol-level error markers, and comprehensive testing for dual-version renderer compatibility. I have reviewed the code changes and the provided feedback; the suggestion to improve the VERSION_MENTION_PATTERN regex is actionable and will improve the robustness of version detection in user prompts.

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

⚡ A2UI Composer PR Preview

Your automated preview is successfully live (commit 2dfa751):
👉 Launch PR Preview

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

Clears an orphaned catalog-handshake watchdog when the handshake frame
was unregistered after a live catalog was established (surfaced here
because registering four catalogs in ng-basic-catalog widened
GET_CATALOG timing on /demos cards past card eviction).
Add generation-protocol-selector with existingUiVersion,
requestedVersions, and selectGenerationVersion (implementing A1/A2/A3
and placeholder rules), and share inspectPayloadVersion across preview
and generation.
Select prompt strategy and versioned catalogs via VersionRegistry in
ChatPromptFactory, decide per-turn version via selectGenerationVersion
in ChatCoordinator (including renderer switches and A2/A3 draft
replacement), and refuse unsupported explicit version asks locally.
Restore basic-with-mcp.catalog.ts verbatim from 231273e and add
companion v0.9 spec files (temporarily skipped) from 231273e.
Add shared v0.9 catalog ID constants and withCatalogId helper, split
v0.9 and v1.0 catalog modules in Lit and React samples, register
[...v10Catalogs, ...v09Catalogs], update sample READMEs, and enable
v0.9 sample specs.
Wrap @a2ui/web_core DynamicStringSchema and DynamicValueSchema with
z.any().transform validators carrying REF:#/$defs markers so v0.9
schema serialization emits zero recursive-reference warnings while
preserving strict runtime validation. Keep v1.0 local schema helpers
in v1-0-mcp-catalog.ts.
Strip tagName/element from Angular v0.9 BasicCatalog entries so v0.9
renders with native Angular components alongside v1.0, register both
v0.9 basic catalog IDs (sharing and memoizing the derived v0.9 schema),
add native v0.9 harness/unit tests, update the Angular README, and
update E2E expectations.
Add Playwright E2E coverage for dual-version Angular, Lit, and React
renderers across Monaco validation, CAR_BOOKING, draft switching,
v0.9 actions, UNSUPPORTED_CATALOG gating, single-catalog pass-through,
mismatch recovery, version-locked chat turns, and unsupported asks.
Accept a single colon (with optional surrounding whitespace) as well as
whitespace after protocol keywords (a2ui, version, protocol, spec), and
allow dotless v09/v10 only immediately after those keywords. Tighten
the keyword left boundary (except slash) so compound tokens and URL
query keys do not match bare or dotless keyword forms; = and - are not
separators, and standalone bare v10/v09 and bare "version 10" stay
excluded.
Comment thread shell/src/app/preview/raw/raw-frame.ts Resolved
Comment thread shell/src/app/preview/raw/raw-frame.ts Resolved
When announcedCatalogs is empty and activeCatalog is set, default the
fake announced list to [activeCatalog()], matching CatalogManagement,
and remove the activeCatalog empty-list special case.
Clear the RawFrame watchdog and return false when sendRenderA2UI returns
false, and require version const 'v0.9' in V09MonacoSchemaStrategy.

Extract resolveStickyEditorProtocol into payload-protocol-resolution.ts
so RawFrame preserves the last supported editor protocol version and
catalog across temporarily unparseable JSON edits when still supported.

Filter PROTOCOL_MARKER_OWNER inside MonacoEditor.onDidChangeMarkers and
remove the redundant filters in RawFrame.

Update formatUnsupportedProtocolVersionMessage with actual wire
versions and check every createSurface.catalogId in multi-surface
payloads.
Keep edited layout snapshots when switching renderers across versions,
tighten STANDALONE_LEFT_BOUNDARY against URLs/paths/identifiers, mark
local unsupported-version refusals with isRefusal so LLM context skips
them while chat history preserves them, and move the switchRenderer
trailing instruction into PromptProtocolStrategy (sharing
BuildSystemPromptOptions) without duplicating draft replacement wording.
Switch lit-basic-catalog v0.9 basicCatalog import to
@a2ui/web_core/v0_9/basic_catalog so catalogSchema exposes theme
definitions and V09_SPEC_FUNCTIONS matching React and Angular.

Add the missing Text child component and assert version: 'v0.9' on the
outbound SEND_TO_SERVER payload in
react-basic-catalog/src/main.v0-9.spec.tsx.
Route **/config.json with apiKeys.default in both chat tests, remove the
redundant Settings API key dialog round-trips, and drop the unused
assets/composer.config.json and **/renderers.json routes.
@jgindin
jgindin requested a review from mikzat November 30, 2026 15:12
@jgindin
jgindin added this pull request to stack #332 November 30, 2026 15:13

This branch has not been deployed

No deployments
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