'use client' import { useState } from 'react' import { cn } from '@/lib/utils' interface RawEntry { id: number ts: string call_type: string direction: string provider?: string model?: string content?: string title?: string site?: string tokens_prompt?: number tokens_completion?: number verdict?: string status_code?: number } export default function AILogCard({ entry }: { entry: RawEntry }) { const [expanded, setExpanded] = useState(false) const isRequest = entry.direction === 'request' const isResponse = entry.direction === 'response' const isError = entry.direction === 'error' const isMatch = entry.verdict === 'YES' const isReject = entry.verdict === 'NO' const totalTokens = (entry.tokens_prompt ?? 0) + (entry.tokens_completion ?? 0) return (
{/* Header */}
{/* Direction badge */} {isRequest ? '→ Prompt' : isResponse ? '← Response' : '⚠ Error'} {entry.call_type} {entry.provider && {entry.provider}} {entry.model && ( {entry.model} )}
{new Date(entry.ts).toLocaleTimeString()}
{/* Lot info */} {(entry.title || entry.site) && (
{entry.title && ( {entry.title.length > 72 ? entry.title.slice(0, 72) + '…' : entry.title} )} {entry.site && · {entry.site}}
)} {/* Verdict */} {isResponse && entry.verdict && (
{isMatch ? 'Match — lot accepted' : 'Reject — lot filtered out'}
)} {/* Expandable content */} {entry.content && (
            {entry.content}
          
{entry.content.length > 180 && ( )}
)} {/* Token counts */} {(entry.tokens_prompt != null || entry.tokens_completion != null) && (
{entry.tokens_prompt ?? '?'} + {entry.tokens_completion ?? '?'} = {totalTokens} tokens
)} {/* Error */} {isError && entry.status_code && (
HTTP {entry.status_code}
)}
) }