fix(chat-message): update part type to UIMessage['parts'][number] and…#783
Conversation
… ensure tool result content is handled correctly
📝 WalkthroughWalkthrough
ChangesTool-result content normalization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
packages/ai-react-ui/tests/tool-result-content.test.tsParsing error: "parserOptions.project" has been provided for 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 9284b24
☁️ Nx Cloud last updated this comment at |
@tanstack/ai
@tanstack/ai-angular
@tanstack/ai-anthropic
@tanstack/ai-client
@tanstack/ai-code-mode
@tanstack/ai-code-mode-skills
@tanstack/ai-devtools-core
@tanstack/ai-elevenlabs
@tanstack/ai-event-client
@tanstack/ai-fal
@tanstack/ai-gemini
@tanstack/ai-grok
@tanstack/ai-groq
@tanstack/ai-isolate-cloudflare
@tanstack/ai-isolate-node
@tanstack/ai-isolate-quickjs
@tanstack/ai-mcp
@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-utils
@tanstack/ai-vue
@tanstack/ai-vue-ui
@tanstack/openai-base
@tanstack/preact-ai-devtools
@tanstack/react-ai-devtools
@tanstack/solid-ai-devtools
commit: |
Tool-result content is `string | Array<ContentPart>`. The renderer previously narrowed array content to '', silently dropping multimodal results. Extract and concatenate the text parts instead (skipping non-text parts), via a small testable `toolResultContentToString` helper, and add unit coverage plus a changeset. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/ai-react-ui/tests/tool-result-content.test.ts (1)
1-46: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMove this unit test alongside its source file.
This test is under
packages/ai-react-ui/tests/, but the project rule requires unit tests to be colocated with source (*.test.tsnext to the module). Please move it next topackages/ai-react-ui/src/tool-result-content.ts(e.g.,packages/ai-react-ui/src/tool-result-content.test.ts).As per coding guidelines, "
**/*.test.ts: Place unit tests alongside source code in*.test.tsfiles".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/ai-react-ui/tests/tool-result-content.test.ts` around lines 1 - 46, The unit test for toolResultContentToString is in the wrong location and should be colocated with its source module. Move the existing test from the standalone tests folder to sit next to tool-result-content in the src area, keeping the test name and assertions intact so it remains discoverable by the project’s `*.test.ts` convention. Ensure any imports still reference toolResultContentToString from the local source module after the move.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/ai-react-ui/tests/tool-result-content.test.ts`:
- Around line 1-46: The unit test for toolResultContentToString is in the wrong
location and should be colocated with its source module. Move the existing test
from the standalone tests folder to sit next to tool-result-content in the src
area, keeping the test name and assertions intact so it remains discoverable by
the project’s `*.test.ts` convention. Ensure any imports still reference
toolResultContentToString from the local source module after the move.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 2b3e5786-354c-47c1-87c6-aca15dade480
📒 Files selected for processing (4)
.changeset/red-pillows-cheer.mdpackages/ai-react-ui/src/chat-message.tsxpackages/ai-react-ui/src/tool-result-content.tspackages/ai-react-ui/tests/tool-result-content.test.ts
✅ Files skipped from review due to trivial changes (2)
- .changeset/red-pillows-cheer.md
- packages/ai-react-ui/src/tool-result-content.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/ai-react-ui/src/chat-message.tsx
tombeckenham
left a comment
There was a problem hiding this comment.
Thank you for this one
🎯 Changes
Restore typing for ChatMessage parts by replacing the migration-era any with the existing UIMessage part type and removing the associated TODO.
This change also adds local narrowing for tool-result content to satisfy the ToolResultPart.content union while preserving the existing renderer contract and runtime behavior.
No public APIs, package functionality, or runtime behavior are changed.
✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit