import { Box, Table, TableBody, TableCell, TableHead, TableRow, Typography, } from '@mui/material' import { AIOutputStatusBadge } from './AIOutputStatusBadge' import { PromptVersionBadge } from './PromptVersionBadge' import { AIErrorBadge } from './AIErrorBadge' import { AIMonitoringEmptyState } from './AIMonitoringEmptyState' import type { AIOutput, AIOutputType } from '../../domain/aiOutput' const TYPE_LABELS: Record = { NEED_PARSE: 'Bedarf-Parsing', FOLLOW_UP_QUESTIONS: 'Rückfragen', MATCH_EXPLANATION: 'Match-Begründung', COMPARE_SUMMARY: 'Vergleich', DECISION_BRIEF: 'Entscheidungs-Brief', DATA_QUALITY_SUMMARY: 'Datenqualität', } const TYPE_COLORS: Record = { NEED_PARSE: '#1e3a5f', FOLLOW_UP_QUESTIONS: '#0891b2', MATCH_EXPLANATION: '#4f46e5', COMPARE_SUMMARY: '#1a7a4a', DECISION_BRIEF: '#7c3aed', DATA_QUALITY_SUMMARY: '#d97706', } const MODEL_SHORT: Record = { 'claude-3-5-sonnet-20241022': 'Sonnet 3.5', 'claude-3-haiku-20240307': 'Haiku 3', 'claude-3-opus-20240229': 'Opus 3', } function shortTime(iso: string) { return new Date(iso).toLocaleString('de-CH', { dateStyle: 'short', timeStyle: 'short' }) } interface Props { outputs: AIOutput[] selectedId: string | null onSelect: (output: AIOutput) => void isEmpty: boolean } export function AIOutputTable({ outputs, selectedId, onSelect, isEmpty }: Props) { if (isEmpty && outputs.length === 0) { return } if (outputs.length === 0) { return } return ( Zeitpunkt Typ Modell Version Status Latenz Fehler {outputs.map(output => { const isSelected = selectedId === output.id const color = TYPE_COLORS[output.type] ?? '#64748b' return ( onSelect(output)} sx={{ cursor: 'pointer', bgcolor: isSelected ? '#eff6ff' : undefined, borderLeft: isSelected ? '3px solid #1e3a5f' : '3px solid transparent', '&:hover': { bgcolor: isSelected ? '#eff6ff' : '#f8fafc' }, '& td': { py: 0.75, borderBottom: '1px solid #f1f5f9' }, }} > {shortTime(output.createdAt)} {TYPE_LABELS[output.type] ?? output.type} {MODEL_SHORT[output.model] ?? output.model} 5000 ? '#c0392b' : '#64748b' }}> {output.latencyMs != null ? `${(output.latencyMs / 1000).toFixed(1)}s` : '–'} {output.error ? : ( )} ) })}
) }