11import { cn } from '../lib/utils'
22import type { Message } from '../mcp/client'
33import { formatTimestamp } from '../lib/utils'
4- import { Bot , User , CheckCircle2 , Clock , AlertCircle } from 'lucide-react'
4+ import { User , CheckCircle2 , Clock , AlertCircle } from 'lucide-react'
55import { MarkdownContent } from './MarkdownContent'
66
7- type ChatMessageProps = {
7+ export interface UserMessageProps {
88 message : Message
9- isLoading ?: boolean
109}
1110
12- export function ChatMessage ( { message, isLoading } : ChatMessageProps ) {
13- const isUserMessage = message . sender === 'user'
14-
11+ export function UserMessage ( { message } : UserMessageProps ) {
1512 const statusIcons = {
1613 sending : < Clock className = "h-3 w-3 text-gray-400" /> ,
1714 sent : < CheckCircle2 className = "h-3 w-3 text-green-500" /> ,
1815 error : < AlertCircle className = "h-3 w-3 text-red-500" /> ,
1916 }
20-
2117 return (
2218 < div
2319 className = { cn (
2420 'flex w-full max-w-full gap-2 py-2 animate-in fade-in' ,
25- isUserMessage ? 'justify-end' : 'justify-start ',
21+ 'justify-end' ,
2622 ) }
2723 >
28- { ! isUserMessage && (
29- < div
30- className = { cn (
31- 'flex h-8 w-8 shrink-0 select-none items-center justify-center rounded-md bg-gray-100 text-gray-900 dark:bg-gray-800 dark:text-gray-100' ,
32- isLoading && 'animate-[pulse_1.5s_ease-in-out_infinite] opacity-80' ,
33- ) }
34- >
35- < Bot className = "h-5 w-5" />
36- </ div >
37- ) }
38-
3924 < div
4025 className = { cn (
41- 'flex flex-col space-y-1' ,
42- isUserMessage ? 'items-end' : 'items-start' ,
26+ 'flex flex-col space-y-1 items-end' ,
4327 'w-full sm:w-[85%] md:w-[75%] lg:w-[65%]' ,
4428 ) }
4529 >
@@ -52,18 +36,14 @@ export function ChatMessage({ message, isLoading }: ChatMessageProps) {
5236 < MarkdownContent content = { message . content } />
5337 </ div >
5438 </ div >
55-
5639 < div className = "flex items-center text-xs text-gray-500 dark:text-gray-400 space-x-1" >
5740 < span > { formatTimestamp ( message . timestamp ) } </ span >
58- { isUserMessage && statusIcons [ message . status ] }
41+ { statusIcons [ message . status ] }
5942 </ div >
6043 </ div >
61-
62- { isUserMessage && (
63- < div className = "flex h-8 w-8 shrink-0 select-none items-center justify-center rounded-md bg-gray-100 text-gray-900 dark:bg-gray-800 dark:text-gray-100" >
64- < User className = "h-5 w-5" />
65- </ div >
66- ) }
44+ < div className = "flex h-8 w-8 shrink-0 select-none items-center justify-center rounded-md bg-gray-100 text-gray-900 dark:bg-gray-800 dark:text-gray-100" >
45+ < User className = "h-5 w-5" />
46+ </ div >
6747 </ div >
6848 )
6949}
0 commit comments