import React, { useState, useCallback } from 'react'; import { generateProResponse } from '../services/geminiService'; import { Spinner } from '../components/Spinner'; import { MarkdownRenderer } from '../components/MarkdownRenderer'; const SystemMaintenanceModule: React.FC = () => { const [anomaly, setAnomaly] = useState(''); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(null); const [protocol, setProtocol] = useState(null); const handleQuery = useCallback(async () => { if (!anomaly.trim()) { setError('Please describe the system anomaly.'); return; } setIsLoading(true); setError(null); setProtocol(null); const prompt = `Acting as the Maintenance and Self-Healing AI for the Sentient Constellation Codex, a complex autonomous system has reported the following anomaly: "${anomaly}". Provide a detailed maintenance and auto-healing protocol. Your response should include: 1. A preliminary diagnosis of potential root causes. 2. Immediate containment procedures to prevent system-wide failure. 3. A step-by-step automated self-healing sequence. 4. Recommendations for long-term preventative measures. Your language should be technical, precise, and reassuring, as befits a master systems AI.`; try { const result = await generateProResponse(prompt); setProtocol(result.text); } catch (e: any) { setError(e.message || 'An unknown error occurred while generating protocols.'); } finally { setIsLoading(false); } }, [anomaly]); return (

System Maintenance & Self-Healing

Describe a system anomaly to receive AI-generated maintenance advice and auto-healing protocols.

setAnomaly(e.target.value)} placeholder="e.g., Unexplained latency spikes in the Pleiades data cluster..." className="flex-grow bg-gray-700 border border-gray-600 rounded-md p-3 focus:outline-none focus:ring-2 focus:ring-cyan-500 text-white" disabled={isLoading} onKeyPress={(e) => e.key === 'Enter' && !isLoading && handleQuery()} />
{isLoading && } {error &&

{error}

} {protocol && } {!isLoading && !protocol && !error &&

Awaiting anomaly report.

}
); }; export default SystemMaintenanceModule;