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.
...base,
defaultVersion: forcedDefault,
versions,
};

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.

The fake still drifts from CatalogManagement when a spec passes activeCatalog + activeProtocolVersion: signal('v1.0') without announcedCatalogs. chat-coordinator.spec.ts L2308-2312 does this; its activeCatalogs signal is []. Here's what happens:

  • announcedCatalogs() stays [], so the unversionedOnly branch (L113-114) is skipped.
  • base already files the catalog under 'v0.9' (via rawPrimary()).
  • L122-132 then return {defaultVersion: 'v1.0', versions: ['v1.0', 'v0.9'], catalogsByVersion: {'v0.9': [cat]}}. A single-catalog v1.0 renderer now looks dual-version, with its only catalog under v0.9.

The real class never gets into this state. Its announced list always includes the primary (catalog-management.ts L159, L397, and the [sanitizedPrimary] fallback in sanitizeCatalogList). ChatCoordinator.systemPrompt (L167) and selectCatalogsForVersion (L918) both read protocolSupport(), so those specs run against a state the app can't reach. L140-142 then hides the empty activeCatalogs() from activeCatalog().

Could the fake default the announced list to [activeCatalog()] when the list is empty and activeCatalog() is set, the way the real class does? Then the L140-142 special case can go. A catalog-management-fake.spec.ts case for {activeCatalog, activeProtocolVersion: signal('v1.0')} that asserts protocolSupport() would pin it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in f501d61. FakeCatalogManagement now defaults its effective announced list to [activeCatalog()] when announcedCatalogs is empty and activeCatalog is set (matching CatalogManagement), and activeCatalog drops the empty-list special case. Added catalog-management-fake.spec.ts coverage for {activeCatalog, activeProtocolVersion: signal('v1.0')} asserting announcedCatalogs(), activeCatalogs(), activeCatalog(), and protocolSupport().


this.hostCommunication.sendRenderA2UI(payload);
this.hostCommunication.sendRenderA2UI(resolved.payload);
return true;

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.

The description says the shell lets a version-less v0.9 payload through and the renderer rejects it. That isn't what happens. Same for "version": "0.9":

  1. resolvePayloadProtocol maps the draft to v0.9 via its catalogId (or detectMessageVersion accepts "0.9"), so the gate passes. V09MonacoSchemaStrategy has version: {type: 'string'} and doesn't require it, so the editor shows no marker.
  2. L618 calls sendRenderA2UI, ignores the false it returns, and L619 returns true, so the callers start the watchdog.
  3. CrossFrameValidator.validateSingleRenderMessage (cross-frame-validator.ts L559-568) accepts only "v0.9" or "1.0", so HostCommunication.sendMessage (L838) blocks the message before postMessage. The user gets a "Malformed payload" entry in Errors and no editor marker. The preview stays on the old surface, and 15 s later the watchdog logs IFRAME_UNRESPONSIVE.

Suggested fix: when sendRenderA2UI returns false, clear the watchdog and return false here, like GuestFrame does (guest-frame.ts L437-442). Also make version required with const: 'v0.9' in the v0.9 Monaco schema so the editor flags it, and fix the description. The other option is letting version === undefined through CrossFrameValidator, but that weakens outbound validation for every renderer.

The ignored return value predates this PR, but before it a v0.9 draft on the basic renderers stopped at the version gate; now it reaches this path.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 6161d0a (and updated the PR description). RawFrame.sendValidatedRenderA2UI now checks the boolean returned by hostCommunication.sendRenderA2UI(resolved.payload) and clears the watchdog / returns false when outbound validation blocks the send (matching GuestFrame). V09MonacoSchemaStrategy also now requires version with const: 'v0.9' so versionless or "0.9" v0.9 drafts show an editor diagnostic aligned with CrossFrameValidator. Added tests in raw-frame.spec.ts and v0-9-monaco-schema-strategy.spec.ts.

protected readonly editorProtocolVersion = computed(() => {
const resolution = this.payloadResolution();
return resolution?.status === 'supported' ? resolution.version : null;
});

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.

onLayoutChange sets layoutJson on every keystroke (L351). As soon as an edit breaks JSON syntax, parsedDraft() is null (L87-93), so resolvedDraft(), editorProtocolVersion() (L120-123) and editorProtocolCatalog() go to null. MonacoEditor then falls back to support.defaultVersion (monaco-editor.ts L504), which is v1.0 on the dual-version basic renderers, and calls setDiagnosticsOptions with v1.0 schemas. Monaco's JSON service still runs schema validation on a document with syntax errors, so typing a comma or a new key in a v0.9 draft flashes v1.0 errors such as Value must be "1.0". across the file. Once the JSON parses again, it swaps back to v0.9. Could the last supported resolution be kept while the draft doesn't parse (e.g. a linkedSignal, or detectRawJsonDraftVersion(layoutJson()) from draft-protocol-strategy.ts as the fallback)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 6161d0a. RawFrame now uses a linkedSignal (lastSupportedEditorResolution) backed by resolveStickyEditorProtocol in payload-protocol-resolution.ts: while JSON is temporarily unparseable, it checks detectRawJsonDraftVersion(rawText) (when supported) and otherwise retains the previous supported version and matching catalog instead of falling back to defaultVersion (v1.0) and flashing spurious v1.0 schema errors. Clearing the editor (which parses as []) or switching to an unsupported renderer resets the sticky state. Added tests in payload-protocol-resolution.spec.ts and raw-frame.spec.ts.

}
run.protocolVersion = decision.version;
run.replacesDraft = decision.replacesDraft;
const dropLayoutSnapshots = replacesSample || run.replacesDraft;

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.

dropLayoutSnapshots = replacesSample || run.replacesDraft (L828) now also strips the layout snapshot when replacesDraft is true. Example: the user has an edited v1.0 canvas on Angular Basic (hadEditedDraft true, so replacesSample is false) and the model switches to React Slack, which is v0.9-only. selectGenerationVersion returns {version: 'v0.9', replacesDraft: true}, L848-852 filter out the snapshot, and the second request says "Rebuild any prior layout" with the user's edits no longer in context. A direct cross-version submitPrompt (e.g. "Rebuild this in v0.9") keeps the snapshot and only adds the replacement instruction, and the comment at L838-840 says earlier layouts stay unless they are the previous renderer's sample.

Suggest keeping the filter on replacesSample only, as before. The spec at L2647-2677 doesn't reach this path: hasEditedDraft defaults to false (L124), so flushDraft() resets the draft to 'Initial draft text' before the version is picked. A case with hasEditedDraft true, a v1.0 draft and a v0.9-only target that asserts the second call still has the snapshot would cover it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 78f773a. Kept dropLayoutSnapshots = replacesSample in ChatCoordinator.switchRendererForToolCall so user-edited layout snapshots stay in context across cross-version renderer switches (consistent with direct cross-version submitPrompt). Added a chat-coordinator.spec.ts case with hasEditedDraft: true, an edited v1.0 draft, and a v0.9-only target verifying the second request retains the snapshot.

const KEYWORD_LEFT_BOUNDARY = String.raw`(?<![.$\w?&=-])`;
const KEYWORD = String.raw`(?:a2ui|version|protocol|spec)`;
const KEYWORD_SEPARATOR = String.raw`(?:\s*:\s*|\s+)`;
const STANDALONE_LEFT_BOUNDARY = String.raw`(?<![.$\w])`;

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.

STANDALONE_LEFT_BOUNDARY (L37) only blocks ., $ and \w, so dotted versions inside URLs and paths still count as version asks: "Bind the form to https://api.example.com/v1.0/orders", "GET /v0.9/users", ?version=v1.0, icon-v1.0 and @a2ui/web_core/v0_9 all return a version. That's the same collision you cite for not matching bare v10, and here it replaces the whole draft on a dual-version renderer or refuses the turn on React Slack / Mock V10.

One option that still allows ranges like v0.9-v1.0 (a quick port of the 118 requestedVersions table rows still passes with it):

const STANDALONE_LEFT_BOUNDARY = String.raw`(?<![.$\w/=?&])(?<![a-zA-Z]-)`;

plus spec rows for the URL and path cases.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 78f773a. Updated STANDALONE_LEFT_BOUNDARY to (?<![.$\w/=?&])(?<![a-zA-Z]-) so dotted versions in URLs, paths, query strings, and letter-prefixed identifiers (https://api.example.com/v1.0/orders, GET /v0.9/users, ?version=v1.0, icon-v1.0, @a2ui/web_core/v0_9) no longer count as version requests while preserving hyphenated ranges like v0.9-v1.0. Added table rows in generation-protocol-selector.spec.ts.

promptId: options?.promptId,
},
]);
return;

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.

Optional: the local refusal in submitPrompt (L486-504) and switchRendererForToolCall (L816-825) is stored as a plain USER + MODEL pair. isFailedOrCancelledOutcome (L281-297) doesn't recognize it, so getConversationalMessages sends both on every later turn: the refused ask (e.g. "make it v0.9" on Mock V10) plus an English MODEL reply, which goes against the JSONL-only output rule and can steer the next generation toward the refused version. Marking the refusal turn (a flag checked in isFailedOrCancelledOutcome, like RENDERER_CHANGED_NOTE) would keep it visible in the chat but out of the model context.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 78f773a. Added isRefusal?: boolean to LlmMessage, marked unsupported-version refusal replies in both submitPrompt and switchRendererForToolCall with isRefusal: true, and updated isFailedOrCancelledOutcome to exclude them from getConversationalMessages while keeping them visible in chat history. Added tests in chat-coordinator.spec.ts for both paths.

content:
this.systemPrompt() +
this.buildSystemPromptFor(run.protocolVersion, run.replacesDraft) +
'\nThe renderer has been selected. Use only this catalog. Rebuild any prior layout using its supported components and emit a complete createSurface/updateComponents/updateDataModel sequence.',

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.

Optional: same as my note on #323. L846 still appends "emit a complete createSurface/updateComponents/updateDataModel sequence" when run.protocolVersion is v1.0, which contradicts V10PromptStrategy's single-message createSurface rule (v1-0-prompt-strategy.ts L255-256, L286-292). Now that buildSystemPromptFor adds formatDraftReplacementInstruction when the switch replaces the draft, L846 could drop that clause or branch on run.protocolVersion.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 78f773a. Moved the renderer-selected suffix into PromptProtocolStrategy.rendererSelectedInstruction (composed via buildPromptTrailingSuffix in prompt-protocol-strategy.ts) and passed {protocolVersion, replacesDraft, rendererSelected: true} via BuildSystemPromptOptions from switchRendererForToolCall. v1.0 now instructs a single-message createSurface payload without contradicting V10PromptStrategy, v0.9 keeps the createSurface/updateComponents/updateDataModel sequence, and draft-replacement text is no longer duplicated. Added tests in chat-prompt-factory.spec.ts and chat-coordinator.spec.ts.


const text = typeof model.getValue === 'function' ? model.getValue() : fallbackText;
const range = computeProtocolMarkerRange(text, problem.anchorText);
monacoInstance.editor.setModelMarkers(model, PROTOCOL_MARKER_OWNER, [

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.

Optional: onDidChangeMarkers (L693-731) doesn't exclude PROTOCOL_MARKER_OWNER, so the error marker set here counts as an error at L705. When a draft that had schema errors is edited into a protocol problem, the schema markers are cleared (schemas: [], L525) but the update waits behind the 3 s ERROR_MARKER_DEBOUNCE_MS instead of the no-error fast path. Until then, RawFrame.hasActiveSchemaErrors and lastErrorSignature keep the old values. Filtering the owner out in onDidChangeMarkers would fix that and let RawFrame drop its two PROTOCOL_MARKER_OWNER filters (raw-frame.ts L364, L449).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 6161d0a. Filtered PROTOCOL_MARKER_OWNER out in MonacoEditor.onDidChangeMarkers so clearing schema errors into a protocol marker takes the immediate no-error path instead of waiting 3 s behind ERROR_MARKER_DEBOUNCE_MS, and removed the two duplicate PROTOCOL_MARKER_OWNER filters in RawFrame. Added tests in monaco-editor.spec.ts and raw-frame.spec.ts.

payloadVersion: A2uiProtocolVersion,
supportedVersions: readonly A2uiProtocolVersion[],
): string {
return `This renderer does not support A2UI ${payloadVersion}. It supports ${supportedVersions.join(', ')}. Change the payload's "version" or select a renderer that supports ${payloadVersion}.`;

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.

Optional: on a v1.0-only renderer this says It supports v1.0. Change the payload's "version" .... Changing the field doesn't turn a v0.9 payload into a v1.0 one. The wire value is "1.0", not "v1.0", which CrossFrameValidator rejects. And payloads detected structurally (e.g. {path} bindings) may have no version at all. Something like Use an A2UI v1.0 payload ("version": "1.0") or select a renderer that supports v0.9. would be accurate.

Related: findRequestedCatalogId (L190-205) returns the first createSurface.catalogId, so in a multi-surface payload an unsupported catalog on a later surface gets past the UNSUPPORTED_CATALOG check at L112-124.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 6161d0a. Updated formatUnsupportedProtocolVersionMessage to include the exact wire version string ("1.0" / "v0.9") via WIRE_VERSION_BY_PROTOCOL (e.g., Use an A2UI v1.0 payload ("version": "1.0") or select a renderer that supports v0.9.), and replaced findRequestedCatalogId with findRequestedCatalogIds so resolvePayloadProtocol validates every createSurface.catalogId in multi-surface payloads. Added tests in payload-protocol-resolution.spec.ts.

}),
window.location.origin,
);
});

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.

Optional: the Button here has child: 'Click Proxy' (L263) with no component of that ID, so it renders empty (main.spec.tsx L279-291 fixed the same fixture with a Text child). The test also doesn't check version: 'v0.9' on the outbound payload (L305), which is the only thing that tells a v0.9 action apart from a 1.0 one. Could you add the Text child and version: 'v0.9' to the expect.objectContaining(...)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 56aaecb. Added the Text child component to the Button fixture and asserted version: 'v0.9' on the outbound SEND_TO_SERVER payload in samples/react-basic-catalog/src/main.v0-9.spec.tsx.

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.

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