import { createSignal, For, Show, type JSX } from "solid-js" import type { MonitorClient } from "./client.js" import { bytes, gpuPercent, percent, uptime } from "./format.js" import type { HistoryPoint } from "./types.js" type Metric = "cpu" | "ram" | "gpu" | "disk" const paths = { cpu: "M8 3v3m4-3v3m4-3v3M8 18v3m4-3v3m4-3v3M3 8h3m-3 4h3m-3 4h3m12-8h3m-3 4h3m-3 4h3M7 6h10a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1Zm2 3h6v6H9Z", ram: "M4 7h16v10H4ZM7 17v3m4-3v3m4-3v3m4-3v3M8 10v4m4-4v4m4-4v4M2 10h2m-2 4h2m16-4h2m-2 4h2", gpu: "M3 6h17v12H3ZM20 10h2m-2 4h2M6 18v3m4-3v3m4-3v3M7 10h4v4H7Zm8 0h2m-2 4h2", disk: "M5 5h14l3 10v5H2v-5Zm-3 10h20M6 18h.01M9 18h.01", } export function MetricIcon(props: { type: Metric }) { return } function Bar(props: { value: number | null; label: string; kind?: Metric }) { return
= 95 ? "critical" : props.value !== null && props.value >= 85 ? "warning" : "normal"}>
} function Sparkline(props: { points: HistoryPoint[]; metric: "cpu" | "ram" | "gpu" }) { const points = () => props.points.filter(point => point[props.metric] !== null) const coordinates = () => { const end = props.points.at(-1)?.at ?? 0 return points().map(point => `${Math.max(0, 300 - (end - point.at) / 600)},${36 - (point[props.metric] ?? 0) * .32}`).join(" ") } return
1}> {points().length > 1 ? "Last 3 minutes · this window" : "Collecting history…"}
} function Card(props: { title: string; badge: string; kind: Metric; children: JSX.Element }) { return

{props.title}

{props.badge}
{props.children}
} export function Dashboard(props: { client: MonitorClient mode: "light" | "dark" compact?: boolean refreshMs: number setRefreshMs: (value: number) => void openWindow?: () => void }) { const client = props.client const [details, setDetails] = createSignal(false) return
{!client.active() ? "Paused" : client.error() ? "Connection error" : client.stale() ? "Stale readings" : "Live system overview"}
Reading disk, memory, CPU, and Intel graphics…
}> {snapshot => <>
{snapshot().hostname}{snapshot().platform}Uptime {uptime(snapshot().uptime)}Checked {client.age() < 2 ? "just now" : `${client.age()}s ago`}
{percent(snapshot().cpu.percent)}used

{snapshot().cpu.name}

All logical processors{percent(snapshot().cpu.percent === null ? null : 100 - snapshot().cpu.percent!)} idle
{percent(snapshot().ram.percent)}used

{bytes(snapshot().ram.used)} of {bytes(snapshot().ram.total)}

Available memory{bytes(snapshot().ram.free)}
{disk =>
{bytes(disk.free)}free

{disk.name} · {bytes(disk.total)} capacity

{bytes(disk.used)} used{percent(disk.percent)} used
{disk.percent >= 95 ? "Very little free space" : disk.percent >= 85 ? "Getting full" : "Plenty of free space"}Checked every 30s
}

{snapshot().disks.error ?? "No fixed drives detected"}

{percent(gpuPercent(snapshot()))}used

{snapshot().gpu.adapter?.name ?? "Intel graphics"}

Shared RAM in use{bytes(snapshot().gpu.adapter?.sharedUsed)}

{snapshot().gpu.error}

Disk readings may be stale: {snapshot().disks.error}

CPU utilization per logical processor

{(value, index) =>
{index() + 1}{percent(value)}
}

GPU utilization is the busiest engine on the Intel adapter, with process counters combined per engine. Other GPUs are excluded. GPU checks are limited to once every 5 seconds.

Integrated graphics borrows system RAM: {bytes(snapshot().gpu.adapter?.sharedUsed)} currently used, with a driver-reported limit of {bytes(snapshot().gpu.adapter?.sharedLimit)}. This is already part of memory usage, not extra dedicated VRAM.

Sampling runs only while this dashboard is visible. Closing it or hiding this window stops automatic checks. Use /system to reopen it or /system_status for a one-time text report. History lives only in this window. Sizes use binary units (GiB).

}
}