import { Box, Stack, Typography, IconButton, Tooltip } from '@mui/material'; import CloseIcon from '@mui/icons-material/Close'; import type { UIMessage } from 'ai'; import type { MessageMeta } from '@/types/agent'; interface UserMessageProps { message: UIMessage; isLastTurn?: boolean; onUndoTurn?: () => void; isProcessing?: boolean; } function extractText(message: UIMessage): string { return message.parts .filter((p): p is Extract => p.type === 'text') .map(p => p.text) .join(''); } export default function UserMessage({ message, isLastTurn = false, onUndoTurn, isProcessing = false, }: UserMessageProps) { const showUndo = isLastTurn && !isProcessing && !!onUndoTurn; const text = extractText(message); const meta = message.metadata as MessageMeta | undefined; const timeStr = meta?.createdAt ? new Date(meta.createdAt).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }) : null; return ( {showUndo && ( )} {text} {timeStr && ( {timeStr} )} ); }