import type { ReactNode } from 'react' import { RobotOutlined, UserOutlined, WarningOutlined } from '@ant-design/icons' import { colors } from '../tokens' interface ChatBubbleProps { role: 'user' | 'agent' | 'system' content: ReactNode meta?: ReactNode pending?: boolean /** 镜像布局:探索下钻里虚拟用户居左、被评对象居右(与常规聊天相反) */ mirrored?: boolean } export default function ChatBubble({ role, content, meta, pending, mirrored }: ChatBubbleProps) { const isUser = role === 'user' const isAgent = role === 'agent' const isSystem = role === 'system' const bg = isUser ? colors.chatUser : isAgent ? colors.chatAgent : colors.chatSystemError const border = isSystem ? '#ffccc7' : 'transparent' const textColor = isSystem ? '#cf1322' : colors.text const alignRight = isSystem ? false : isUser ? !mirrored : !!mirrored const align = alignRight ? 'flex-end' : 'flex-start' const radius = alignRight ? '10px 10px 2px 10px' : '10px 10px 10px 2px' const icon = isUser ? : isAgent ? : const label = isUser ? '用户' : isAgent ? '智能体' : '系统' return (
{!isUser && icon} {label} {isUser && icon} {meta}
{pending ? : content}
) } function TypingDots() { return ( ) }