"use client" import { useEffect, useState } from 'react' import ConfigurationPanel from './ConfigurationPanel' 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) { const listenerSummary = data.listenerSummary ? `\nListener: ${data.listenerSummary}` : '' const showUpstreamSummary = !data.reachable || data.degraded || data.truthState !== 'verified' const upstreamSummary = showUpstreamSummary && (data.upstreamStatus || data.upstreamStatusText) ? `\nUpstream probe: ${data.upstreamStatus ?? 'no-status'} ${data.upstreamStatusText ?? ''}`.trimEnd() : '' const inventorySummary = typeof data.inventoryCount === 'number' ? `Inventory visibility: ${data.inventoryCount} live sandbox${data.inventoryCount === 1 ? '' : 'es'}.` : 'Inventory visibility: unknown.' const mappingSummary = data.sandboxId ? (data.authority?.usedMappedSandboxInstance ? `Sandbox ${data.sandboxId} resolved to OpenClaw instance ${data.instanceId} via bridge mapping (fallback-active).` : `Sandbox ${data.sandboxId} resolved to OpenClaw instance ${data.instanceId}.`) : `OpenClaw instance: ${data.instanceId}.` const reachabilitySummary = data.reachable ? `Dashboard reachability: reachable at ${data.dashboardUrl}.` : `Dashboard reachability: unreachable at ${data.dashboardUrl}.` if (data.degraded) { return `${inventorySummary} ${mappingSummary} ${reachabilitySummary} Degraded truth: the dashboard is reachable, but live OpenShell inventory is zero, so mapping alone does not prove the sandbox currently exists.${listenerSummary}${upstreamSummary}` } if (data.reachable) { return `${inventorySummary} ${mappingSummary} ${data.note || reachabilitySummary}`.trim() } return `${inventorySummary} ${mappingSummary} ${data.note || `OpenClaw Dashboard at ${data.dashboardUrl} is currently unreachable from this host.`}${listenerSummary}${upstreamSummary}` } export default function SandboxList({ sandboxes, nemoclaw, dashboardSessionId, selectedSandboxId, selectedSandbox, onSandboxSelect, isDestroyMode, onInventoryRefresh, }: SandboxListProps) { const [terminalMessage, setTerminalMessage] = useState('') const [dashboardMessage, setDashboardMessage] = useState('') 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) } } return (
{sandboxes.length === 0 ? (

No Sandboxes Detected

No live OpenShell sandboxes reported yet

) : ( <>

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

REFRESH: 10s
{!isDestroyMode && (

Inventory Source

Live OpenShell gateway inventory

NemoClaw Operator Surface

{nemoclaw?.available ? 'Local registry + services' : 'Unavailable'}

Inventory visibility: {sandboxes.length} live sandbox{sandboxes.length === 1 ? '' : 'es'}
Mapping truth: intent only, not proof of sandbox existence
{sandboxes.length === 0 ? 'Truth state: degraded / unverified' : 'Truth state: verified from live inventory'}

Dashboard session: {dashboardSessionId.slice(0, 8)}

{nemoclaw?.defaultSandboxNames?.length ? (

Default sandbox marker: {nemoclaw.defaultSandboxNames.join(', ')}

) : null} {nemoclaw?.serviceLines?.length ? (
{nemoclaw.serviceLines.slice(0, 4).map((line) => (
{line}
))}
) : null}
)}
{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()}

)} )}
) }