import * as React from 'react' import { RefreshCw } from 'lucide-react' import { AppDataTable, type AppDataTableColumn } from '@/components/app/AppDataTable' import { AppEmptyState } from '@/components/app/AppEmptyState' import { AppPage } from '@/components/app/AppPage' import { AppPageHeader } from '@/components/app/AppPageHeader' import { Button } from '@/components/ui/button' import { Badge } from '@/components/ui/badge' import { StatusBadge } from '@/features/ai-platform/status' import { formatDateTime } from '@/lib/format' import { listAgentRuns } from './api' import type { AgentRunSummary } from './types' export function AgentRunListPage() { const [items, setItems] = React.useState([]) const [error, setError] = React.useState('') const load = React.useCallback(async () => { try { setItems(await listAgentRuns()); setError('') } catch (reason) { setError(reason instanceof Error ? reason.message : '加载运行记录失败') } }, []) React.useEffect(() => { void load() }, [load]) const columns: AppDataTableColumn[] = [ { key: 'agent', header: 'Agent', cell: (item) =>

{item.agent_name}

{item.public_id.slice(0, 8)}…

}, { key: 'version', header: '版本', cell: (item) =>
v{item.agent_version}{item.sandbox ? 沙箱 : 正式}
}, { key: 'status', header: '状态', cell: (item) => }, { key: 'progress', header: '当前阶段', cell: (item) =>

{item.progress_message || item.current_step || '-'}

{item.current_step || '等待执行'} · {item.total_steps} 步{item.retry_count ? ` · 重试 ${item.retry_count}` : ''}

}, { key: 'usage', header: 'Token / 耗时', cell: (item) => {item.input_tokens + item.output_tokens} · {item.duration_ms} ms }, { key: 'created', header: '创建时间', cell: (item) => {formatDateTime(item.created_at)} } ] return } />}>{error ? : item.public_id} emptyTitle="暂无运行记录" emptyDescription="从 Agent 详情的测试页启动一次运行。" onRowClick={(item) => { window.location.hash = `/agent-runs/${item.public_id}` }} />} }