Repository navigation
Conversation
There was a problem hiding this comment.
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.
⚡ A2UI Composer PR PreviewYour automated preview is successfully live (commit
|
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.
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.
930143a to
96382f6
Compare
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.
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 A2UIv0.9payloads alongsidev1.0. Every renderer continues to default tov1.0for new/blank sessions when it supports both versions, while single-version renderers (Mock V09,Mock V10,React Slack) strictly enforce their single announced version.CatalogManagement,catalog-domain.ts,FakeCatalogManagement): AddProtocolSupport(defaultVersion,versions,catalogsByVersion,announcedCatalogCount),resolveProtocolSupport, andselectCatalogsForVersionwhile keepingactiveProtocolVersion(),activeCatalog(),activeCatalogs(), andmergedActiveCatalog()scoped strictly todefaultVersionso initial boot staysv1.0for dual-version renderers.FakeCatalogManagementdefaultsannouncedCatalogsto[activeCatalog()]when empty andactiveCatalog()is set, matchingCatalogManagement. 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 liveA2UI_CATALOGhandshake 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 onHostCommunication.unregisterIframeis left as a follow-up#335). This fixes a/demosflake where registering four catalogs inng-basic-catalogslowed per-cardGET_CATALOGanswers and widened the pre-existing race window whenDemos.reconcileMountedCards()evicted off-screen cards mid-handshake.payload-protocol-resolution.ts,protocol-version-mismatch.ts,RawFrame,GuestFrame,Gallery): ReplacevalidatePayloadProtocolVersionwith sharedscanPayloadVersion(inspectPayloadVersion+detectPayloadVersion),resolvePayloadProtocol, andgatePayloadDispatch. Add nov0_9/v0.9catalogIdsubstring heuristic while keeping the existingv1_0check and A2A partitioner behavior unchanged; for indeterminate payloads,resolvePayloadProtocolresolvescreateSurface.catalogIdviaProtocolSupport.catalogsByVersion.RawFramechecks the boolean return ofHostCommunication.sendRenderA2UI(clearing the watchdog and returningfalsewhenCrossFrameValidatorblocks a payload missing a valid wire"version": "v0.9" | "1.0"). Reject unknown catalogs across allcreateSurface.catalogIdentries in a payload on multi-catalog renderers (announcedCatalogCount > 1) withUNSUPPORTED_CATALOGwhile letting single-catalog renderers pass through, and report wire versions ("v0.9"/"1.0") accurately informatUnsupportedProtocolVersionMessage.MonacoEditor,V09MonacoSchemaStrategy,RawFrame,resolveStickyEditorProtocol): Select the JSON validation schema and versioned catalogs viaVersionRegistrystrategies andselectCatalogsForVersionso pasting av0.9payload into anAngular Basicworkspace validates against thev0.9schema without false"Value must be \"1.0\"."markers. Requireversionwithconst: 'v0.9'inV09MonacoSchemaStrategy, extractresolveStickyEditorProtocol(vialinkedSignal) so unparseable JSON preserves the last supported editor protocol version and catalog (resetting todefaultVersionwhen cleared to empty, updating on valid supported drafts, and clearing tonullwhen unsupported or whenprotocolSupport()drops the version), and filterPROTOCOL_MARKER_OWNERinsideMonacoEditor.onDidChangeMarkersso clearing schema errors takes the immediate fast path.generation-protocol-selector.ts,ChatPromptFactory,PromptProtocolStrategy,ChatCoordinator,StateSync): Decide chat generation version in one pure function (selectGenerationVersion) sharingdetectRawJsonDraftVersionwithStateSync.sanitizeLayoutfor unparseable drafts: keep existing non-placeholder UI version unless explicitly asked to switch (replacing the draft when switching), treat a barecreateSurfaceplaceholder viaisUntouchedBlankDraftas from-scratch (v1.0default unlessv0.9is 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_0on their own withSTANDALONE_LEFT_BOUNDARY(?<![.$\w/=?&])(?<![a-zA-Z]-)blocking URLs/paths/query params/identifiers likeicon-v1.0while allowing digit-preceded ranges likev0.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 withoutv, and dotlessv09/v10), validate/heal LLM output againstselectCatalogsForVersion, keep edited layout snapshots acrossswitchRendererversion changes, mark local unsupported-version refusals withisRefusalso they stay visible inchatHistorywhilegetConversationalMessagesexcludes them from later LLM requests, and move theswitchRenderertrailing instruction intoPromptProtocolStrategy(V09PromptStrategy/V10PromptStrategy) without duplicating draft-replacement wording.v0.9basic samples & MCP recursive-ref fix (samples/ng-basic-catalog,samples/lit-basic-catalog,samples/react-basic-catalog,bridge/src/mcp/): Restore thev0.9catalog builders and tests removed in#324(231273eb) under bothhttps://a2ui.org/specification/v0_9/basic_catalog.jsonandhttps://a2ui.org/specification/v0_9/catalogs/basic/catalog.json(using@a2ui/web_core/v0_9/basic_catalogin both Lit and React so Lit'scatalogSchemaexposes theme$defsandV09_SPEC_FUNCTIONSmatching React and Angular), serving native Angularv0.9(a2ui-v09-*) components alongsidev1.0custom elements viatoNativeAngularEntriesand memoizing/reusingBasicWithMcpCatalog's generated schema inBasicWithMcpNpmIdCatalog; wrapDynamicStringSchema/DynamicValueSchemainbridge/src/mcp/functions/common.tswithz.any().transformcarryingREF:#/$defs/...markers so@a2ui/web_core0.15.0emits$ref: '#/$defs/DynamicString'forcallMcpTool.name(with$defs.DynamicStringpresent in the generated catalog schema) and zero recursive-reference warnings while keeping strict v0.9 runtime validation (and preserving nullable v1.0 helpers inv1-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 localMockCatalogManagementstub frompr7-qa-cleanup(productionmergeCatalogsnever stripped keys; frame-boundary stripping remains covered incross-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 toAngular Basicwith an editedv0.9draft now rendersUser Customised Car Bookingviaa2ui-v09-textand assertsmismatchCount === 0(previously expectedPROTOCOL_VERSION_MISMATCHandmismatchCount === 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: RemovedvalidatePayloadProtocolVersionassertions (superseded byresolvePayloadProtocolinpayload-protocol-resolution.spec.ts), updateddetectPayloadVersion/inspectPayloadVersiontests sov0_9/v0.9catalogIdsubstrings are not treated as version signals, and documented A2Asurface-partitioner.tspre-branch default ('v0.9') andv1_0catalogId 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 updatedformatUnsupportedProtocolVersionMessagewording, expanded mockprotocolSupport, and added tests forv0.9dispatch on a two-version renderer andUNSUPPORTED_CATALOGvs single-catalog pass-through.Commits
65 files changed, 8051 insertions(+), 655 deletions(-)
Stack
Stacked PR 8/9 — base:
pr7-qa-cleanup→ merge in order:pr1-e2e-stabilization(mergedb7632586)pr2-upgrade-a2ui-deps(merged900b65f6)pr3-bridge-v1-0(mergedbe5e24d3)pr4-shell-v1-0-core(mergedf82a26dd)pr5-shell-v1-0-copilot-rpc-a2apr6-samples-demos-v1-0pr7-qa-cleanuppr8-restore-v0-9-rendererspr9-cancel-handshake-on-unregister(fix(shell): cancel catalog handshake when its frame unregisters, stacked on feat(samples,shell): restore A2UI v0.9 alongside v1.0 #334)Verification
Run locally at
2dfa7517(pr8-restore-v0-9-rendererstip):corepack yarn workspace a2ui-bridge clean && corepack yarn build: exit 0corepack 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 0shell/,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)corepack yarn --cwd shell e2e-headless): 244/244 passed (8.7m)Pre-launch Checklist