11'use client' ;
22
3- import { useChat } from '@ai-sdk/react' ;
43import { FC , useState } from 'react' ;
5- import { AiProvider as AuiProvider } from '@creatorem/ai-chat/primitives/ai-provider'
6- import {
7- ThreadPrimitiveRoot ,
8- ThreadPrimitiveViewport ,
9- ThreadPrimitiveViewportFooter ,
10- ThreadPrimitiveMessages ,
11- ThreadPrimitiveSuggestion ,
12- ThreadPrimitiveScrollToBottom ,
13- ThreadPrimitiveIf
14- } from '@creatorem/ai-chat/primitives/thread/index'
15-
16- import * as ComposerPrimitive from '@creatorem/ai-chat/primitives/composer/index'
17- // import { ThreadPrimitiveIf } from '@creatorem/ai-chat/primitives/thread/thread-if'
4+ import { AiProvider } from '@creatorem/ai-react/ai-provider'
5+ import * as ComposerPrimitive from '@creatorem/ai-react/primitives/composer'
186import {
197 Root as MessagePrimitiveRoot ,
20- Parts as MessagePrimitiveParts ,
218 If as MessagePrimitiveIf ,
229 Error as MessagePrimitiveError ,
23- } from '@creatorem/ai-chat/primitives/message/index'
24- import {
25- Root as ErrorPrimitiveRoot ,
26- Message as ErrorPrimitiveMessage
27- } from '@creatorem/ai-chat/primitives/error/index'
10+ } from '@creatorem/ai-react/primitives/message'
11+ import * as ErrorPrimitive from '@creatorem/ai-react/primitives/error'
2812
29- import * as ActionBarPrimitive from '@creatorem/ai-chat/primitives/action-bar/index'
30- import * as BranchPickerPrimitive from '@creatorem/ai-chat/primitives/branch-picker/index'
31- import * as ActionBarMorePrimitive from '@creatorem/ai-chat/primitives/action-bar-more/index'
13+ import * as ActionBarPrimitive from "@creatorem/ai-react/primitives/action-bar" ;
14+ import * as ActionBarMorePrimitive from "@creatorem/ai-react/primitives/action-bar-more" ;
15+ import * as BranchPickerPrimitive from "@creatorem/ai-react/primitives/branch-picker" ;
16+ import * as ThreadPrimitive from "@creatorem/ai-react/primitives/thread" ;
17+ import * as MessagePrimitive from "@creatorem/ai-react/primitives/message" ;
18+ // import { MessagePrimitiveParts } from "@creatorem/ai-react/primitives/message";
3219import { Button } from '@/components/ui/button' ;
3320import { ArrowDownIcon , ArrowUpIcon , CheckIcon , ChevronLeftIcon , ChevronRightIcon , CopyIcon , DownloadIcon , MoreHorizontalIcon , PencilIcon , RefreshCwIcon , SquareIcon } from 'lucide-react' ;
3421import { TooltipIconButton } from '@/components/ai-chat/tooltip-icon-button' ;
3522import { cn } from '@/lib/utils' ;
3623import { SidebarInset , SidebarProvider , SidebarTrigger } from '@/components/ui/sidebar' ;
3724import { Separator } from '@/components/ui/separator' ;
3825import { Breadcrumb , BreadcrumbItem , BreadcrumbLink , BreadcrumbList , BreadcrumbPage , BreadcrumbSeparator } from '@/components/ui/breadcrumb' ;
39- import { Tooltip , TooltipContent , TooltipTrigger } from '@/components/ui/tooltip' ;
4026import { ComposerAddAttachment , ComposerAttachments , UserMessageAttachments } from './attachment' ;
4127import { Reasoning , ReasoningGroup } from './reasoning' ;
4228import { ToolFallback } from './tool-fallback' ;
@@ -46,90 +32,90 @@ import { WeatherToolRegistration } from './weather-tool-ui';
4632
4733export default function Chat ( ) {
4834 return (
49- < AuiProvider >
50- < SidebarProvider >
51- < div className = "flex h-dvh w-full pr-0.5" >
52- < ThreadListSidebar />
53- < SidebarInset >
54- < header className = "flex h-16 shrink-0 items-center gap-2 border-b px-4" >
55- < SidebarTrigger />
56- < Separator orientation = "vertical" className = "mr-2 h-4" />
57- < Breadcrumb >
58- < BreadcrumbList >
59- < BreadcrumbItem className = "hidden md:block" >
60- < BreadcrumbLink
61- href = "https://www.assistant-ui.com/docs/getting-started"
62- target = "_blank"
63- rel = "noopener noreferrer"
64- >
65- Build Your Own ChatGPT UX
66- </ BreadcrumbLink >
67- </ BreadcrumbItem >
68- < BreadcrumbSeparator className = "hidden md:block" />
69- < BreadcrumbItem >
70- < BreadcrumbPage > Starter Template</ BreadcrumbPage >
71- </ BreadcrumbItem >
72- </ BreadcrumbList >
73- </ Breadcrumb >
74- </ header >
75- < div className = "flex-1 overflow-hidden" >
76- < Thread />
77- </ div >
78- </ SidebarInset >
79- </ div >
80- </ SidebarProvider >
81- </ AuiProvider >
35+ < AiProvider >
36+ < SidebarProvider >
37+ < div className = "flex h-dvh w-full pr-0.5" >
38+ < ThreadListSidebar />
39+ < SidebarInset >
40+ < header className = "flex h-16 shrink-0 items-center gap-2 border-b px-4" >
41+ < SidebarTrigger />
42+ < Separator orientation = "vertical" className = "mr-2 h-4" />
43+ < Breadcrumb >
44+ < BreadcrumbList >
45+ < BreadcrumbItem className = "hidden md:block" >
46+ < BreadcrumbLink
47+ href = "https://www.assistant-ui.com/docs/getting-started"
48+ target = "_blank"
49+ rel = "noopener noreferrer"
50+ >
51+ Build Your Own ChatGPT UX
52+ </ BreadcrumbLink >
53+ </ BreadcrumbItem >
54+ < BreadcrumbSeparator className = "hidden md:block" />
55+ < BreadcrumbItem >
56+ < BreadcrumbPage > Starter Template</ BreadcrumbPage >
57+ </ BreadcrumbItem >
58+ </ BreadcrumbList >
59+ </ Breadcrumb >
60+ </ header >
61+ < div className = "flex-1 overflow-hidden" >
62+ < Thread />
63+ </ div >
64+ </ SidebarInset >
65+ </ div >
66+ </ SidebarProvider >
67+ </ AiProvider >
8268 ) ;
8369}
8470
8571const Thread : React . FC = ( ) => {
8672 return (
87- < ThreadPrimitiveRoot >
73+ < ThreadPrimitive . Root >
8874 < WeatherToolRegistration />
8975 < div
9076 className = "aui-root aui-thread-root @container flex h-full flex-col"
9177 style = { {
9278 [ "--thread-max-width" as string ] : "44rem" ,
9379 } }
9480 >
95- < ThreadPrimitiveViewport
81+ < ThreadPrimitive . Viewport
9682 turnAnchor = "top"
9783 className = 'aui-thread-viewport relative flex flex-1 flex-col overflow-x-auto overflow-y-scroll scroll-smooth px-4 pt-4'
9884 >
9985
100- < ThreadPrimitiveIf empty = { true } >
86+ < ThreadPrimitive . If empty = { true } >
10187 < ThreadWelcome />
102- </ ThreadPrimitiveIf >
88+ </ ThreadPrimitive . If >
10389
104- < ThreadPrimitiveMessages
90+ < ThreadPrimitive . Messages
10591 components = { {
10692 UserMessage,
10793 EditComposer,
10894 AssistantMessage,
10995 } }
11096 />
11197
112- < ThreadPrimitiveViewportFooter className = "aui-thread-viewport-footer sticky bottom-0 mx-auto mt-auto flex w-full max-w-(--thread-max-width) flex-col gap-4 overflow-visible rounded-t-3xl bg-background pb-4 md:pb-6" >
98+ < ThreadPrimitive . ViewportFooter className = "aui-thread-viewport-footer sticky bottom-0 mx-auto mt-auto flex w-full max-w-(--thread-max-width) flex-col gap-4 overflow-visible rounded-t-3xl bg-background pb-4 md:pb-6" >
11399 < ThreadScrollToBottom />
114100 < Composer />
115- </ ThreadPrimitiveViewportFooter >
116- </ ThreadPrimitiveViewport >
101+ </ ThreadPrimitive . ViewportFooter >
102+ </ ThreadPrimitive . Viewport >
117103 </ div >
118- </ ThreadPrimitiveRoot >
104+ </ ThreadPrimitive . Root >
119105 ) ;
120106} ;
121107
122108const ThreadScrollToBottom : FC = ( ) => {
123109 return (
124- < ThreadPrimitiveScrollToBottom asChild >
110+ < ThreadPrimitive . ScrollToBottom asChild >
125111 < TooltipIconButton
126112 tooltip = "Scroll to bottom"
127113 variant = "outline"
128114 className = "aui-thread-scroll-to-bottom absolute -top-12 z-10 self-center rounded-full p-4 disabled:invisible dark:bg-background dark:hover:bg-accent"
129115 >
130116 < ArrowDownIcon />
131117 </ TooltipIconButton >
132- </ ThreadPrimitiveScrollToBottom >
118+ </ ThreadPrimitive . ScrollToBottom >
133119 ) ;
134120} ;
135121
@@ -173,7 +159,7 @@ const ThreadSuggestions: FC = () => {
173159 className = "aui-thread-welcome-suggestion-display fade-in slide-in-from-bottom-2 @md:nth-[n+3]:block nth-[n+3]:hidden animate-in fill-mode-both duration-200"
174160 style = { { animationDelay : `${ 100 + index * 50 } ms` } }
175161 >
176- < ThreadPrimitiveSuggestion prompt = { suggestion . prompt } send asChild >
162+ < ThreadPrimitive . Suggestion prompt = { suggestion . prompt } send asChild >
177163 < Button
178164 variant = "ghost"
179165 className = "aui-thread-welcome-suggestion h-auto w-full @md:flex-col flex-wrap items-start justify-start gap-1 rounded-2xl border px-4 py-3 text-left text-sm transition-colors hover:bg-muted"
@@ -186,7 +172,7 @@ const ThreadSuggestions: FC = () => {
186172 { suggestion . label }
187173 </ span >
188174 </ Button >
189- </ ThreadPrimitiveSuggestion >
175+ </ ThreadPrimitive . Suggestion >
190176 </ div >
191177 ) ) }
192178 </ div >
@@ -218,7 +204,7 @@ const ComposerAction: FC = () => {
218204 < div className = "aui-composer-action-wrapper relative mx-2 mb-2 flex items-center justify-between" >
219205 < ComposerAddAttachment />
220206
221- < ThreadPrimitiveIf running = { false } >
207+ < ThreadPrimitive . If running = { false } >
222208 < ComposerPrimitive . Send asChild >
223209 < TooltipIconButton
224210 tooltip = "Send message"
@@ -232,9 +218,9 @@ const ComposerAction: FC = () => {
232218 < ArrowUpIcon className = "aui-composer-send-icon size-4" />
233219 </ TooltipIconButton >
234220 </ ComposerPrimitive . Send >
235- </ ThreadPrimitiveIf >
221+ </ ThreadPrimitive . If >
236222
237- < ThreadPrimitiveIf running = { true } >
223+ < ThreadPrimitive . If running = { true } >
238224 < ComposerPrimitive . Cancel asChild >
239225 < Button
240226 type = "button"
@@ -246,7 +232,7 @@ const ComposerAction: FC = () => {
246232 < SquareIcon className = "aui-composer-cancel-icon size-3 fill-current" />
247233 </ Button >
248234 </ ComposerPrimitive . Cancel >
249- </ ThreadPrimitiveIf >
235+ </ ThreadPrimitive . If >
250236 </ div >
251237 ) ;
252238} ;
@@ -255,9 +241,9 @@ const ComposerAction: FC = () => {
255241const MessageError : FC = ( ) => {
256242 return (
257243 < MessagePrimitiveError >
258- < ErrorPrimitiveRoot className = "aui-message-error-root mt-2 rounded-md border border-destructive bg-destructive/10 p-3 text-destructive text-sm dark:bg-destructive/5 dark:text-red-200" >
259- < ErrorPrimitiveMessage className = "aui-message-error-message line-clamp-2" />
260- </ ErrorPrimitiveRoot >
244+ < ErrorPrimitive . Root className = "aui-message-error-root mt-2 rounded-md border border-destructive bg-destructive/10 p-3 text-destructive text-sm dark:bg-destructive/5 dark:text-red-200" >
245+ < ErrorPrimitive . Message className = "aui-message-error-message line-clamp-2" />
246+ </ ErrorPrimitive . Root >
261247 </ MessagePrimitiveError >
262248 ) ;
263249} ;
@@ -270,7 +256,7 @@ const AssistantMessage: FC = () => {
270256 data-role = "assistant"
271257 >
272258 < div className = "aui-assistant-message-content wrap-break-word px-2 text-foreground leading-relaxed" >
273- < MessagePrimitiveParts
259+ < MessagePrimitive . Parts
274260 components = { {
275261 Text : MarkdownText ,
276262 Reasoning,
@@ -348,7 +334,7 @@ const UserMessage: FC = () => {
348334
349335 < div className = "aui-user-message-content-wrapper relative col-start-2 min-w-0" >
350336 < div className = "aui-user-message-content wrap-break-word rounded-2xl bg-muted px-4 py-2.5 text-foreground" >
351- < MessagePrimitiveParts />
337+ < MessagePrimitive . Parts />
352338 </ div >
353339 < div className = "aui-user-action-bar-wrapper absolute top-1/2 left-0 -translate-x-full -translate-y-1/2 pr-2" >
354340 < UserActionBar />
@@ -417,8 +403,8 @@ const BranchPicker: FC<BranchPickerPrimitive.Root.Props> = ({
417403 < ChevronLeftIcon />
418404 </ TooltipIconButton >
419405 </ BranchPickerPrimitive . Previous >
420- < span className = "aui-branch-picker-state font-medium" >
421- < BranchPickerPrimitive . Number /> / < BranchPickerPrimitive . Count />
406+ < span className = "aui-branch-picker-state flex items-center gap-1 font-medium" >
407+ < BranchPickerPrimitive . Number /> < span > / </ span > < BranchPickerPrimitive . Count />
422408 </ span >
423409 < BranchPickerPrimitive . Next asChild >
424410 < TooltipIconButton tooltip = "Next" >
0 commit comments