import { useEffect, useRef } from 'react' import { Terminal } from 'lucide-react' import type { TerminalLine } from '../../types' import { resolveInfraNode } from '../../lib/infraCatalog' import { cn } from '../../lib/utils' type Props = { subjectId: string | null subjectLabel: string lines: TerminalLine[] busy: boolean expanded: boolean onToggle: () => void } const LEVEL: Record = { info: 'text-foreground-muted', ok: 'text-success', warn: 'text-warning', err: 'text-danger', cmd: 'text-docker', llm: 'text-violet-400', } export function TerminalDock({ subjectId, subjectLabel, lines, busy, expanded, onToggle }: Props) { const bottomRef = useRef(null) const infra = resolveInfraNode(subjectId) useEffect(() => { if (expanded) bottomRef.current?.scrollIntoView({ behavior: 'smooth' }) }, [lines, busy, expanded]) return (
{expanded && (
{infra && (

$ {infra.ssh} (copied via Shell button)

)} {lines.length === 0 && (

Select a node or agent · click Shell or Probe to see output

)} {lines.map((line) => (
{line.ts ? new Date(line.ts).toLocaleTimeString('en-US', { hour12: false }) : ''} {' '} [{line.phase}] {line.text}
))} {busy && }
)}
) }