refactor and feat: implement WebAppFrameSrcdoc component and consolidate iframe communication into WebAppFrameBridgeService - #2139
Conversation
…he Pong sample application
…schema validation, and data synchronization
There was a problem hiding this comment.
Code Review
This pull request introduces the WebAppFrameSrcdoc component to support rendering sandboxed, model-generated HTML/JS layouts via srcdoc in Angular, alongside the existing WebAppFrameUrl component. To avoid code duplication, the shared iframe bridging logic has been refactored into a new WebAppFrameBridgeService. Feedback on these changes highlights several performance and resource management improvements: compiling Ajv schemas on every message or action is inefficient and should be optimized using a validator cache; synchronous network I/O in the agent's asynchronous tool function blocks the event loop and should be run in an executor; and the MessageChannel port (appPort) needs to be properly closed upon service destruction to prevent resource leaks.
…tor caching with port cleanup
| "WebAppFrameSrcdoc": { | ||
| "type": "object", | ||
| "allOf": [ | ||
| { |
There was a problem hiding this comment.
Please diff with the iframe sample I had for contact finder in case we have any gaps. We can replace that iframe component with the security approved one then.
There was a problem hiding this comment.
I can check once the old iframe sample is revived.
I assume it is using v0.8. Would be best if we can also add some of the feature updates to leverage the v0.9 features.
|
Looks great! Please loop @josemontesp into future work in this area, because he will be responsible for ensuring the necessary MCP app / iframe components get released as part of our open source offerings! |
… URL origin fallback to constant
Description
Overview
This pull request introduces the WebAppFrameSrcdoc component to enable rendering interactive sandboxed web frames from inline HTML strings (
srcdoc), alongside the existing URL-based WebAppFrameUrl component.To prevent code duplication across URL-based and inline HTML frame components, this change extracts shared iframe communication, schema validation, lifecycle management, and two-way data synchronization into an Angular service named WebAppFrameBridgeService. It also consolidates common Zod property schemas into WebAppFrameBasePropsSchema.
The Pong sample application is updated to demonstrate and verify
srcdoc-based inline web frames.New components and catalog additions
srcdocattribute.WebAppFrameSrcdocin the Angular A2UI component catalog in catalog.ts and added it to the sample app template in app.html.srcdocweb frame tool calls.WebAppFrameSrcdocto mcp_app_catalog.json.Shared iframe bridge service and schema consolidation
@Injectable()) to centralizepostMessageevent handling, Ajv-based JSON schema validation for allowed actions and functions,ResizeObservercontainer dimension tracking, and two-way data model synchronization.WebAppFrameBridgeService. This removes 824 lines of duplicated logic while adding 528 lines across the service and component implementations.config,data,allowedEvents,allowedFunctions,mutableData,disableSchemaValidation) into WebAppFrameBasePropsSchema in web-frame-messages.ts. BothwebAppFrameUrlPropertiesSchemaandwebAppFrameSrcdocPropertiesSchemaextend this base schema.Pong sample application integration
WebAppFrameSrcdocinstead of a remote URL.srcdoc-rendered iframe message handshakes and data updates.Changed files
srcdocattribute.WebAppFrameBridgeService.WebAppFrameBasePropsSchemato share common property validation between frame components.WebAppFrameSrcdocin the Angular client catalog.WebAppFrameSrcdocto the sample application layout.WebAppFrameSrcdocschema to the 0.9 MCP app catalog.srcdocframe rendering.WebAppFrameSrcdocUI payloads.WebAppFrameSrcdoccomponents.srcdocframes.Verification
WebAppFrameUrlandWebAppFrameSrcdoccompile cleanly with no TypeScript or lint errors.a2ui_app_frame_ready,a2ui_app_frame_init), schema validation, action dispatching, and two-way data model updates work across both URL andsrcdociframe components.srcdoc-based rendering.Pre-launch Checklist
One time:
For this PR:
If you need help, consider asking for advice on the discussion board.