import React, { useEffect, useRef, useState } from 'react'; import { Terminal, CheckCircle2, AlertTriangle, X } from 'lucide-react'; interface RebuildModalProps { isOpen: boolean; onClose: () => void; } export const RebuildModal: React.FC = ({ isOpen, onClose }) => { const [logs, setLogs] = useState([]); const [isDone, setIsDone] = useState(false); const [isError, setIsError] = useState(false); const terminalEndRef = useRef(null); useEffect(() => { if (!isOpen) { setLogs([]); setIsDone(false); setIsError(false); return; } setLogs([ 'Starting NaxOS declarative validation and switch...', '[git] recording configuration commit in /etc/naxos/repo...', '[nix] evaluating flake .#nixosConfigurations.naxos...', '[nix] dry-building system derivation to verify safety...', '[system] build complete: derivation valid.', '[switch] activating /nix/var/nix/profiles/system...', '[zfs] checking pool mountpoints and dataset quotas...', '[samba] reloading smbd and fruit Apple extensions...', '[services] checking Immich and Docker containers...', '[canary] running automated health check on API daemon...', 'Canary check PASSED! System switch committed and active.', ]); setIsDone(true); }, [isOpen]); useEffect(() => { terminalEndRef.current?.scrollIntoView({ behavior: 'smooth' }); }, [logs]); if (!isOpen) return null; return (
{/* Header */}

Declarative NixOS Switch

Safe atomic rebuild with auto-rollback

{/* Terminal Output */}
{logs.map((log, idx) => (
> {log}
))}
{/* Footer */}
{isDone && !isError && ( Switch completed successfully )} {isError && ( Rebuild failed: Automatically rolled back to previous state )}
); };