refactor(create): rebuild AI Assistant on @tanstack/ai-react/ui createChatHook - #509
refactor(create): rebuild AI Assistant on @tanstack/ai-react/ui createChatHook#509jherr wants to merge 1 commit into
Conversation
…eChatHook Migrate the React AI add-on's floating "AI Assistant" from the older useChat/createChatClientOptions API with hand-rolled message rendering to the newer @tanstack/ai-react/ui createChatHook registry pattern, matching the ts-react-ui-chatbot reference example. - Add demo-ai-ui-context.ts (createChatHookContexts) and demo-chat-registry.tsx (createChatHook with layout/message/input chrome + text part + recommendGuitar tool component), styled with the existing demo-* / --sea-ink tokens. - Render the assistant panel via <chat.AppChat /> instead of a bespoke Messages list and textarea form. - Pass a plain options object rather than createChatClientOptions so the @tanstack/ai-react/ui type helpers can structurally infer the named tools (createChatClientOptions hid `tools`, resolving the tool part to `never`). The ai-chat.tsx full-page route is intentionally left on the current hook; the guitar-recommendation domain and styling are unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (5)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe React AI Assistant now uses ChangesAI Assistant registry migration
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to The floating React AI Assistant now uses the registered chat UI while retaining text streaming, input behavior, error display, and inline guitar recommendations. No current merge-blocking risk remains. Sequence Diagram(s)sequenceDiagram
participant AIAssistant
participant useAppChat
participant ChatLayout
participant ChatMessage
participant TextPart
participant RecommendGuitarTool
AIAssistant->>useAppChat: obtain chat registry
useAppChat->>ChatLayout: render AppChat
ChatLayout->>ChatMessage: dispatch messages
ChatMessage->>TextPart: dispatch text parts
ChatMessage->>RecommendGuitarTool: dispatch recommendGuitar output
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
What
Migrates the React AI add-on's floating "AI Assistant" widget from the older
useChat/createChatClientOptionsAPI (with hand-rolled message rendering) to the newer@tanstack/ai-react/uicreateChatHookregistry pattern, matching thets-react-ui-chatbotreference example.Changes
components/ai/demo-ai-ui-context.ts—createChatHookContexts()(scoped chat/part/interrupt contexts).components/ai/demo-chat-registry.tsx—createChatHook({...})registeringlayout/message/inputchrome plus atextpart and therecommendGuitartool component. Styled with the existingdemo-*/--sea-inkdesign tokens (no new dependencies; reusesStreamdown).components/demo-AIAssistant.tsx— renders the panel via<chat.AppChat />instead of a bespokeMessageslist + textarea form. Keeps theshowAIAssistantstore used by the guitar card.lib/demo-ai-hook.ts— exports a plain options object instead of wrapping increateChatClientOptions, so the@tanstack/ai-react/uitype helpers can structurally infer the named tools (the wrapper hidtools, resolving the tool part type tonever). The existingai-chat.tsxroute +InferChatMessagesstill compile.Scope
ai-chat.tsxroute is intentionally left on the current hook.Verification
--add-ons aiagainst the published@tanstack/ai-react@0.24.0: my files typecheck clean.recommendGuitarguitar card through the new tool component.pnpm build && pnpm test, incl. e2e add-on smoke tests) passes.🤖 Generated with Claude Code
Summary by CodeRabbit