@@ -17,14 +17,21 @@ import { Card } from '../ui/card';
1717import { Avatar , AvatarFallback , AvatarImage } from '../ui/avatar' ;
1818import { Markdown } from '@/components/markdown' ;
1919import { ScrollArea } from '../ui/scroll-area' ;
20+ import { cn } from '@/lib/utils' ;
2021
2122interface MessageBubbleProps {
2223 chat : any ;
2324 message : Message ;
2425 onSend : ( content : string ) => void ;
26+ className ?: string ;
2527}
2628
27- const MessageBubble = ( { chat, message, onSend } : MessageBubbleProps ) => {
29+ const MessageBubble = ( {
30+ chat,
31+ message,
32+ onSend,
33+ className,
34+ } : MessageBubbleProps ) => {
2835 const { chatSource } = useChat ( chat . id ) ;
2936 const { user } = useUser ( ) ;
3037
@@ -50,7 +57,11 @@ const MessageBubble = ({ chat, message, onSend }: MessageBubbleProps) => {
5057
5158 return (
5259 < Card
53- className = { `flex items-center gap-2 shadow-sm px-3 py-1 rounded-md ${ resultClass } ` }
60+ className = { cn (
61+ 'flex items-center gap-2 shadow-sm px-3 py-1 rounded-md' ,
62+ resultClass ,
63+ className
64+ ) }
5465 >
5566 { success ? (
5667 < Icons . checkCircle className = "w-4 h-4" />
@@ -64,7 +75,12 @@ const MessageBubble = ({ chat, message, onSend }: MessageBubbleProps) => {
6475 ) ;
6576 } else if ( message . content . startsWith ( StatusMessage . running ) ) {
6677 return (
67- < Card className = "flex items-center gap-2 shadow-sm px-3 py-1 bg-blue-500/20 text-blue-500 rounded-md" >
78+ < Card
79+ className = { cn (
80+ 'flex items-center gap-2 shadow-sm px-3 py-1 bg-blue-500/20 text-blue-500 rounded-md' ,
81+ className
82+ ) }
83+ >
6884 < Icons . node className = "w-4 h-4" />
6985 < span className = "text-sm font-semibold" >
7086 Collaboration started... Please wait for the conclusion.
@@ -86,7 +102,7 @@ const MessageBubble = ({ chat, message, onSend }: MessageBubbleProps) => {
86102 ? 'bg-yellow-600/20 text-yellow-600'
87103 : message . role === 'assistant'
88104 ? 'bg-primary text-primary-foreground'
89- : 'bg-muted/20 text-muted-foreground ' ;
105+ : 'bg-primary-foreground text-primary-content ' ;
90106
91107 let avatarIcon = < Icons . node className = "w-4 h-4" /> ;
92108 if ( message . role === 'user' ) {
@@ -119,15 +135,17 @@ const MessageBubble = ({ chat, message, onSend }: MessageBubbleProps) => {
119135 </ >
120136 ) }
121137 </ div >
122- < div className = "text-muted-foreground/20 text-xs" >
138+ < div className = "text-muted-foreground text-xs" >
123139 { new Date ( message . created_at ) . toLocaleString ( ) }
124140 </ div >
125141 </ div >
126142 ) ;
127143 }
128144
129145 return (
130- < Card className = { `${ messageClass } p-1 w-full mx-auto shadow-sm max-w-4xl ` } >
146+ < Card
147+ className = { cn ( messageClass , 'p-1 w-full mx-auto shadow-sm' , className ) }
148+ >
131149 < div className = "flex items-center gap-2" >
132150 < div
133151 className = { `w-8 h-8 rounded-full text-sm flex items-center justify-center` }
@@ -180,31 +198,27 @@ const MessageBubble = ({ chat, message, onSend }: MessageBubbleProps) => {
180198interface MessageListProps {
181199 chat : any ;
182200 messages : Message [ ] ;
201+ className ?: string ;
183202 onSend : ( content : string ) => void ;
184203}
185204
186- export const MessageList = ( { chat, messages, onSend } : MessageListProps ) => {
187- if ( ! messages . length ) {
188- return (
189- < div className = "flex flex-col items-center justify-center h-full text-muted-foreground/50" >
190- < div className = "flex flex-col items-center gap-4" >
191- < Icons . node className = "w-10 h-10" />
192- < p > Let's start chatting!</ p >
193- </ div >
194- </ div >
195- ) ;
196- }
197-
205+ export const MessageList = ( {
206+ chat,
207+ messages,
208+ onSend,
209+ className,
210+ } : MessageListProps ) => {
198211 return (
199- < div className = "flex flex-col gap-1 w-full max-w-4xl mx-auto" >
212+ < >
200213 { messages . map ( ( message , index ) => (
201214 < MessageBubble
202215 key = { message . id || index }
203216 chat = { chat }
204217 message = { message }
205218 onSend = { onSend }
219+ className = { className }
206220 />
207221 ) ) }
208- </ div >
222+ </ >
209223 ) ;
210224} ;
0 commit comments