import React, { useState, useEffect } from 'react'; import { Box, Text } from 'ink'; import { MonitorState, NexusAlert } from './types.js'; interface NexusAlertsProps { alerts: NexusAlert[]; } export function NexusAlerts({ alerts }: NexusAlertsProps) { const [isVisible, setIsVisible] = useState(true); // Blinking effect for CRITICAL alerts useEffect(() => { const hasCritical = alerts.some(a => a.severity === 'CRITICAL'); if (!hasCritical) { setIsVisible(true); return; } const interval = setInterval(() => { setIsVisible(v => !v); }, 800); return () => clearInterval(interval); }, [alerts]); if (!alerts || alerts.length === 0) return null; const topAlert = alerts[0]; const isCritical = topAlert.severity === 'CRITICAL'; const color = isCritical ? 'red' : 'yellow'; return ( {isCritical ? ' ☢ NEXUS BREACH ☢ ' : ' ⚡ NEXUS ALERT ⚡ '} {topAlert.title.toUpperCase()} Hive Signal: {topAlert.message.substring(0, 100)}... ); }