import { ColumnDef } from '@tanstack/react-table' import type { ProcessedTrial } from '../types/metrics' import { DataTable } from '@/components/ui/data-table' import { Badge } from '@/components/ui/badge' interface TrialsDataTableProps { trials: ProcessedTrial[] onTrialSelect: (trial: ProcessedTrial) => void } const statusVariant: Record = { pass: 'success', fail: 'destructive', error: 'error', timeout: 'warning', } const columns: ColumnDef[] = [ { accessorKey: 'status', header: 'Status', cell: ({ row }) => { const status = row.getValue('status') as string return ( {status} ) }, enableGrouping: true, }, { accessorKey: 'taskName', header: 'Task', cell: ({ row }) => ( {row.getValue('taskName')} ), enableGrouping: true, }, { accessorKey: 'agent', header: 'Agent', enableGrouping: true, }, { accessorKey: 'model', header: 'Model', enableGrouping: true, }, { accessorKey: 'reward', header: 'Reward', cell: ({ row }) => { const reward = row.getValue('reward') as number | null if (reward === null) return — return ( {reward.toFixed(2)} ) }, }, { accessorKey: 'costUsd', header: 'Cost', cell: ({ row }) => { const cost = row.getValue('costUsd') as number | null if (cost === null) return — return `$${cost.toFixed(4)}` }, }, { accessorKey: 'durationMs', header: 'Duration', cell: ({ row }) => { const ms = row.getValue('durationMs') as number if (ms < 1000) return `${ms}ms` if (ms < 60000) return `${(ms / 1000).toFixed(1)}s` return `${Math.floor(ms / 60000)}m ${Math.floor((ms % 60000) / 1000)}s` }, }, { accessorKey: 'inputTokens', header: 'Input Tokens', cell: ({ row }) => { const tokens = row.getValue('inputTokens') as number | null if (tokens === null) return — return tokens.toLocaleString() }, }, { accessorKey: 'outputTokens', header: 'Output Tokens', cell: ({ row }) => { const tokens = row.getValue('outputTokens') as number | null if (tokens === null) return — return tokens.toLocaleString() }, }, { accessorKey: 'jobName', header: 'Job', enableGrouping: true, }, { accessorKey: 'exceptionInfo', header: 'Error', cell: ({ row }) => { const exception = row.original.exceptionInfo if (!exception) return null return ( {exception.exception_type} ) }, }, ] export function TrialsDataTable({ trials, onTrialSelect }: TrialsDataTableProps) { return ( ) }