Repository navigation
feat(vue): native generative UI with the standard catalog - #8280
Conversation
Move the style, URL, chart config and map helpers of Angular's standard catalog to @copilotkit/shared/generative-ui so the Vue port can reuse them. Angular imports them from shared with no behavior change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e error boundaries Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…wnSurfaces Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ns, selects and list items Co-Authored-By: Claude Opus 5.5 <[email protected]>
CopilotKitProvider takes generativeUI={ ui } and registers the surface,
function-call and render_ui renderers. CopilotChat, CopilotPopup and
CopilotSidebar take a #generative-ui-surface slot, and the assistant message
renders a2ui fences as surfaces with the markdown transport.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…d map entries Adds the generative-ui, generative-ui/chart and generative-ui/map subpaths, keeps chart.js, maplibre-gl and the core/shared generative-ui code external, type-checks the .test-d.ts type tests, and updates the public API manifest. Co-Authored-By: Claude Opus 5.5 <[email protected]>
useId is new in Vue 3.5. The standard components now use useStandardId, which is useId when Vue has it and a module counter otherwise. Also corrects test comments that still described the provider wiring as pending. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
This PR was not deployed automatically as @AlemTuzlak does not have access to the Railway project. In order to get automatic PR deploys, please add @AlemTuzlak to your workspace on Railway. |
|
Caution Review failedThe pull request is closed.
Warning Some tools did not complete. Review the errors below.
|
Production Digest-Pinning AuditAll 43 services digest-pinned. Run 2026-11-09 07:29:42 PST — 0 finding(s). |
|
Size Change: +16.8 kB (+0.68%) Total Size: 2.47 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: |
The /generative-ui-standard page passes standardUI to CopilotKitProvider and lets the agent answer in the chat with cards, tables, charts and forms. Charts are turned on with the GenerativeUIChart plugin. Co-Authored-By: Claude Opus 5.5 <[email protected]>
mxmzb
left a comment
There was a problem hiding this comment.
Nice port: the tests, the build and the built chunk graph all look good (/v2 and /v2/generative-ui share one copy of the provider injection keys). The main theme of this review: the branch was cut before #8260 landed, and #8260 hardened the React generative UI that this port mirrors. A few of those fixes need to come over to Vue too. Details are inline.
Missing docs test for Vue. #8260 added showcase/shell-docs/src/lib/__tests__/react-native-generative-ui-docs.test.ts, which pins snippets and reference prop names to the code. This PR adds a lot of Vue docs with nothing that keeps them in sync. The snippets are correct today (I checked them), so this is about keeping them that way. Worth pinning in a Vue equivalent:
- the props in
GenerativeUISurface.mdxagainstGenerativeUISurfaceProps - the nested
generativeUIkeys inCopilotKitProvider.mdxagainstruntime-context.ts - the chat slot props against
GenerativeUIChatSurfaceSlotProps - no
:generative-ui=binding anywhere in the docs, README or demo (the camelCase pitfall) - every
@copilotkit/vue/v2/generative-ui*import resolving to a real export
| export function openUrl(href: string | undefined) { | ||
| if (!href || typeof window === "undefined") return; | ||
| const safe = safeHref(href); | ||
| if (safe) window.open(safe, "_blank", "noopener,noreferrer"); |
There was a problem hiding this comment.
This fails main's Hermes API scan once the branch is rebased. I merged main locally and ran core's tests; hermes-globals.test.ts fails with:
shared/src/generative-ui/standard/url.ts:48: window.location or window.open; use a feature check
Moving this into @copilotkit/shared/generative-ui puts it on the React Native path. On RN window is an alias of global, so the typeof window guard passes and window.open(...) throws. Suggest a function check, with the marker on this line so the scan accepts it:
if (typeof window === "undefined" || typeof window.open !== "function") return;
const safe = safeHref(url);
if (safe) window.open(safe, "_blank", "noopener,noreferrer"); // hermes-ok: feature-checkedThere was a problem hiding this comment.
Fixed in 64b435a (the merge of main). openUrl now returns when typeof window.open !== "function", and the two lines that use window.open carry // hermes-ok:. The Hermes API scan in core passes.
| message.role === "activity" && | ||
| message.activityType === GENERATIVE_UI_ACTIVITY_TYPE | ||
| ) { | ||
| manager.ingest( |
There was a problem hiding this comment.
An activity message with malformed content (for example null) throws here: manager.ingest reads content.surfaceId without a check. That happens inside the agent's onMessagesChanged during the run, and the messages after it are not ingested.
#8260 fixed this in React: ingestMessages in packages/react-core/src/v2/generative-ui/use-generative-ui-root.ts (on main) parses the content first, skips a malformed message, and warns once per distinct issue in development. Could you port that, with a test for null content?
There was a problem hiding this comment.
Fixed in e3c2e9f. ingestMessages parses the content first, skips a malformed message, and warns once per distinct issue in development, the same as React. To keep one copy, 0ca589a moves GenerativeUISurfaceContentSchema and parseGenerativeUISurfaceContent to @copilotkit/core/generative-ui. React re-exports them from activity.ts, and the Vue chat renderer uses the same schema. New tests in use-generative-ui-root.test.ts cover null, a string, missing operations, and a NaN rejected index. With the old ingest, the null case fails with your TypeError.
| }, | ||
| ); | ||
| onErrorCaptured((cause) => { | ||
| if (isShowingFallback) return; |
There was a problem hiding this comment.
The comment above says a fallback's own error goes to the boundary above "as in React". That was true before #8260. React now wraps the fallback in a FallbackGuard (packages/react-core/src/v2/generative-ui/boundaries.tsx on main), so a throwing app errorBoundary.fallback stays inside its node. Here it reaches SurfaceBoundary and the whole surface is replaced, for good (see the next comment).
#8260 also reports each failure once per place until its content changes. Here a component that keeps failing reports to onError again on every new revision.
There was a problem hiding this comment.
Fixed in e3c2e9f. A FallbackGuard now wraps the app's errorBoundary.fallback. When the fallback throws, the default fallback with Retry shows in its place, and onError gets "The error fallback of threw: ..." with the original error as cause. The failure stays in its node. Each boundary and guard now reports a failure once until it renders without one, so a component that keeps failing across revisions reports once. A different error reports again. Tests: boundaries.test.ts.
| * chat or the host page. It reports the error with the kind "render" and | ||
| * shows the default fallback for the whole surface. | ||
| */ | ||
| export const SurfaceBoundary = defineComponent({ |
There was a problem hiding this comment.
Once this boundary catches an error, it never resets: the surface shows the fallback for the rest of its life, even when the agent sends new content. React's SurfaceBoundary resets when its revision prop changes, and offers Retry when the surface is retryable.
There was a problem hiding this comment.
Fixed in e3c2e9f. SurfaceBoundary takes a revision that changes when new content of the surface arrives: a new applied operation, or a rebuilt surface. It resets on that change, and a failure that stays the same is reported once. I left out Retry on purpose. Vue has one surface boundary, and it sits inside the root. That matches React's inner boundary, which has no Retry: the failure comes back the same until the content changes. Vue has no host root that can fail on its own, so there is no outer boundary to retry.
| const RETRY_STYLE = { marginLeft: "8px", textDecoration: "underline" }; | ||
|
|
||
| /** A thrown value as an `Error`. A thrown string becomes its message. */ | ||
| function toError(cause: unknown) { |
There was a problem hiding this comment.
Small parity point from #8260: a thrown non-Error value (undefined, null, 0, "") becomes Error("undefined") etc. and the original value is lost. React now keeps it as the error's cause (withCause in boundaries.tsx on main, set with defineProperty, because older engines lack the cause option).
There was a problem hiding this comment.
Fixed. 0ca589a moves toError and withCause to @copilotkit/shared/generative-ui, React re-exports them, and the Vue boundaries use them. A thrown undefined now becomes "A value that is not an Error was thrown: undefined", with the value kept as cause (test in boundaries.test.ts).
Resolve the docs conflicts with React Native generative UI (#8260): the generative UI pages keep both the React Native and the Vue tabs. openUrl in @copilotkit/shared/generative-ui now checks for window.open, so the Hermes API scan from #8260 passes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ntent parser Move the framework-free toError and withCause from react-core's boundaries to @copilotkit/shared/generative-ui, and the surface activity content schema and parser from react-core's activity module to @copilotkit/core/generative-ui, so the Vue port uses the same code. React re-exports them, so its exports do not change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Skip an activity message with malformed content (for example null), with one development warning per issue, instead of throwing inside the agent's run. - Guard the app's errorBoundary.fallback: when it throws, the default fallback with Retry stands in, and the failure stays in its node. - Report a failure once per place until it renders without one, not again on every revision. - Reset the surface boundary when new content of the surface arrives. - Keep a thrown value that is not an Error as the cause. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Check the reference props of GenerativeUISurface, the generativeUI keys of CopilotKitProvider and the chat slot props against their types, that no page, README or demo binds the kebab-case :generative-ui, and that every name imported from @copilotkit/vue/v2/generative-ui* is exported. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks for the review. Every point is done:
Checks: |
❌ Showcase Build FailedThe Docker build triggered by this PR's merge failed. Run: https://github.com/CopilotKit/CopilotKit/actions/runs/42649318407 @AlemTuzlak — please check the build logs and fix the issue. |
Brings in main up to c5f8a4f: Vue generative UI (#8280), React Native generative UI (#8260), the A2UI playground demo (#8100, #8285, #8289) and the showcase/docs fixes. Adapted to 2.0.0: - react-core: main's /v2/generative-ui/native entry ships as /generative-ui/native; the purity, dist-context-types and docs tests use the root subpaths. - Vue generative UI: wired into the thin provider through ɵassembleActivityRenderers, prose renders with the provider's markdown renderer instead of streamdown-vue, Math shows its TeX source (no katex), icons load from the optional `lucide` peer instead of lucide-vue-next. No stylesheet import in the docs. - React Native: zod is not a peer on 2.0.0, so the docs ask for zod 4 and drop the zod 3 advice. The UTF-8 polyfill classes live in polyfills/encoding.ts so no shared chunk loads before the polyfill barrel (main's new barrel-order gate). - examples: the A2UI playground goes under examples/demos, the Vue demo pages under examples/dev/by-frontend/vue/demo. - Lint and knip baselines take the new generative UI code from main. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 (#7819) and Angular (#8105) have. It includes all 69 components of the standard catalog. To try it, run the Vue demo and open
/generative-uior/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.<CopilotKitProvider :generativeUI="{ ui }">turns the feature on. It supports the tool transport (render_ui) and the markdown transport (a2ui fences).<GenerativeUISurface id="...">on the page. The default slot of the surface is the fallback content.useGenerativeUIStateanduseGenerativeUIFunctionconnect generated UI to the app.standardUIhas all 69 components as Vue SFCs. Chart and Map are opt-in withapp.use(GenerativeUIChart)andapp.use(GenerativeUIMap). Without the plugins, Chart shows a table and Map shows a list.#generative-ui-surfaceslot onCopilotChat,CopilotPopupandCopilotSidebarreplaces the default card.How a generated Vue component gets its props:
xis the propxplus anupdate:xemit, sodefineModel("x")works.child()andchildList()keys are named slots. A list slot gives one VNode for each child.Other changes:
@copilotkit/shared/generative-ui. Angular imports them from there, and its behavior does not change. React still has its own copies.openUrlchecks thatwindow.openexists, so the Hermes API scan from feat(react-native): generative UI with custom native catalogs #8260 passes.toError,withCauseand the surface activity content parser moved fromreact-coreto@copilotkit/shared/generative-uiand@copilotkit/core/generative-ui. React re-exports them, so its exports do not change. Vue uses the same code.GenerativeUISurface,useGenerativeUIState,useGenerativeUIFunction.CopilotKitProviderandCopilotChatreference pages are updated./generative-ui: a store page, ported from the React demo. The agent renders into named places on the page./generative-ui-standard:standardUIin the chat. Charts are turned on with a Nuxt plugin that callsapp.use(GenerativeUIChart).packages/vue/PARITY.mdhas 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
Checklist
!(for examplefeat(react-core)!: ...) and the description has aBREAKING CHANGE:line with migration steps. See VERSIONING.md (no breaking change: all additions)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 ofmain. 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.npm run pretypecheck,npm run test:ci,npm run typecheckinshowcase/shell-docs): pass. Shell-docs has no Nx target.pnpm --filter @copilotkit/vue-demo lint: pass. The demo build passes withNODE_OPTIONS=--max-old-space-size=8192. It runs out of memory at the default size onmaintoo.Manual test (needs an OpenAI key)
pnpm nx run @copilotkit/vue:build.OPENAI_API_KEY=... pnpm -C examples/v2/vue/demo devand openhttp://localhost:3000/generative-ui.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
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.tspins the Vue docs to the code: the reference props, the chat slot props, the camelCase:generativeUIbinding, and the imported names..test-d.tsfiles.check-typesnow runs them throughtsconfig.typetests.json./generative-uiand/generative-ui-standardpages inexamples/v2/vue/demo.Risk / rollback
The risk is low for current users. Everything is new and opt-in: nothing changes unless an app sets
generativeUIor imports/v2/generative-ui.CopilotKitProvider.vue, the chat components (to pass the slot on), Angular's imports of the moved helpers, and React's imports oftoError,withCauseand the content parser. The React tests pass unchanged.@copilotkit/vue/v2alone does not load the standard catalog. A check of the built output confirms this.chart.jsandmaplibre-glare optional peers. The demo addschart.jsas a dependency for its chart.Public API change
Before
After
Write the binding in camelCase (
:generativeUI). Vue reads:generative-uias a different prop,generativeUi. The existingopenGenerativeUIprop works the same way.🤖 Generated with Claude Code