diff --git a/src/components/layout/AgentMonitor.tsx b/src/components/layout/AgentMonitor.tsx index d228ca8..e2b3e1a 100644 --- a/src/components/layout/AgentMonitor.tsx +++ b/src/components/layout/AgentMonitor.tsx @@ -1,9 +1,11 @@ /** * AgentMonitor — Agent 状态指示器 + * + * 完全使用 MUI 组件,Table 布局标签-值对。 */ -import { Box, Typography, Stack } from '@mui/material'; -import { Activity, Cpu, Clock } from 'lucide-react'; +import { Box, Typography, Stack, Table, TableBody, TableRow, TableCell, Chip } from '@mui/material'; +import { Activity, Cpu } from 'lucide-react'; import { useEffect } from 'react'; import { useAgentStore, type AgentStatus } from '@renderer/stores/agent-store'; import { AGENT_STATUS_COLORS, AGENT_STATUS_LABELS, PROVIDER_LABELS } from '@renderer/lib/constants'; @@ -20,7 +22,6 @@ export function AgentMonitor(): React.JSX.Element { const traceSteps = useAgentStore((s) => s.traceSteps); const setMaxIterations = useAgentStore((s) => s.setMaxIterations); - // 启动时从数据库读取 maxIterations useEffect(() => { if (window.metona?.config?.get) { window.metona.config.get('agent.maxIterations').then((v) => { @@ -29,47 +30,68 @@ export function AgentMonitor(): React.JSX.Element { } }, [setMaxIterations]); - // 监听配置变更 - useEffect(() => { - const interval = setInterval(() => { - if (window.metona?.config?.get) { - window.metona.config.get('agent.maxIterations').then((v) => { - if (typeof v === 'number' && v > 0) setMaxIterations(v); - }).catch(() => {}); - } - }, 3000); - return () => clearInterval(interval); - }, [setMaxIterations]); const StatusIcon = STATUS_ICONS[agentStatus]; const statusColor = AGENT_STATUS_COLORS[agentStatus]; const statusLabel = AGENT_STATUS_LABELS[agentStatus]; const totalDuration = traceSteps.reduce((sum, s) => sum + (s.completedAt ? s.completedAt - s.startedAt : 0), 0); - const InfoRow = ({ icon: Icon, label, value }: { icon: typeof Activity; label: string; value: string }) => ( - - - {label} - - {value} - - ); - return ( - Agent 状态 - - - - {statusLabel} - - - - - - {totalDuration > 0 && } + + Agent 状态 + + + {/* 状态指示 */} + + + + {statusLabel} + {(agentStatus === 'thinking' || agentStatus === 'executing') && ( + + )} + + + + {/* 详情表格 */} + + + + Provider + + {PROVIDER_LABELS[provider] ?? provider} + + + + 模型 + + {model} + + + + 迭代 + + {currentIteration} / {maxIterations} + + + {totalDuration > 0 && ( + + 总耗时 + + {formatDuration(totalDuration)} + + + )} + +
); }