import { UIMessage as VercelMessage } from '@ai-sdk/react' import { type PropsWithChildren } from 'react' import { cn } from 'ui' import { useMessageInfoContext } from './Message.Context' import { MessagePartSwitcher } from './Message.Parts' import { MessageMarkdown } from './MessageMarkdown' import { ProfileImage as ProfileImageDisplay } from '@/components/ui/ProfileImage' import { useProfileNameAndPicture } from '@/lib/profile' function MessageDisplayProfileImage() { const { username, avatarUrl } = useProfileNameAndPicture() return ( ) } function MessageDisplayContainer({ children, onClick, className, }: PropsWithChildren<{ onClick?: () => void; className?: string }>) { return (
{children}
) } function MessageDisplayMainArea({ children, className, }: PropsWithChildren<{ className?: string }>) { return
{children}
} function MessageDisplayContent({ message }: { message: VercelMessage }) { const { id, isLoading, readOnly } = useMessageInfoContext() const messageParts = message.parts const content = ('content' in message && typeof message.content === 'string' && message.content.trim()) || undefined return (
{messageParts?.length > 0 ? messageParts.map((part: NonNullable, idx) => { const isLastPart = idx === messageParts.length - 1 return }) : content && ( {content} )}
) } function MessageDisplayTextMessage({ id, isLoading, readOnly, children, }: PropsWithChildren<{ id: string; isLoading: boolean; readOnly?: boolean }>) { return ( {children} ) } export const MessageDisplay = { Container: MessageDisplayContainer, Content: MessageDisplayContent, MainArea: MessageDisplayMainArea, ProfileImage: MessageDisplayProfileImage, }