fleet-manager ui: render a never-reported host's last_seen as "never"

A just-approved inventory record has a zero-value last_seen (Go 0001-01-01),
which parsed to a pre-epoch instant and slipped past the !t guard, rendering as
"739800d ago". Treat any at-or-before-epoch timestamp as "never" — the honest
state for a born-but-never-connected host (its health/version stay "—" until an
agent dials the gRPC plane).
This commit is contained in:
Audiobuzz
2026-07-04 10:03:28 +00:00
parent 0360c1c6d1
commit bf546a80a6
+4 -1
View File
@@ -3,7 +3,10 @@
export function relTime(iso) {
if (!iso) return '—'
const t = new Date(iso).getTime()
if (!t) return '—'
if (Number.isNaN(t)) return '—'
// Go's zero time (0001-01-01) serialises as a real string but parses to a
// pre-epoch instant — a born-but-never-reported host. Render it honestly.
if (t <= 0) return 'never'
const s = Math.max(0, Math.round((Date.now() - t) / 1000))
if (s < 60) return s + 's ago'
if (s < 3600) return Math.floor(s / 60) + 'm ago'