fleet(tower): 0.18 — Tasks-View (Spool/Dead-Letter/Alarm) + Task-Detail-Modal + /healthz + /api/status; Fleet-Views 0.13-0.18 erstmals versioniert
This commit is contained in:
@@ -0,0 +1,118 @@
|
||||
"use client"
|
||||
|
||||
import { useEffect, useState } from "react"
|
||||
|
||||
/**
|
||||
* EscalationHistory — Kernfeature 4: HITL-/Escalation-Historie.
|
||||
* Journal-Filter type=escalation (Deadman-Alarm, Agent-Escalations) plus
|
||||
* rejected-Quarantine-Events. Poll 5 s. Kein psql — Spool ist die Wahrheit.
|
||||
*/
|
||||
|
||||
type JournalLine = {
|
||||
event?: string
|
||||
task_id?: string
|
||||
from?: string
|
||||
to?: string
|
||||
type?: string
|
||||
priority?: string
|
||||
time_epoch?: number
|
||||
errors?: string
|
||||
[k: string]: unknown
|
||||
}
|
||||
|
||||
export default function EscalationHistory() {
|
||||
const [esc, setEsc] = useState<JournalLine[]>([])
|
||||
const [rej, setRej] = useState<JournalLine[]>([])
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false
|
||||
const load = () => {
|
||||
fetch("/api/fleet/escalations", { cache: "no-store" })
|
||||
.then(async (res) => {
|
||||
if (!res.ok) throw new Error((await res.json()).error || `HTTP ${res.status}`)
|
||||
return res.json()
|
||||
})
|
||||
.then((d: { escalations: JournalLine[]; rejected: JournalLine[] }) => {
|
||||
if (cancelled) return
|
||||
setEsc(d.escalations)
|
||||
setRej(d.rejected)
|
||||
setError(null)
|
||||
})
|
||||
.catch((e: Error) => {
|
||||
if (!cancelled) setError(e.message)
|
||||
})
|
||||
}
|
||||
load()
|
||||
const timer = setInterval(load, 5000)
|
||||
return () => {
|
||||
cancelled = true
|
||||
clearInterval(timer)
|
||||
}
|
||||
}, [])
|
||||
|
||||
const row = (l: JournalLine, kind: "esc" | "rej") => (
|
||||
<div
|
||||
key={`${l.task_id}-${l.time_epoch}-${kind}`}
|
||||
className="border-b border-[var(--border)] py-2 font-mono text-xs flex gap-3 items-baseline"
|
||||
data-fleet-escalation={kind}
|
||||
>
|
||||
<span className="text-[var(--foreground-dim)] w-36 shrink-0">
|
||||
{l.time_epoch ? new Date(l.time_epoch * 1000).toLocaleString("de-DE") : "--"}
|
||||
</span>
|
||||
<span className="w-20 shrink-0">{l.from || "system"}</span>
|
||||
<span className="text-[var(--foreground-dim)] w-4 shrink-0">→</span>
|
||||
<span className="w-16 shrink-0">{l.to || "-"}</span>
|
||||
<span className="w-8 shrink-0 text-[var(--status-stopped)]">{l.priority || ""}</span>
|
||||
<span className="truncate text-[var(--foreground-dim)]">{l.task_id?.slice(0, 8) || l.errors || ""}</span>
|
||||
</div>
|
||||
)
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<div className="panel p-8 text-center" data-testid="fleet-escalations-error">
|
||||
<h3 className="text-sm font-semibold text-[var(--status-stopped)] uppercase tracking-wider">
|
||||
Journal nicht erreichbar
|
||||
</h3>
|
||||
<p className="text-xs text-[var(--foreground-dim)] mt-2 font-mono break-all">{error}</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div className="panel p-4 flex items-center gap-4">
|
||||
<h1 className="text-lg font-semibold text-[var(--nvidia-green)] uppercase tracking-wider mr-auto">
|
||||
ESCALATIONS
|
||||
</h1>
|
||||
<span className="text-[10px] font-mono text-[var(--foreground-dim)]">
|
||||
{esc.length} Alarme · {rej.length} Quarantaene
|
||||
</span>
|
||||
</div>
|
||||
<div className="panel p-4">
|
||||
<h2 className="text-[10px] uppercase tracking-wider text-[var(--status-stopped)] mb-3">
|
||||
HITL-Alarme (type=escalation)
|
||||
</h2>
|
||||
{esc.length === 0 ? (
|
||||
<p className="text-xs text-[var(--foreground-dim)] font-mono py-4 text-center">
|
||||
Keine Alarme — alles ruhig
|
||||
</p>
|
||||
) : (
|
||||
esc.map((l) => row(l, "esc"))
|
||||
)}
|
||||
</div>
|
||||
<div className="panel p-4">
|
||||
<h2 className="text-[10px] uppercase tracking-wider text-[var(--foreground-dim)] mb-3">
|
||||
Quarantaene (rejected/invalid)
|
||||
</h2>
|
||||
{rej.length === 0 ? (
|
||||
<p className="text-xs text-[var(--foreground-dim)] font-mono py-4 text-center">
|
||||
Keine abgelehnten Envelopes
|
||||
</p>
|
||||
) : (
|
||||
rej.map((l) => row(l, "rej"))
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user