import { useEffect, useState } from "react"; import { Link } from "react-router-dom"; import { api, type CurrentUser, type RobotAccount } from "../api/client"; import ReadNowButton from "../components/ReadNowButton"; import EmptyState from "../components/EmptyState"; import TimeAgo from "../components/TimeAgo"; import { BlockSkeleton } from "../components/Skeleton"; import { ErrorNotice } from "../components/Notice"; import { readableError } from "../utils/errors"; import PageIntro from "../components/PageIntro"; function Badge({ a }: { a: RobotAccount }) { if (!a.enabled) return Off; if (!a.state) return Not read yet; if (!a.fresh) return Can’t be read; if (a.problems.some((x) => x.severity === "critical")) return Needs a look; if (a.problems.length > 0) return Needs a look; return In order; } function Tile({ label, value, sub, warn }: { label: string; value: string; sub?: string | null; warn?: boolean }) { return (
{label}
{value}
{sub &&
{sub}
}
); } /** "Paid until 2026-12-01", or, for one that is cancelled, when it ends and how long that is. */ function Until({ date, cancelled, days }: { date: string | null; cancelled: boolean; days: number | null | undefined }) { if (!date) return —; if (!cancelled) return paid until {date}; const urgent = days !== null && days !== undefined && days <= 7; const soon = days !== null && days !== undefined && days <= 30; return ( <> cancelled
ends {date} {days !== null && days !== undefined ? (days < 0 ? " — has ended" : days === 0 ? " — today" : ` — ${days} day${days === 1 ? "" : "s"} left`) : ""}
); } function Card({ a, canRead, onRead }: { a: RobotAccount; canRead: boolean; onRead: () => void }) { const s = a.state; const rescue = s?.servers.filter((v) => v.rescue === true).length ?? 0; const cancelled = (s?.servers.filter((v) => v.cancelled).length ?? 0) + (s?.storageBoxes?.filter((b) => b.cancelled).length ?? 0); return (

{a.name}

{a.status ? <>read : "not read yet"} {canRead && a.enabled && }
{a.status && !a.status.ok &&
The last attempt to read it failed: {a.status.error ?? "no answer"}.
} {a.problems.length > 0 && ( )} {s && ( <>
0 ? "the next boot is into it" : "none"} warn={rescue > 0} /> 0 ? "servers and storage boxes shutting down" : "nothing shutting down"} warn={cancelled > 0} /> b.locked) ? "one is locked" : null} warn={!!s.storageBoxes?.some((b) => b.locked)} />
{s.skippedDetail > 0 &&
{s.skippedDetail} server{s.skippedDetail === 1 ? "" : "s"} beyond the first 25 were not asked about their rescue system (Hetzner allows 200 requests an hour).
} {s.servers.length > 0 && (
{s.servers.map((v) => ( ))}
Server Product Address Traffic Status Rescue Paid
{v.name}
#{v.number}
{v.product ?? "—"} {v.dc &&
{v.dc}
}
{v.ip ? {v.ip} : "—"} {v.ipv6 && (
{v.ipv6}
)}
{v.traffic ?? "—"} {v.status === "ready" ? ready : {v.status}} {v.rescue === null ? ( — ) : v.rescue ? ( <> on {v.rescueSince && (
since
)} ) : ( off )}
)} {s.storageBoxes && s.storageBoxes.length > 0 && ( <>

Storage boxes

{s.storageBoxes.map((b) => ( ))}
Storage box Product Location Linked to State Paid
{b.name}
{b.login ?? `#${b.id}`}
{b.product ?? "—"} {b.location ?? "—"} {b.linkedServer !== null ? (s.servers.find((v) => v.number === b.linkedServer)?.name ?? `server ${b.linkedServer}`) : "—"} {b.locked ? locked : open}
)} )}
); } /** Hetzner Robot: the account's dedicated servers (rescue system, cancellation) and storage boxes. */ export default function HetznerRobot({ user }: { user: CurrentUser }) { const [data, setData] = useState(null); const [error, setError] = useState(null); const load = () => api.hetznerRobot .list() .then((r) => { setData(r.accounts); setError(null); }) .catch((err) => setError(readableError(err))); useEffect(() => { void load(); const t = setInterval(load, 60_000); return () => clearInterval(t); }, []); const canRead = user.role === "admin" || user.role === "operator"; return ( <>

Hetzner Robot

Dedicated servers and storage boxes at Hetzner (Robot — the cloud servers are on Hetzner Cloud), read every fifteen minutes (see Integrations) — nothing is reset, ordered or cancelled.{" "} A server or storage box that is cancelled and about to shut down, a locked storage box, a rescue system left on and a server stuck being set up are alerts — see Alerts. {!data && !error && } {data && data.length === 0 && (
)} {data?.map((a) => void load()} />)} ); }