refactor: change CustomEvent property from 'data' to 'value' for AG-UI#307
refactor: change CustomEvent property from 'data' to 'value' for AG-UI#307
Conversation
…I compliance Co-Authored-By: Warp <agent@warp.dev>
|
No actionable comments were generated in the recent review. 🎉 📝 WalkthroughWalkthroughRefactors the CustomEvent payload field from Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
View your CI Pipeline Execution ↗ for commit 7064598
☁️ Nx Cloud last updated this comment at |
@tanstack/ai
@tanstack/ai-anthropic
@tanstack/ai-client
@tanstack/ai-devtools-core
@tanstack/ai-fal
@tanstack/ai-gemini
@tanstack/ai-grok
@tanstack/ai-ollama
@tanstack/ai-openai
@tanstack/ai-openrouter
@tanstack/ai-preact
@tanstack/ai-react
@tanstack/ai-react-ui
@tanstack/ai-solid
@tanstack/ai-solid-ui
@tanstack/ai-svelte
@tanstack/ai-vue
@tanstack/ai-vue-ui
@tanstack/preact-ai-devtools
@tanstack/react-ai-devtools
@tanstack/solid-ai-devtools
commit: |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
packages/typescript/ai/src/activities/chat/stream/processor.ts (1)
76-81:⚠️ Potential issue | 🟡 Minor
onCustomEventcallback parameter name is now inconsistent withCustomEvent.value.The second parameter
data(line 79) is forwarded directly fromchunk.value(line 866). Since this is a public-facing events API, callers who name their callback parameter after the interface field will have a mismatch between the callback declaration and theCustomEventtype they imported.✏️ Suggested fix
onCustomEvent?: ( eventType: string, - data: unknown, + value: unknown, context: { toolCallId?: string }, ) => void🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/typescript/ai/src/activities/chat/stream/processor.ts` around lines 76 - 81, The onCustomEvent callback's second parameter is named "data" but is forwarded from chunk.value and should match the public CustomEvent.value name; update the onCustomEvent signature to use "value" instead of "data" (and adjust any internal references) so it aligns with CustomEvent.value and the value forwarded from chunk.value in the stream processor.packages/typescript/ai/src/types.ts (1)
356-373:⚠️ Potential issue | 🟡 Minor
ToolExecutionContext.emitCustomEventparameter name and JSDoc are now stale.The second parameter is still named
data(line 372) and the JSDoc still says@param data - Event payload data(line 359), but the payload it produces lands inCustomEvent.value. This is a public API method, so the inconsistency will confuse callers who see the emitter callemitCustomEvent(name, data)but observe the event with.value.✏️ Suggested fix
/** * `@param` eventName - Name of the custom event - * `@param` data - Event payload data + * `@param` value - Event payload value */ - emitCustomEvent: (eventName: string, data: Record<string, any>) => void + emitCustomEvent: (eventName: string, value: Record<string, any>) => void🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/typescript/ai/src/types.ts` around lines 356 - 373, ToolExecutionContext.emitCustomEvent's second parameter and JSDoc are out of sync with the emitted CustomEvent payload — update the method signature and docs so the param is named "value" (not "data") and the JSDoc `@param` reflects that this becomes CustomEvent.value; update the example usage in the JSDoc to call emitCustomEvent(name, value) and ensure the type remains Record<string, any> for the "value" parameter so callers and runtime behavior match (refer to ToolExecutionContext.emitCustomEvent and the example block in the same comment).
🧹 Nitpick comments (1)
packages/typescript/ai/src/activities/chat/index.ts (1)
610-611: Lambda parameterdatais inconsistent with the renamedvalueparameter.Both
executeToolCallscallbacks at lines 610 and 673 pass a localdatavariable directly tocreateCustomEventChunk'svalueparameter. This is a harmless nitpick but creates a naming disconnect that could confuse a future reader of the call chain.✏️ Suggested fix
- (eventName, data) => this.createCustomEventChunk(eventName, data), + (eventName, value) => this.createCustomEventChunk(eventName, value),(Apply to both occurrences at lines 610 and 673.)
Also applies to: 672-674
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/typescript/ai/src/activities/chat/index.ts` around lines 610 - 611, The lambda parameter name `data` passed into executeToolCalls should match the renamed parameter `value` expected by createCustomEventChunk to avoid confusion; update both callback lambdas (the ones that call this.createCustomEventChunk(...)) to use `value` as the parameter name instead of `data` so the call becomes (value) => this.createCustomEventChunk(eventName, value) in both occurrences referencing createCustomEventChunk and the executeToolCalls callbacks.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@packages/typescript/ai/src/activities/chat/stream/processor.ts`:
- Around line 76-81: The onCustomEvent callback's second parameter is named
"data" but is forwarded from chunk.value and should match the public
CustomEvent.value name; update the onCustomEvent signature to use "value"
instead of "data" (and adjust any internal references) so it aligns with
CustomEvent.value and the value forwarded from chunk.value in the stream
processor.
In `@packages/typescript/ai/src/types.ts`:
- Around line 356-373: ToolExecutionContext.emitCustomEvent's second parameter
and JSDoc are out of sync with the emitted CustomEvent payload — update the
method signature and docs so the param is named "value" (not "data") and the
JSDoc `@param` reflects that this becomes CustomEvent.value; update the example
usage in the JSDoc to call emitCustomEvent(name, value) and ensure the type
remains Record<string, any> for the "value" parameter so callers and runtime
behavior match (refer to ToolExecutionContext.emitCustomEvent and the example
block in the same comment).
---
Nitpick comments:
In `@packages/typescript/ai/src/activities/chat/index.ts`:
- Around line 610-611: The lambda parameter name `data` passed into
executeToolCalls should match the renamed parameter `value` expected by
createCustomEventChunk to avoid confusion; update both callback lambdas (the
ones that call this.createCustomEventChunk(...)) to use `value` as the parameter
name instead of `data` so the call becomes (value) =>
this.createCustomEventChunk(eventName, value) in both occurrences referencing
createCustomEventChunk and the executeToolCalls callbacks.
TanStack#307) * refactor: change CustomEvent property from 'data' to 'value' for AG-UI compliance Co-Authored-By: Warp <agent@warp.dev> * fixing the oh so lovely tests * ci: apply automated fixes --------- Co-authored-by: Warp <agent@warp.dev> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
🎯 Changes
Changing data to value for AG-UI
✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit
datatovaluefor custom events (including approval-requested and tool-input-available) across Python and TypeScript packages.valuepayload field for custom event scenarios.