Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces comprehensive support for the A2UI v1.0 protocol, including concurrent client-to-agent RPCs, single-message surface creation, multi-catalog merging, and prototype pollution sanitization. It also adds an interactive RpcReplyForm in the Debug Events tab to manually resolve pending agent function calls with a 30-second countdown. The review feedback highlights critical improvement opportunities to prevent memory leaks and hanging background processes, such as using a WeakSet for iframe window references, cleaning up active streams on component destruction, optimizing timer initialization, and immediately unregistering unmounted preview frames.
⚡ A2UI Composer PR PreviewYour automated preview is successfully live (commit
|
be6a5af to
9a8b3d2
Compare
wrenj
left a comment
There was a problem hiding this comment.
LGTM — A2A v1.0 strategy support, surface partitioning updates, payload parser v1.0 healing, and the RPC registry/debugger UI fit together cleanly. A few non-blocking suggestions inline.
mikzat
left a comment
There was a problem hiding this comment.
Clean strategy split across payload parsing, prompt generation, and A2A wire formatting, and the v0.9 paths stay well isolated. Before merging, a few issues look worth addressing: in-flight callAgentFunction RPCs being silently cancelled without an error response when an action/Stop/reset runs, the outbound v1.0 action envelope exceeding maxProperties: 2, normal chat/action turns omitting protocolVersion (so v1.0 is advertised first even for v0.9 renderers), and the main v1.0 prompt example calling an undeclared submitForm function. The remaining capability-metadata, catalog-ID healing, RPC stream/partitioning, and cleanup notes inline can be addressed here or tracked as follow-ups.
- Optional (
shell/src/app/chat/chat-coordinator/chat-coordinator.ts:747): Afterselect_rendererswitches to a v1.0 renderer, the appended system note inswitchRendererForToolCallstill asks for "a complete createSurface/updateComponents/updateDataModel sequence", contradictingV10PromptStrategy's single-createSurfacerule. Consider branching onactiveProtocolVersion()or using protocol-neutral wording.
9a8b3d2 to
0672c35
Compare
Change ownedWindows from Set<Window> to WeakSet<Window> to avoid holding strong references to iframe windows. In addition, ignore non-action SEND_TO_SERVER envelopes such as updateDataModel and error, validate v1.0 actions against the wire specification, and guard against prototype pollution on incoming envelopes. Addresses review feedback on #323.
0672c35 to
f8d5151
Compare
Change ownedWindows from Set<Window> to WeakSet<Window> to avoid holding strong references to iframe windows. In addition, ignore non-action SEND_TO_SERVER envelopes such as updateDataModel and error, validate v1.0 actions against the wire specification, and guard against prototype pollution on incoming envelopes. Addresses review feedback on #323.
- Strip one-shot RPCs from persisted surface state and flush after frame dispatch - Clear queued RPCs on Stop and agent configuration reset - Omit taskId on outgoing RPC A2A messages and sendMessageStream calls - Cancel pending RPCs when rendererUrl navigates on the same WindowProxy - Scope v1.0 prompt callRendererFunction guidance and sendA2uiAction abort - Fix rpc-reply-form aria-labels/roles and PendingRpcRegistry duplicate handling - Guard _activeRpcCount decrement and remove unused isMcpSupportedByActiveCatalog
f8d5151 to
13da233
Compare
Change ownedWindows from Set<Window> to WeakSet<Window> to avoid holding strong references to iframe windows. In addition, ignore non-action SEND_TO_SERVER envelopes such as updateDataModel and error, validate v1.0 actions against the wire specification, and guard against prototype pollution on incoming envelopes. Addresses review feedback on #323.
- Strip one-shot RPCs from persisted surface state and flush after frame dispatch - Clear queued RPCs on Stop and agent configuration reset - Omit taskId on outgoing RPC A2A messages and sendMessageStream calls - Cancel pending RPCs when rendererUrl navigates on the same WindowProxy - Scope v1.0 prompt callRendererFunction guidance and sendA2uiAction abort - Fix rpc-reply-form aria-labels/roles and PendingRpcRegistry duplicate handling - Guard _activeRpcCount decrement and remove unused isMcpSupportedByActiveCatalog
52d5b0a to
0e863ef
Compare
* feat(bridge): add v0.9 and v1.0 protocol strategies
Add BridgeProtocolStrategy interface, BaseBridgeProtocolStrategy base
class, and concrete implementations for v0.9 and v1.0 protocol
envelopes, wire types, and synthetic payloads. Update PreviewBridge to
delegate surface reset detection through protocol strategies.
Implement multi-catalog schema normalization and GET_CATALOG handshake
resolution returning both primary schema and all schemas for backwards
and forwards compatibility. Add sendOutboundMessage to forward outbound
RPC messages to window.parent over SEND_TO_SERVER.
Update Angular, Lit, and React sandbox adapters to accept two-argument
signatures supporting multi-catalog arrays, class providers, and direct
instances, guard single-catalog ID aliasing on catalog resolution, and
wire processorOptions.outboundListener to forward remote calls.
* refactor(bridge): rename dynamic-values to v0-9-dynamic-value-strategy
Rename dynamic-values.ts to v0-9-dynamic-value-strategy.ts to prepare
for A2UI v1.0 dynamic value evaluation strategy without breaking file
history. Update internal callers to point to the renamed module.
* feat(bridge): add v0.9/v1.0 MCP strategies and McpFunctionsCatalog
Introduce DynamicValueStrategy interface with version-specific
strategies for A2UI v0.9 and v1.0 dynamic values:
- v0.9 strategy handles {path} bindings and {call, args, returnType}.
- v1.0 strategy resolves bracket-notated ['@path'] bindings and
['@call', args, catalogId] calls, strictly omitting returnType.
- Author McpFunctionsCatalog with MCP_FUNCTIONS_CATALOG_ID and
createMcpFunctionsCatalog registering all 6 MCP and data functions
using zod/v3 schemas and lazy singleton routing via window.a2uiBridge.
- Preserve ReDoS validation via isSafeRegex and sanitize object
prototypes against pollution during dynamic value resolution.
- Provide deduplicated resolveDynamicTree helper in strategy module.
* feat(bridge): support multi-catalog GET_CATALOG and v1.0 RPCs
Extend PreviewBridge and framework bridges (Angular, Lit, React) to
negotiate canonical A2UI v1.0 wire protocol messages alongside v0.9.
Key changes:
- Track activeProtocolVersion in PreviewBridge, defaulting to v0.9 and
negotiating canonical 1.0 upon receiving 1.0 payloads or catalogs.
- Safe activeProtocolVersion assignment in handleRenderA2ui only after
processor.processMessages succeeds to avoid corrupting state.
- Delegate normalization, version stamping, and action envelopes to
BridgeProtocolStrategy.
- Support multi-catalog GET_CATALOG resolution without network fetch.
- Add callAgentFunction forwarding on PreviewBridge and framework
adapters.
- Dispose message processors cleanly on React component unmount.
- Support useUniversalComponents in Angular sandbox bootstrapping.
* fix(bridge): tolerate frozen catalogs in aliasSingleCatalogId
aliasSingleCatalogId mutates a catalog object taken from the renderer
config. If a sample passes a frozen or otherwise read-only catalog, the
id assignment throws inside catalog resolution. Wrap the assignment in
a try/catch that warns instead, since aliasing is best-effort.
Also drop the redundant `catalogs ?? []` guard in provideA2uiSandbox;
the parameter is non-nullable.
Addresses review feedback on #321.
* fix(bridge): address review comments on dynamic value strategies, mcp catalog, and protocol versioning
Address all 18 review comments on PR #321:
- Simplify catalog mapping in Angular bridge.
- Survive minification for UniversalOnlyComponent check in Angular.
- Expose model property on Angular RendererProcessor wrapper.
- Enforce strict property checks on v0.9 dynamic value strategy.
- Forward depth in resolveDynamicValueWithContext to guard MAX_DEPTH.
- Avoid v0.9 function-call guessing on literal objects in v1.0.
- Use standard 'args' key in v1.0 function calls without '@Args'.
- Map undefined fields to null in McpFunctionsCatalog schemas.
- Restrict pure data functions to rendererOrAgent, others rendererOnly.
- Remove redundant isSafeRegex guard before RE2JS compilation.
- Ensure dispose cleanup is called on unmount in React bridge.
- Direct protocol resolution in sendOutboundMessage to v1.0 strategy.
- Normalize protocol versions consistently across catalog inference.
- Gate multi-catalog schema responses strictly on isMultiCatalog.
- Tag and isolate catalog in-memory normalization errors in logging.
- Lazily evaluate catalogSchema toJson only when schema is absent.
- Preserve first created surfaceId in multi-surface batch ready event.
* fix(bridge): address PR #321 review feedback
- Guard normalizeCatalogEntry against calling toJson() when catalogSchema exists
- Defer catalog extractability checks until network fallback with console.warn
- Share isV1ProtocolVersion helper across bridge and protocol strategies
- Check UniversalOnlyComponent by identity without fragile name fallback
- Throw A2uiExpressionError on prototype-pollution paths in updateDataModel
- Remove manualProcessor / setActiveProcessor and simplify getActiveProcessor
- Stop resolveDynamicTree when normalized function calls pass through unchanged
- Remove redundant aliasing and lastResolvedCatalogId in notifyCatalogResolved
- Restore @deprecated CatalogDetails export for compatibility
* fix(samples): mock isV1ProtocolVersion in ng-basic-catalog specs
Export isV1ProtocolVersion from the mocked a2ui-bridge module in
ng-basic-catalog tests so PreviewBridge tests pass on PRs #321-#323.
0e863ef to
2e67f5c
Compare
Copy a2ui-payload-parser.ts byte-for-byte to component-name-healer.ts to preserve git blame and rename history for component healing logic.
Extract protocol-specific payload parsing into v0.9 and v1.0 strategies and update coordinator validations for both protocol versions. - Add PayloadProtocolStrategy interface and v0.9 / v1.0 strategies. - Maintain backward compatibility for v0.9 JSON and JSONL streams. - Parse v1.0 createSurface, incremental updates, and function calls. - Enforce catalog compatibility checks across active protocol versions. - Guard CopilotKitChatPanel presentedTurns component count safely.
Rename chat-prompt-factory.service.ts to v0-9-prompt-strategy.ts to preserve git blame and history for the v0.9 prompt strategy.
Add v0.9 and v1.0 prompt generation strategies and enable multi-catalog MCP tools for the chat copilot. - Extract prompt construction into protocol-specific strategies. - Provide dedicated v0.9 and v1.0 system prompt generators. - Wire active protocol selection in ChatPromptFactory. - Support multi-catalog tool aggregation in McpClientManagerService.
Add PendingRpcRegistry to track unresolved callAgentFunction requests and provide RpcReplyForm in the Debug Events panel to reply value or error responses back to originating guest frame windows. - Track active RPC requests with countdown timers and status states. - Support JSON validation on reply value and structured error replies. - Route responses strictly to the calling guest frame window. - Surface badge counts and inline forms in Debug Events.
- Introduce A2aProtocolStrategy with V09A2aStrategy and V10A2aStrategy implementations for protocol negotiation, canonical '1.0' version normalization, and recursive prototype pollution sanitization. - Support multi-catalog advertisement in standard A2A transport. - Partition single-message createSurface with inline components and data models alongside A2UI RPC envelope routing. - Add pre-extraction A2UI RPC envelope filtering to prevent RPC echo payloads from rendering as generic tool-call chips. - Manage concurrent callAgentFunction RPC streams in A2aChatView with per-call AbortControllers, window-targeted response delivery, action.userMessage rendering, and cancellation cleanup. - Author hermetic Playwright suites covering v0.9 compatibility regressions and function RPC journeys across shell views.
Change ownedWindows from Set<Window> to WeakSet<Window> to avoid holding strong references to iframe windows. In addition, ignore non-action SEND_TO_SERVER envelopes such as updateDataModel and error, validate v1.0 actions against the wire specification, and guard against prototype pollution on incoming envelopes. Addresses review feedback on #323.
…cle, and surface partitioning
- Strip one-shot RPCs from persisted surface state and flush after frame dispatch - Clear queued RPCs on Stop and agent configuration reset - Omit taskId on outgoing RPC A2A messages and sendMessageStream calls - Cancel pending RPCs when rendererUrl navigates on the same WindowProxy - Scope v1.0 prompt callRendererFunction guidance and sendA2uiAction abort - Fix rpc-reply-form aria-labels/roles and PendingRpcRegistry duplicate handling - Guard _activeRpcCount decrement and remove unused isMcpSupportedByActiveCatalog
2e67f5c to
a9857fc
Compare
- Rename RenderedFrame.payloadDispatched (and chat bindings) to payloadRendered/inlinePayloadRendered, backed by a FIFO inFlightDispatches queue and resetRenderState() so pipelined payloads emit in order and follow-up RPC RENDER_SUCCESS events never re-emit. - Post RENDER_SUCCESS in function-rpc-journeys.e2e.ts stub renderer. - Consolidate A2aChatView per-window tracking into TrackedSurfaceFrame, enforce surfaceId containment on Canvas switches, evict Canvas frames synchronously in closeCanvasSurface(), and unify turn cancellation via abortActiveTurn().
f48c22a to
6694a7f
Compare
Tag GuestFrame RENDER_A2UI dispatches with a renderId and echo it from PreviewBridge on RENDER_SUCCESS and RENDER_ERROR so RenderedFrame settles coalesced dispatches up to the echoed ID and ignores untagged RPC acks on renderId-capable bridges (preserving legacy fallback for older bridges). Queue incremental follow-ups behind a pending createSurface timer in FIFO order, and emit documentReset on same-URL reload and renderStateReset from RenderedFrame when render state clears.
Walk message history backward from agentMessageId across both inline and canvas payloads to resolve the active surface owner for scoped RPCs and pending flush matching, and drop trackedFrames entries whenever RenderedFrame emits renderStateReset on document switch, reload, or reset.
Define A2UI_ONE_SHOT_RPC_KEYS, hasDefinedObjectKey, and isV10RpcEnvelopeItem in bridge-message.ts and reuse it in PreviewBridge.extractRpcEnvelopeFollowUps across superseding createSurface dispatches; preserve pendingRenderId across coalescing; emit documentReset in GuestFrame onLoad reloads and renderRejected on mismatch/rejected sends; return boolean status from HostCommunication sends; wire RenderedFrame.renderStateReset to PendingRpcRegistry cancellation; guard bumpState() on changed in cancelPendingCalls; move the debug-log clear watermark to EventsLogState using <; align stripPrototypePollutionKeys maxDepth to 64; fix demo-card-1 a2ui key in function-rpc-journeys.e2e.ts; and wait for gallery nav hydration in guest-frame-sends.e2e.ts.
Re-export isV10RpcEnvelopeItem from a2ui-bridge in a2ui-rpc-envelope.ts and remove the isOneShotRpcEnvelope wrapper; unify normalizeV10RpcEnvelopeItem and V10PayloadStrategy shorthand rules into BasePayloadProtocolStrategy.normalizeBlocks; remove the buildAgentFunctionResponseItem type cast; share hasDefinedObjectKey in BaseA2aProtocolStrategy and V10A2aStrategy; add override modifiers and remove V09PromptStrategy pass-through wrappers; use LOCAL_DEF_REF_PREFIX in collectLocalDefRefs; and pin literal a8fe50c guidance text in prompt-strategy-helpers.spec.ts.
Extract frame tracking, queued surface RPC flushing, Canvas payload pinning, and bidirectional v1.0 RPC stream lifecycle from A2aChatView into SurfaceRpcCoordinator. Separate frameBindings from render-ready trackedFrames so closeCanvasFrames still aborts pending Canvas calls after same-document render-state resets; guard catch/finally double errors and dead-window duplicate cancels in handleCallAgentFunction; reuse isV10RpcEnvelopeItem in executeRpcStream; route agentFunctionResponse by functionCallId; track activeCanvasArtifactId via resolveActiveSurfaceIds; emit RenderedFrame.documentReset separately from renderStateReset with a single reset per rejection; and assert Canvas state via A2aChatMessageHarness.isCanvasActive.
Description
Summary
PayloadProtocolStrategy(
BasePayloadProtocolStrategy,V09PayloadStrategy,V10PayloadStrategy):preserve v0.9 JSON and JSONL compatibility, share prototype-pollution
sanitization and version stamping, unify
normalizeV10RpcEnvelopeItemacross A2A and Copilot payload paths, and wire multi-catalog schema healing
plus
callRendererFunctionsurface validation inChatCoordinator(
component-name-healer.tsis seeded froma2ui-payload-parser.tstopreserve history).
ChatPromptFactory(
chat-prompt-factory.service.tsrenamed tov0-9-prompt-strategy.ts),share prompt and MCP tool formatting helpers (
prompt-strategy-helpers.ts),and update
McpClientManagerService(catalogSupportsMcp) to check MCPsupport across multiple active catalogs.
PendingRpcRegistrytracking unresolvedcallAgentFunctionrequests with countdown timers, anEventsLogStateclear watermark (
<), and anRpcReplyFormin the Debug Events panelthat routes value or error replies strictly to the originating guest frame
window.
A2aProtocolStrategy(V09A2aStrategy,V10A2aStrategy) forprotocol negotiation, canonical
'1.0'normalization, sharedisV10RpcEnvelopeItem/A2UI_ONE_SHOT_RPC_KEYS(a2ui-bridge),prototype-pollution sanitization (
maxDepth = 64), and multi-catalogadvertisement over A2A; filter A2UI RPC envelopes before tool-call
extraction.
SurfaceRpcCoordinatorfromA2aChatViewto manage concurrentcallAgentFunctionandrendererFunctionResponsestreams,functionCallIdresponse routing,
resolveExpectedBindingsForSurfaceCanvas payloadpinning,
resolveActiveSurfaceIdsCanvas matching, and queued RPCflushing.
GuestFrame,PreviewBridge, andRenderedFramerender ackswith
renderId(preserving queued RPC envelopes andpendingRenderIdacross superseding
createSurfacedispatches), and returnbooleanstatus from
HostCommunicationsends.RenderedFrame.documentResetfromrenderStateReset,GuestFrame.documentReset, andGuestFrame.renderRejectedso RPC streamsabort only on document teardown, document replacement, or Canvas close.
(
e2e/v09-compat-regression.e2e.ts) and function RPC journeys(
e2e/function-rpc-journeys.e2e.ts), plus a/gallerynav-hydration waitin
e2e/guest-frame-sends.e2e.ts.NOTE: The last three commits (
1f937d71,26cbe5c5, and231273eb) wereadded after the earlier approval and are larger than the review comments they
answer.
Commits
90 files changed, 17168 insertions(+), 1393 deletions(-)
Stack
Stacked PR 5/7 — base:
main(f82a26dd) → 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-renderers(feat(samples,shell): restore A2UI v0.9 alongside v1.0, stacked on fix(shell,slack): harden cross-frame validation, catalog sync, and RPC routing #325)pr9-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 at PR #323 head (
pr5-shell-v1-0-copilot-rpc-a2a,231273eb):a2ui-bridge: 331,lit-basic-catalog: 9,ng-basic-catalog: 19,react-basic-catalog: 14,react-slack-catalog: 196,a2ui-composer-shell: 2754)tsc, andprettierchecks pass42/42):e2e/function-rpc-journeys.e2e.ts,e2e/guest-frame-sends.e2e.ts,e2e/v09-compat-regression.e2e.ts,e2e/slack-renderer.e2e.ts,e2e/a2a-multi-frame-surfaces.e2e.ts, ande2e/a2a-inline-surface-order.e2e.ts(full local E2E suite was not run)231273ebfinished with 10 passed, 5 skipped,0 failed
Pre-launch Checklist