import { useQuery } from "@tanstack/react-query"; import { Activity, Download, Gauge, HardDrive, MemoryStick, ScanSearch, Terminal } from "lucide-react"; import { useEffect, useRef, useState, type ReactNode } from "react"; import { EmptyState, Spinner } from "@/components/ui"; import { api } from "@/lib/api"; import { cn } from "@/lib/cn"; import { formatBytes } from "@/lib/format"; import type { StatJob, SystemStats } from "@/lib/types"; import { useAuth } from "@/store/auth"; const REFRESH_MS = 2000; /** DESIGN.md capacity bars: blue, peach at 80%, red at 95%. */ function meterColor(percent: number): string { if (percent >= 95) return "bg-ctp-red"; if (percent >= 80) return "bg-ctp-peach"; return "bg-ctp-blue"; } function Meter({ percent, className }: { percent: number; className?: string }) { return (
{job.summary ?? job.detail}
) : ( <>{job.progress}% · {job.detail}
> )}Host telemetry, background jobs and the application log. Refreshing every {REFRESH_MS / 1000} s.
up {formatUptime(system.uptime_seconds)}
{system.cpu.cores} logical cores {system.cpu.physical_cores ? ` · ${system.cpu.physical_cores} physical` : ""} {system.cpu.load.length > 0 ? ` · load ${system.cpu.load.join(" / ")}` : ""}
{formatBytes(system.memory.used)} /{" "} {formatBytes(system.memory.total)} · {formatBytes(system.memory.available)} free
swap {formatBytes(system.memory.swap_used)} /{" "} {formatBytes(system.memory.swap_total)}
{gpu.name}
{gpu.memory_used !== null && gpu.memory_total !== null ? `vram ${formatBytes(gpu.memory_used)} / ${formatBytes(gpu.memory_total)}` : "vram unknown"} {gpu.temperature !== null ? ` · ${gpu.temperature}°C` : ""}
)) ) : (No NVIDIA GPU reported by nvidia-smi.
)}{formatBytes(disk.watched_folder.used)} /{" "} {formatBytes(disk.watched_folder.total)} · {formatBytes(disk.watched_folder.free)} free
library {formatBytes(disk.watched_folder.library_size)} ·{" "} {disk.library_items} items
media {formatBytes(disk.media.size)} · temp{" "} {formatBytes(disk.temp.size)} ({disk.temp.files} files)
Nothing running — downloads and match scans appear here.
) : (No finished jobs yet.
) : (No log file yet — it is created on the next log write.
) : (