Generative UI lets your agent return structured JSON specs that render as Angular components in the chat. ChatComponent auto-detects JSON specs in AI messages and renders them โ no manual wiring needed.
The detection and rendering are adapter-neutral: the same [views] path works whether the agent is driven by the LangGraph adapter or the AG-UI adapter. The examples below use @threadplane/langgraph, but only the provideAgent/injectAgent imports change for AG-UI.
When AI messages stream token-by-token, the ChatComponent classifies each message's content automatically:
AI message content (token by token)
โ ContentClassifier (auto-detect per message)
โ First non-whitespace is { โ JSON spec path
โ Anything else โ Markdown path
โ ChatComponent template renders both:
โ Markdown prose via renderMarkdown()
โ JSON specs via RenderSpecComponent + your view registry
The JSON path uses @cacheplane/partial-json to parse incomplete JSON character-by-character, producing a live Spec signal with structural sharing โ unchanged elements keep the same object reference so Angular skips re-rendering them.
When a spec wires an on event binding (for example a button's on: { click: 'submitForm' }), the named handler is looked up in the [handlers] map you pass to <chat>. The map is Record<string, (params) => unknown | Promise<unknown>> โ each key is a handler name a spec can reference, and the value runs when the event fires.
For agents that emit A2UI JSONL payloads, ChatComponent auto-detects content prefixed with ---a2ui_JSON---. Pass a2uiBasicCatalog() to [views] when you want those surfaces rendered with the built-in components. See the A2UI guide for details.