A2uiSurfaceComponent
Angular component that renders a single A2UI surface. It converts the surface's component map and data model into a json-render Spec, then delegates rendering to RenderSpecComponent.
Import:
Selector: a2ui-surface
Inputs
| Input | Type | Required | Description |
|---|---|---|---|
surface | A2uiSurface | Yes | The surface to render |
catalog | ViewRegistry | Yes | Component registry used to resolve A2UI type names to Angular components |
Outputs
| Output | Type | Description |
|---|---|---|
events | RenderEvent | Emits render events from the underlying RenderSpecComponent -- handler execution, state changes, and lifecycle signals |
The events output forwards all RenderEvent emissions from the render engine. This includes events triggered by the default A2UI handlers (a2ui:event and a2ui:localAction) as well as any state change or lifecycle events.
How It Works
A2uiSurfaceComponent bridges the A2UI surface model to the json-render engine in three steps:
1. Convert surface to Spec (surfaceToSpec)
The surfaceToSpec() function walks the flat component map and produces a json-render Spec. It requires a component with id: 'root' to be present โ if no root exists, nothing renders.
2. Resolve dynamic values
Before the spec is emitted, each component prop is evaluated against the surface's data model. A prop can be:
- A literal value โ passed through as-is
- A path reference
{ path: '/some/pointer' }โ resolved via JSON Pointer againstdataModel - A function call
{ call: 'formatCurrency', args: { ... } }โ executed by the built-in function registry - A template string
"Hello ${/name}"โ interpolated with values fromdataModel
3. Map actions to on bindings
surfaceToSpec() converts each component's A2UI action prop into a render-spec on binding on the corresponding element. Event actions map to the a2ui:event handler, and function call actions map to the a2ui:localAction handler. This bridges the A2UI interaction model to the render-lib event system.
4. Expand template children
When a component's children field is an A2uiChildTemplate ({ path, componentId }), the surface component expands it over the array at path in the data model. Each array item gets its own cloned element with props resolved in that item's scope.
5. Render via RenderSpecComponent
The final Spec is passed to RenderSpecComponent along with the ViewRegistry (converted to an Angular registry via toRenderRegistry). Rendering is fully reactive โ when the surface signal updates, the spec recomputes and only affected elements re-render.
Usage Outside ChatComponent
A2uiSurfaceComponent is used internally by ChatComponent, but you can also use it directly to embed a surface in any Angular template.
The surface must contain a component with id: 'root'. If no root component has been received yet (for example, while the agent is still streaming), A2uiSurfaceComponent renders nothing until one arrives.
surfaceToSpec()
The conversion function is exported for testing or custom rendering pipelines.
Import:
Signature:
Returns null when the surface has no root component. Otherwise returns a complete json-render Spec with all dynamic values resolved against the current dataModel.