Repository navigation
feat: native generative UI (createGenerativeUI, tool and markdown transports, standard catalog, inspector pane) - #7819
Conversation
Experimental. Constants and types for the generative-ui-surface activity, the browser manifest, structural A2UI v0.9 operation validation (rejects prototype-polluting and app-owned paths), and an incremental parser that extracts complete operations from streamed render_ui arguments.
…er_ui per operation
Injects a render_ui tool when the browser forwards a generativeUI manifest
(or CopilotRuntime({ generativeUI }) enables it), validates each streamed
A2UI operation against the manifest, and commits it immediately as an
ACTIVITY_SNAPSHOT (new surface) or ACTIVITY_DELTA (each further op).
Invalid ops are rejected individually and reported back to the model.
Also adds createSurfaceWriter, a programmatic surface façade for custom
agents.
…d function binding
- createGenerativeUICatalog: React components + zod props, events and
slots compiled to a serializable manifest
- <CopilotKitProvider generativeUI={{ catalog, functions, errorBoundary }}>,
<GenerativeUISurface id>, <CopilotChat generativeUISurface>
- surface manager over @a2ui/web_core: tail-only op application, stable
component identity, per-node error boundaries, app-owned /app state
(useGenerativeUIState), user-owned field drafts (useGenerativeUIField)
- function dispatcher shared by generativeUI.functions and
useFrontendTool({ exposeToGenerativeUI: true }); fails closed
- core: FrontendTool.exposeToGenerativeUI flag
/generative-ui page with an inline recommendations surface, chat surfaces, provider and hook functions (addToCart, applyCoupon, unexposed removeFromCart), live cart app state, a checkout form with user-owned fields, and a crash-isolation widget, backed by a BuiltInAgent route with generativeUI enabled.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
Priority: Merge Risk:
|
|
Size Change: +477 kB (+25.35%) 🚨 Total Size: 2.36 MB 📦 View Changed
ℹ️ View Unchanged
|
@copilotkit/a2ui-renderer
@copilotkit/agentcore-runner
@copilotkit/angular
@copilotkit/channels
@copilotkit/channels-core
@copilotkit/channels-discord
@copilotkit/channels-intelligence
@copilotkit/channels-slack
@copilotkit/channels-teams
@copilotkit/channels-ui
@copilotkit/channels-whatsapp
@copilotkit/core
@copilotkit/intelligence-langgraph
@copilotkit/intelligence-mastra
@copilotkit/learning
@copilotkit/mcp-apps-renderer
@copilotkit/react-core
@copilotkit/react-native
@copilotkit/react-textarea
@copilotkit/react-ui
@copilotkit/runtime
@copilotkit/runtime-client-gql
@copilotkit/sdk-js
@copilotkit/shared
@copilotkit/sqlite-runner
@copilotkit/voice
@copilotkit/vue
@copilotkit/web-components
@copilotkit/web-inspector
commit: |
…ldren The render_ui guide caused two bugs in the demo: - A follow-up in chat (cart, then checkout) updated the earlier chat surface. This replaced the old UI and what the user typed in it. The guide now says to create a new surface for a different view. - A ProductGrid root was sometimes sent without "children". Only the title rendered. The guide now says that the root must list its child ids before the children are sent.
GenerativeUIEventHandler now takes the catalog and an event name, for example GenerativeUIEventHandler<typeof catalog, "onSubmit">. It reads the args from the "parameters" schema of that event, so components do not repeat them. If components declare the same event with different parameters, the handler type cannot be called and names the conflict. createGenerativeUICatalog is now generic and keeps the component definitions in a type-only field. The old GenerativeUIEventHandler<Args> form is removed. It was never released.
GenerativeUIComponentProps<typeof catalog, "CheckoutForm"> gives the props that the renderer passes to a catalog component: the parsed "props" schema, a handler for each event, and a ReactNode for each slot. Event and slot props are optional, because the agent can leave them out. A component can use this type on its own props, although the catalog also references the component. To make this possible without a circular type, createGenerativeUICatalog now accepts any function or class as "component" and does not read its props type.
…nerative UI manifest
…nd drop app state
…tiveUI Declare state and functions once. Props that match a state key or a bind selector, and events that match a function, are bound by the library and are hidden from the model. - typed useGenerativeUIState(ui, key, value) and useGenerativeUIFunction(ui, name, handler) - extends, with matching on the merged result - description prop on GenerativeUISurface - removes generativeUI.functions and FrontendTool.exposeToGenerativeUI
… and template slots
Add CopilotKitUIEnvelope (format 2) and readCopilotKitUIEnvelope for the generative UI
manifest at forwardedProps.copilotkit.ui. Add the markdown-transport guideline for
a2ui code fences. A "multiple" slot in validateOperation now also takes a template
{ componentId, path }.
… fence parser addScopedProperties registers forwarded props for the runs of named agents, and getPropertiesForAgent merges them into each run. The a2ui-markdown module (from PR #7829) splits assistant text into prose and a2ui fences, reads a target=<id> info string, parses the operations with JSON repair, and lifts prose out of a surface.
buildActionMessageText turns an event that no function matches into the text of a visible user message, as in PR #7829. createComponentLabelResolver finds the label of the component that sent the event.
… envelope GenerativeUIMiddleware now reads the manifest from forwardedProps.copilotkit.ui and runs only for the tool transport. A markdown-transport run never gets it. The hidden event path (generativeUIAction and the log_generative_ui_event call) is removed: an event that no function matches now arrives as a normal user message.
…late slots
A component lists the props it can write in `writable`, and gets a typed set<Prop> setter.
When the model binds such a prop to { path }, the setter writes the data model and the path
becomes user-owned: agent writes to it are ignored until the surface is deleted. A
"multiple" slot also renders a template { componentId, path } once per list item.
useGenerativeUIField is removed; writable replaces it.
…he transport config generativeUI is now a union on transport: "tool" (default) or "markdown". Only the markdown form has sendContext and includeCatalog. The manifest goes to forwardedProps.copilotkit.ui through addScopedProperties, limited to agentIds. An event that no function matches becomes a visible user message and starts a run. A theme sets the --a2ui-* CSS variables on each surface root.
…media components Port the PR #7829 standard catalog tokens and styles, and its layout (16) and media (6) components, to createGenerativeUI. Containers take children through a "multiple" slot, so a template list works. Add recharts as a dependency and maplibre-gl as an optional peer for the chart and map components that come next.
…mponents Port the rest of the PR #7829 standard catalog to createGenerativeUI: text (12, with streamdown markdown and katex math), inputs (12, writable values and onClick/onSubmit events), feedback (9), and data (8, with a recharts Chart and a lazily loaded maplibre Map that falls back to a list of places).
…surface engine With transport "markdown", a2ui fences in assistant messages feed the surface manager. The fence that creates a surface renders it in the chat, or a target=<id> fence renders it in <GenerativeUISurface id>. A later fence with the same surfaceId updates it in place. Prose is lifted out of chat surfaces. The guideline and a compact schema go to the agent as context entries, unless sendContext is false.
…face summary GenerativeUISurfaceSummary has the target, the values the user entered (dataModel), and the operations the client dropped (rejected, at most 20 lines of 500 characters). The envelope reader checks them. The markdown guideline tells the model to read them.
…n the render_ui guide
… UI surface summary describeSurfaces returns GenerativeUISurfaceSummary, with the rejected operations of both the runtime and the client. The markdown-mode schema context entry lists the existing surfaces, so a rejected fence operation reaches the model on the next run.
…t/react-core/v2/generative-ui standardUI is one createGenerativeUI object with the 63 standard components. The whole generative UI API is now exported from the v2/generative-ui subpath, and /v2 no longer exports it. The subpath is an entry of the /v2 build, so both share one runtime context.
… subpath Import the generative UI API from @copilotkit/react-core/v2/generative-ui. The checkout form lists email and note in writable and uses the setters, so the user's input stays when the agent updates the form.
…ed strings through labels (CopilotKit#7867) ## What does this PR do? Routes the prebuilt chat's remaining hard-coded strings through the `labels` config, so apps can translate them. | Key | Default | Where | | --- | --- | --- | | `reasoningMessageThinkingLabel` | "Thinking…" | reasoning header while the model reasons (React, Vue, Angular) | | `chatInputSlashMenuLabel` | "Slash commands" | name of the slash-command menu (React, Vue) | | `chatInputSlashMenuEmptyText` | "No commands found" | its empty state (React, Vue) | | `attachmentRemoveButtonLabel` | "Remove attachment" | queued attachment (React, Vue, Angular) | | `attachmentPlayVideoButtonLabel` | "Play video" | queued video (React, Vue) | | `attachmentPreviewCloseButtonLabel` | "Close preview" | attachment preview (React, Vue) | | `modalHeaderCloseButtonLabel` | "Close" | popup and sidebar header (React, Vue) | | `modalHeaderThreadsButtonLabel` | "Open threads" | threads drawer launcher (React, Vue) | | `sidebarLabel` | "Copilot chat sidebar" | name of the sidebar region (React, Vue) | **"Thought for N seconds"** carries a number and plural rules, which a plain string label can't express. Its English default stays as it is. The reasoning header slot now also receives `elapsedSeconds` (React; Vue's `header` and `layout` slots), so an app can render its own text with correct plurals: ```tsx <CopilotChat messageView={{ reasoningMessage: { header: ({ isStreaming, elapsedSeconds, ...props }) => ( <CopilotChatReasoningMessage.Header {...props} isStreaming={isStreaming} label={isStreaming ? "Denkt nach…" : `${Math.round(elapsedSeconds)} Sekunden nachgedacht`} /> ), }, }} /> ``` The change is additive: same English defaults, and no visual change unless an app sets the new labels. The reference pages for `useCopilotChatConfiguration` (React, Vue) and `provideCopilotChatLabels` list the new keys, and the reasoning-messages guide documents `elapsedSeconds`. Not included: - Angular's popup and sidebar close buttons keep their own names ("Close Copilot chat", "Close Copilot sidebar"). Angular's reasoning message has no header slot to pass `elapsedSeconds` to. - The A2UI renderer's own strings ("Building interface", "Retrying generation…", "Filter options...") are left out, since the A2UI catalog is being reworked in CopilotKit#7819 / CopilotKit#7829. ## Related PRs and Issues - Closes CopilotKit#7864 - Same pattern as CopilotKit#6771. Independent of CopilotKit#7865 (the icon-only button names): the two touch different keys and lines. ## Testing New tests. Each fails against `main` and passes here: - React: `CopilotChat.labels.test.tsx` (7). Covers every string above, plus `elapsedSeconds` reaching a custom header (fake timers: 0, then 3 after three seconds). - Vue: `CopilotChat.labels.test.ts` (6). - Angular: `copilot-chat-labels.spec.ts` (2). Checks: - `nx run-many -t check-types,test` for `react-core`, `vue` and `angular`, run one after another: react-core 1905 tests, vue 1186, angular 543 (1 skipped), all passing, and type checks clean. - `nx run-many -t build,publint,attw` for the same three: passing. - `oxlint` and `oxfmt --check` on the changed files: no new warnings. Browser check: a page built against `@copilotkit/react-core` packed from this branch, with German `labels`, in Chromium 149 via Playwright. Repro and capture script: https://github.com/Mordris/copilotkit-ui-repro | | 1.79.1 | This branch | | --- | --- | --- | | Reasoning header (streaming) | "Thinking…" | "Denkt nach…" | | Slash menu, no matches | `listbox "Slash commands": No commands found` | `listbox "Befehle": Keine Befehle gefunden` | | Attachment buttons | "Remove attachment", "Play video" | "Anhang entfernen", "Video abspielen" | | Preview close button | "Close preview" | "Vorschau schließen" | | Same page, English labels | | identical to 1.79.1 (byte-identical screenshot in light mode) | ## Checklist - [x] I have read the [Contribution Guide](https://github.com/copilotkit/copilotkit/blob/master/CONTRIBUTING.md) - [x] If the PR changes or adds functionality, I have updated the relevant documentation - [x] If the PR contains a breaking change, the title has `!` (for example `feat(react-core)!: ...`) and the description has a `BREAKING CHANGE:` line with migration steps. See [VERSIONING.md](https://github.com/CopilotKit/CopilotKit/blob/main/VERSIONING.md) (not a breaking change) - [x] "Allow edits by maintainers" is checked (lets us help iterate on your PR directly — faster turnaround for everyone) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Chat labels can now be customized across Angular, React, and Vue for reasoning status, slash-command menus, attachment controls, modal buttons, and sidebar accessibility names. * Reasoning headers can access elapsed reasoning time to create localized labels. * Default labels are provided when custom labels are not set. * **Documentation** * Updated configuration references and customization guides to cover the new labels and elapsed-time information. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
…t#8039) The standard catalog needs room for its components without turning the overview into a long gallery. This adds dedicated reference pages while reusing the existing examples and SDK metadata. - Keep the catalog's 69 component pills as a linked index, with a focused sidebar grouped by category. - Give 59 standalone components their own pages; document 10 structural parts under their parents with anchors, examples, and prop tables. - Reuse the existing A2UI samples through shared fixtures. Examples run scripted browser-local streams, show local interaction events, and offer copyable surface operations without a model connection. - Preserve legacy component fragments and canonical component links from framework-specific docs. - Set an explicit Turbopack root covering the docs app and sibling shared fixtures. The standalone Docker build has no monorepo lockfile, so its inferred root otherwise excludes those imports; a regression test covers this build boundary. Validation: formatter and scoped lint passed; explicit TypeScript check passed; all 563 tests across 90 files passed; production Next.js build passed; npm lockfile dry-run passed. Public-route checks against the local production build covered all 59 pages, 10 part anchors, 69 index links, seven group anchors, scoped redirects, and unknown-route 404s. Commit hooks passed. The [docs Docker build check](https://github.com/CopilotKit/CopilotKit/actions/runs/40625519619/job/122609492676) passed on fix commit `a51dcdaa7798bdce23c198d79ac70b54dffe4a38`. No deployment configuration changes are included. Local container execution was not used; the automatic PR check verified the Docker build. Map/WebGL and external media behavior have not been fully verified in a browser. Extends the GenUI documentation introduced in CopilotKit#7819. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Added an interactive Standard Component Catalog with live previews, local sample data, event feedback, and component API details. * Added dedicated documentation pages for catalog components, including examples and documentation for structural parts alongside their parent components. * Catalog links and legacy component anchors now navigate to relevant documentation pages, including when browsing framework-scoped docs. * **Documentation** * Updated the Standard Component Catalog guide to describe interactive previews and component pages. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
…tKit#8260) ## What does this PR do? Brings generative UI (catalogs and surfaces from CopilotKit#7819, the feature CopilotKit#8105 brought to Angular) to React Native, so an RN app can let the agent render its **own native components**. ```tsx import { GenerativeUIActivity, GenerativeUIProvider, createGenerativeUI, } from "@copilotkit/react-native/generative-ui"; const ui = createGenerativeUI({ id: "bank", components: { BalanceCard: { props, component: BalanceCard } } }); <CopilotKitProvider runtimeUrl={url}> <GenerativeUIProvider ui={ui}> {/* anywhere: a chat list, or a screen with no chat at all */} <GenerativeUIActivity message={activityMessage} agent={agent} /> </GenerativeUIProvider> </CopilotKitProvider> ``` The runtime needs no changes: `CopilotRuntime` already adds `render_ui` and validates every operation when the app sends a catalog. ### `@copilotkit/react-native/generative-ui` (new entry) - `createGenerativeUI`, `child`/`childList` and the generative UI hooks, re-exported from react-core. - `GenerativeUIProvider`: goes inside `CopilotKitProvider`. It runs react-core's `useGenerativeUIRoot` and supplies React Native host elements (`nativeGenerativeUIHost`, overridable with `host`). Tool transport only for now: `theme` is not in its props type, and a `theme` or another transport from untyped code is dropped with a dev warning. react-core's root wiring skips malformed activity messages on both platforms (dev warning once per distinct issue), and a second provider with a `ui` on one core warns. - `GenerativeUIActivity`: renders the surface of any agent's activity message. It works in a chat list or outside chat, for example a home screen composed by a background agent run, and it avoids the single-active-thread limit of named targets. `isGenerativeUIActivity` is a type guard for message lists. - `GenerativeUISurface`: a named target, with `onGenerationStart` (once per `render_ui` start, StrictMode-safe, callback errors contained) in place of the DOM `autoScroll`. `style`/`testID` also apply to the fallback, and a `Wrapper` sees rejected operations. - The accessibility wrapper is a real, non-collapsable `View` with `aria-live` mapped; the node fallback is a native view. - Every published entry (`/`, `/components`, `/generative-ui`) imports the polyfills first and is listed in `sideEffects`; the built-barrel check verifies that for every exports entry in both formats. - Opt-in by design. An import-graph test, derived from the packages' exports maps, keeps the default and `/headless` entries from reaching it and keeps it on react-core's DOM-free entry. - `zod` stays an optional peer at `>=3.0.0`; the docs pin `zod@^3.25` because `child()`/`childList()` return zod 3 schemas. ### react-core - `SurfaceView` and the error boundaries now read their host elements from `GenerativeUIHostContext`: the surface root, the accessibility wrapper and the node fallback. The defaults are the existing DOM elements, so web output is unchanged and the existing tests pass untouched. - New entry `@copilotkit/react-core/v2/generative-ui/native`: the catalog API, the hooks, the root wiring and `SurfaceView`, without the standard catalog (react-dom portals, KaTeX), the markdown surfaces (streamdown) or the DOM `<GenerativeUISurface>`. - It is built alongside `/v2` and `/v2/generative-ui`, so all three share one copy of each context; `assert-dist-context-types` checks every native export against that. - It is covered by `assert-headless-purity`, which now also scans its dependencies for class static blocks and for Lit/react-dom exactly. Both gate scripts have failure-path test suites. - Failure containment: a throwing app `errorFallback`, host `NodeFallback`, `SurfaceRoot` or `AccessibilityWrapper` stays inside its node, and any thrown value (including `undefined`, `null`, `0` and `""`) becomes an Error with the value as its `cause`. A render failure is reported to `onError` once per rendered place until the content changes, so streamed chunks, StrictMode and remounts do not repeat it. ### Hermes / Metro fixes found by running it in a real app 1. **core:** the surface manager imported its models from the `@a2ui/web_core/v0_9` barrel, which also re-exports the basic catalog's Lit elements. lit-html reads `document` at module load, which throws in Hermes. The same classes now come from the `catalog` and `state` entries, and the UMD build maps both to the existing `v0_9` global. 2. **react-core:** `static contextType` on the boundaries was lowered to `static {}` blocks, which Metro's Babel preset cannot parse. It is now assigned after each class, and the purity gate fails the build if a static block comes back. 3. **core / shared:** Hermes has no `structuredClone`, and the surface manager calls it on data-model writes and function-call payloads. Instead of a global polyfill (which would change `@ag-ui/client`'s clone for every React Native user), the generative UI engine and the interrupt state use `cloneValue` from `@copilotkit/shared`: the native `structuredClone` when present, otherwise a local deep copy with the same semantics (undefined, Date/Map/Set, cycles, NaN, `DataCloneError` where native throws). A differential test compares the two. 4. **react-native:** tsdown hoisted the provider chunk above the polyfill import in the root entry, so `@copilotkit/core` could load before the polyfills. Every entry now imports them first, and the built-barrel guard checks it. Further Hermes-path fixes from review: - User-owned writes keep `structuredClone` semantics (as before on web); the agent gets their JSON form, and a `bigint` or a cycle is left out of the request instead of making it throw. `null`/`undefined` writes remove the key, and the agent is told `null`. - `pluralize` falls back to the English rule without `Intl.PluralRules`. A missing `Intl.NumberFormat`/`DateTimeFormat` or `window.open` throws a `PlatformError` (exported from `@copilotkit/core/generative-ui`), reported to the model as `handler_failed`. - `openUrl` keeps WHATWG URL behaviour on a browser page and uses a small parser on React Native, whose `URL` class differs by version. - No `Object.hasOwn`, `Error` `cause` option or `Array.prototype.at` on the native path (iOS 12.4 JSC and older Hermes lack them). A parser-based scan of the modules the native entry ships enforces this. ### Docs - React Native tabs on the components-and-surfaces pages (try it, surfaces, catalogs, state and actions, transports), and React Native notes on the standard catalog, markdown mode and theming pages. - A "Generative UI with your own components" section on the React Native page: a native catalog, `GenerativeUIProvider`, `GenerativeUIActivity` in your own message list, a home screen composed with no chat, and where errors show on the device (including the silent cases). - Reference pages for `GenerativeUIProvider`, `GenerativeUIActivity` and `GenerativeUISurface`, and the `/generative-ui` entry in the package README and USAGE. - `react-native-generative-ui-docs.test.ts` keeps duplicated snippets identical and pins key claims to the code; the shell-docs workflow now also runs when that code changes. ### Not in this PR - The markdown transport on RN. - A native standard catalog. - `theme` on RN (there are no CSS variables; style the catalog's components directly). - Rendering surfaces inside the prebuilt RN `CopilotChat`. CopilotKit#7469 is rewriting it; it still drops activity messages. - `cloneValue` parity with native `structuredClone` for exotic types (iterator helpers, `Intl` objects, detached or resizable buffers, and similar). Plain data, Date/Map/Set, typed arrays, errors and cycles match. - Pre-existing surface-manager and core edges found in review (for example `reportErrorSafely` swallowing, the JSON fallback of the other `structuredClone` call sites in core on Hermes). They are tracked as follow-ups and are not changed here. ## How it was tested - Package checks: `nx run-many -t lint,check-types,test,build` passes for shared, core, react-core and react-native. - shared: 36 files, 884 tests, including the `cloneValue` unit and differential tests. - core: 112 files, 1945 tests, including the engine run with Hermes-missing globals removed, the owned-JSON boundary and a scan of the shipped files for unsupported APIs. - react-core: 216 files, 2759 tests, including a containment matrix (throw site x path x thrown value x follow-up event) with StrictMode and remount cases; plus 130 script tests for the purity and dist-context-type gates. - react-native: 27 files, 467 tests, including the generative UI components, provider wiring, a provider props type test and the entry guards; plus 32 script tests for the polyfill-barrel guard. - `pnpm check:public-api-manifest` and `size:assert-headless` pass. The shell-docs suite (typecheck and 606 tests) passes. - In a real bare RN 0.88 app on the iOS simulator, in both Debug and Release (Hermes, eager module loading), against a Node `CopilotRuntime`: - a home screen composed by a background agent run with no chat; - Ask-style answers with surfaces rendered inline; - a custom catalog of 15 native components, with forms the agent pre-fills. - Fixes 1 to 3 above are what that app hit, in that order. The later review fixes are covered by the tests above and were not re-run on the simulator. ## Related PRs and Issues - CopilotKit#7819: generative UI (catalogs, surfaces, tool and markdown transports) - CopilotKit#8105: the same feature for Angular; this PR follows its packaging (separate entry, separate provider) - CopilotKit#7469: RN chat design refresh (surfaces in `CopilotChat` should land after it) - CopilotKit#8033: headless provider. Same area of react-core, but this PR does not touch `CopilotKitProvider.tsx`. ## Checklist - [x] I have read the [Contribution Guide](https://github.com/copilotkit/copilotkit/blob/master/CONTRIBUTING.md) - [x] If the PR changes or adds functionality, I have updated the relevant documentation - [x] No breaking change: web output and the existing entries are unchanged - [x] "Allow edits by maintainers" is checked 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Added experimental React Native Generative UI, including native catalogs, providers, chat activities, named surfaces, accessibility support, and error fallbacks. * Added React Native and React Core native Generative UI entry points. * **Bug Fixes** * Improved error containment, reporting, deduplication, and retry behavior for Generative UI surfaces. * Improved compatibility with React Native runtimes lacking browser APIs or `structuredClone`, including URL handling and value copying. * Malformed activity content is skipped without blocking later valid content. * **Documentation** * Added React Native setup, usage, and API guidance, including platform limitations and requirements. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
…#8280) A Vue app can now let the agent render its own Vue components in the chat or in named places on the page. This is the same native generative UI that React (CopilotKit#7819) and Angular (CopilotKit#8105) have. It includes all 69 components of the standard catalog. To try it, run the Vue demo and open `/generative-ui` or `/generative-ui-standard` (steps below). ## What does this PR do? It adds a new entry, `@copilotkit/vue/v2/generative-ui`. Its exports have the same names as React's `/v2/generative-ui`. - **Setup:** `<CopilotKitProvider :generativeUI="{ ui }">` turns the feature on. It supports the tool transport (`render_ui`) and the markdown transport (a2ui fences). - **Where UI goes:** the agent renders into the chat, or into a `<GenerativeUISurface id="...">` on the page. The default slot of the surface is the fallback content. - **App state and functions:** `useGenerativeUIState` and `useGenerativeUIFunction` connect generated UI to the app. - **Standard catalog:** `standardUI` has all 69 components as Vue SFCs. Chart and Map are opt-in with `app.use(GenerativeUIChart)` and `app.use(GenerativeUIMap)`. Without the plugins, Chart shows a table and Map shows a list. - **Chat card:** a `#generative-ui-surface` slot on `CopilotChat`, `CopilotPopup` and `CopilotSidebar` replaces the default card. How a generated Vue component gets its props: - Data props are normal Vue props. Declare them explicitly in the SFC. - A writable prop `x` is the prop `x` plus an `update:x` emit, so `defineModel("x")` works. - Events are optional function props. The component awaits the result. - `child()` and `childList()` keys are named slots. A list slot gives one VNode for each child. Other changes: - **Shared helpers:** the framework-free helpers of Angular's standard catalog (style, URL, chart config, map guards) moved to `@copilotkit/shared/generative-ui`. Angular imports them from there, and its behavior does not change. React still has its own copies. `openUrl` checks that `window.open` exists, so the Hermes API scan from CopilotKit#8260 passes. - **Shared with React:** `toError`, `withCause` and the surface activity content parser moved from `react-core` to `@copilotkit/shared/generative-ui` and `@copilotkit/core/generative-ui`. React re-exports them, so its exports do not change. Vue uses the same code. - **Docs:** the 9 generative UI guide pages have a Vue tab, next to the React Native tab from CopilotKit#8260. New Vue reference pages: `GenerativeUISurface`, `useGenerativeUIState`, `useGenerativeUIFunction`. `CopilotKitProvider` and `CopilotChat` reference pages are updated. - **Demo:** the Nuxt demo has two new pages: - `/generative-ui`: a store page, ported from the React demo. The agent renders into named places on the page. - `/generative-ui-standard`: `standardUI` in the chat. Charts are turned on with a Nuxt plugin that calls `app.use(GenerativeUIChart)`. - **Hardening from CopilotKit#8260, in Vue too:** an activity message with malformed content is skipped, not thrown. A throwing app error fallback stays inside its node. A failure is reported once per place. The surface boundary resets when new content arrives. - **Parity:** `packages/vue/PARITY.md` has the matrix rows and the intentional divergences. Each commit is one piece of the port, so you can review the PR commit by commit. ## Related PRs and Issues - CopilotKit#7819: native generative UI in React - CopilotKit#8105: native generative UI in Angular - CopilotKit#8260: generative UI in React Native ## Checklist - [ ] I have read the [Contribution Guide](https://github.com/copilotkit/copilotkit/blob/master/CONTRIBUTING.md) - [x] If the PR changes or adds functionality, I have updated the relevant documentation - [x] If the PR contains a breaking change, the title has `!` (for example `feat(react-core)!: ...`) and the description has a `BREAKING CHANGE:` line with migration steps. See [VERSIONING.md](https://github.com/CopilotKit/CopilotKit/blob/main/VERSIONING.md) (no breaking change: all additions) - [ ] "Allow edits by maintainers" is checked (lets us help iterate on your PR directly — faster turnaround for everyone) ## Testing **Commands run** - `pnpm nx run-many -t build,test,check-types,publint,attw -p @copilotkit/vue`: pass. 161 test files, 1787 tests passed, 1 skipped. 42 of the files test generative UI. - `pnpm nx run-many -t test,build -p @copilotkit/shared @copilotkit/angular @copilotkit/core`: pass, after the merge of `main`. The core tests include the Hermes API scan. - `pnpm check:public-api-manifest`: current. - `pnpm nx run-many -t build,test,check-types,publint,attw -p @copilotkit/vue @copilotkit/shared @copilotkit/core @copilotkit/react-core @copilotkit/angular`: pass, after the review fixes. - The shell-docs CI steps (`npm run pretypecheck`, `npm run test:ci`, `npm run typecheck` in `showcase/shell-docs`): pass. Shell-docs has no Nx target. - `pnpm --filter @copilotkit/vue-demo lint`: pass. The demo build passes with `NODE_OPTIONS=--max-old-space-size=8192`. It runs out of memory at the default size on `main` too. **Manual test** (needs an OpenAI key) 1. Run `pnpm nx run @copilotkit/vue:build`. 2. Run `OPENAI_API_KEY=... pnpm -C examples/v2/vue/demo dev` and open `http://localhost:3000/generative-ui`. 3. Click "Add" on a featured product. The cart badge shows "Cart 1, $179". 4. Click the "Buy headphones" suggestion. The agent renders 3 product cards in the "Headphones" area, not in the chat. The first card shows "In cart: 1" from the app state. 5. Click "Add to cart" on a generated card. The cart badge changes to "Cart 2, $358". 6. Click the "Featured products" suggestion. The generated cards go away and the featured list comes back. 7. Open `http://localhost:3000/generative-ui-standard`. Click "Compare laptops", then "Revenue chart", then "Trip form". Each answer is a card in the chat: a table with a badge, a chart.js bar chart, and a form with a text field, a select, a checkbox and a button. I did these steps in headless Chromium against a real OpenAI model. All steps passed with no console errors. The pages stayed responsive during the agent runs, and the generated form took typed text, a select choice and a checkbox. **How this PR makes testing easy** - Vue tests for every layer: catalog types, root composable, `SurfaceView`, surfaces, the chat card, the markdown transport, provider wiring, and each standard component group. Where the case translates, the test names are the same as the React tests. - `showcase/shell-docs/src/lib/__tests__/vue-generative-ui-docs.test.ts` pins the Vue docs to the code: the reference props, the chat slot props, the camelCase `:generativeUI` binding, and the imported names. - Type tests in `.test-d.ts` files. `check-types` now runs them through `tsconfig.typetests.json`. - The `/generative-ui` and `/generative-ui-standard` pages in `examples/v2/vue/demo`. ## Risk / rollback The risk is low for current users. Everything is new and opt-in: nothing changes unless an app sets `generativeUI` or imports `/v2/generative-ui`. - **Shared areas:** the existing code this PR changes is `CopilotKitProvider.vue`, the chat components (to pass the slot on), Angular's imports of the moved helpers, and React's imports of `toError`, `withCause` and the content parser. The React tests pass unchanged. - **Bundle:** importing `@copilotkit/vue/v2` alone does not load the standard catalog. A check of the built output confirms this. - **Peers:** `chart.js` and `maplibre-gl` are optional peers. The demo adds `chart.js` as a dependency for its chart. - **Rollback:** revert the PR. ## Public API change **Before** ```vue <CopilotKitProvider runtime-url="/api/copilotkit"> <CopilotChat /> </CopilotKitProvider> ``` **After** ```vue <script setup lang="ts"> import { standardUI } from "@copilotkit/vue/v2/generative-ui"; </script> <template> <CopilotKitProvider runtime-url="/api/copilotkit" :generativeUI="{ ui: standardUI }"> <CopilotChat /> </CopilotKitProvider> </template> ``` Write the binding in camelCase (`:generativeUI`). Vue reads `:generative-ui` as a different prop, `generativeUi`. The existing `openGenerativeUI` prop works the same way. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Try it: run
examples/v2/generative-ui-shop(setup in its README) and ask the chat for "Top rated" products. The home row on the page changes to what the agent picked. This PR makes generative UI one feature: an agent streams React components into the chat or into named areas of the page, with therender_uitool (tool transport) or with a2ui code fences in its reply (markdown transport). It includes a standard catalog of 69 components (the A2UI 1.0 basic catalog, from #7879, with the follow-ups of #7888, #7890 and #7898), the work of #7829 and #7848, two new examples, and a Generative UI pane in the inspector.What does this PR do?
Catalog (
@copilotkit/react-core/v2/generative-ui)createGenerativeUI({ id, extends, state, functions, overrides, components })declares the components, the app state, and the functions. Schemas can be any Standard Schema (zod 3, zod 4.2+, Valibot, ArkType). Props need a JSON Schema, and props and state must validate synchronously.bindselector, gets its value from app state. An event with the name of a function (oronXforx) calls it. An event that no function matches becomes a visible user message.writable: ["value"]gives a component a typedsetValue. A path that the user wrote becomes user-owned: later agent writes to it are ignored.extendsmerges catalogs, with full types for every component.overrides: { Card: { component: MyCard } }replaces the React component of a base component and keeps what the model sees.standardUI.omit(["Map"])drops components, also from the prompt.useGenerativeUIState(ui, key, value)anduseGenerativeUIFunction(ui, name, handler)connect app state and handlers, with types fromui.Surfaces
<GenerativeUISurface id description ui components fallback />is a named area of the page. The fallback shows until the agent renders into it.uiprop typescomponents, so a wrong component name is atscerror.componentsneedsui.componentslimits the area to those components. Other components are rejected, and the model gets the reason.autoScroll={false}turns this off for one surface.Standard catalog and theme
standardUI: 69 components for layout, text, inputs, feedback, data, media, and composites (the a2ui-renderer catalog, ported in feat(react-core): port the a2ui-renderer standard catalog and markdown-mode behaviour onto createGenerativeUI #7848). Chart usesrecharts. Map loadsmaplibre-gl(an optional peer)..darkclass, like the CopilotKit chat. The map uses a dark basemap.themekeys are the exact--a2ui-*variables, so a wrong name is a type error. Top-level values apply in both modes, anddark: { … }replaces them in dark mode. The theme is a stylesheet on the surface root.Wire and runtime (
@copilotkit/shared,@copilotkit/core, runtime)createSurfacewith inlinecomponentsanddataModel,{"@path"}bindings,{"@call"}function calls in events,{"@call":"@index"}in templates,userMessageon events, and"value": nulldeletes.catalogIdis optional.supportedCatalogIdslists the id of the UI first, then the id of every catalog in itsextends. An operation can name any of these ids incatalogId, and the surface keeps that id. An unknown id on a component or a function call is rejected with a reason. An unknown id oncreateSurfaceis replaced with the id of the UI.callRendererFunctionis off for now (feat(react-core): no agent-called renderer functions for now, A2UI default for allowedCallers, experimental callout, two prompt rules #7890): the prompts do not mention it, and the validator rejects it with a reason. The code and its tests stay behindGENERATIVE_UI_AGENT_FUNCTION_CALLS.forwardedProps.copilotkit.ui(format 3, the v1.0 renderer capabilities shape), only to the agents inagentIds. The guide sends only the rules that the catalog needs (about 575 tokens for a small catalog, 930 with all rules).CopilotRuntime({ generativeUI: true })gives tool-transport runsrender_uithroughGenerativeUIMiddleware. A markdown-transport run never gets it.target=<id>renders in that surface, and the v1 chat (@copilotkit/react-ui) renders a2ui fences too.Inspector (
@copilotkit/web-inspector)A new Generative UI pane, with three tabs:
slotsand thechild()/childList()refs at any depth. Hover over the card of a page surface to outline it on the page and scroll to it.extendshas an "extended" tag and starts closed. A small search filters components and functions.render_uiguide. The large text is drawn only when you open it.React-core gives core an internal debug source (
ɵGenerativeUIDebugSource), and the pane reads it. The prompt builder moved from runtime to@copilotkit/shared, so the pane shows the same guide that the runtime builds.Examples
examples/v2/generative-ui-shop(new, React Router): the shop from the AI-powered apps workshop, with Prisma and SQLite. A TanStack AI agent with server tools fills four page surfaces: the home row, the product recommendations, the cart items, and the cart suggestions.examples/v2/a2ui-markdown(Next.js): both transports, page surfaces with pills, and/catalogwith every standard component.examples/v2/react/demo/generative-ui: a storefront withbind,writable, and a limited surface.Known gaps
callRendererFunction) are off. Their result goes back as a developer message, and not every backend keeps that message where the model reads it in order.deleteSurface.HtmlViewcontent stays light-styled in dark mode: it is a sandboxed iframe that the theme cannot reach.sendDataModel.extendsmerges catalogs into one namespace, and overrides replace by name.catalogId.callAgentFunctionandagentFunctionResponseare not implemented. A user event starts a new run instead.@a2ui/web_corestays 0.10.4: the engine uses itsv0_9surface and data models. Version 0.14 hasv1_0models, and the move is a separate integration task.@ag-ui/a2ui-toolkit0.0.5 writes v0.9 operations, so agent tools built with it do not work with this engine. Therender_uiroute does not use the toolkit, and it works with a LangGraph Python agent (see Testing).exportA2UICataloggives the portable JSON, but definitions without React are not split out yet.Related PRs and Issues
createGenerativeUI.calc.exportA2UICatalog, and an adoption guide.allowedCallers, the experimental callout, and two prompt rules.Loading,LoadingIndicator,LoadingBlockandCelebration.Checklist
!(for examplefeat(react-core)!: ...) and the description has aBREAKING CHANGE:line with migration steps. See VERSIONING.mdDocs: a new "Components and surfaces" section under Generative UI, in the Declarative group (
showcase/shell-docs/src/content/docs/generative-ui/components/), with 9 pages, and an adoption guide from thea2uirenderer is one of them. Its support matrix lists these limits. The quickstart has a "When something does not render" table that points to the tab of the inspector pane to open. The Inspector page,surfaces.mdx, andcatalogs.mdxlink to the pane too. Reference pages forcreateGenerativeUI,GenerativeUISurface, and the hooks come in a later PR. There is no breaking change for users: none of these APIs is onmain.Testing
Commands run
tsc --noEmitpasses in react-core and in the three examples (generative-ui-shop,a2ui-markdown,react/demo), after a rebuild of react-core.omit, and the type rules.pnpm install --frozen-lockfile --lockfile-onlypasses for all 86 workspace projects.032d695e21,89ec79e649,ae485ca8bf). A lockfile change makes that step run the Go and Ruby runtime tests, which cannot run on the author's machine. CI runs them.tsc --noEmitin those four and in runtime. These tests pass:generative-ui-view.spec.tsandhud-conformance.test.ts(69),use-generative-ui-root.test.tsxandcatalog.test.tsx(46),generative-ui-debug.test.ts(2),generative-ui-middleware.test.ts(44), andshared/src/generative-ui(76).tsc --noEmitin web-inspector, and the 69 inspector tests pass. The docs commit has no code.examples/v2/a2ui-markdown(CopilotKitMiddleware,uv syncfrom itsuv.lock) with an OpenAI model, on both transports. With the tool transport, it rendered a dashboard into a page target, then updated the same surface in place. A sign-up form showed its checks, and Create account stayed disabled until every field was valid. The submit event started a new run, and the agent repeated the 4 values. The inspector showed 2 surfaces and no rejected operations. With the markdown transport, a fence rendered a checklist in thenotestarget, and no fence text appeared in the chat. The agent and the runtime logged no errors.extends(2ac89b6e67), after a rebase on feat(react-core): drop Loading, LoadingIndicator, LoadingBlock and Celebration; keep a fade under reduced motion #7898: builds of shared and core, thentsc --noEmitin shared, core, react-core and runtime. The touched test files pass:validate-operation.test.tsanda2ui-envelope.test.ts(102),a2ui-markdown-operations.test.ts(74),catalog.test.tsx,markdown-source.test.ts,surface-manager.test.tsanduse-generative-ui-root.test.tsx(130), andgenerative-ui-middleware.test.ts(42). The full pre-commit hook passed. In one earlier hook run, the react-coreCharttest instandard/__tests__/data.test.tsxtimed out under load. It passes alone.Manual test
examples/v2/generative-ui-shop/README.md, then runpnpm example-devand open http://localhost:3012.darkclass to<html>in the devtools ofexamples/v2/a2ui-markdown/catalog. Every standard component switches to dark.buttonin the search: the standard catalog opens with its matches. On Surfaces, hover over a page surface card: the surface gets an outline on the page.examples/v2/a2ui-markdown(seeagent/README.md), then open http://localhost:3011/?agent=langgraph&transport=tool. Click Dashboard on the page, then Update the dashboard: the same surface changes. Click Sign-up with validation, fill the form, and submit it: the agent repeats what you entered.How this PR makes testing easy
packages/web-inspector/src/components/generative-ui-view.spec.ts,packages/react-core/src/v2/generative-ui/**/__tests__,packages/shared/src/__tests__/a2ui-*.test.ts,packages/core/src/__tests__/a2ui-markdown-*.test.ts, andpackages/runtime/src/v2/runtime/__tests__/generative-ui-*.test.ts./catalogrenders with no model.Risk / rollback
Low risk for current users. All new APIs are experimental and opt-in, and the
a2uiprop path does not change. react-core getsrechartsas a dependency andmaplibre-glas an optional peer; apps that do not import the subpath do not bundle them. The new shop example adds Prisma, TanStack AI React, and Faker to the lockfile. To undo, revert the PR.Public API change
New experimental exports. Nothing that exists on
mainchanges.Before
After
Summary by CodeRabbit
New Features
a2uicontent, targeted surfaces, inline rendering, and chat integration.Documentation