/** * SetupTab/CortexRuntimeInstallCard.tsx — operator-run install guide card * (ENC-2a). * * Pure render. When `SetupStatusResponse.nativeOrtInstallGuide` is non-null * (opt-in on, effective runtime still wasm, platform installable), this card * surfaces the three copy-paste steps the operator runs OUTSIDE the dashboard: * install onnxruntime-node, restart via pi, and the expected next status. When * the guide is null the card hides entirely (the modifiers card already * surfaces the honest ENC-0g state). * * NO client-side execution — the install script is never spawned from here. * Data comes exclusively from the existing /api/setup-status poll. */ import type React from "react"; import { useState, useCallback, useEffect } from "react"; import type { SetupStatusResponse } from "@contracts"; import { fetchSetupStatus } from "../../api/client"; import { styles } from "./CortexSetupStyles"; function useCopyState(): [boolean, (text: string) => Promise] { const [copied, setCopied] = useState(false); const copy = useCallback(async (text: string) => { try { await navigator.clipboard.writeText(text); setCopied(true); window.setTimeout(() => setCopied(false), 1500); } catch { setCopied(false); } }, []); return [copied, copy]; } export default function CortexRuntimeInstallCard(): React.ReactElement { const [status, setStatus] = useState(null); const [copied, copy] = useCopyState(); const loadStatus = useCallback(() => { fetchSetupStatus() .then(setStatus) .catch(() => { /* best-effort poll; hide card when unavailable */ }); }, []); useEffect(() => { loadStatus(); const id = setInterval(loadStatus, 5000); return () => clearInterval(id); }, [loadStatus]); const guide = status?.nativeOrtInstallGuide ?? null; const installedVersion = status?.nativeOrtInstalledVersion ?? null; if (!guide) return <>; return (

Encoder Runtime Install

Platform: {guide.platform}

{installedVersion !== null && (
Detected: {installedVersion}
)} {guide.commands.map((command, i) => (
Step {i + 1}: {command}
))}

Script:{" "} {guide.scriptPath}

{copied && (

Copied to clipboard

)}
); }