1- import {
2- ActionBarPrimitive ,
3- BranchPickerPrimitive ,
4- ComposerPrimitive ,
5- ErrorPrimitive ,
6- MessagePrimitive ,
7- ThreadPrimitive ,
8- } from "@assistant-ui/react" ;
91import {
102 ArrowDownIcon ,
113 ArrowUpIcon ,
@@ -17,20 +9,31 @@ import {
179 RefreshCwIcon ,
1810 Square ,
1911} from "lucide-react" ;
12+
13+ import {
14+ ActionBarPrimitive ,
15+ BranchPickerPrimitive ,
16+ ComposerPrimitive ,
17+ ErrorPrimitive ,
18+ MessagePrimitive ,
19+ ThreadPrimitive ,
20+ } from "@assistant-ui/react" ;
21+
2022import type { FC } from "react" ;
23+ import { LazyMotion , MotionConfig , domAnimation } from "motion/react" ;
24+ import * as m from "motion/react-m" ;
2125
26+ import { Button } from "@/components/ui/button" ;
27+ import { MarkdownText } from "@/components/assistant-ui/markdown-text" ;
28+ import { ToolFallback } from "@/components/assistant-ui/tool-fallback" ;
29+ import { TooltipIconButton } from "@/components/assistant-ui/tooltip-icon-button" ;
2230import {
2331 ComposerAddAttachment ,
2432 ComposerAttachments ,
2533 UserMessageAttachments ,
2634} from "@/components/assistant-ui/attachment" ;
27- import { MarkdownText } from "@/components/assistant-ui/markdown-text" ;
28- import { ToolFallback } from "@/components/assistant-ui/tool-fallback" ;
29- import { TooltipIconButton } from "@/components/assistant-ui/tooltip-icon-button" ;
30- import { Button } from "@/components/ui/button" ;
35+
3136import { cn } from "@/lib/utils" ;
32- import { LazyMotion , MotionConfig , domAnimation } from "motion/react" ;
33- import * as m from "motion/react-m" ;
3437
3538export const Thread : FC = ( ) => {
3639 return (
@@ -43,7 +46,9 @@ export const Thread: FC = () => {
4346 } }
4447 >
4548 < ThreadPrimitive . Viewport className = "aui-thread-viewport relative flex flex-1 flex-col overflow-x-auto overflow-y-scroll px-4" >
46- < ThreadWelcome />
49+ < ThreadPrimitive . If empty >
50+ < ThreadWelcome />
51+ </ ThreadPrimitive . If >
4752
4853 < ThreadPrimitive . Messages
4954 components = { {
@@ -52,9 +57,11 @@ export const Thread: FC = () => {
5257 AssistantMessage,
5358 } }
5459 />
60+
5561 < ThreadPrimitive . If empty = { false } >
5662 < div className = "aui-thread-viewport-spacer min-h-8 grow" />
5763 </ ThreadPrimitive . If >
64+
5865 < Composer />
5966 </ ThreadPrimitive . Viewport >
6067 </ ThreadPrimitive . Root >
@@ -79,37 +86,36 @@ const ThreadScrollToBottom: FC = () => {
7986
8087const ThreadWelcome : FC = ( ) => {
8188 return (
82- < ThreadPrimitive . Empty >
83- < div className = "aui-thread-welcome-root mx-auto my-auto flex w-full max-w-[var(--thread-max-width)] flex-grow flex-col" >
84- < div className = "aui-thread-welcome-center flex w-full flex-grow flex-col items-center justify-center" >
85- < div className = "aui-thread-welcome-message flex size-full flex-col justify-center px-8" >
86- < m . div
87- initial = { { opacity : 0 , y : 10 } }
88- animate = { { opacity : 1 , y : 0 } }
89- exit = { { opacity : 0 , y : 10 } }
90- className = "aui-thread-welcome-message-motion-1 text-2xl font-semibold"
91- >
92- Hello there!
93- </ m . div >
94- < m . div
95- initial = { { opacity : 0 , y : 10 } }
96- animate = { { opacity : 1 , y : 0 } }
97- exit = { { opacity : 0 , y : 10 } }
98- transition = { { delay : 0.1 } }
99- className = "aui-thread-welcome-message-motion-2 text-2xl text-muted-foreground/65"
100- >
101- How can I help you today?
102- </ m . div >
103- </ div >
89+ < div className = "aui-thread-welcome-root mx-auto my-auto flex w-full max-w-[var(--thread-max-width)] flex-grow flex-col" >
90+ < div className = "aui-thread-welcome-center flex w-full flex-grow flex-col items-center justify-center" >
91+ < div className = "aui-thread-welcome-message flex size-full flex-col justify-center px-8" >
92+ < m . div
93+ initial = { { opacity : 0 , y : 10 } }
94+ animate = { { opacity : 1 , y : 0 } }
95+ exit = { { opacity : 0 , y : 10 } }
96+ className = "aui-thread-welcome-message-motion-1 text-2xl font-semibold"
97+ >
98+ Hello there!
99+ </ m . div >
100+ < m . div
101+ initial = { { opacity : 0 , y : 10 } }
102+ animate = { { opacity : 1 , y : 0 } }
103+ exit = { { opacity : 0 , y : 10 } }
104+ transition = { { delay : 0.1 } }
105+ className = "aui-thread-welcome-message-motion-2 text-2xl text-muted-foreground/65"
106+ >
107+ How can I help you today?
108+ </ m . div >
104109 </ div >
105110 </ div >
106- </ ThreadPrimitive . Empty >
111+ < ThreadSuggestions />
112+ </ div >
107113 ) ;
108114} ;
109115
110- const ThreadWelcomeSuggestions : FC = ( ) => {
116+ const ThreadSuggestions : FC = ( ) => {
111117 return (
112- < div className = "aui-thread-welcome-suggestions grid w-full gap-2 @md:grid-cols-2" >
118+ < div className = "aui-thread-welcome-suggestions grid w-full gap-2 pb-4 @md:grid-cols-2" >
113119 { [
114120 {
115121 title : "What's the weather" ,
@@ -142,8 +148,7 @@ const ThreadWelcomeSuggestions: FC = () => {
142148 >
143149 < ThreadPrimitive . Suggestion
144150 prompt = { suggestedAction . action }
145- method = "replace"
146- autoSend
151+ send
147152 asChild
148153 >
149154 < Button
@@ -169,14 +174,11 @@ const Composer: FC = () => {
169174 return (
170175 < div className = "aui-composer-wrapper sticky bottom-0 mx-auto flex w-full max-w-[var(--thread-max-width)] flex-col gap-4 overflow-visible rounded-t-3xl bg-background pb-4 md:pb-6" >
171176 < ThreadScrollToBottom />
172- < ThreadPrimitive . Empty >
173- < ThreadWelcomeSuggestions />
174- </ ThreadPrimitive . Empty >
175- < ComposerPrimitive . Root className = "aui-composer-root relative flex w-full flex-col rounded-3xl border border-border bg-muted px-1 pt-2 shadow-[0_9px_9px_0px_rgba(0,0,0,0.01),0_2px_5px_0px_rgba(0,0,0,0.06)] dark:border-muted-foreground/15" >
177+ < ComposerPrimitive . Root className = "aui-composer-root group/input-group relative flex w-full flex-col rounded-3xl border border-input bg-background px-1 pt-2 shadow-xs transition-[color,box-shadow] outline-none has-[textarea:focus-visible]:border-ring has-[textarea:focus-visible]:ring-[3px] has-[textarea:focus-visible]:ring-ring/50 dark:bg-background" >
176178 < ComposerAttachments />
177179 < ComposerPrimitive . Input
178180 placeholder = "Send a message..."
179- className = "aui-composer-input mb-1 max-h-32 min-h-16 w-full resize-none bg-transparent px-3.5 pt-1.5 pb-3 text-base outline-none placeholder:text-muted-foreground focus:outline-primary "
181+ className = "aui-composer-input mb-1 max-h-32 min-h-16 w-full resize-none bg-transparent px-3.5 pt-1.5 pb-3 text-base outline-none placeholder:text-muted-foreground focus-visible:ring-0 "
180182 rows = { 1 }
181183 autoFocus
182184 aria-label = "Message input"
@@ -239,7 +241,7 @@ const AssistantMessage: FC = () => {
239241 return (
240242 < MessagePrimitive . Root asChild >
241243 < div
242- className = "aui-assistant-message-root relative mx-auto w-full max-w-[var(--thread-max-width)] animate-in py-4 duration-200 fade-in slide-in-from-bottom-1 last:mb-24"
244+ className = "aui-assistant-message-root relative mx-auto w-full max-w-[var(--thread-max-width)] animate-in py-4 duration-150 ease-out fade-in slide-in-from-bottom-1 last:mb-24"
243245 data-role = "assistant"
244246 >
245247 < div className = "aui-assistant-message-content mx-2 leading-7 break-words text-foreground" >
@@ -292,7 +294,7 @@ const UserMessage: FC = () => {
292294 return (
293295 < MessagePrimitive . Root asChild >
294296 < div
295- className = "aui-user-message-root mx-auto grid w-full max-w-[var(--thread-max-width)] animate-in auto-rows-auto grid-cols-[minmax(72px,1fr)_auto] gap-y-2 px-2 py-4 duration-200 fade-in slide-in-from-bottom-1 first:mt-3 last:mb-5 [&:where(>*)]:col-start-2"
297+ className = "aui-user-message-root mx-auto grid w-full max-w-[var(--thread-max-width)] animate-in auto-rows-auto grid-cols-[minmax(72px,1fr)_auto] gap-y-2 px-2 py-4 duration-150 ease-out fade-in slide-in-from-bottom-1 first:mt-3 last:mb-5 [&:where(>*)]:col-start-2"
296298 data-role = "user"
297299 >
298300 < UserMessageAttachments />
0 commit comments