Repository navigation
feat(react-native): stream tool-call renders, add useRenderToolCall - #6346
Closed
davidmckayv wants to merge 6 commits into
Closed
davidmckayv wants to merge 6 commits into
davidmckayv wants to merge 6 commits into
Conversation
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]>
davidmckayv
requested review from
jpr5,
marthakelly,
mme,
ranst91 and
tylerslaton
as code owners
August 3, 2026 19:54
@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-telegram
@copilotkit/channels-ui
@copilotkit/channels-whatsapp
@copilotkit/core
@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: |
Contributor
|
Size Change: 0 B Total Size: 1.27 MB ℹ️ View Unchanged
|
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
force-pushed
the
feat/rn-streaming-tool-render
branch
from
August 3, 2026 20:27
d258e03 to
6614287
Compare
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)
Merged
3 tasks done
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 -->
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
CopilotChatparsed tool arguments withJSON.parse: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 withuseRenderTool/useComponenttherefore rendered nothing until the call completed — no progressive build at all, while the web core has had it (partialJSONParse+ aninProgressstate).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
CopilotChatrenders 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'suseRenderToolCallis deliberately not re-exported (src/index.ts: "depends on DOM elements viaDefaultToolCallRenderer"), 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:This is also what makes
useComponentusable outsideCopilotChaton React Native.Breaking-ish
RenderToolProps.statusgains"inProgress"andargsbecomesPartial<T>, reflecting that arguments are incomplete while streaming. Renderers that switch exhaustively onstatusneed an"inProgress"branch. Flagged in the changeset as a minor.Testing
useRenderToolCall: registered/unregistered lookup, partial args atinProgress, a fragment with no complete key,executing,completewith result pass-through, and absent arguments.CopilotChatand edge-case tests.check-typesclean,buildclean.useComponent+useRenderToolCall: seven registered panels, nocomposeStage. 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