import Link from "next/link"; import { formatDistanceToNowStrict } from "date-fns"; import { cn } from "@/lib/utils"; import { formatEta } from "@/app/(dashboard)/pipeline/status-colors"; import type { FarmStatus } from "@/lib/dashboard/ops"; /** * Farm health: who is up, what is waiting, and who is running an old worker. * * The version row is not trivia — a worker's version is what decides whether * it has a given fix, and a machine that quietly stayed behind keeps producing * the bug everyone else has stopped seeing. */ export function FarmStrip({ farm }: { farm: FarmStatus }) { return (

{farm.online} of {farm.total} online

Machines →
{farm.machines.length === 0 ? (

No machines have registered yet.

) : ( farm.machines.map((m) => (
{m.name} {m.currentJob ? `${m.currentJob.shotCode ?? "job"} ${m.currentJob.versionString ?? ""} · ${Math.round( (m.currentJob.progress ?? 0) * 100 )}% · ETA ${formatEta(m.currentJob.etaSeconds)}` : m.status === "ONLINE" ? "Idle" : m.lastSeenAt ? `Offline · last seen ${formatDistanceToNowStrict(new Date(m.lastSeenAt))} ago` : "Never seen"} {m.workerVersion ?? "—"}
)) )}
{farm.queued.render} renders queued
{farm.queued.preview} previews queued
{farm.oldestQueuedMs == null ? "—" : formatDistanceToNowStrict(new Date(Date.now() - farm.oldestQueuedMs))} oldest wait
{farm.behindMachines.length > 0 && (
{farm.behindMachines.length} machine {farm.behindMachines.length === 1 ? " is" : "s are"} behind{" "} {farm.latestWorkerVersion} —{" "} {farm.behindMachines .map((m) => `${m.name} (${m.workerVersion ?? "unknown"})`) .join(", ")}
)}
); }