Skip to content

feat(shell): A2UI v1.0 copilot prompts, RPC registry, A2A strategies - #323

Open
jgindin wants to merge 15 commits into
mainfrom
pr5-shell-v1-0-copilot-rpc-a2a
Open

jgindin wants to merge 15 commits into
mainfrom
pr5-shell-v1-0-copilot-rpc-a2a

Conversation

@jgindin

@jgindin jgindin commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Description

Summary

  • Extract protocol-specific payload parsing into PayloadProtocolStrategy
    (BasePayloadProtocolStrategy, V09PayloadStrategy, V10PayloadStrategy):
    preserve v0.9 JSON and JSONL compatibility, share prototype-pollution
    sanitization and version stamping, unify normalizeV10RpcEnvelopeItem
    across A2A and Copilot payload paths, and wire multi-catalog schema healing
    plus callRendererFunction surface validation in ChatCoordinator
    (component-name-healer.ts is seeded from a2ui-payload-parser.ts to
    preserve history).
  • Add v0.9 and v1.0 prompt strategies wired through ChatPromptFactory
    (chat-prompt-factory.service.ts renamed to v0-9-prompt-strategy.ts),
    share prompt and MCP tool formatting helpers (prompt-strategy-helpers.ts),
    and update McpClientManagerService (catalogSupportsMcp) to check MCP
    support across multiple active catalogs.
  • Add a workspace PendingRpcRegistry tracking unresolved
    callAgentFunction requests with countdown timers, an EventsLogState
    clear watermark (<), and an RpcReplyForm in the Debug Events panel
    that routes value or error replies strictly to the originating guest frame
    window.
  • Add A2aProtocolStrategy (V09A2aStrategy, V10A2aStrategy) for
    protocol negotiation, canonical '1.0' normalization, shared
    isV10RpcEnvelopeItem / A2UI_ONE_SHOT_RPC_KEYS (a2ui-bridge),
    prototype-pollution sanitization (maxDepth = 64), and multi-catalog
    advertisement over A2A; filter A2UI RPC envelopes before tool-call
    extraction.
  • Extract SurfaceRpcCoordinator from A2aChatView to manage concurrent
    callAgentFunction and rendererFunctionResponse streams, functionCallId
    response routing, resolveExpectedBindingsForSurface Canvas payload
    pinning, resolveActiveSurfaceIds Canvas matching, and queued RPC
    flushing.
  • Correlate GuestFrame, PreviewBridge, and RenderedFrame render acks
    with renderId (preserving queued RPC envelopes and pendingRenderId
    across superseding createSurface dispatches), and return boolean
    status from HostCommunication sends.
  • Separate RenderedFrame.documentReset from renderStateReset,
    GuestFrame.documentReset, and GuestFrame.renderRejected so RPC streams
    abort only on document teardown, document replacement, or Canvas close.
  • Add hermetic Playwright suites for v0.9 compatibility regressions
    (e2e/v09-compat-regression.e2e.ts) and function RPC journeys
    (e2e/function-rpc-journeys.e2e.ts), plus a /gallery nav-hydration wait
    in e2e/guest-frame-sends.e2e.ts.

NOTE: The last three commits (1f937d71, 26cbe5c5, and 231273eb) were
added after the earlier approval and are larger than the review comments they
answer.

Commits

01445e29 refactor(shell): seed component-name-healer from a2ui-payload-parser
fc6ee2bf feat(shell): add v0.9/v1.0 payload strategies and coordinator checks
ecec6453 refactor(shell): rename chat-prompt-factory to v0-9-prompt-strategy
8626c67f feat(shell): add v0.9/v1.0 prompt strategies and multi-catalog MCP
be6bf290 feat(shell): add workspace PendingRpcRegistry and Debug Events reply UI
c824c07b feat(shell): support v1.0 A2A capabilities, concurrent RPCs, and E2E
5b3138a1 fix(shell): harden A2aChatView window tracking and action filtering
ce996d7d fix(shell): address review comments on v1.0 a2a transport, rpc lifecycle, and surface partitioning
a9857fc2 fix(shell): address PR #323 review feedback
6694a7fd fix(shell): emit payloadRendered on RENDER_SUCCESS and unify frame state
2717d27c fix(bridge,shell): correlate render acks with renderId and emit resets
a8fe50c1 fix(shell): resolve surface owner from history and clear stale frames
1f937d71 fix(bridge,shell,e2e): harden RPC queue and gallery nav wait
26cbe5c5 refactor(shell): centralize protocol, prompt, and RPC envelope helpers
231273eb fix(shell): scope Canvas RPC ownership and extract SurfaceRpcCoordinator

90 files changed, 17168 insertions(+), 1393 deletions(-)

Stack

Stacked PR 5/7 — base: main (f82a26dd) → merge in order:

Verification

Run at PR #323 head (pr5-shell-v1-0-copilot-rpc-a2a, 231273eb):

  • Build and unit tests pass across all workspaces (a2ui-bridge: 331,
    lit-basic-catalog: 9, ng-basic-catalog: 19, react-basic-catalog: 14,
    react-slack-catalog: 196, a2ui-composer-shell: 2754)
  • Lint, tsc, and prettier checks pass
  • Six Playwright E2E specs pass (42/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, and
    e2e/a2a-inline-surface-order.e2e.ts (full local E2E suite was not run)
  • GitHub Actions checks for 231273eb finished with 10 passed, 5 skipped,
    0 failed

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 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.

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

⚡ A2UI Composer PR Preview

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

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

@wrenj wrenj 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.

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 mikzat 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.

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): After select_renderer switches to a v1.0 renderer, the appended system note in switchRendererForToolCall still asks for "a complete createSurface/updateComponents/updateDataModel sequence", contradicting V10PromptStrategy's single-createSurface rule. Consider branching on activeProtocolVersion() or using protocol-neutral wording.

@jgindin
jgindin force-pushed the pr5-shell-v1-0-copilot-rpc-a2a branch from 9a8b3d2 to 0672c35 Compare November 13, 2026 17:53
jgindin added a commit that referenced this pull request Nov 13, 2026
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.
@jgindin
jgindin force-pushed the pr5-shell-v1-0-copilot-rpc-a2a branch from 0672c35 to f8d5151 Compare November 13, 2026 19:22
@jgindin
jgindin added this pull request to stack #332 November 16, 2026 13:16
jgindin added a commit that referenced this pull request Nov 16, 2026
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.
jgindin added a commit that referenced this pull request Nov 16, 2026
- 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
@jgindin
jgindin force-pushed the pr5-shell-v1-0-copilot-rpc-a2a branch from f8d5151 to 13da233 Compare November 16, 2026 21:21
jgindin added a commit that referenced this pull request Nov 16, 2026
Export isV1ProtocolVersion from the mocked a2ui-bridge module in
ng-basic-catalog tests so PreviewBridge tests pass on PRs #321-#323.
jgindin added a commit that referenced this pull request Nov 16, 2026
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.
jgindin added a commit that referenced this pull request Nov 16, 2026
- 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
@jgindin
jgindin force-pushed the pr5-shell-v1-0-copilot-rpc-a2a branch 3 times, most recently from 52d5b0a to 0e863ef Compare November 16, 2026 23:51
jgindin added a commit that referenced this pull request Nov 17, 2026
* 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.
@jgindin
jgindin force-pushed the pr5-shell-v1-0-copilot-rpc-a2a branch from 0e863ef to 2e67f5c Compare November 17, 2026 00:37
Base automatically changed from pr4-shell-v1-0-core to main November 17, 2026 02:20
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.
- 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
@jgindin
jgindin force-pushed the pr5-shell-v1-0-copilot-rpc-a2a branch from 2e67f5c to a9857fc Compare November 17, 2026 02:20
- 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().
@jgindin
jgindin force-pushed the pr5-shell-v1-0-copilot-rpc-a2a branch from f48c22a to 6694a7f Compare November 17, 2026 17:23
@jgindin
jgindin requested a review from mikzat November 17, 2026 18:22
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.
@jgindin
jgindin requested a review from mikzat November 19, 2026 19:11
Comment thread bridge/src/preview-bridge.ts Resolved
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.

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.

3 participants