import { Button, Dropdown, Space, Tag, Tooltip, Avatar } from 'antd'; import type { BranchInfo, ChatMessage } from '../../../../api'; import type { Agent } from '../../../../api/agents'; import Markdown from '../../../../components/Markdown'; import { ProductCopyIcon } from '../../../../components/icons'; import type { CopyMode } from '../../utils/copy'; import { ReasoningView, RetrievedView, ToolCallView } from './MetaViews'; export default function MessageItem(props: { message: ChatMessage; agentList: Agent[]; currentAgentId: string; highlighted?: boolean; branch?: BranchInfo; busy?: boolean; onRegenerate?: (id: string) => void; onSwitchBranch?: (userMsgId: string, branchId: string) => void; onCopy?: (text: string, mode: CopyMode) => void; }) { const { message, agentList, currentAgentId, highlighted, branch, busy, onRegenerate, onSwitchBranch, onCopy } = props; // 获取回答者 Agent 信息 const answerAgentId = message.agent_id || (message.role === 'assistant' ? currentAgentId : undefined); const answerAgent = answerAgentId ? agentList.find(a => a.id === answerAgentId) : undefined; const hasBranches = !!branch && branch.total > 1; const activeIdx = branch?.activeIndex ?? 0; const total = branch?.total ?? 1; const goPrev = () => { if (!branch || !message.parentId) return; const i = Math.max(0, activeIdx - 1); onSwitchBranch?.(message.parentId, branch.ids[i]); }; const goNext = () => { if (!branch || !message.parentId) return; const i = Math.min(total - 1, activeIdx + 1); onSwitchBranch?.(message.parentId, branch.ids[i]); }; return (