Skip to content

feat(react-native): stream tool-call renders, add useRenderToolCall - #6346

Closed
davidmckayv wants to merge 6 commits into
mainfrom
feat/rn-streaming-tool-render
Closed

davidmckayv wants to merge 6 commits into
mainfrom
feat/rn-streaming-tool-render

Conversation

@davidmckayv

@davidmckayv davidmckayv commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

What

Two related gaps in the React Native SDK, both found while building an in-car concierge app (an agent composes the entire screen, so this is the whole product surface there).

1. Tool-call renders never streamed on RN

CopilotChat parsed tool arguments with JSON.parse:

args = JSON.parse(tc.function.arguments || "{}");   // throws on every delta

While the model is still writing the call the argument string is incomplete JSON, so this threw, warned, and fell back to {}. A component registered with useRenderTool / useComponent therefore rendered nothing until the call completed — no progressive build at all, while the web core has had it (partialJSONParse + an inProgress state).

Now uses partialJSONParse, already exported from @copilotkit/shared, which this package already depends on. Incomplete JSON is itself the signal that the call is mid-write, so no new stream state was needed.

2. Non-chat surfaces couldn't render a registered component at all

CopilotChat renders tool calls inline, which is right for a chat. But plenty of RN surfaces aren't chats — an in-car stage, a kiosk, a dashboard — and there was no public way to render a registered component outside it. react-core's useRenderToolCall is deliberately not re-exported (src/index.ts: "depends on DOM elements via DefaultToolCallRenderer"), and excluding it dropped the capability along with the DOM dependency.

Adds an RN-native useRenderToolCall() reading this package's own registry, so one registration works both in the chat and on a custom surface:

const renderToolCall = useRenderToolCall();
return <View>{toolCalls.map((tc) => renderToolCall({ toolCall: tc }))}</View>;

This is also what makes useComponent usable outside CopilotChat on React Native.

Breaking-ish

RenderToolProps.status gains "inProgress" and args becomes Partial<T>, reflecting that arguments are incomplete while streaming. Renderers that switch exhaustively on status need an "inProgress" branch. Flagged in the changeset as a minor.

Testing

  • 7 new tests for useRenderToolCall: registered/unregistered lookup, partial args at inProgress, a fragment with no complete key, executing, complete with result pass-through, and absent arguments.
  • Full package suite: 258 passing, including the existing CopilotChat and edge-case tests.
  • check-types clean, build clean.
  • Verified end to end in a running RN app. That app now renders its entire stage through useComponent + useRenderToolCall: seven registered panels, no composeStage. Captured on device, 1.5s into a four-panel command the stage shows the first two panels with the spinner still running, the rest arriving after — i.e. it builds progressively instead of appearing at once. Two app-side changes were needed and are worth knowing about when adopting this: anything that hides the surface for the duration of a run (a scrim, or parking content off-screen until completion) will mask the streaming, and renderers must tolerate partial props.

🤖 Generated with Claude Code

CopilotChat parsed tool arguments with JSON.parse, which throws on every delta
while the model is still writing the call: it warned and fell back to {}, so a
component registered via useRenderTool/useComponent rendered nothing until the
call completed. There was no progressive rendering on React Native at all, while
the web core has had it (partialJSONParse + an inProgress state).

- CopilotChat now uses partialJSONParse from @copilotkit/shared, which the package
  already depends on, and reports inProgress while the argument JSON is still
  incomplete. Incomplete JSON is itself the signal, so no new stream state.
- Adds useRenderToolCall(): renders one tool call through this package's registry,
  placeable anywhere. Non-chat RN surfaces (in-car stage, kiosk, dashboard) had no
  public way to render a registered component; react-core's version is excluded
  from RN because it pulls DOM via DefaultToolCallRenderer, and excluding it had
  dropped the capability with it. This is also what makes useComponent usable
  outside CopilotChat on RN.
- RenderToolProps: adds 'inProgress' status, args becomes Partial<T>.

Found while building an in-car concierge app, where the agent composes the
whole screen and nothing could render until each call finished.

7 new tests; 258 pass in the package.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@pkg-pr-new

pkg-pr-new Bot commented Aug 3, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@copilotkit/a2ui-renderer

pnpm add https://pkg.pr.new/@copilotkit/a2ui-renderer@6346

@copilotkit/agentcore-runner

pnpm add https://pkg.pr.new/@copilotkit/agentcore-runner@6346

@copilotkit/angular

pnpm add https://pkg.pr.new/@copilotkit/angular@6346

@copilotkit/channels

pnpm add https://pkg.pr.new/@copilotkit/channels@6346

@copilotkit/channels-core

pnpm add https://pkg.pr.new/@copilotkit/channels-core@6346

@copilotkit/channels-discord

pnpm add https://pkg.pr.new/@copilotkit/channels-discord@6346

@copilotkit/channels-intelligence

pnpm add https://pkg.pr.new/@copilotkit/channels-intelligence@6346

@copilotkit/channels-slack

pnpm add https://pkg.pr.new/@copilotkit/channels-slack@6346

@copilotkit/channels-teams

pnpm add https://pkg.pr.new/@copilotkit/channels-teams@6346

@copilotkit/channels-telegram

pnpm add https://pkg.pr.new/@copilotkit/channels-telegram@6346

@copilotkit/channels-ui

pnpm add https://pkg.pr.new/@copilotkit/channels-ui@6346

@copilotkit/channels-whatsapp

pnpm add https://pkg.pr.new/@copilotkit/channels-whatsapp@6346

@copilotkit/core

pnpm add https://pkg.pr.new/@copilotkit/core@6346

@copilotkit/react-core

pnpm add https://pkg.pr.new/@copilotkit/react-core@6346

@copilotkit/react-native

pnpm add https://pkg.pr.new/@copilotkit/react-native@6346

@copilotkit/react-textarea

pnpm add https://pkg.pr.new/@copilotkit/react-textarea@6346

@copilotkit/react-ui

pnpm add https://pkg.pr.new/@copilotkit/react-ui@6346

@copilotkit/runtime

pnpm add https://pkg.pr.new/@copilotkit/runtime@6346

@copilotkit/runtime-client-gql

pnpm add https://pkg.pr.new/@copilotkit/runtime-client-gql@6346

@copilotkit/sdk-js

pnpm add https://pkg.pr.new/@copilotkit/sdk-js@6346

@copilotkit/shared

pnpm add https://pkg.pr.new/@copilotkit/shared@6346

@copilotkit/sqlite-runner

pnpm add https://pkg.pr.new/@copilotkit/sqlite-runner@6346

@copilotkit/voice

pnpm add https://pkg.pr.new/@copilotkit/voice@6346

@copilotkit/vue

pnpm add https://pkg.pr.new/@copilotkit/vue@6346

@copilotkit/web-components

pnpm add https://pkg.pr.new/@copilotkit/web-components@6346

@copilotkit/web-inspector

pnpm add https://pkg.pr.new/@copilotkit/web-inspector@6346

commit: 4a77c03

@github-actions

github-actions Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Size Change: 0 B

Total Size: 1.27 MB

ℹ️ View Unchanged
Filename Size
packages/a2ui-renderer/dist/_virtual/_rolldown/runtime.cjs 516 B
packages/a2ui-renderer/dist/a2ui-types.cjs 172 B
packages/a2ui-renderer/dist/a2ui-types.mjs 171 B
packages/a2ui-renderer/dist/index.cjs 864 B
packages/a2ui-renderer/dist/index.mjs 576 B
packages/a2ui-renderer/dist/index.umd.js 12.5 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/A2uiSurface.cjs 1.49 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/A2uiSurface.mjs 1.43 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/adapter.cjs 1.07 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/adapter.mjs 1.01 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/AudioPlayer.cjs 904 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/AudioPlayer.mjs 492 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Button.cjs 1 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Button.mjs 596 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Card.cjs 829 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Card.mjs 419 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/CheckBox.cjs 1.1 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/CheckBox.mjs 1.02 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/ChildList.cjs 799 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/ChildList.mjs 737 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/ChoicePicker.cjs 1.63 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/ChoicePicker.mjs 1.57 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Column.cjs 856 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Column.mjs 802 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/DateTimeInput.cjs 1.12 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/DateTimeInput.mjs 1.05 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Divider.cjs 842 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Divider.mjs 432 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Icon.cjs 877 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Icon.mjs 469 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Image.cjs 995 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Image.mjs 587 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/List.cjs 920 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/List.mjs 508 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Modal.cjs 1.19 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Modal.mjs 1.13 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Row.cjs 855 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Row.mjs 801 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Slider.cjs 1.06 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Slider.mjs 984 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Tabs.cjs 1.1 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Tabs.mjs 1.04 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Text.cjs 903 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Text.mjs 489 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/TextField.cjs 1.21 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/TextField.mjs 1.14 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Video.cjs 788 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Video.mjs 378 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/index.cjs 928 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/index.mjs 855 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/utils.cjs 579 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/utils.mjs 556 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/Button.cjs 982 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/Button.mjs 580 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/ChildList.cjs 800 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/ChildList.mjs 735 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/Column.cjs 1.08 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/Column.mjs 1.02 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/Row.cjs 1.07 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/Row.mjs 1.01 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/Text.cjs 894 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/Text.mjs 839 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/TextField.cjs 1.21 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/TextField.mjs 802 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/index.cjs 849 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/index.mjs 804 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/index.cjs 310 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/index.mjs 325 B
packages/a2ui-renderer/dist/react-renderer/catalog-utils.cjs 1.59 kB
packages/a2ui-renderer/dist/react-renderer/catalog-utils.mjs 1.52 kB
packages/a2ui-renderer/dist/react-renderer/core/A2UIProvider.cjs 1.5 kB
packages/a2ui-renderer/dist/react-renderer/core/A2UIProvider.mjs 1.42 kB
packages/a2ui-renderer/dist/react-renderer/core/A2UIRenderer.cjs 728 B
packages/a2ui-renderer/dist/react-renderer/core/A2UIRenderer.mjs 671 B
packages/a2ui-renderer/dist/react-renderer/create-catalog.cjs 1.35 kB
packages/a2ui-renderer/dist/react-renderer/create-catalog.mjs 1.28 kB
packages/a2ui-renderer/dist/react-renderer/filter-catalog.cjs 622 B
packages/a2ui-renderer/dist/react-renderer/filter-catalog.mjs 569 B
packages/a2ui-renderer/dist/react-renderer/hooks/useA2UI.cjs 316 B
packages/a2ui-renderer/dist/react-renderer/hooks/useA2UI.mjs 309 B
packages/a2ui-renderer/dist/react-renderer/index.cjs 409 B
packages/a2ui-renderer/dist/react-renderer/index.mjs 524 B
packages/a2ui-renderer/dist/react-renderer/lib/utils.cjs 236 B
packages/a2ui-renderer/dist/react-renderer/lib/utils.mjs 188 B
packages/a2ui-renderer/dist/react-renderer/styles/index.cjs 239 B
packages/a2ui-renderer/dist/react-renderer/styles/index.mjs 231 B
packages/a2ui-renderer/dist/react-renderer/theme/ThemeContext.cjs 436 B
packages/a2ui-renderer/dist/react-renderer/theme/ThemeContext.mjs 381 B
packages/a2ui-renderer/dist/web-components/_virtual/_rolldown/runtime.cjs 260 B
packages/a2ui-renderer/dist/web-components/_virtual/_rolldown/runtime.mjs 258 B
packages/a2ui-renderer/dist/web-components/adapter.cjs 346 B
packages/a2ui-renderer/dist/web-components/adapter.mjs 335 B
packages/a2ui-renderer/dist/web-components/bound-component.cjs 670 B
packages/a2ui-renderer/dist/web-components/bound-component.mjs 662 B
packages/a2ui-renderer/dist/web-components/catalog/basic/audio-player.cjs 536 B
packages/a2ui-renderer/dist/web-components/catalog/basic/audio-player.mjs 492 B
packages/a2ui-renderer/dist/web-components/catalog/basic/button.cjs 647 B
packages/a2ui-renderer/dist/web-components/catalog/basic/button.mjs 604 B
packages/a2ui-renderer/dist/web-components/catalog/basic/card.cjs 448 B
packages/a2ui-renderer/dist/web-components/catalog/basic/card.mjs 402 B
packages/a2ui-renderer/dist/web-components/catalog/basic/check-box.cjs 743 B
packages/a2ui-renderer/dist/web-components/catalog/basic/check-box.mjs 695 B
packages/a2ui-renderer/dist/web-components/catalog/basic/choice-picker.cjs 1.27 kB
packages/a2ui-renderer/dist/web-components/catalog/basic/choice-picker.mjs 1.24 kB
packages/a2ui-renderer/dist/web-components/catalog/basic/column.cjs 474 B
packages/a2ui-renderer/dist/web-components/catalog/basic/column.mjs 431 B
packages/a2ui-renderer/dist/web-components/catalog/basic/components.cjs 482 B
packages/a2ui-renderer/dist/web-components/catalog/basic/components.mjs 424 B
packages/a2ui-renderer/dist/web-components/catalog/basic/date-time-input.cjs 756 B
packages/a2ui-renderer/dist/web-components/catalog/basic/date-time-input.mjs 714 B
packages/a2ui-renderer/dist/web-components/catalog/basic/divider.cjs 450 B
packages/a2ui-renderer/dist/web-components/catalog/basic/divider.mjs 404 B
packages/a2ui-renderer/dist/web-components/catalog/basic/icon.cjs 504 B
packages/a2ui-renderer/dist/web-components/catalog/basic/icon.mjs 455 B
packages/a2ui-renderer/dist/web-components/catalog/basic/ids.cjs 192 B
packages/a2ui-renderer/dist/web-components/catalog/basic/ids.mjs 190 B
packages/a2ui-renderer/dist/web-components/catalog/basic/image.cjs 624 B
packages/a2ui-renderer/dist/web-components/catalog/basic/image.mjs 578 B
packages/a2ui-renderer/dist/web-components/catalog/basic/index.cjs 465 B
packages/a2ui-renderer/dist/web-components/catalog/basic/index.mjs 526 B
packages/a2ui-renderer/dist/web-components/catalog/basic/list.cjs 534 B
packages/a2ui-renderer/dist/web-components/catalog/basic/list.mjs 483 B
packages/a2ui-renderer/dist/web-components/catalog/basic/modal.cjs 842 B
packages/a2ui-renderer/dist/web-components/catalog/basic/modal.mjs 800 B
packages/a2ui-renderer/dist/web-components/catalog/basic/row.cjs 471 B
packages/a2ui-renderer/dist/web-components/catalog/basic/row.mjs 427 B
packages/a2ui-renderer/dist/web-components/catalog/basic/slider.cjs 701 B
packages/a2ui-renderer/dist/web-components/catalog/basic/slider.mjs 653 B
packages/a2ui-renderer/dist/web-components/catalog/basic/tabs.cjs 780 B
packages/a2ui-renderer/dist/web-components/catalog/basic/tabs.mjs 730 B
packages/a2ui-renderer/dist/web-components/catalog/basic/text-field.cjs 857 B
packages/a2ui-renderer/dist/web-components/catalog/basic/text-field.mjs 814 B
packages/a2ui-renderer/dist/web-components/catalog/basic/text.cjs 553 B
packages/a2ui-renderer/dist/web-components/catalog/basic/text.mjs 501 B
packages/a2ui-renderer/dist/web-components/catalog/basic/utils.cjs 484 B
packages/a2ui-renderer/dist/web-components/catalog/basic/utils.mjs 462 B
packages/a2ui-renderer/dist/web-components/catalog/basic/video.cjs 400 B
packages/a2ui-renderer/dist/web-components/catalog/basic/video.mjs 352 B
packages/a2ui-renderer/dist/web-components/catalog/children.cjs 302 B
packages/a2ui-renderer/dist/web-components/catalog/children.mjs 300 B
packages/a2ui-renderer/dist/web-components/catalog/minimal/button.cjs 629 B
packages/a2ui-renderer/dist/web-components/catalog/minimal/button.mjs 584 B
packages/a2ui-renderer/dist/web-components/catalog/minimal/column.cjs 609 B
packages/a2ui-renderer/dist/web-components/catalog/minimal/column.mjs 559 B
packages/a2ui-renderer/dist/web-components/catalog/minimal/components.cjs 245 B
packages/a2ui-renderer/dist/web-components/catalog/minimal/components.mjs 263 B
packages/a2ui-renderer/dist/web-components/catalog/minimal/index.cjs 724 B
packages/a2ui-renderer/dist/web-components/catalog/minimal/index.mjs 654 B
packages/a2ui-renderer/dist/web-components/catalog/minimal/row.cjs 593 B
packages/a2ui-renderer/dist/web-components/catalog/minimal/row.mjs 544 B
packages/a2ui-renderer/dist/web-components/catalog/minimal/text-field.cjs 874 B
packages/a2ui-renderer/dist/web-components/catalog/minimal/text-field.mjs 822 B
packages/a2ui-renderer/dist/web-components/catalog/minimal/text.cjs 509 B
packages/a2ui-renderer/dist/web-components/catalog/minimal/text.mjs 477 B
packages/a2ui-renderer/dist/web-components/catalog/minimal/utils.cjs 291 B
packages/a2ui-renderer/dist/web-components/catalog/minimal/utils.mjs 287 B
packages/a2ui-renderer/dist/web-components/create-catalog.cjs 1.89 kB
packages/a2ui-renderer/dist/web-components/create-catalog.mjs 1.83 kB
packages/a2ui-renderer/dist/web-components/define.cjs 440 B
packages/a2ui-renderer/dist/web-components/define.mjs 341 B
packages/a2ui-renderer/dist/web-components/index.cjs 960 B
packages/a2ui-renderer/dist/web-components/index.mjs 655 B
packages/a2ui-renderer/dist/web-components/node.cjs 1.05 kB
packages/a2ui-renderer/dist/web-components/node.mjs 1.04 kB
packages/a2ui-renderer/dist/web-components/surface.cjs 2.83 kB
packages/a2ui-renderer/dist/web-components/surface.mjs 2.81 kB
packages/core/dist/index.cjs 52.5 kB
packages/core/dist/index.mjs 52.1 kB
packages/core/dist/index.umd.js 55.9 kB
packages/react-core/dist/copilotkit-CmMYFfLV.cjs 108 kB
packages/react-core/dist/copilotkit-DMmUbvpo.mjs 107 kB
packages/react-core/dist/index.cjs 16.9 kB
packages/react-core/dist/index.mjs 16.8 kB
packages/react-core/dist/index.umd.js 65.4 kB
packages/react-core/dist/v2/context.cjs 1.55 kB
packages/react-core/dist/v2/context.mjs 1.47 kB
packages/react-core/dist/v2/headless.cjs 13.6 kB
packages/react-core/dist/v2/headless.mjs 13.1 kB
packages/react-core/dist/v2/index.cjs 1.26 kB
packages/react-core/dist/v2/index.mjs 1.11 kB
packages/react-core/dist/v2/index.umd.js 108 kB
packages/react-textarea/dist/index.cjs 18.1 kB
packages/react-textarea/dist/index.mjs 17.4 kB
packages/react-textarea/dist/index.umd.js 18.8 kB
packages/react-ui/dist/index.cjs 24.7 kB
packages/react-ui/dist/index.mjs 24 kB
packages/react-ui/dist/index.umd.js 25.9 kB
packages/runtime-client-gql/dist/_virtual/_rolldown/runtime.cjs 516 B
packages/runtime-client-gql/dist/client/conversion.cjs 1.52 kB
packages/runtime-client-gql/dist/client/conversion.mjs 1.45 kB
packages/runtime-client-gql/dist/client/CopilotRuntimeClient.cjs 1.58 kB
packages/runtime-client-gql/dist/client/CopilotRuntimeClient.mjs 1.54 kB
packages/runtime-client-gql/dist/client/types.cjs 701 B
packages/runtime-client-gql/dist/client/types.mjs 642 B
packages/runtime-client-gql/dist/graphql/@generated/gql.cjs 850 B
packages/runtime-client-gql/dist/graphql/@generated/gql.mjs 850 B
packages/runtime-client-gql/dist/graphql/@generated/graphql.cjs 2.4 kB
packages/runtime-client-gql/dist/graphql/@generated/graphql.mjs 2.36 kB
packages/runtime-client-gql/dist/graphql/definitions/mutations.cjs 740 B
packages/runtime-client-gql/dist/graphql/definitions/mutations.mjs 732 B
packages/runtime-client-gql/dist/graphql/definitions/queries.cjs 316 B
packages/runtime-client-gql/dist/graphql/definitions/queries.mjs 304 B
packages/runtime-client-gql/dist/index.cjs 679 B
packages/runtime-client-gql/dist/index.mjs 495 B
packages/runtime-client-gql/dist/index.umd.js 9.58 kB
packages/runtime-client-gql/dist/message-conversion/agui-to-gql.cjs 1.72 kB
packages/runtime-client-gql/dist/message-conversion/agui-to-gql.mjs 1.7 kB
packages/runtime-client-gql/dist/message-conversion/gql-to-agui.cjs 1.56 kB
packages/runtime-client-gql/dist/message-conversion/gql-to-agui.mjs 1.53 kB
packages/runtime-client-gql/dist/package.cjs 181 B
packages/runtime-client-gql/dist/package.mjs 116 B
packages/shared/dist/_virtual/_rolldown/runtime.cjs 516 B
packages/shared/dist/a2ui-prompts.cjs 2.85 kB
packages/shared/dist/a2ui-prompts.mjs 2.85 kB
packages/shared/dist/attachments/utils.cjs 1.74 kB
packages/shared/dist/attachments/utils.mjs 1.7 kB
packages/shared/dist/constants/index.cjs 362 B
packages/shared/dist/constants/index.mjs 345 B
packages/shared/dist/debug.cjs 454 B
packages/shared/dist/debug.mjs 452 B
packages/shared/dist/finalize-events.cjs 1.05 kB
packages/shared/dist/finalize-events.mjs 1 kB
packages/shared/dist/index.cjs 2.03 kB
packages/shared/dist/index.mjs 1.69 kB
packages/shared/dist/index.umd.js 21.5 kB
packages/shared/dist/logger.cjs 112 B
packages/shared/dist/logger.mjs 112 B
packages/shared/dist/package.cjs 181 B
packages/shared/dist/package.mjs 116 B
packages/shared/dist/standard-schema.cjs 740 B
packages/shared/dist/standard-schema.mjs 737 B
packages/shared/dist/telemetry/lambda-client.cjs 1.14 kB
packages/shared/dist/telemetry/lambda-client.mjs 1.13 kB
packages/shared/dist/telemetry/telemetry-client.cjs 1.33 kB
packages/shared/dist/telemetry/telemetry-client.mjs 1.27 kB
packages/shared/dist/telemetry/utils.cjs 321 B
packages/shared/dist/telemetry/utils.mjs 277 B
packages/shared/dist/transcription-errors.cjs 951 B
packages/shared/dist/transcription-errors.mjs 944 B
packages/shared/dist/utils/clipboard.cjs 407 B
packages/shared/dist/utils/clipboard.mjs 405 B
packages/shared/dist/utils/conditions.cjs 540 B
packages/shared/dist/utils/conditions.mjs 536 B
packages/shared/dist/utils/console-styling.cjs 1.24 kB
packages/shared/dist/utils/console-styling.mjs 1.22 kB
packages/shared/dist/utils/errors.cjs 4.51 kB
packages/shared/dist/utils/errors.mjs 4.41 kB
packages/shared/dist/utils/index.cjs 1.4 kB
packages/shared/dist/utils/index.mjs 1.67 kB
packages/shared/dist/utils/inspector-metadata.cjs 1.46 kB
packages/shared/dist/utils/inspector-metadata.mjs 1.45 kB
packages/shared/dist/utils/json-schema.cjs 1.97 kB
packages/shared/dist/utils/json-schema.mjs 1.91 kB
packages/shared/dist/utils/random-id.cjs 618 B
packages/shared/dist/utils/random-id.mjs 559 B
packages/shared/dist/utils/requests.cjs 706 B
packages/shared/dist/utils/requests.mjs 704 B
packages/shared/dist/utils/types.cjs 161 B
packages/shared/dist/utils/types.mjs 160 B
packages/voice/dist/_virtual/_rolldown/runtime.cjs 516 B
packages/voice/dist/index.cjs 175 B
packages/voice/dist/index.mjs 95 B
packages/voice/dist/index.umd.js 1.5 kB
packages/voice/dist/transcription/transcription-service-openai.cjs 495 B
packages/voice/dist/transcription/transcription-service-openai.mjs 434 B
packages/web-inspector/dist/assets/inspector-logo-icon.cjs 499 B
packages/web-inspector/dist/assets/inspector-logo-icon.mjs 434 B
packages/web-inspector/dist/assets/inspector-logo.cjs 4.32 kB
packages/web-inspector/dist/assets/inspector-logo.mjs 4.23 kB
packages/web-inspector/dist/index.cjs 74.3 kB
packages/web-inspector/dist/index.mjs 74.3 kB
packages/web-inspector/dist/index.umd.js 96.6 kB
packages/web-inspector/dist/lib/context-helpers.cjs 862 B
packages/web-inspector/dist/lib/context-helpers.mjs 830 B
packages/web-inspector/dist/lib/inspector-metadata.cjs 760 B
packages/web-inspector/dist/lib/inspector-metadata.mjs 750 B
packages/web-inspector/dist/lib/persistence.cjs 1.2 kB
packages/web-inspector/dist/lib/persistence.mjs 1.16 kB
packages/web-inspector/dist/lib/telemetry.cjs 3.86 kB
packages/web-inspector/dist/lib/telemetry.mjs 3.74 kB
packages/web-inspector/dist/lib/thread-selection.cjs 566 B
packages/web-inspector/dist/lib/thread-selection.mjs 563 B
packages/web-inspector/dist/package.cjs 181 B
packages/web-inspector/dist/package.mjs 116 B
packages/web-inspector/dist/styles/generated.cjs 7.48 kB
packages/web-inspector/dist/styles/generated.mjs 7.42 kB

compressed-size-action

davidmckayv and others added 2 commits August 3, 2026 13:03
react-core's useComponent is re-exported by this package but registers into
react-core's render registry, which RN's renderers do not read. A component
registered with it therefore rendered NOWHERE on React Native - not in
CopilotChat, not on a custom surface. It looked like controlled generative UI was
supported here; it was not.

Adds an RN useComponent that wraps this package's useRenderTool, so one
registration renders both in the chat and anywhere useRenderToolCall() is used,
and stops re-exporting react-core's from headless so the working one wins.

Render-only and props-spread, matching react-core's ergonomics: a component needs
no knowledge of CopilotKit.

3 new tests; 261 pass in the package.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@davidmckayv
davidmckayv force-pushed the feat/rn-streaming-tool-render branch from d258e03 to 6614287 Compare August 3, 2026 20:27
@linear-code

linear-code Bot commented Aug 3, 2026

Copy link
Copy Markdown

FOR-213

BenTaylorDev added a commit that referenced this pull request Aug 6, 2026
## What does this PR do?

Community PRs keep arriving with `.changeset/*.md` files even though the
repo migrated off Changesets to conventional-commit-driven releases.
`.changeset/` has now been deleted from `main` twice (`5afa55f067` on
2026-06-16, `1e5ba689e0` on 2026-07-29) and **five open PRs carry
changeset files today** (#6287, #6289, #6290, #6292, #6346).

Three mechanisms keep feeding it:

1. **Stale forks.** `rodboev/CopilotKit`'s default branch still contains
10 of the pre-cleanup `.changeset/*.md` debris files. Three of the five
open PRs come from that fork — the contributor's agent opens the repo,
sees a directory full of changesets, and adds one more. (No
`config.json`, and `@changesets/cli` isn't installed anywhere, so these
are hand-written by agents, not CLI output.)
2. **Merging stale PRs re-seeds `main`.** The two files Tyler removed in
`1e5ba689e0` arrived via 2026-06-10-authored branches (#2910, #5360)
merged on 2026-07-25 — they sat on `main` for four days, and anyone who
forked in that window inherited the directory. His hunch in that commit
message was right.
3. **Convention inference, uncontradicted.** #6346 is from a branch in
this repo, where `.changeset/` does *not* exist, and it still has one.
The repo reads as a Changesets repo: pnpm workspace monorepo,
per-package `CHANGELOG.md` in Changesets' exact `### Patch Changes`
output format, `chore: release monorepo vX.Y.Z` release PRs. Nothing in
`CONTRIBUTING.md`, the PR template, `AGENTS.md`, `CLAUDE.md`, or
`.claude/docs/` said otherwise, so the guess was well-supported.

This PR closes all three off:

- **`CONTRIBUTING.md`** — new "Changelogs and releases — do not add a
changeset" section: we did use Changesets, `scripts/release/` now builds
changelogs from commit subjects, `.changeset/*.md` is inert, write a
good conventional commit subject instead, and leave versions/changelogs
to maintainers. Includes a note to rebase old forks.
- **`AGENTS.md` / `CLAUDE.md`** — the same rule as an Essentials bullet.
This is the highest-leverage change: the contributors doing this are
coding agents, and agents load these files automatically while mostly
not reading `CONTRIBUTING.md`.
- **`static / check binaries`** — fail the PR on added `.changeset/*`
files, so this stops depending on review catching it (which is what
failed in July and restarted the loop). Added to the existing
forbidden-files gate rather than a new workflow: it already runs on
every PR to `main`, is fork-safe (`contents: read`, no secrets), and has
exactly this `git diff --name-only origin/BASE...HEAD` + `VIOLATIONS`
shape. Filters on `--diff-filter=AM` so a PR that *deletes* stale
changesets still passes.
- **`.oxfmtrc.json`** — drop the ignore entry for
`.github/actions/changesets-action/src/run.ts`, a path that hasn't
existed for a long time. It was the last grep-visible "we use
changesets" signal in a root config file.

## Related PRs and Issues

- Follows up `1e5ba689e0` ("fix: remove all changesets"), whose commit
message asked for exactly this: a durable record of the decision that
future agents can find.
- Open PRs that would be caught by the new gate: #6287, #6289, #6290,
#6292, #6346.

## Testing

Docs + CI-config change, so verification focused on the guard.
`actionlint` was run on the workflow, then the step body was extracted
with `yq` and executed against real branches.

**Lint / parse:**
```
$ actionlint .github/workflows/static_check-binaries.yml
actionlint: clean
$ python3 -c "import json; json.load(open('.oxfmtrc.json'))"   # oxfmtrc still valid JSON
oxfmtrc JSON OK
```

**True positive** — real head of #6292, via `yq
'.jobs.check-binaries.steps[1].run'` piped to bash with `BASE_REF=main`:
```
::error::Changeset files detected in PR:
.changeset/enable-mcp-apps-tool-filters.md
This repo no longer uses Changesets — releases are driven by conventional commit subjects (see scripts/release/).
Nothing reads .changeset/*.md. Delete these files and describe the change in your commit subject instead.
See the 'Changelogs and releases' section of CONTRIBUTING.md.

This PR contains files that should not be committed (see the errors above).
Please remove them and update your .gitignore if needed.
exit=1
```

**True negative** — same script on this branch, which has five changed
files and no changesets:
```
$ git diff --name-only origin/main...HEAD
.github/workflows/static_check-binaries.yml
.oxfmtrc.json
AGENTS.md
CLAUDE.md
CONTRIBUTING.md
$ BASE_REF=main bash step.sh
No binary artifacts or oversized files detected.
exit=0
```

**Delete-safety** — a commit that *removes* changesets must not be
punished. Using the real cleanup commit (`8806f668d1...1e5ba68`):
```
unfiltered:                      with --diff-filter=AM (what the gate uses):
.changeset/coalesce-...md        (empty)
.changeset/fix-parallel-...md
```

Not verified locally: the gate firing in real GitHub Actions — that
needs this PR's own CI run (the `static / check binaries` check on this
PR exercises the true-negative path).

🤖 Generated with [Claude Code](https://claude.com/claude-code)
AlemTuzlak added a commit that referenced this pull request Aug 13, 2026
…'s shared registry (#6438)

## What does this PR do?

`@copilotkit/react-native` maintained a **private tool-call render
registry** (`hooks/RenderToolContext.tsx`) alongside the canonical one
that `CopilotKitCoreReact` already provides — and which every React
Native app already ships, unused. This PR deletes the fork and points
React Native at the shared registry.

That fork caused three bugs:

| Bug | Symptom | Cause |
|---|---|---|
| **Tool renders never streamed** | A component registered with
`useRenderTool` / `useComponent` painted nothing until the tool call
completed | `CopilotChat` used `JSON.parse` on the argument buffer.
While a model writes a tool call that buffer is *invalid JSON by design*
— AG-UI delivers `TOOL_CALL_ARGS` deltas that are concatenated
client-side — so the parse threw on every delta, warned, and fell back
to `{}` |
| **`useComponent` rendered nowhere** | Silently, with no error | It
writes to core's registry; React Native's chat read React Native's
private `Map` |
| **Chat history degraded** | Navigating away from the registering
screen turned earlier tool calls into a `Called: <name>` placeholder |
The private `Map` deleted renderers on unmount; core deliberately keeps
them |

`@copilotkit/react-core` has used `partialJSONParse` on this path since
v2 shipped. React Native diverged because `useRenderToolCall` was
excluded from its re-exports on the stated grounds that it "depends on
DOM elements via `DefaultToolCallRenderer`" — a claim that was never
true of the hook itself. It was only ever reachable through the fat
`/v2` entry, whose weight is the real hazard (#4893). #5883 moved it
into `/v2/headless` on 2026-07-23; the exclusion comment was rewritten
the next day without revisiting the reason.

### What changed

- **One registry.** `useRenderTool` registers through `useFrontendTool`
into `CopilotKitCoreReact.renderToolCalls`. `CopilotChat` and any custom
surface consume react-core's `useRenderToolCall`.
- **Types are derived, not declared.** `RenderToolProps` is now
`React.ComponentProps<ReactToolCallRenderer<T>["render"]>`, so React
Native cannot drift from `ReactToolCallRenderer` — the contract every
registered renderer is actually invoked against. Change that contract
and `check-types` names every React Native renderer the change breaks.
React Native narrows only the *return* type to `ReactElement | null`,
which `FlatList`'s `renderItem` genuinely requires.
_Scope of that guarantee (corrected during review):_ it does **not**
extend to the type react-core publicly exports under the same name.
Web's `RenderToolProps<S>`
(`react-core/src/v2/hooks/use-render-tool.tsx`) is a separate
hand-declared union, generic over a schema, carrying arguments under
`parameters` (not `args`) and declaring `status` as string literals
rather than `ToolCallStatus` members. Both divergences are live today
and nothing type-checks them shut — the one place the shapes meet,
react-core's own bridge, compiles because a string-enum member is
assignable to its own literal type but not the reverse. Aligning web's
alias is a breaking web API change, filed separately.
- **`RenderToolContext.tsx` deleted** (−150 lines), along with 15 tests
that described the removed subsystem. One of them — `unregisters the
render function on unmount` — asserted the chat-history bug as a
requirement.
- **Two structural CI guards for #4893**, in opposite directions: a test
failing if any React Native source imports the fat `/v2` entry, and a
script failing if react-core's `/v2/headless` or `/v2/context` chunks
ever link shiki/mermaid/cytoscape/katex/streamdown. Both were verified
able to fail by deliberately introducing the regression. These are
*structural* assertions, not size budgets — `dev-docs/bundle-size.md`
freezes `limit` fields until OSS-122.
- **`react-native` added to the bundle-size glob**, which it had never
been in, plus a `size:headless` measurement.

React Native also gains capabilities it lacked: render props inferred
from your schema, `name`/`toolCallId` on render props, and `result` on
completed calls.

**Corrected during review — two capabilities this originally claimed are
not delivered:**

- **Wildcard (`"*"`) renderers do not work on React Native.** Because
`useRenderTool` routes through `useFrontendTool` (which calls
`addTool`), `name: "*"` registers a frontend tool literally named `*` —
advertised to the model, and colliding with core's separate
wildcard-executable-tool path. react-core's `useRenderTool` is
renderer-only and special-cases the wildcard; React Native's is not. The
guide now advises against it.
- **`followUp` (and `available`) are not forwarded**, and the handler's
`context` argument is dropped, so `stopAgent()`'s abort signal is
unreachable from an RN handler.

Both are tracked in § Known limitations for the follow-up that converges
React Native onto react-core's hooks — deleting RN's `useRenderTool` in
favour of re-exporting `useFrontendTool` (tool + renderer) and
react-core's `useRenderTool` (renderer-only, wildcard-capable). That is
an API change with its own migration note, so it is not in this PR.

### ⚠️ Breaking (in a minor)

`useRenderToolRegistry` and `RenderToolProvider` are **removed**. Both
are documented on the docs site, so this is a real break — see the
`BREAKING CHANGE:` footer on `db67ccf`, which is what the release notes
derive from, plus the rewritten reference pages.

```diff
- const registry = useRenderToolRegistry();
- const renderer = registry.get(toolCall.function.name);
- return renderer ? renderer({ args, status }) : null;
+ const renderToolCall = useRenderToolCall();
+ return renderToolCall({ toolCall });
```

Also note two semantic changes: `args` is `Partial<T>` **only** while
`status` is `"inProgress"`, and a render function is now captured at
registration — if it closes over changing values you must declare them
in `deps` (React Native previously refreshed the closure on every
render).

**Known limitation:** agent-scoped renderer resolution does not take
effect on React Native. `CopilotChatConfigurationProvider` is not in
RN's provider tree, so `agentId` always resolves to the default.
Renderers still resolve by name; two agents registering the same tool
name resolve arbitrarily. Filed separately.

### A data point worth recording

Adding `useRenderToolCall` to the measured headless entry moved the
bundle **92.8 kB → 92.7 kB**. Flat. The hook React Native spent months
not using was already inside the chunk every RN app resolves whole —
Metro doesn't tree-shake, so the fork never saved a byte. It cost them.

### Testing

- `@copilotkit/react-native`: **253 passing / 22 files** ·
`@copilotkit/react-core`: **1480 passing / 123 files** · `check-types`
and `build` green for both.
- Each of the three bugs has a deterministic test driving a real
`CopilotKitCoreReact` — no mocking of the code under test.
- Both #4893 guards carry mutation evidence: introduce the regression,
watch them fail, revert, watch them pass.

### Follow-up

`useRenderTool`'s JSDoc is split across two blocks, which orphans the
primary description from IDE hover (the `@param deps` warning still
surfaces). One-line fix, deliberately left out of the final fix wave.

## Related PRs and Issues

- **Supersedes #6346** (@davidmckayv) — its diagnoses were correct and
its test assertions are ported here, re-driven through the real registry
rather than a mocked local one. Credited via `Co-Authored-By` on
`4104bd1`.
- Addresses the React Native half of **#4893**.
- Builds on **#5883**, which created the lean `/v2/headless` entry this
PR consumes.

## Checklist

- [x] I have read the Contribution Guide
- [x] If the PR changes or adds functionality, I have updated the
relevant documentation
- [x] "Allow edits by maintainers" is checked

🤖 Generated with [Claude Code](https://claude.com/claude-code)
pull Bot pushed a commit to Ditto190/CopilotKit_ModMe that referenced this pull request Aug 13, 2026
… the converged path

Assertions originally written by David McKay in PR CopilotKit#6346, re-driven through
CopilotKitCoreReact's registry instead of a mocked local one.

Co-Authored-By: David McKay <[email protected]>
mxmzb added a commit that referenced this pull request Sep 9, 2026
…6533)

Closes #6438's deferred review finding **5b**. #6438 shipped 5a —
retracting the false claim that React Native supported wildcard
renderers, and documenting the gap as a known limitation. This is the
actual fix.

## The defect: one cause, not nine

React Native's `useRenderTool` was **not** react-core's `useRenderTool`.
Its entire body forwarded to a *different* hook while wearing the other
one's name:

```ts
useFrontendTool<T>({ name, description, parameters, handler, agentId, render }, deps);
```

react-core has two hooks:

| hook | registers | wildcard `"*"` |
| --- | --- | --- |
| `useFrontendTool` | a tool **and** its renderer (`addTool`) | no
special case |
| `useRenderTool` | a renderer **only** (`addHookRenderToolCall`) |
special-cased into a schema-less fallback |

RN aliased the first under the second's name. Because that took the
`addTool` path, `name: "*"` registered a frontend tool **literally named
`*`**.

**Correction from review.** Earlier revisions of this description said
that tool was advertised to the model. It was not, and @BenTaylorDev
caught it: core filters the wildcard name out of the advertised list in
`run-handler.ts`, and that filter landed in `31aa1e2162` — before this
PR was opened, but after the base it was originally written against. The
1273-commit rebase moved the code forward and left the prose behind. All
seven code and doc sites have been corrected.

**What it actually did is worse.** A tool named `*` is core's catch-all
*handler*. When a tool call has no exact-name frontend tool and no
result yet, core reaches for the wildcard tool and runs
`executeWildcardTool` — and the tool-result splice sits *outside* the
`if (wildcardTool?.handler)` guard. So an RN app whose author wanted a
display-only fallback was also auto-answering every otherwise-unanswered
tool call with an empty tool result and requesting a follow-up turn.
Measured by driving a real turn through both paths: the old handler-less
`*` produced **2 turns and a spliced `{ toolCallId, content: "" }`**;
the shim's route produces 1 turn and no result.

Eight further reported symptoms share that single cause: a render-only
registration was advertised and shadowed a same-named server tool;
`addTool` evicted an existing same-named handler with only a
`console.warn`; `description` / `parameters` were required though both
are *tool* fields; `followUp` / `available` were not forwarded;
`handler` dropped core's context argument, leaving `stopAgent()`'s abort
signal unreachable; `agentId` changes never re-registered; two
structurally incompatible `RenderTool*Props` families shipped side by
side; and `hooks/index.ts` was a dead barrel.

## The fix

RN's own implementation is gone. `useRenderTool` and `useFrontendTool`
are now re-exported from react-core, so each capability has exactly one
implementation — **and `"*"` works as a real wildcard on React Native
for the first time.**

Deleting rather than re-pointing the name was deliberate: re-pointing
would let a `{ name, parameters, render }` call with no handler keep
compiling while silently ceasing to register the tool.

## The landing is soft, on purpose

Following @BenTaylorDev's review, `useRenderTool` **still exists on
React Native** as a deprecated shim for one minor. It routes by shape
and warns in development, once per tool name:

| call shape | routes to | why |
| --- | --- | --- |
| `name: "*"` | core's `useRenderTool` (renderer-only) | **unconditional
— wildcard always wins**, even with old tool fields present |
| carries `handler` or `description` | `useFrontendTool` | that is what
the old hook actually did |
| anything else | core's `useRenderTool` | renderer-only was the intent
|

The wildcard rule is deliberately not the obvious reading. The old hook
made `description` **required**, so anyone who ever attempted a wildcard
renderer necessarily wrote it *with* the old tool fields. Routing "has
old fields" to `useFrontendTool` would have recreated the original
`*`-named-tool bug for exactly the people who tried hardest to use the
wildcard.

**Why a shim rather than a clean break.** `@copilotkit/react-native`
sits in the `monorepo` release scope — 16 packages versioned in
lockstep, all currently `1.68.1`. A major would take every
`@copilotkit/*` package to `2.0.0`. So this ships in a minor and the `!`
marker buys a release-note line, nothing more. That leaves the compiler
as the only signal reaching consumers, and there are shapes it cannot
see: a hoisted config whose `render` ignores its props, old fields
arriving via a spread, and untyped or `@ts-nocheck` call sites. In all
three, core's hook silently ignores `description` and `handler`, and
because the bridge spreads `{ ...props, parameters: props.args }`, an
old `render: ({ args }) => …` keeps painting — the screen looks
unchanged while the tool stops being advertised and the handler never
runs. The shim's warning is the only mechanism that reaches that
population.

**What the shim does not restore:** the old *render prop* name. A
renderer reading `args` still fails `TS2339`. The registration keeps
working; the render body still needs the rename.

## ⚠️ BREAKING — needs product ratification

Removes `RenderToolProps`, `RenderToolFunction` and
`UseRenderToolOptions` from `@copilotkit/react-native`. `useRenderTool`
is deprecated, not removed, and is scheduled for removal next minor.

**@tylerslaton — this needs your explicit sign-off.** @BenTaylorDev has
clarified that his deferral on #6438 was not a precedent, and would
rather both removals be ratified together.

### Migration

| Before (RN) | After |
| --- | --- |
| `useRenderTool({ name, description, parameters, handler, render },
deps)` | `useFrontendTool({ …identical object }, deps)` — the shim keeps
this working with a warning this release |
| renderer-only registration: impossible | `useRenderTool({ name,
parameters, render, agentId? }, deps)` |
| wildcard: registers a tool named `*` | `useRenderTool({ name: "*",
render })` — works, same as web |
| render props `{ args, status, … }` | `{ parameters, status, … }` —
**not** covered by the shim |
| `RenderToolProps<T>` (args-shaped) | `RenderToolProps<S>`
(parameters-shaped, generic over schema) |
| bare `RenderToolProps` | now `TS2314` — core's has no default type
argument; supply the schema type |
| `UseRenderToolOptions<T>` | gone — write the config inline
(`RenderToolConfig` is core-internal) |
| `RenderToolFunction<T>` | gone — see `FrontendToolRenderFunction<T>`
below |

The table also lives on the docs page, deliberately: the release-note
collector reads `git log --format=%H %s` into a `{ hash, subject }`
type, so a `BREAKING CHANGE:` footer has nowhere to land (#6479).

## Restoring the React Native render-type safety

Ben caught a property the migration silently traded away. RN's deleted
`RenderToolFunction` was the only thing narrowing an RN render to
`React.ReactElement | null`. `useFrontendTool`'s `render` is a
`React.ComponentType`, so it returns `ReactNode` — meaning a bare string
now compiles and then throws *Text strings must be rendered within a
`<Text>` component* on device. Before the rename that call site was
rejected.

`FrontendToolRenderFunction<T>` is now exported from `/headless` for
that. It derives its props from core's canonical `ReactToolCallRenderer`
unchanged and narrows only the return type, so it cannot drift from the
contract. It is **opt-in** — annotate your renderer to get the
protection — and the hazard is now documented on `useFrontendTool.mdx`,
which previously had zero mentions of `ReactElement`, `ReactNode` or
`FlatList`.

## `status` changes vocabulary, and that is NOT a break

RN's `status` moves from the `ToolCallStatus` enum to core's
string-literal union. A string-enum member is assignable to its own
literal type, so `status === ToolCallStatus.Complete` compiles **and
narrows** against the union — verified in all four combinations. No
migration work follows.

This PR also deletes a false claim #6438 shipped: that comparing the
enum to a bare string literal does not typecheck. Ben raised exactly
this in #6438's review; it was corrected in the migration note and left
standing in the guide bullet.

## The react-core half (2 files, 6 lines)

`ReactToolCallRenderer.render` is a `React.ComponentType`, and a
function component returns `ReactNode` — of which `null` is a member. So
`null` already worked where a renderer is *invoked*; only the two
build-side helpers forbade it. Widened to `React.ReactElement | null` in
`use-render-tool.tsx` and `types/defineToolCallRenderer.ts`. Both are
required — widening only the hook yields `TS2322`.

Three things this does **not** claim:

- **Not type-only.** oxlint's `consistent-type-imports` converted
`defineToolCallRenderer.ts`'s `ToolCallStatus` import to `import type`,
removing a runtime `@copilotkit/core` import from the emitted JS.
Harmless, but not a types-only diff.
- **Not uniform.** `useDefaultRenderTool` still requires `ReactElement`,
so core's two wildcard entry points differ. That divergence fails loudly
(`TS2322`) and gets its own change.
- **Not web-only in reach.** `defineToolCallRenderer` is re-exported
from `@copilotkit/react-native`.

It lives in its own commit and lifts out cleanly if you would rather
this PR stay RN-only.

## Two symptoms are documented, not fixed

- **`agentId` re-registration** — both core hooks omit `agentId` from
the effect's dependency check, so the `deps` workaround stands.
- **`useDefaultRenderTool`'s narrower render return**, per above.

## Testing

- **Red-green on the wildcard.** Before the deletion, `getTool({
toolName: "*" })` returned a real tool object — `{ name: "*",
description: undefined, parameters: undefined }` — the defect verbatim.
Green after: the `"*"` renderer paints for an unmatched call **and** no
tool named `*` is registered. The shim has its own version of this test,
since its wildcard rule exists to prevent that exact regression. Note
per the correction above that the **registry** assertions are the
discriminating ones; the `advertised` assertions are kept as forward
guards against someone making `*` advertisable later, and their comments
now say so rather than claiming to be load-bearing.
- **All three shim routing rules**, asserted on core's observable state
— `getTool`, `core.tools`, and the advertised tool list core hands an
agent on a real run.
- **The identity guard was replaced, not weakened.**
`headless-entry-surface.test.ts` previously asserted only that
`useRenderTool` was *present*, never which hook it was, so it would have
stayed green through this entire change. The identity assertion closed
that; the shim made identity false, so it is now a delegation test plus
a graph-wide deny-list on `addTool` / `removeTool` /
`addHookRenderToolCall` / `renderToolCalls` / `createContext`. Five
mutations were run against it: re-growing a local registry fails both
new guards; an early-return shim that still *looks* delegating fails 14
behavioural tests; removing the wildcard rule reproduces the original
bug; removing the production gate and the warn-once dedup each fail
their own test.
- **A test whose name asserted the opposite of its behaviour** was
replaced — it claimed to prove agent scoping and never checked that a
scoped renderer does not paint under the default agent.
- The RN suite was rewritten around what RN owns. The old file tested
forwarding through a double so thin that its own header comment recorded
that deleting the `deps`/`handler`/`agentId` forwarding left it fully
green.
- **A coverage pin was re-homed, not dropped.** An RN test pinning
core's `JSON.stringify(extraDeps)` comparator was testing core, and no
react-core test covered the case.
- **`FrontendToolRenderFunction` is mutation-proved both ways** —
widening the return to `ReactNode` or loosening the props each break the
type test.
- `packages/react-native/USAGE.md` was still teaching the deleted API.
It **ships in the published tarball** (no `files` array, no
`.npmignore`).

### Results

```
check-types (--skip-nx-cache)   2 projects + 34 dependency tasks   ✅
react-native vitest             298 passed / 23 files              ✅
react-core src/v2 vitest        1503 passed / 120 files            ✅
react-core test:scripts         47 pass / 0 fail                   ✅
react-native test:scripts       26 pass / 0 fail                   ✅
```

vitest transpiles without type-checking, so `tsc --noEmit` is the only
guard against a re-narrowing of the six widened annotations.
`static_quality.yml`'s `check-types` job runs it, and `nx.json`'s
`targetDefaults.check-types.dependsOn` builds react-core's dist first,
so the RN-side typecheck is meaningful rather than stale.

### What is NOT covered

Worth stating plainly: **nothing here proves the package works on a real
device.** The RN suite runs in jsdom with `react-native` aliased to a
52-line stub whose `FlatList` is a mock; no CI job runs Metro, a
simulator, or Detox; and `examples/v2/react-native/demo` is not built or
typechecked in CI. What this PR verifies is types, export surface, and
behaviour against core's real registry. Separately, #6438's finding that
RN's dist-relative `sideEffects` globs strip the polyfill import from
the built entries is still live and still out of scope.

## Follow-ups (not in this PR)

- Widen `use-default-render-tool.tsx`'s four render annotations, or
document why core's two wildcard entry points differ.
- Remove the shim next minor — tracked in #6976 and Linear OSS-1148, and
cited in the shim's JSDoc.
- Build or typecheck the RN example app in CI — the cheapest real-RN
signal available.
- `assert-headless-purity.mjs`'s `isCompleteLiteralArgument` reads
`code` rather than `masked` — @BenTaylorDev's non-blocking ask on #6438,
never actioned.
- #6346 (@davidmckayv) is still open; Ben asked for it to be closed with
a pointer when #6438 landed.

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Renderers can now return `null` to intentionally suppress tool-call
UI.
- React Native supports renderer-only tool-call registration, including
named and wildcard renderers.
  - Added type guidance for React Native-safe renderer return values.

- **Bug Fixes**
- Improved compatibility routing for existing React Native
`useRenderTool` configurations.
- Prevented unnecessary renderer re-registration when dependencies are
non-serializable.

- **Documentation**
- Updated React Native guidance for `useFrontendTool`, `useRenderTool`,
shared rendering, migration, and deprecation behavior.
- Clarified renderer props, status values, and `null` rendering
behavior.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@davidmckayv

Copy link
Copy Markdown
Contributor Author

Closing this. The work it was written for is complete and this is not being pursued further.

The branch is retained if the react-native parity fixes are wanted later: streaming tool-call renders via partialJSONParse, an RN-native useRenderToolCall, and an RN useComponent that registers where the RN renderers actually read.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant