"use client" import { useEffect, useState } from 'react' import ConfigurationPanel from './ConfigurationPanel' import SandboxInferencePanel from './SandboxInferencePanel' import type { NemoClawSummary, SandboxInventoryItem } from '../hooks/useSandboxInventory' import { buildOperatorTerminalRoute } from '../lib/dashboardSession' interface TelemetryData { cpu: number memory: number disk: number gpuMemoryUsed?: number gpuMemoryTotal?: number gpuTemperature?: number timestamp: string } interface SandboxListProps { sandboxes: SandboxInventoryItem[] nemoclaw: NemoClawSummary | null dashboardSessionId: string selectedSandboxId: string | null selectedSandbox: SandboxInventoryItem | null onSandboxSelect: (id: string | null) => void isDestroyMode: boolean onInventoryRefresh: () => Promise } function renderDashboardTruthMessage(data: any) { if (data.reachable) return 'OpenClaw dashboard opened in a new tab.' return 'OpenClaw dashboard is not reachable from this host right now.' } function openDashboardUrl(url: string, openInNewTab: boolean) { if (openInNewTab) { window.open(url, '_blank', 'noopener,noreferrer') } else { window.location.href = url } } export default function SandboxList({ sandboxes, nemoclaw: _nemoclaw, dashboardSessionId, selectedSandboxId, selectedSandbox, onSandboxSelect, isDestroyMode, onInventoryRefresh, }: SandboxListProps) { const [terminalMessage, setTerminalMessage] = useState('') const [dashboardMessage, setDashboardMessage] = useState('') const [restartInProgress, setRestartInProgress] = useState(false) const [telemetry, setTelemetry] = useState({ cpu: 0, memory: 0, disk: 0, timestamp: new Date().toISOString() }) useEffect(() => { if (selectedSandboxId) { fetchTelemetry() const interval = setInterval(fetchTelemetry, 5000) return () => clearInterval(interval) } }, [selectedSandboxId]) const fetchTelemetry = async () => { try { const response = await fetch('/api/telemetry/combined') const data = await response.json() setTelemetry(data) } catch (error) { console.error('Error fetching telemetry:', error) } } const restartSandbox = async () => { if (!selectedSandbox || restartInProgress) return try { setRestartInProgress(true) setDashboardMessage(`Restarting sandbox ${selectedSandbox.name}...`) const response = await fetch(`/api/sandbox/${encodeURIComponent(selectedSandbox.id)}/restart`, { method: 'POST', }) const data = await response.json() if (!response.ok) throw new Error(data.error || data.note || 'Failed to restart sandbox') setDashboardMessage(data.note || `Sandbox ${selectedSandbox.name} restarted.`) await onInventoryRefresh() } catch (error) { setDashboardMessage(error instanceof Error ? error.message : 'Failed to restart sandbox.') } finally { setRestartInProgress(false) } } return (
{sandboxes.length === 0 ? (

No Sandboxes Detected

No live OpenShell sandboxes reported yet

) : ( <>

{isDestroyMode ? 'SELECT SANDBOX TO DESTROY' : 'ACTIVE SANDBOXES'}

REFRESH: 10s
{sandboxes.map((sandbox) => ( ))}
{!isDestroyMode && selectedSandbox && ( <>

{selectedSandbox.name} — TELEMETRY

LIVE
{(dashboardMessage || terminalMessage) && (
{dashboardMessage &&
{dashboardMessage}
} {terminalMessage &&
{terminalMessage}
}
)}

CPU

{telemetry.cpu.toFixed(1)}%

MEM

{telemetry.memory.toFixed(1)}%

DISK

{telemetry.disk.toFixed(1)}%

UPDATED

{new Date(telemetry.timestamp).toLocaleTimeString()}

)} )}
) }