import React, { useEffect, useState, useRef } from 'react'; import { Terminal, Database, Cpu, Activity, Server, RadioTower } from 'lucide-react'; const BOOT_LOGS = [ "[SYS] Initializing DRC-Env v3 Protocol...", "[WARN] GPU Acceleration enabled. PyTorch weights loaded.", "[NET] Establishing secure connection to Groq Inference nodes...", "[MEM] Allocating 4096MB VRAM for MAPPO Training Matrix.", "[DB] Restoring cached topological graphs for Zone routing.", "[SYS] Anti-Hallucination Validator online.", "[OK] System ready. Awaiting telemetry." ]; const LIVE_LOG_TEMPLATES = [ "[NET] Incoming ping from Node {node}. Latency: {lat}ms.", "[INF] Recalculating casualty vectors for grid {gridId}...", "[SYS] Memory pool garbage collection triggered. Freed {mem}MB.", "[SEC] Rejecting unauthorized payload from edge device.", "[AI] Greedy Heuristic cache hit. Serving cached action.", "[AI] Overriding wait penalty at grid {gridId} due to severity spike.", "[DB] Syncing step {step} to persistent storage.", "[WARN] High resource contention detected on route alpha-9.", "[NET] Packet loss detected on satellite downlink. Retrying...", "[OK] Data block {block} verified and committed." ]; export function SystemLogsTab() { const [logs, setLogs] = useState([]); const scrollRef = useRef(null); useEffect(() => { // Run boot sequence let bootIndex = 0; const bootInterval = setInterval(() => { if (bootIndex < BOOT_LOGS.length) { setLogs(prev => [...prev, `${new Date().toISOString()} ${BOOT_LOGS[bootIndex]}`]); bootIndex++; } else { clearInterval(bootInterval); } }, 300); return () => clearInterval(bootInterval); }, []); useEffect(() => { // Run live faux logs after 3 seconds const liveInterval = setInterval(() => { const template = LIVE_LOG_TEMPLATES[Math.floor(Math.random() * LIVE_LOG_TEMPLATES.length)]; const logLine = template .replace('{node}', `0x${Math.floor(Math.random()*16777215).toString(16).toUpperCase()}`) .replace('{lat}', Math.floor(Math.random() * 80).toString()) .replace('{gridId}', ["A","B","C","D","E"][Math.floor(Math.random()*5)]) .replace('{mem}', Math.floor(Math.random() * 50).toString()) .replace('{step}', Math.floor(Math.random() * 1000).toString()) .replace('{block}', `BLK-${Math.floor(Math.random() * 9999)}`); setLogs(prev => [...prev, `${new Date().toISOString()} ${logLine}`].slice(-100)); // Keep last 100 }, Math.random() * 2000 + 1000); // Random interval between 1s and 3s return () => clearInterval(liveInterval); }, []); useEffect(() => { if (scrollRef.current) { scrollRef.current.scrollTop = scrollRef.current.scrollHeight; } }, [logs]); return (
{/* Left Side: Terminal */}

Server Instance: Prod-01

Listening port 8001
{/* Scanlines */}
{logs.map((log, i) => { let color = "text-zinc-400"; if (log.includes("[WARN]")) color = "text-amber-400 font-bold"; else if (log.includes("[OK]")) color = "text-emerald-400 font-bold drop-shadow-[0_0_3px_rgba(52,211,153,0.5)]"; else if (log.includes("[SEC]")) color = "text-red-500 font-bold drop-shadow-[0_0_3px_rgba(239,68,68,0.5)]"; else if (log.includes("[AI]")) color = "text-cyan-400 dropdown-shadow-[0_0_3px_rgba(34,211,238,0.5)]"; // Highlight timestamp const splitLog = log.split('] '); const timePart = splitLog[0] + ']'; const msgPart = splitLog.slice(1).join('] '); return (
{timePart.substring(0, 24)} {timePart.substring(25)} {msgPart}
); })}
{/* Right Side: Server Vitals */}

System Vitals

CPU Usage 14%
Memory (VRAM) 4.2 / 8 GB
Network I/O 128 Kbps
Redis Cache ONLINE
SSE Stream ACTIVE
); }