Repository navigation
refactor(create): rebuild AI Assistant on @tanstack/ai-react/ui createChatHook - #509
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. Walkthrough
Merge Risk:
|
🦋 Changeset detectedLatest commit: 658a1cc The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The AI Assistant PR branch now includes current main. Both chat surfaces keep the same thread ID, and the floating panel still displays the guitar recommendation.
|
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