import { useState } from "react"; import { PROMPTS, THEME } from "../constants"; interface LiveCaptionProps { caption: string; isRunning?: boolean; error?: string | null; history: HistoryEntry[]; stats?: { tps?: number; ttft?: number }; } export interface HistoryEntry { timestamp: string; text: string; } export default function LiveCaption({ caption, isRunning, error, history, stats, }: LiveCaptionProps) { const [showHistory, setShowHistory] = useState(false); const content = error || caption; const status = error ? { bg: "bg-[var(--mistral-red)]/10", border: "border-[var(--mistral-red)]", text: "text-[var(--mistral-red)]", dot: "bg-[var(--mistral-red)]", label: "SYSTEM ERROR", } : isRunning ? { bg: "bg-[var(--mistral-orange)]/5", border: "border-[var(--mistral-orange)]", text: "text-[var(--mistral-orange)]", dot: "bg-[var(--mistral-orange)]", label: "LIVE INFERENCE", } : { bg: "bg-gray-50", border: "border-[var(--mistral-beige-dark)]", text: "text-gray-500", dot: "bg-gray-400", label: "STANDBY", }; return ( <>
Output Stream
{/* View History Button */} {/* Status Badge */}
{isRunning && ( )}
{status.label}
{/* Main Content Area */}
{/* Background Grid Pattern */}
{showHistory ? (
{history.length === 0 ? (

No history recorded yet.

) : (
{history.map((entry, idx) => (
[{entry.timestamp}] {entry.text}
))}
)}
) : (
{content ? (

{content} {/* Blinking Block Cursor */} {!error && isRunning && ( )}

) : (
{isRunning ? ( <>

{PROMPTS.processingMessage}

) : (

// Awaiting visual input...
// Model ready.

)}
)}
)}
{/* Footer Metadata */}
ttft:{" "} {stats?.ttft ? `${stats.ttft.toFixed(0)}ms` : isRunning ? "..." : "0ms"} tokens/sec:{" "} {stats?.tps ? stats.tps.toFixed(2) : isRunning ? "..." : "0"}
ctx: 3.3B-Instruct
); }