/** * 讨论历史页面 */ import React, { useEffect, useState } from 'react' import { Table, Card, Tag, Typography, Space, Button, Modal, List, Descriptions, Progress, Empty } from 'antd' import { CheckCircleOutlined, CloseCircleOutlined, EyeOutlined, RobotOutlined } from '@ant-design/icons' import { discussionApi } from '../services/api' import type { DiscussionResult } from '../types' import dayjs from 'dayjs' const { Title, Text, Paragraph } = Typography const DiscussionHistory: React.FC = () => { const [discussions, setDiscussions] = useState([]) const [total, setTotal] = useState(0) const [loading, setLoading] = useState(false) const [detailVisible, setDetailVisible] = useState(false) const [selectedDiscussion, setSelectedDiscussion] = useState(null) const fetchDiscussions = async (page = 1, pageSize = 20) => { setLoading(true) try { const result = await discussionApi.list(undefined, pageSize) setDiscussions(result.discussions) setTotal(result.total) } catch (e) { console.error('Failed to fetch discussions:', e) } finally { setLoading(false) } } useEffect(() => { fetchDiscussions() }, []) const showDetail = (record: DiscussionResult) => { setSelectedDiscussion(record) setDetailVisible(true) } const columns = [ { title: '讨论目标', dataIndex: 'objective', key: 'objective', width: 300, ellipsis: true }, { title: '状态', dataIndex: 'consensus_reached', key: 'consensus_reached', width: 120, render: (reached: boolean, record: DiscussionResult) => ( {reached ? ( }>达成共识 ) : ( }>未达成 )} ) }, { title: '置信度', dataIndex: 'confidence', key: 'confidence', width: 120, render: (confidence: number) => ( = 0.8 ? '#52c41a' : confidence >= 0.5 ? '#faad14' : '#ff4d4f'} /> ) }, { title: '轮数', dataIndex: 'total_rounds', key: 'total_rounds', width: 80 }, { title: '消息数', dataIndex: 'total_messages', key: 'total_messages', width: 80 }, { title: '参与Agent', dataIndex: 'participating_agents', key: 'participating_agents', width: 150, render: (agents: string[]) => ( {agents.length} 个 ) }, { title: '时间', dataIndex: 'created_at', key: 'created_at', width: 180, render: (time: string) => dayjs(time).format('YYYY-MM-DD HH:mm') }, { title: '操作', key: 'actions', width: 80, render: (_: unknown, record: DiscussionResult) => ( ) } ] return (
讨论历史 `共 ${t} 条记录` }} /> {/* 详情弹窗 */} setDetailVisible(false)} footer={null} width={800} > {selectedDiscussion && (
{selectedDiscussion.objective} {selectedDiscussion.consensus_reached ? ( 达成共识 ) : ( 未达成共识 )} {selectedDiscussion.total_rounds} {selectedDiscussion.total_messages} {selectedDiscussion.end_reason || '无'} {dayjs(selectedDiscussion.created_at).format('YYYY-MM-DD HH:mm:ss')} {selectedDiscussion.completed_at ? dayjs(selectedDiscussion.completed_at).format('YYYY-MM-DD HH:mm:ss') : '进行中'} {selectedDiscussion.summary || '暂无摘要'} {selectedDiscussion.action_items.length > 0 ? ( ( {item} )} /> ) : ( )} {selectedDiscussion.unresolved_issues.length > 0 ? ( ( {item} )} /> ) : ( )} {Object.entries(selectedDiscussion.agent_contributions).map(([agentId, count]) => ( }> {agentId}: {count}条消息 ))}
)}
) } export default DiscussionHistory