Stabilize dashboard runtime proxy
This commit is contained in:
+85
-277
@@ -1,9 +1,10 @@
|
||||
"use client"
|
||||
|
||||
import Link from 'next/link'
|
||||
import { Suspense, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { useSearchParams } from 'next/navigation'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import 'xterm/css/xterm.css'
|
||||
import { ensureDashboardSessionId, HYDRATION_SAFE_DASHBOARD_SESSION_ID } from '../lib/dashboardSession'
|
||||
|
||||
interface ReadinessPodSummary {
|
||||
containers?: string[]
|
||||
@@ -41,25 +42,30 @@ interface ReadinessResponse {
|
||||
interface LiveTerminalSession {
|
||||
sessionId: string
|
||||
sandboxId: string
|
||||
dashboardSessionId: string
|
||||
replay?: string
|
||||
websocketUrl: string
|
||||
sshHostAlias?: string
|
||||
}
|
||||
|
||||
type XTermModule = typeof import('xterm')
|
||||
type FitAddonModule = typeof import('xterm-addon-fit')
|
||||
type XTermInstance = InstanceType<XTermModule['Terminal']>
|
||||
type FitAddonInstance = InstanceType<FitAddonModule['FitAddon']>
|
||||
|
||||
type LoadState = 'idle' | 'loading' | 'ready' | 'error'
|
||||
|
||||
const defaultAlias = (sandboxId: string | null) => `ssh openshell-${sandboxId || 'my-assistant'}`
|
||||
const defaultFallback = (sandboxId: string | null) => `ssh -i ~/.ssh/id_ed25519_openclaw_labmac openshell-${sandboxId || 'my-assistant'}`
|
||||
const defaultLoginShell = (sandboxId: string | null) => `env PATH=/opt/homebrew/bin:$PATH zsh -l -c 'ssh openshell-${sandboxId || 'my-assistant'}'`
|
||||
const DEFAULT_SHELL_HINT = 'If your non-interactive shell misses Homebrew tooling, retry from a login shell or prepend PATH=/opt/homebrew/bin:$PATH before ssh.'
|
||||
const defaultFallback = (sandboxId: string | null) => `ssh openshell-${sandboxId || 'my-assistant'}`
|
||||
const defaultLoginShell = (sandboxId: string | null) => `env PATH=$HOME/.local/bin:$PATH bash -l -c 'ssh openshell-${sandboxId || 'my-assistant'}'`
|
||||
const DEFAULT_SHELL_HINT = 'If your non-interactive shell misses local tooling, retry from a login shell or prepend PATH=$HOME/.local/bin:$PATH before ssh.'
|
||||
|
||||
export default function OperatorTerminalPage() {
|
||||
function OperatorTerminalInner() {
|
||||
const searchParams = useSearchParams()
|
||||
const sandboxId = searchParams.get('sandboxId')
|
||||
const requestedDashboardSessionId = searchParams.get('dashboardSessionId')
|
||||
const [dashboardSessionId, setDashboardSessionId] = useState(
|
||||
() => requestedDashboardSessionId?.trim() || HYDRATION_SAFE_DASHBOARD_SESSION_ID
|
||||
)
|
||||
const [state, setState] = useState<LoadState>(sandboxId ? 'loading' : 'idle')
|
||||
const [data, setData] = useState<ReadinessResponse | null>(null)
|
||||
const [lastCheckedAt, setLastCheckedAt] = useState<string | null>(null)
|
||||
@@ -73,6 +79,10 @@ export default function OperatorTerminalPage() {
|
||||
const fitAddonRef = useRef<FitAddonInstance | null>(null)
|
||||
const socketRef = useRef<WebSocket | null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
setDashboardSessionId(ensureDashboardSessionId(requestedDashboardSessionId))
|
||||
}, [requestedDashboardSessionId])
|
||||
|
||||
const refreshReadiness = useCallback(async () => {
|
||||
if (!sandboxId) {
|
||||
setState('idle')
|
||||
@@ -84,43 +94,29 @@ export default function OperatorTerminalPage() {
|
||||
setCopyMessage('')
|
||||
|
||||
try {
|
||||
const response = await fetch(`/api/openshell/terminal/readiness?sandboxId=${encodeURIComponent(sandboxId)}`, {
|
||||
cache: 'no-store',
|
||||
})
|
||||
const response = await fetch(`/api/openshell/terminal/readiness?sandboxId=${encodeURIComponent(sandboxId)}`, { cache: 'no-store' })
|
||||
const result: ReadinessResponse = await response.json()
|
||||
setData(result)
|
||||
setState(response.ok && result.ok ? 'ready' : 'error')
|
||||
setLastCheckedAt(new Date().toLocaleTimeString())
|
||||
} catch (error) {
|
||||
setData({
|
||||
ok: false,
|
||||
error: error instanceof Error ? error.message : 'Failed to inspect sandbox readiness.',
|
||||
})
|
||||
setData({ ok: false, error: error instanceof Error ? error.message : 'Failed to inspect sandbox readiness.' })
|
||||
setState('error')
|
||||
setLastCheckedAt(new Date().toLocaleTimeString())
|
||||
}
|
||||
}, [sandboxId])
|
||||
|
||||
const ensureLiveSession = useCallback(async () => {
|
||||
if (!sandboxId) {
|
||||
setLiveSession(null)
|
||||
setTerminalState('idle')
|
||||
return
|
||||
}
|
||||
|
||||
setTerminalState('connecting')
|
||||
setTerminalStatus('Initializing live PTY session…')
|
||||
setTerminalStatus(sandboxId
|
||||
? `Initializing live terminal session for ${sandboxId}…`
|
||||
: 'Initializing host-mode live terminal session…')
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/openshell/terminal/live', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
sandboxId,
|
||||
sessionId: liveSession?.sessionId,
|
||||
}),
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ sandboxId, sessionId: liveSession?.sessionId, dashboardSessionId }),
|
||||
})
|
||||
const result = await response.json()
|
||||
if (!response.ok || !result.ok) {
|
||||
@@ -129,50 +125,34 @@ export default function OperatorTerminalPage() {
|
||||
setLiveSession({
|
||||
sessionId: result.sessionId,
|
||||
sandboxId: result.sandboxId,
|
||||
dashboardSessionId: result.dashboardSessionId || dashboardSessionId,
|
||||
replay: result.replay,
|
||||
websocketUrl: result.websocketUrl,
|
||||
sshHostAlias: result.sshHostAlias,
|
||||
})
|
||||
} catch (error) {
|
||||
setTerminalState('error')
|
||||
setTerminalStatus(error instanceof Error ? error.message : 'Failed to initialize live terminal session.')
|
||||
}
|
||||
}, [sandboxId, liveSession?.sessionId])
|
||||
}, [dashboardSessionId, sandboxId, liveSession?.sessionId])
|
||||
|
||||
useEffect(() => { refreshReadiness() }, [refreshReadiness])
|
||||
useEffect(() => { ensureLiveSession() }, [ensureLiveSession])
|
||||
|
||||
useEffect(() => {
|
||||
refreshReadiness()
|
||||
}, [refreshReadiness])
|
||||
|
||||
useEffect(() => {
|
||||
ensureLiveSession()
|
||||
}, [ensureLiveSession])
|
||||
|
||||
useEffect(() => {
|
||||
if (!terminalContainerRef.current || terminalRef.current) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!terminalContainerRef.current || terminalRef.current) return
|
||||
let disposed = false
|
||||
let cleanupResize: (() => void) | null = null
|
||||
|
||||
;(async () => {
|
||||
const [{ Terminal }, { FitAddon }] = await Promise.all([
|
||||
import('xterm'),
|
||||
import('xterm-addon-fit'),
|
||||
])
|
||||
|
||||
if (disposed || !terminalContainerRef.current) {
|
||||
return
|
||||
}
|
||||
const [{ Terminal }, { FitAddon }] = await Promise.all([import('xterm'), import('xterm-addon-fit')])
|
||||
if (disposed || !terminalContainerRef.current) return
|
||||
|
||||
const term = new Terminal({
|
||||
cursorBlink: true,
|
||||
fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace',
|
||||
fontSize: 13,
|
||||
theme: {
|
||||
background: '#000000',
|
||||
foreground: '#f5f5f5',
|
||||
cursor: '#76b900',
|
||||
},
|
||||
theme: { background: '#000000', foreground: '#f5f5f5', cursor: '#76b900' },
|
||||
scrollback: 5000,
|
||||
allowTransparency: false,
|
||||
})
|
||||
@@ -180,23 +160,24 @@ export default function OperatorTerminalPage() {
|
||||
term.loadAddon(fitAddon)
|
||||
term.open(terminalContainerRef.current)
|
||||
fitAddon.fit()
|
||||
|
||||
term.focus()
|
||||
terminalRef.current = term
|
||||
fitAddonRef.current = fitAddon
|
||||
|
||||
const focusTerminal = () => term.focus()
|
||||
terminalContainerRef.current.addEventListener('click', focusTerminal)
|
||||
|
||||
const handleResize = () => {
|
||||
fitAddon.fit()
|
||||
if (socketRef.current?.readyState === WebSocket.OPEN) {
|
||||
socketRef.current.send(JSON.stringify({
|
||||
type: 'resize',
|
||||
cols: term.cols,
|
||||
rows: term.rows,
|
||||
}))
|
||||
socketRef.current.send(JSON.stringify({ type: 'resize', cols: term.cols, rows: term.rows }))
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('resize', handleResize)
|
||||
cleanupResize = () => window.removeEventListener('resize', handleResize)
|
||||
cleanupResize = () => {
|
||||
window.removeEventListener('resize', handleResize)
|
||||
terminalContainerRef.current?.removeEventListener('click', focusTerminal)
|
||||
}
|
||||
})().catch((error) => {
|
||||
setTerminalState('error')
|
||||
setTerminalStatus(error instanceof Error ? error.message : 'Failed to load terminal renderer.')
|
||||
@@ -213,46 +194,31 @@ export default function OperatorTerminalPage() {
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (!liveSession?.websocketUrl || !terminalRef.current) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!liveSession?.websocketUrl || !terminalRef.current) return
|
||||
const term = terminalRef.current
|
||||
term.reset()
|
||||
if (liveSession.replay) {
|
||||
term.write(liveSession.replay)
|
||||
}
|
||||
if (liveSession.replay) term.write(liveSession.replay)
|
||||
|
||||
const socket = new WebSocket(liveSession.websocketUrl)
|
||||
socketRef.current = socket
|
||||
|
||||
const inputDisposable = term.onData((data) => {
|
||||
if (socket.readyState === WebSocket.OPEN) {
|
||||
socket.send(JSON.stringify({ type: 'input', data }))
|
||||
}
|
||||
if (socket.readyState === WebSocket.OPEN) socket.send(JSON.stringify({ type: 'input', data }))
|
||||
})
|
||||
|
||||
socket.addEventListener('open', () => {
|
||||
setTerminalState('connected')
|
||||
setTerminalStatus(`Live PTY connected for ${liveSession.sandboxId}.`)
|
||||
if (fitAddonRef.current) {
|
||||
fitAddonRef.current.fit()
|
||||
}
|
||||
socket.send(JSON.stringify({
|
||||
type: 'resize',
|
||||
cols: term.cols,
|
||||
rows: term.rows,
|
||||
}))
|
||||
setTerminalStatus(`Live terminal connected for ${liveSession.sandboxId} in dashboard session ${liveSession.dashboardSessionId.slice(0, 8)}.`)
|
||||
fitAddonRef.current?.fit()
|
||||
term.focus()
|
||||
socket.send(JSON.stringify({ type: 'resize', cols: term.cols, rows: term.rows }))
|
||||
})
|
||||
|
||||
socket.addEventListener('message', (event) => {
|
||||
try {
|
||||
const message = JSON.parse(event.data)
|
||||
if (message.type === 'ready') {
|
||||
if (message.replay) {
|
||||
term.reset()
|
||||
term.write(message.replay)
|
||||
}
|
||||
if (message.type === 'ready' && message.replay) {
|
||||
term.reset()
|
||||
term.write(message.replay)
|
||||
} else if (message.type === 'data' && typeof message.data === 'string') {
|
||||
term.write(message.data)
|
||||
} else if (message.type === 'exit') {
|
||||
@@ -277,67 +243,22 @@ export default function OperatorTerminalPage() {
|
||||
return () => {
|
||||
inputDisposable.dispose()
|
||||
socket.close()
|
||||
if (socketRef.current === socket) {
|
||||
socketRef.current = null
|
||||
}
|
||||
if (socketRef.current === socket) socketRef.current = null
|
||||
}
|
||||
}, [liveSession])
|
||||
|
||||
const readiness = useMemo(() => {
|
||||
if (!sandboxId) {
|
||||
return {
|
||||
tone: 'border-[var(--status-pending)] text-[var(--status-pending)]',
|
||||
label: 'NO SANDBOX SELECTED',
|
||||
detail: 'Return to the dashboard and choose a sandbox before opening Operator Terminal.',
|
||||
}
|
||||
}
|
||||
|
||||
if (state === 'loading') {
|
||||
return {
|
||||
tone: 'border-[var(--status-pending)] text-[var(--status-pending)]',
|
||||
label: 'CHECKING READINESS',
|
||||
detail: 'Verifying pod metadata and bounded shell reachability so the page can report terminal truth in one pass.',
|
||||
}
|
||||
}
|
||||
|
||||
if (state === 'ready' && data?.ok && data?.podReady && data?.sshReachable) {
|
||||
return {
|
||||
tone: 'border-[var(--status-running)] text-[var(--status-running)]',
|
||||
label: 'LIVE TERMINAL PATH VERIFIED',
|
||||
detail: 'The backend confirmed pod readiness and shell reachability, and the dashboard is now wired for a live PTY transport.',
|
||||
}
|
||||
}
|
||||
|
||||
if (state === 'ready' && data?.ok && data?.podExists && data?.degraded) {
|
||||
return {
|
||||
tone: 'border-[var(--status-pending)] text-[var(--status-pending)]',
|
||||
label: 'DEGRADED: POD UP, SHELL UNCONFIRMED',
|
||||
detail: 'The pod exists, but the readiness probe did not fully succeed. The live terminal may still connect, but direct SSH remains the stronger fallback.',
|
||||
}
|
||||
}
|
||||
|
||||
if (state === 'ready' && data?.ok && data?.podExists) {
|
||||
return {
|
||||
tone: 'border-[var(--status-running)] text-[var(--status-running)]',
|
||||
label: 'READY FOR LIVE TERMINAL',
|
||||
detail: 'Pod metadata is present and the dashboard live terminal can attempt a real PTY session.',
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
tone: 'border-[var(--status-stopped)] text-[var(--status-stopped)]',
|
||||
label: 'READINESS CHECK FAILED',
|
||||
detail: 'The dashboard could not confirm pod metadata or shell reachability. Use the recovery commands below, then retry.',
|
||||
}
|
||||
if (!sandboxId) return { tone: 'border-[var(--status-pending)] text-[var(--status-pending)]', label: 'HOST MODE', detail: 'No sandbox query was provided. The dashboard terminal stays in host mode and keeps dashboard-session diagnostics for reconnect behavior.' }
|
||||
if (state === 'loading') return { tone: 'border-[var(--status-pending)] text-[var(--status-pending)]', label: 'CHECKING READINESS', detail: 'Verifying pod metadata and shell reachability.' }
|
||||
if (state === 'ready' && data?.ok && data?.podReady && data?.sshReachable) return { tone: 'border-[var(--status-running)] text-[var(--status-running)]', label: 'LIVE TERMINAL PATH VERIFIED', detail: 'The backend confirmed pod readiness and shell reachability, and the dashboard is wired for a live terminal transport.' }
|
||||
if (state === 'ready' && data?.ok && data?.podExists && data?.degraded) return { tone: 'border-[var(--status-pending)] text-[var(--status-pending)]', label: 'DEGRADED: POD UP, SHELL UNCONFIRMED', detail: 'The pod exists, but the readiness probe did not fully succeed. The live terminal may still connect, but direct SSH remains the stronger fallback.' }
|
||||
if (state === 'ready' && data?.ok && data?.podExists) return { tone: 'border-[var(--status-running)] text-[var(--status-running)]', label: 'READY FOR LIVE TERMINAL', detail: 'Pod metadata is present and the dashboard live terminal can attempt a real shell session.' }
|
||||
return { tone: 'border-[var(--status-stopped)] text-[var(--status-stopped)]', label: 'READINESS CHECK FAILED', detail: 'The dashboard could not confirm pod metadata or shell reachability. Use the recovery commands below, then retry.' }
|
||||
}, [sandboxId, state, data])
|
||||
|
||||
const copyCommand = useCallback(async (command: string) => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(command)
|
||||
setCopyMessage(`Copied: ${command}`)
|
||||
} catch {
|
||||
setCopyMessage(`Copy failed. Use: ${command}`)
|
||||
}
|
||||
try { await navigator.clipboard.writeText(command); setCopyMessage(`Copied: ${command}`) }
|
||||
catch { setCopyMessage(`Copy failed. Use: ${command}`) }
|
||||
}, [])
|
||||
|
||||
const aliasCommand = data?.attach?.aliasCommand || defaultAlias(sandboxId)
|
||||
@@ -352,169 +273,56 @@ export default function OperatorTerminalPage() {
|
||||
<div>
|
||||
<p className="text-[10px] uppercase tracking-[0.25em] text-[var(--foreground-dim)] font-mono">Operator path</p>
|
||||
<h1 className="text-2xl font-semibold uppercase tracking-wider mt-2">Operator Terminal</h1>
|
||||
<p className="text-sm text-[var(--foreground-dim)] mt-3 max-w-3xl">
|
||||
Real live terminal surface for the selected sandbox. Browser keys flow into a PTY-backed shell process and output streams back live into the dashboard.
|
||||
</p>
|
||||
<p className="text-sm text-[var(--foreground-dim)] mt-3 max-w-3xl">{sandboxId ? 'Live operator terminal for the selected sandbox, brokered through the dashboard-owned terminal bridge.' : 'Live operator terminal for host mode, brokered through the dashboard-owned terminal bridge.'}</p>
|
||||
<p className="text-[11px] text-[var(--foreground-dim)] font-mono mt-2">Dashboard session {dashboardSessionId.slice(0, 8)}</p>
|
||||
</div>
|
||||
<Link
|
||||
href="/"
|
||||
className="px-4 py-2 rounded-sm bg-[var(--background-tertiary)] text-[var(--foreground)] text-xs font-mono uppercase tracking-wider hover:bg-[var(--background-panel)]"
|
||||
>
|
||||
Back to Dashboard
|
||||
</Link>
|
||||
<Link href="/" className="px-4 py-2 rounded-sm bg-[var(--background-tertiary)] text-[var(--foreground)] text-xs font-mono uppercase tracking-wider hover:bg-[var(--background-panel)]">Back to Dashboard</Link>
|
||||
</div>
|
||||
|
||||
<section className={`panel p-6 border-2 ${readiness.tone}`}>
|
||||
<div className="flex items-center justify-between gap-4 flex-wrap">
|
||||
<div>
|
||||
<p className="text-[10px] uppercase tracking-[0.2em] font-mono opacity-80">Sandbox</p>
|
||||
<h2 className="text-lg font-semibold mt-1">{sandboxId || 'UNSELECTED'}</h2>
|
||||
</div>
|
||||
<div className="text-right">
|
||||
<p className="text-[10px] uppercase tracking-[0.2em] font-mono opacity-80">Status</p>
|
||||
<p className="text-sm font-mono mt-1">{readiness.label}</p>
|
||||
{lastCheckedAt && <p className="text-[10px] mt-1 opacity-80">Last checked {lastCheckedAt}</p>}
|
||||
</div>
|
||||
<div><p className="text-[10px] uppercase tracking-[0.2em] font-mono opacity-80">Sandbox</p><h2 className="text-lg font-semibold mt-1">{sandboxId || 'HOST'}</h2></div>
|
||||
<div><p className="text-[10px] uppercase tracking-[0.2em] font-mono opacity-80">Dashboard Session</p><h2 className="text-lg font-semibold mt-1">{dashboardSessionId.slice(0, 8)}</h2></div>
|
||||
<div className="text-right"><p className="text-[10px] uppercase tracking-[0.2em] font-mono opacity-80">Status</p><p className="text-sm font-mono mt-1">{readiness.label}</p>{lastCheckedAt && <p className="text-[10px] mt-1 opacity-80">Last checked {lastCheckedAt}</p>}</div>
|
||||
</div>
|
||||
<p className="text-sm mt-4 text-[var(--foreground)]">{readiness.detail}</p>
|
||||
</section>
|
||||
|
||||
<section className="panel p-6 space-y-4">
|
||||
<div className="flex items-center justify-between gap-3 flex-wrap">
|
||||
<div>
|
||||
<h3 className="text-sm font-semibold uppercase tracking-wider">Live Dashboard Terminal</h3>
|
||||
<p className="text-xs text-[var(--foreground-dim)] mt-2">
|
||||
xterm-backed live terminal. Supports typed input, streamed output, resize, and session reconnect.
|
||||
</p>
|
||||
</div>
|
||||
<div><h3 className="text-sm font-semibold uppercase tracking-wider">Live Dashboard Terminal</h3><p className="text-xs text-[var(--foreground-dim)] mt-2">Browser terminal backed by the dashboard terminal server.</p></div>
|
||||
<div className="text-[11px] text-[var(--foreground-dim)] font-mono">{terminalStatus}</div>
|
||||
</div>
|
||||
|
||||
<div className="rounded-sm border border-[var(--border-subtle)] bg-black p-3">
|
||||
<div ref={terminalContainerRef} className="h-[520px] w-full" />
|
||||
</div>
|
||||
|
||||
<div className="rounded-sm border border-[var(--border-subtle)] bg-black p-3"><div ref={terminalContainerRef} className="h-[520px] w-full" /></div>
|
||||
<div className="flex items-center gap-3 flex-wrap">
|
||||
<button
|
||||
onClick={ensureLiveSession}
|
||||
disabled={!sandboxId || terminalState === 'connecting'}
|
||||
className="px-3 py-2 rounded-sm border border-[var(--border-subtle)] text-xs font-mono uppercase tracking-wider hover:border-[var(--nvidia-green)] disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
>
|
||||
{terminalState === 'connecting' ? 'Connecting…' : 'Reconnect Live Terminal'}
|
||||
</button>
|
||||
<button
|
||||
onClick={refreshReadiness}
|
||||
className="px-3 py-2 rounded-sm border border-[var(--border-subtle)] text-xs font-mono uppercase tracking-wider hover:border-[var(--nvidia-green)]"
|
||||
>
|
||||
Refresh Readiness
|
||||
</button>
|
||||
<span className="text-[11px] text-[var(--foreground-dim)] font-mono">
|
||||
{liveSession?.sessionId ? `session ${liveSession.sessionId.slice(0, 8)}` : 'no session'}
|
||||
</span>
|
||||
<button onClick={ensureLiveSession} disabled={terminalState === 'connecting'} className="px-3 py-2 rounded-sm border border-[var(--border-subtle)] text-xs font-mono uppercase tracking-wider hover:border-[var(--nvidia-green)] disabled:opacity-50 disabled:cursor-not-allowed">{terminalState === 'connecting' ? 'Connecting…' : 'Reconnect Live Terminal'}</button>
|
||||
<button onClick={refreshReadiness} disabled={!sandboxId} className="px-3 py-2 rounded-sm border border-[var(--border-subtle)] text-xs font-mono uppercase tracking-wider hover:border-[var(--nvidia-green)] disabled:opacity-50 disabled:cursor-not-allowed">Refresh Readiness</button>
|
||||
<span className="text-[11px] text-[var(--foreground-dim)] font-mono">{liveSession?.sessionId ? `session ${liveSession.sessionId.slice(0, 8)}` : 'no session'}</span>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="grid grid-cols-1 xl:grid-cols-[1.1fr_0.9fr] gap-6">
|
||||
<div className="panel p-6 space-y-5">
|
||||
<div className="flex items-center justify-between gap-3 flex-wrap">
|
||||
<div>
|
||||
<h3 className="text-sm font-semibold uppercase tracking-wider">Direct Attach Fallbacks</h3>
|
||||
<p className="text-xs text-[var(--foreground-dim)] mt-2">
|
||||
If the live dashboard terminal is degraded, these remain the authoritative escape hatches.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div><h3 className="text-sm font-semibold uppercase tracking-wider">Direct Attach Fallbacks</h3><p className="text-xs text-[var(--foreground-dim)] mt-2">If the live dashboard terminal is degraded, these remain the authoritative escape hatches.</p></div>
|
||||
<div className="space-y-3">
|
||||
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-4">
|
||||
<p className="text-[10px] uppercase tracking-[0.2em] text-[var(--foreground-dim)] font-mono">Preferred attach command</p>
|
||||
<code className="block mt-2 text-sm font-mono text-[var(--nvidia-green)] break-all">{aliasCommand}</code>
|
||||
<button
|
||||
onClick={() => copyCommand(aliasCommand)}
|
||||
className="mt-3 px-3 py-2 rounded-sm border border-[var(--border-subtle)] text-xs font-mono uppercase tracking-wider hover:border-[var(--nvidia-green)]"
|
||||
>
|
||||
Copy Alias Command
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-4"><p className="text-[10px] uppercase tracking-[0.2em] text-[var(--foreground-dim)] font-mono">Preferred attach command</p><code className="block mt-2 text-sm font-mono text-[var(--nvidia-green)] break-all">{aliasCommand}</code><button onClick={() => copyCommand(aliasCommand)} className="mt-3 px-3 py-2 rounded-sm border border-[var(--border-subtle)] text-xs font-mono uppercase tracking-wider hover:border-[var(--nvidia-green)]">Copy Alias Command</button></div>
|
||||
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-4 space-y-3">
|
||||
<div>
|
||||
<p className="text-[10px] uppercase tracking-[0.2em] text-[var(--foreground-dim)] font-mono">Fallback if alias or agent config is missing</p>
|
||||
<code className="block mt-2 text-sm font-mono text-[var(--foreground)] break-all">{fallbackCommand}</code>
|
||||
<p className="text-xs text-[var(--foreground-dim)] mt-2">{shellHint}</p>
|
||||
<button
|
||||
onClick={() => copyCommand(fallbackCommand)}
|
||||
className="mt-3 px-3 py-2 rounded-sm border border-[var(--border-subtle)] text-xs font-mono uppercase tracking-wider hover:border-[var(--nvidia-green)]"
|
||||
>
|
||||
Copy Fallback Command
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] p-3">
|
||||
<p className="text-[10px] uppercase tracking-[0.2em] text-[var(--foreground-dim)] font-mono">Login-shell retry for Homebrew/path issues</p>
|
||||
<code className="block mt-2 text-sm font-mono text-[var(--foreground)] break-all">{loginShellCommand}</code>
|
||||
<button
|
||||
onClick={() => copyCommand(loginShellCommand)}
|
||||
className="mt-3 px-3 py-2 rounded-sm border border-[var(--border-subtle)] text-xs font-mono uppercase tracking-wider hover:border-[var(--nvidia-green)]"
|
||||
>
|
||||
Copy Login-Shell Retry
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{copyMessage && (
|
||||
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-3 text-xs text-[var(--foreground-dim)]">
|
||||
{copyMessage}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="panel p-6 space-y-5">
|
||||
<div>
|
||||
<h3 className="text-sm font-semibold uppercase tracking-wider">Readiness Evidence</h3>
|
||||
<p className="text-xs text-[var(--foreground-dim)] mt-2">
|
||||
Live pod introspection and bounded shell evidence from the backend.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="space-y-3 text-sm">
|
||||
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-4">
|
||||
<p className="text-[10px] uppercase tracking-[0.2em] text-[var(--foreground-dim)] font-mono">Pod phase / ready</p>
|
||||
<p className="mt-2 font-mono break-words">{data?.pod?.phase || 'Unknown'} / {data?.pod?.readyCondition || 'Unknown'}</p>
|
||||
</div>
|
||||
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-4">
|
||||
<p className="text-[10px] uppercase tracking-[0.2em] text-[var(--foreground-dim)] font-mono">Containers</p>
|
||||
<p className="mt-2 font-mono break-words">{data?.pod?.containers?.length ? data.pod.containers.join(', ') : 'Unavailable'}</p>
|
||||
</div>
|
||||
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-4">
|
||||
<p className="text-[10px] uppercase tracking-[0.2em] text-[var(--foreground-dim)] font-mono">Images</p>
|
||||
<p className="mt-2 font-mono break-words">{data?.pod?.images?.length ? data.pod.images.join(', ') : 'Unavailable'}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-4 space-y-3">
|
||||
<div className="flex items-center justify-between gap-3 flex-wrap">
|
||||
<div>
|
||||
<p className="text-[10px] uppercase tracking-[0.2em] text-[var(--foreground-dim)] font-mono">Shell probe</p>
|
||||
<p className="text-xs text-[var(--foreground-dim)] mt-2">Readiness-side shell evidence.</p>
|
||||
</div>
|
||||
<div className="text-[11px] text-[var(--foreground-dim)] font-mono">
|
||||
{data?.shellProbe?.ok ? 'Probe passed' : 'Probe not confirmed'}
|
||||
</div>
|
||||
</div>
|
||||
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] p-3">
|
||||
<p className="text-[10px] uppercase tracking-[0.2em] text-[var(--foreground-dim)] font-mono">Probe stdout</p>
|
||||
<pre className="mt-2 text-xs whitespace-pre-wrap break-words font-mono text-[var(--foreground)] min-h-16">{data?.shellProbe?.output || 'No backend shell output captured yet.'}</pre>
|
||||
</div>
|
||||
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] p-3">
|
||||
<p className="text-[10px] uppercase tracking-[0.2em] text-[var(--foreground-dim)] font-mono">Probe stderr / status</p>
|
||||
<pre className="mt-2 text-xs whitespace-pre-wrap break-words font-mono text-[var(--foreground)] min-h-16">{data?.shellProbe?.error || data?.shellProbe?.stderr || data?.note || 'No stderr.'}</pre>
|
||||
<div><p className="text-[10px] uppercase tracking-[0.2em] text-[var(--foreground-dim)] font-mono">Fallback if alias or agent config is missing</p><code className="block mt-2 text-sm font-mono text-[var(--foreground)] break-all">{fallbackCommand}</code><p className="text-xs text-[var(--foreground-dim)] mt-2">{shellHint}</p><button onClick={() => copyCommand(fallbackCommand)} className="mt-3 px-3 py-2 rounded-sm border border-[var(--border-subtle)] text-xs font-mono uppercase tracking-wider hover:border-[var(--nvidia-green)]">Copy Fallback Command</button></div>
|
||||
<div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background)] p-3"><p className="text-[10px] uppercase tracking-[0.2em] text-[var(--foreground-dim)] font-mono">Login-shell retry for Homebrew/path issues</p><code className="block mt-2 text-sm font-mono text-[var(--foreground)] break-all">{loginShellCommand}</code><button onClick={() => copyCommand(loginShellCommand)} className="mt-3 px-3 py-2 rounded-sm border border-[var(--border-subtle)] text-xs font-mono uppercase tracking-wider hover:border-[var(--nvidia-green)]">Copy Login-Shell Retry</button></div>
|
||||
</div>
|
||||
</div>
|
||||
{copyMessage && <div className="rounded-sm border border-[var(--border-subtle)] bg-[var(--background-tertiary)] p-3 text-xs text-[var(--foreground-dim)]">{copyMessage}</div>}
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
||||
export default function OperatorTerminalPage() {
|
||||
return (
|
||||
<Suspense fallback={<main className="min-h-screen bg-[var(--background)] text-[var(--foreground)] p-8"><div className="mx-auto max-w-6xl"><div className="panel p-6">Loading operator terminal…</div></div></main>}>
|
||||
<OperatorTerminalInner />
|
||||
</Suspense>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user