useGeneration (ai-react): caller-supplied `devtools` can override the framework identification
@AlemTuzlak is already working on this.
Since Aug 21, 2026.
- Dominant language
- TypeScript
- Stars
- 3.1k
- Forks
- 331
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 160
Description
Found while reviewing the @tanstack/ai-octane port (#1000). Fixed there; ai-react has the same ordering.
Problem
packages/ai-react/src/use-generation.ts builds its devtools metadata with the hardcoded identity before the caller's spread:
devtools: {
hookName: 'useGeneration',
framework: 'react',
...opts.devtools, // <-- caller wins
},
useGeneration is documented as public API ("You can also use it directly for custom generation types"), so callers do pass devtools. A caller supplying devtools.framework or devtools.hookName silently overrides the identity, and the devtools then misattribute the activity.
Notably ai-vue and ai-solid already spread first and are not affected — ai-react is the odd one out.
Fix
Match the sibling adapters:
devtools: {
- hookName: 'useGeneration',
- framework: 'react',
- ...opts.devtools,
+ ...opts.devtools,
+ framework: 'react',
+ hookName: 'useGeneration',
},
Unrelated caller metadata (e.g. outputKind) still passes through; only the identity keys become non-overridable.
Test
packages/ai-octane/tests/conformance/devtools-identification.test.ts covers this by spying on the bridge factory and asserting the metadata survives a hostile devtools: { framework: 'react' }. It was verified to fail against the un-fixed ordering. The same approach ports directly to ai-react.
Affected
-
@tanstack/ai-react
(ai-vue / ai-solid already correct; @tanstack/ai-octane fixed in #1000.)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.