Clean up OpenShell control UI

This commit is contained in:
Codex
2026-04-24 15:41:05 +00:00
parent a5eca0d188
commit b0e4d8fc4c
8 changed files with 136 additions and 436 deletions
+13 -10
View File
@@ -130,16 +130,14 @@ export default function ConfigurationPanel({ sandboxId, mode = 'existing', onCre
if (!sandboxName.trim()) throw new Error('sandbox name is required')
const res = await fetch('/api/sandbox/create', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ blueprint: selectedBlueprint, sandboxName: sandboxName.trim(), enableTailscale, policy: assembledPolicy, preset: selectedPreset || null }) })
const data = await res.json()
if (!res.ok) throw new Error([data.error, data.verification?.summary, data.verification?.error, data.gatewayReusePolicy, data.stdout, data.stderr].filter(Boolean).join('\n\n'))
if (!res.ok) throw new Error([data.error, data.verification?.summary, data.verification?.error, data.stdout, data.stderr].filter(Boolean).join('\n\n'))
const createdSandboxId = data.verification?.details?.id || data.verification?.details?.name || data.sandboxName
if (onInventoryRefresh) {
await onInventoryRefresh()
}
setMessage([
`Sandbox '${data.sandboxName}' created via ${data.mode}.${data.enableTailscale ? ' Tailscale-enabled path requested.' : ' Tailscale disabled.'}`,
`Sandbox '${data.sandboxName}' created.`,
data.verification?.summary,
data.gatewayReusePolicy,
'Inventory refresh requested immediately.',
].filter(Boolean).join('\n\n'))
if (createdSandboxId && onCreateSuccess) {
await onCreateSuccess(createdSandboxId)
@@ -159,16 +157,21 @@ export default function ConfigurationPanel({ sandboxId, mode = 'existing', onCre
return (
<div className="panel p-6 mt-6 border-t-2 border-[var(--nvidia-green)]">
<div className="flex items-center justify-between mb-6 pb-4 border-b border-[var(--border-subtle)]"><h4 className="text-sm font-semibold text-[var(--foreground)] uppercase tracking-wider">{mode === 'create' ? 'CREATE SANDBOX WORKFLOW' : `${sandboxId} — OPENSHELL POLICY`}</h4><div className="flex gap-2"><Badge tone="static">Static / Recreate Required</Badge><Badge tone="dynamic">Dynamic / Apply Live</Badge></div></div>
<div className="flex items-center justify-between mb-6 pb-4 border-b border-[var(--border-subtle)]">
<h4 className="text-sm font-semibold text-[var(--foreground)] uppercase tracking-wider">
{mode === 'create' ? 'New Sandbox' : `${sandboxId} — OpenShell Policy`}
</h4>
<button onClick={savePolicy} disabled={saving} className="px-4 py-2 rounded-sm bg-[var(--nvidia-green)] text-white text-xs font-mono uppercase tracking-wider disabled:opacity-50">
{saving ? "Working..." : mode === 'create' ? 'Create Sandbox' : 'Save Policy'}
</button>
</div>
{loading ? <div className="text-sm text-[var(--foreground-dim)]">Loading policy…</div> : <div className="space-y-8">
{mode === 'create' && <section className="space-y-4 rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-4"><div><h5 className="text-xs uppercase tracking-wider text-[var(--foreground)]">Create Sandbox</h5><p className="text-xs text-[var(--foreground-dim)] mt-1">Choose a blueprint-backed workflow or create a custom sandbox, then provide a sandbox name.</p></div><div className="rounded-sm border border-[rgba(118,185,0,0.25)] bg-[rgba(118,185,0,0.08)] p-3 text-xs text-[var(--foreground-dim)] whitespace-pre-wrap">Gateway reuse policy:
- reuse the existing OpenShell gateway when `openshell status` reports `Connected`
- only start a fresh gateway when no healthy gateway is already connected
- force non-interactive PATH to include $HOME/.local/bin so openshell resolves during setup</div><div className="grid grid-cols-1 md:grid-cols-2 gap-4">{blueprints.map((bp) => <button key={bp.id} type="button" onClick={() => setSelectedBlueprint(bp.id)} className={`rounded-sm border p-4 text-left ${selectedBlueprint === bp.id ? 'border-[var(--nvidia-green)] bg-[rgba(118,185,0,0.08)]' : 'border-[var(--border-subtle)] bg-[var(--background)]'}`}><div className="flex items-center justify-between gap-3"><span className="text-sm font-semibold text-[var(--foreground)] uppercase tracking-wider">{bp.label}</span><Badge tone={bp.type === 'custom' ? 'static' : 'dynamic'}>{bp.type}</Badge></div><p className="text-xs text-[var(--foreground-dim)] mt-2">{bp.description}</p><p className="text-[10px] font-mono text-[var(--foreground-dim)] mt-3">{bp.source}</p></button>)}</div><div><label className="text-xs uppercase tracking-wider text-[var(--foreground-dim)]">Sandbox Name<FieldHelp text="Operator-facing sandbox name used by OpenShell create/connect flows. Lowercase letters, numbers, and hyphens only." /></label><input value={sandboxName} onChange={(e) => setSandboxName(e.target.value)} placeholder={selectedBlueprint === 'nemoclaw-blueprint' ? 'my-assistant' : 'custom-sandbox'} className="mt-2 w-full rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] px-3 py-2 text-xs font-mono text-[var(--foreground)]" /></div>{activeBlueprint?.supportsTailscale && <label className="flex items-center gap-3 text-sm text-[var(--foreground)] font-mono"><input type="checkbox" checked={enableTailscale} onChange={(e) => setEnableTailscale(e.target.checked)} /> Enable Tailscale <FieldHelp text="Optional. Only enable this when you want the Tailscale/NVIDIA-backed path. This is the only case where NVIDIA_API_KEY should be required." /></label>}{enableTailscale && <div className="rounded-sm border border-amber-500/40 bg-amber-500/10 p-3 text-sm text-amber-300">Tailscale-enabled creation requires NVIDIA_API_KEY in the dashboard process environment.</div>}</section>}
{mode === 'create' && <section className="space-y-4 rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-4"><div><h5 className="text-xs uppercase tracking-wider text-[var(--foreground)]">Create Sandbox</h5><p className="text-xs text-[var(--foreground-dim)] mt-1">Choose a template and enter a sandbox name.</p></div><div className="grid grid-cols-1 md:grid-cols-2 gap-4">{blueprints.map((bp) => <button key={bp.id} type="button" onClick={() => setSelectedBlueprint(bp.id)} className={`rounded-sm border p-4 text-left ${selectedBlueprint === bp.id ? 'border-[var(--nvidia-green)] bg-[rgba(118,185,0,0.08)]' : 'border-[var(--border-subtle)] bg-[var(--background)]'}`}><div className="flex items-center justify-between gap-3"><span className="text-sm font-semibold text-[var(--foreground)] uppercase tracking-wider">{bp.label}</span><Badge tone={bp.type === 'custom' ? 'static' : 'dynamic'}>{bp.type}</Badge></div><p className="text-xs text-[var(--foreground-dim)] mt-2">{bp.description}</p></button>)}</div><div><label className="text-xs uppercase tracking-wider text-[var(--foreground-dim)]">Sandbox Name<FieldHelp text="Lowercase letters, numbers, and hyphens only." /></label><input value={sandboxName} onChange={(e) => setSandboxName(e.target.value)} placeholder={selectedBlueprint === 'nemoclaw-blueprint' ? 'my-assistant' : 'custom-sandbox'} className="mt-2 w-full rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] px-3 py-2 text-xs font-mono text-[var(--foreground)]" /></div>{activeBlueprint?.supportsTailscale && <label className="flex items-center gap-3 text-sm text-[var(--foreground)] font-mono"><input type="checkbox" checked={enableTailscale} onChange={(e) => setEnableTailscale(e.target.checked)} /> Enable Tailscale</label>}{enableTailscale && <div className="rounded-sm border border-amber-500/40 bg-amber-500/10 p-3 text-sm text-amber-300">Tailscale-enabled creation requires NVIDIA_API_KEY in the dashboard process environment.</div>}</section>}
<section className="space-y-4"><div className="flex items-center justify-between gap-4 flex-wrap"><div><h5 className="text-xs uppercase tracking-wider text-[var(--foreground)]">Security Presets</h5><p className="text-xs text-[var(--foreground-dim)] mt-1">Use a canned profile for new sandboxes or switch an existing sandbox policy baseline on the fly.</p></div><div className="min-w-[260px]"><select value={selectedPreset} onChange={(e) => { const value = e.target.value as SecurityPresetId | ''; setSelectedPreset(value); if (value) applyPreset(value) }} className="w-full rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] px-3 py-2 text-xs font-mono text-[var(--foreground)]"><option value="">Select preset…</option>{SECURITY_PRESETS.map((preset) => <option key={preset.id} value={preset.id}>{preset.label}</option>)}</select></div></div>{activePreset && <div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-4 space-y-3"><div className="flex items-center gap-3 flex-wrap"><span className="text-sm font-semibold text-[var(--foreground)] uppercase tracking-wider">{activePreset.label}</span></div><p className="text-sm text-[var(--foreground-dim)]">{activePreset.summary}</p></div>}</section>
<section className="space-y-4"><div className="flex items-center gap-3"><h5 className="text-xs uppercase tracking-wider text-[var(--foreground)]">Filesystem Policy</h5><Badge tone="static">Static</Badge></div><label className="flex items-center gap-3 text-sm text-[var(--foreground)] font-mono"><input type="checkbox" checked={policy.filesystem_policy.include_workdir} onChange={(e) => setPolicy({ ...policy, filesystem_policy: { ...policy.filesystem_policy, include_workdir: e.target.checked } })} />Include workdir<FieldHelp text="Automatically adds the agent working directory to read_write. Static: changing this requires recreating the sandbox." /></label><div className="grid grid-cols-1 md:grid-cols-2 gap-4"><TextListEditor label="Read-only paths" tooltipText="Absolute paths the sandbox can read but not modify. Paths not listed are inaccessible." value={policy.filesystem_policy.read_only} onChange={(v) => setPolicy({ ...policy, filesystem_policy: { ...policy.filesystem_policy, read_only: v } })} placeholder="/usr\n/lib\n/etc" /><TextListEditor label="Read-write paths" tooltipText="Absolute paths the sandbox can read and write. Keep this scoped; broad paths are rejected." value={policy.filesystem_policy.read_write} onChange={(v) => setPolicy({ ...policy, filesystem_policy: { ...policy.filesystem_policy, read_write: v } })} placeholder="/sandbox\n/tmp" /></div></section>
<section className="space-y-4"><div className="flex items-center gap-3"><h5 className="text-xs uppercase tracking-wider text-[var(--foreground)]">Network Policies</h5><Badge tone="dynamic">Dynamic</Badge></div><button onClick={addBlock} className="px-3 py-2 rounded-sm bg-[var(--background-tertiary)] text-xs font-mono uppercase tracking-wider hover:bg-[var(--background-panel)]">Add policy block</button></section>
<section className="space-y-3"><div className="flex items-center justify-between"><h5 className="text-xs uppercase tracking-wider text-[var(--foreground)]">Policy JSON Preview</h5><button onClick={savePolicy} disabled={saving} className="px-4 py-2 rounded-sm bg-[var(--nvidia-green)] text-white text-xs font-mono uppercase tracking-wider disabled:opacity-50">{saving ? "Working…" : mode === 'create' ? 'Create Sandbox' : 'Save Policy'}</button></div><pre className="overflow-auto rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-4 text-[11px] leading-5 text-[var(--foreground)]">{JSON.stringify(assembledPolicy, null, 2)}</pre>{message && <div className="text-sm text-[var(--foreground-dim)] whitespace-pre-wrap">{message}</div>}</section>
{mode === 'existing' && <section className="space-y-3"><h5 className="text-xs uppercase tracking-wider text-[var(--foreground)]">Policy JSON</h5><pre className="overflow-auto rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-4 text-[11px] leading-5 text-[var(--foreground)]">{JSON.stringify(assembledPolicy, null, 2)}</pre></section>}
{message && <div className="text-sm text-[var(--foreground-dim)] whitespace-pre-wrap">{message}</div>}
</div>}
</div>
)
+1 -1
View File
@@ -111,7 +111,7 @@ export default function SandboxDetails({
</div>
<div className="text-right">
<p className="text-[10px] text-[var(--foreground-dim)] uppercase tracking-wider">Running</p>
<p className="text-xs font-mono text-[var(--nvidia-green)]">NEMOSHELL</p>
<p className="text-xs font-mono text-[var(--nvidia-green)]">OPENSHELL</p>
</div>
</div>
</div>
+4 -73
View File
@@ -26,32 +26,8 @@ interface SandboxListProps {
}
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}`
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) {
@@ -64,7 +40,7 @@ function openDashboardUrl(url: string, openInNewTab: boolean) {
export default function SandboxList({
sandboxes,
nemoclaw,
nemoclaw: _nemoclaw,
dashboardSessionId,
selectedSandboxId,
selectedSandbox,
@@ -119,51 +95,6 @@ export default function SandboxList({
</span>
</div>
{!isDestroyMode && (
<div className="panel p-4 space-y-2">
<div className="flex items-center justify-between gap-4 flex-wrap">
<div>
<p className="text-[10px] uppercase tracking-wider text-[var(--foreground-dim)]">Inventory Source</p>
<p className="text-sm font-mono text-[var(--foreground)] mt-1">Live OpenShell gateway inventory</p>
</div>
<div>
<p className="text-[10px] uppercase tracking-wider text-[var(--foreground-dim)]">NemoClaw Operator Surface</p>
<p className="text-sm font-mono text-[var(--foreground)] mt-1">
{nemoclaw?.available ? 'Local registry + services' : 'Unavailable'}
</p>
</div>
</div>
<div className="grid grid-cols-1 md:grid-cols-3 gap-2 pt-1">
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] px-3 py-2 text-xs font-mono text-[var(--foreground-dim)]">
Inventory visibility: {sandboxes.length} live sandbox{sandboxes.length === 1 ? '' : 'es'}
</div>
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] px-3 py-2 text-xs font-mono text-[var(--foreground-dim)]">
Mapping truth: intent only, not proof of sandbox existence
</div>
<div className={`rounded-sm border px-3 py-2 text-xs font-mono ${sandboxes.length === 0 ? 'border-[var(--status-pending)] bg-[var(--status-pending-bg)] text-[var(--status-pending)]' : 'border-[var(--border-subtle)] bg-[var(--background-tertiary)] text-[var(--foreground-dim)]'}`}>
{sandboxes.length === 0 ? 'Truth state: degraded / unverified' : 'Truth state: verified from live inventory'}
</div>
</div>
<p className="text-xs text-[var(--foreground-dim)] font-mono">
Dashboard session: {dashboardSessionId.slice(0, 8)}
</p>
{nemoclaw?.defaultSandboxNames?.length ? (
<p className="text-xs text-[var(--foreground-dim)] font-mono">
Default sandbox marker: {nemoclaw.defaultSandboxNames.join(', ')}
</p>
) : null}
{nemoclaw?.serviceLines?.length ? (
<div className="grid grid-cols-1 md:grid-cols-2 gap-2 pt-1">
{nemoclaw.serviceLines.slice(0, 4).map((line) => (
<div key={line} className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] px-3 py-2 text-xs font-mono text-[var(--foreground-dim)]" title={line}>
{line}
</div>
))}
</div>
) : null}
</div>
)}
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
{sandboxes.map((sandbox) => (
<button
@@ -266,7 +197,7 @@ export default function SandboxList({
}}
className="px-3 py-2 rounded-sm bg-[var(--background-tertiary)] text-[var(--foreground)] text-xs font-mono uppercase tracking-wider hover:border-[var(--nvidia-green)] border border-[var(--border-subtle)]"
>
Open Operator Terminal Path
Open Operator Terminal
</button>
<button
onClick={async () => {
+93 -269
View File
@@ -1,294 +1,118 @@
"use client"
import type { NemoClawSummary, SandboxInventoryItem } from '../hooks/useSandboxInventory'
interface SidebarProps {
hostIP: string
sandboxes: SandboxInventoryItem[]
nemoclaw: NemoClawSummary | null
dashboardSessionId: string
selectedSandboxId: string | null
onSandboxSelect: (id: string | null) => void
isSubmenuOpen: boolean
onToggleSubmenu: () => void
sandboxesRunning: number
sandboxesTotal: number
activeView: 'settings' | 'sandboxes'
isCreateMode: boolean
isDestroyMode: boolean
activeView: 'overview' | 'settings' | 'sandboxes'
onSandboxesClick: () => void
onCreateClick: () => void
onDestroyClick: () => void
onOverviewClick: () => void
onSettingsClick: () => void
onExitMode: () => void
}
export default function Sidebar({
hostIP,
sandboxes,
nemoclaw,
dashboardSessionId,
selectedSandboxId,
onSandboxSelect,
isSubmenuOpen,
onToggleSubmenu,
sandboxesRunning,
sandboxesTotal,
activeView,
isCreateMode,
isDestroyMode,
activeView,
onSandboxesClick,
onCreateClick,
onDestroyClick,
onOverviewClick,
onSettingsClick,
onExitMode
onExitMode,
}: SidebarProps) {
return (
<>
<aside className="fixed left-0 top-0 h-screen w-64 bg-[var(--background-secondary)] border-r border-[var(--border-subtle)] flex flex-col z-20">
<div className="p-4 border-b border-[var(--border-subtle)]">
<div className="flex items-center gap-3">
<div className="w-8 h-8 bg-[var(--nvidia-green)] rounded-sm flex items-center justify-center">
<svg className="w-5 h-5 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6" />
</svg>
</div>
<div>
<p className="text-[10px] text-[var(--foreground-dim)] uppercase tracking-wider font-semibold">Host</p>
<p className="text-sm font-mono text-[var(--nvidia-green)] tracking-tight">{hostIP}</p>
<p className="text-[10px] text-[var(--foreground-dim)] font-mono mt-1">session {dashboardSessionId.slice(0, 8)}</p>
</div>
</div>
</div>
<nav className="flex-1 p-2">
<button
onClick={onToggleSubmenu}
className={`w-full flex items-center justify-between px-3 py-2 rounded-sm transition-colors ${
isSubmenuOpen
? 'bg-[var(--nvidia-green)] text-white'
: 'hover:bg-[var(--background-tertiary)] text-[var(--foreground-dim)]'
}`}
>
<span className="flex items-center gap-3">
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4" />
</svg>
<span className="text-sm font-medium tracking-tight">Sandboxes</span>
</span>
<svg
className={`w-4 h-4 transition-transform ${isSubmenuOpen ? 'rotate-90' : ''}`}
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M9 5l7 7-7 7" />
<aside className="fixed left-0 top-0 h-screen w-64 bg-[var(--background-secondary)] border-r border-[var(--border-subtle)] flex flex-col z-20">
<div className="p-4 border-b border-[var(--border-subtle)]">
<div className="flex items-center gap-3">
<div className="w-8 h-8 bg-[var(--nvidia-green)] rounded-sm flex items-center justify-center">
<svg className="w-5 h-5 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M4 7l8-4 8 4v10l-8 4-8-4V7z" />
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M4 7l8 4 8-4M12 11v10" />
</svg>
</button>
<div className="mt-4 space-y-1">
<button
onClick={onCreateClick}
className={`w-full flex items-center gap-3 px-3 py-2 rounded-sm transition-colors ${
isCreateMode
? 'bg-[var(--nvidia-green)] text-white'
: 'hover:bg-[var(--background-tertiary)] text-[var(--foreground-dim)]'
}`}
>
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M12 4v16m8-8H4" />
</svg>
<span className="text-sm">Create Sandbox</span>
</button>
<button
onClick={onDestroyClick}
className={`w-full flex items-center gap-3 px-3 py-2 rounded-sm transition-colors ${
isDestroyMode
? 'bg-[var(--status-stopped)] text-white'
: 'hover:bg-[var(--background-tertiary)] text-[var(--foreground-dim)]'
}`}
>
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
</svg>
<span className="text-sm">Destroy Sandbox</span>
</button>
{(isCreateMode || isDestroyMode) && (
<button
onClick={onExitMode}
className="w-full flex items-center gap-3 px-3 py-2 rounded-sm bg-[var(--background-tertiary)] text-[var(--foreground-dim)] hover:bg-[var(--background-panel)] transition-colors"
>
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
</svg>
<span className="text-sm">Cancel</span>
</button>
)}
<button
onClick={onSettingsClick}
className={`w-full flex items-center gap-3 px-3 py-2 rounded-sm transition-colors ${
activeView === 'settings'
? 'bg-[var(--nvidia-green)] text-white'
: 'hover:bg-[var(--background-tertiary)] text-[var(--foreground-dim)]'
}`}
>
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" />
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
</svg>
<span className="text-sm">Settings</span>
</button>
<button
onClick={onOverviewClick}
className={`w-full flex items-center gap-3 px-3 py-2 rounded-sm transition-colors ${
activeView === 'overview'
? 'bg-[var(--nvidia-green)] text-white'
: 'hover:bg-[var(--background-tertiary)] text-[var(--foreground-dim)]'
}`}
>
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z" />
</svg>
<span className="text-sm">Overview</span>
</button>
</div>
</nav>
<div className="p-4 border-t border-[var(--border-subtle)]">
<p className="text-[10px] text-[var(--foreground-dim)] uppercase tracking-wider">OpenShell Control</p>
<p className="text-[10px] text-[var(--foreground-dim)] font-mono">v1.0.0</p>
</div>
</aside>
<div
className={`fixed left-64 top-0 h-screen w-72 bg-[var(--background)] border-r border-[var(--border-subtle)] transform transition-transform duration-200 ease-in-out z-10 ${
isSubmenuOpen ? 'translate-x-0' : '-translate-x-full'
}`}
>
<div className="p-4 border-b border-[var(--border-subtle)]">
<h3 className="text-sm font-semibold text-[var(--foreground)] uppercase tracking-wider">
{isCreateMode ? 'CREATE SANDBOX' : isDestroyMode ? 'DESTROY SANDBOX' : 'SANDBOXES'}
</h3>
<p className="text-[10px] text-[var(--foreground-dim)] font-mono mt-1">
{isDestroyMode && 'SELECT A SANDBOX BELOW'}
{!isCreateMode && !isDestroyMode && `${sandboxes.filter(s => s.status === 'running').length} RUNNING / ${sandboxes.length} TOTAL`}
</p>
{!isCreateMode && !isDestroyMode && (
<div className="mt-3 rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-2">
<p className="text-[10px] uppercase tracking-wider text-[var(--foreground-dim)]">Inventory Source</p>
<p className="mt-1 text-[11px] text-[var(--foreground)] font-mono">Live OpenShell sandboxes</p>
<p className="mt-2 text-[10px] uppercase tracking-wider text-[var(--foreground-dim)]">NemoClaw Operator</p>
<p className="mt-1 text-[11px] text-[var(--foreground)] font-mono">
{nemoclaw?.available ? 'Registry/service summary available' : 'No NemoClaw summary detected'}
</p>
<p className="mt-1 text-[10px] text-[var(--foreground-dim)] font-mono">Dashboard session: {dashboardSessionId.slice(0, 8)}</p>
{nemoclaw?.defaultSandboxNames?.length ? (
<p className="mt-1 text-[10px] text-[var(--foreground-dim)] font-mono">
Default: {nemoclaw.defaultSandboxNames.join(', ')}
</p>
) : null}
{nemoclaw?.serviceLines?.slice(0, 2).map((line) => (
<p key={line} className="mt-1 text-[10px] text-[var(--foreground-dim)] font-mono truncate" title={line}>{line}</p>
))}
</div>
)}
</div>
<div className="p-2 overflow-y-auto h-[calc(100vh-80px)]">
{isCreateMode ? (
<div className="text-center py-8">
<svg className="w-12 h-12 mx-auto mb-4 text-[var(--nvidia-green)]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={1.5} d="M12 4v16m8-8H4" />
</svg>
<p className="text-xs text-[var(--foreground-dim)]">CONFIGURATION PANEL WILL OPEN BELOW</p>
</div>
) : isDestroyMode ? (
<div className="space-y-1">
{sandboxes.length === 0 ? (
<div className="text-center py-8">
<p className="text-xs text-[var(--foreground-dim)]">NO SANDBOXES TO DESTROY</p>
</div>
) : (
sandboxes.map((sandbox) => (
<button
key={sandbox.id}
onClick={() => onSandboxSelect(sandbox.id)}
className="w-full px-3 py-2 rounded-sm text-left transition-colors border-2 border-[var(--status-stopped)] hover:bg-[var(--status-stopped-bg)]"
>
<div className="flex items-center justify-between">
<div className="flex items-center gap-2">
<span className="w-2 h-2 rounded-sm bg-[var(--status-stopped)] animate-pulse" />
<span className="text-sm font-mono truncate text-[var(--status-stopped)]">{sandbox.name}</span>
</div>
<svg className="w-3 h-3 text-[var(--status-stopped)]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M9 5l7 7-7 7" />
</svg>
</div>
<p className="text-[10px] text-[var(--foreground-dim)] font-mono mt-1 ml-4">
{sandbox.ip}
</p>
</button>
))
)}
</div>
) : (
<div className="space-y-1">
<button
onClick={() => onSandboxSelect(null)}
className={`w-full px-3 py-2 rounded-sm text-left transition-colors ${
selectedSandboxId === null
? 'bg-[var(--nvidia-green)] text-white'
: 'hover:bg-[var(--background-tertiary)] text-[var(--foreground)]'
}`}
>
<div className="flex items-center justify-between">
<span className="text-sm font-medium">ALL SANDBOXES</span>
<svg className="w-3 h-3 opacity-75" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M9 5l7 7-7 7" />
</svg>
</div>
</button>
{sandboxes.map((sandbox) => (
<button
key={sandbox.id}
onClick={() => onSandboxSelect(sandbox.id)}
className={`w-full px-3 py-2 rounded-sm text-left transition-colors ${
selectedSandboxId === sandbox.id
? 'bg-[var(--nvidia-green)] text-white'
: 'hover:bg-[var(--background-tertiary)] text-[var(--foreground)]'
}`}
>
<div className="flex items-center justify-between">
<div className="flex items-center gap-2">
<span
className={`w-2 h-2 rounded-sm ${
sandbox.status === 'running'
? 'bg-[var(--status-running)]'
: sandbox.status === 'stopped'
? 'bg-[var(--status-stopped)]'
: sandbox.status === 'error'
? 'bg-red-500'
: 'bg-[var(--status-pending)]'
}`}
/>
<span className="text-sm font-mono truncate">{sandbox.name}</span>
{sandbox.isDefault ? (
<span className="rounded-sm border border-[var(--border-subtle)] px-1.5 py-0.5 text-[9px] uppercase tracking-wider text-[var(--foreground-dim)]">default</span>
) : null}
</div>
<svg className="w-3 h-3 opacity-75" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M9 5l7 7-7 7" />
</svg>
</div>
<p className="text-[10px] text-[var(--foreground-dim)] font-mono mt-1 ml-4">
{sandbox.namespace} · {sandbox.ip}
</p>
</button>
))}
</div>
)}
<div>
<p className="text-sm font-semibold text-[var(--foreground)] tracking-tight">OpenShell Control</p>
<p className="text-[10px] text-[var(--foreground-dim)] font-mono mt-1">
{sandboxesRunning} running / {sandboxesTotal} total
</p>
</div>
</div>
</div>
</>
<nav className="flex-1 p-2">
<button
onClick={onSandboxesClick}
className={`w-full flex items-center gap-3 px-3 py-2 rounded-sm transition-colors ${
activeView === 'sandboxes' && !isCreateMode && !isDestroyMode
? 'bg-[var(--nvidia-green)] text-white'
: 'hover:bg-[var(--background-tertiary)] text-[var(--foreground-dim)]'
}`}
>
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4" />
</svg>
<span className="text-sm">Sandboxes</span>
</button>
<button
onClick={onCreateClick}
className={`mt-1 w-full flex items-center gap-3 px-3 py-2 rounded-sm transition-colors ${
isCreateMode
? 'bg-[var(--nvidia-green)] text-white'
: 'hover:bg-[var(--background-tertiary)] text-[var(--foreground-dim)]'
}`}
>
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M12 4v16m8-8H4" />
</svg>
<span className="text-sm">Create Sandbox</span>
</button>
<button
onClick={onDestroyClick}
className={`mt-1 w-full flex items-center gap-3 px-3 py-2 rounded-sm transition-colors ${
isDestroyMode
? 'bg-[var(--status-stopped)] text-white'
: 'hover:bg-[var(--background-tertiary)] text-[var(--foreground-dim)]'
}`}
>
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6M4 7h16" />
</svg>
<span className="text-sm">Destroy Sandbox</span>
</button>
{(isCreateMode || isDestroyMode) && (
<button
onClick={onExitMode}
className="mt-1 w-full flex items-center gap-3 px-3 py-2 rounded-sm bg-[var(--background-tertiary)] text-[var(--foreground-dim)] hover:bg-[var(--background-panel)] transition-colors"
>
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
</svg>
<span className="text-sm">Cancel</span>
</button>
)}
<button
onClick={onSettingsClick}
className={`mt-4 w-full flex items-center gap-3 px-3 py-2 rounded-sm transition-colors ${
activeView === 'settings'
? 'bg-[var(--nvidia-green)] text-white'
: 'hover:bg-[var(--background-tertiary)] text-[var(--foreground-dim)]'
}`}
>
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M12 6v6l4 2m5-2a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
<span className="text-sm">Status</span>
</button>
</nav>
</aside>
)
}