fleet(tower): 0.20 — Re-Dispatch-Provenienz sichtbar (Badge statt Doppel-Button)
Dead-Letter-Zeile mit re_dispatched_to zeigt '↻ zugestellt <id>' statt des Aktions-Buttons; Spool-Zeilen mit re_dispatch_of tragen ein ↻ vor dem Topic. TaskEnvelope um re_dispatch_of/re_dispatched_to erweitert.
This commit is contained in:
@@ -33,6 +33,8 @@ type TaskEnvelope = {
|
||||
vs: string
|
||||
claimed_at: string
|
||||
status_label: string
|
||||
re_dispatched_to: string
|
||||
re_dispatch_of: string
|
||||
file: string
|
||||
}
|
||||
|
||||
@@ -116,6 +118,7 @@ export default function TaskBrowser() {
|
||||
const [detail, setDetail] = useState<TaskDetail | null>(null)
|
||||
const [detailLoading, setDetailLoading] = useState(false)
|
||||
const [detailError, setDetailError] = useState("")
|
||||
const [redis, setRedis] = useState<Record<string, { state: string; msg: string }>>({})
|
||||
const modalRef = useRef<HTMLDivElement | null>(null)
|
||||
|
||||
const load = useCallback(async () => {
|
||||
@@ -139,6 +142,46 @@ export default function TaskBrowser() {
|
||||
return () => clearInterval(t)
|
||||
}, [load])
|
||||
|
||||
/** Dead-Letter-Re-Dispatch: neuer Envelope ueber den board-service (Tower schreibt nie selbst). */
|
||||
const redispatch = useCallback(
|
||||
async (taskId: string) => {
|
||||
setRedis((prev) => ({ ...prev, [taskId]: { state: "busy", msg: "stelle zu…" } }))
|
||||
try {
|
||||
const res = await fetch("/api/fleet/task-redispatch", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ id: taskId }),
|
||||
})
|
||||
const body = (await res.json()) as {
|
||||
result?: string
|
||||
new_task_id?: string
|
||||
reason?: string
|
||||
problems?: string[]
|
||||
}
|
||||
const result = String(body.result || `HTTP ${res.status}`)
|
||||
let state = "err"
|
||||
let msg = result
|
||||
if (result === "OK_REDISPATCHED") {
|
||||
state = "ok"
|
||||
msg = `erneut zugestellt -> ${body.new_task_id}`
|
||||
} else if (result === "OK_ALREADY") {
|
||||
state = "already"
|
||||
msg = `bereits re-dispatched -> ${body.new_task_id || "?"}`
|
||||
} else if (body.reason || body.problems?.length) {
|
||||
msg = `${result}: ${body.reason || body.problems?.join("; ")}`
|
||||
}
|
||||
setRedis((prev) => ({ ...prev, [taskId]: { state, msg } }))
|
||||
await load()
|
||||
} catch (e) {
|
||||
setRedis((prev) => ({
|
||||
...prev,
|
||||
[taskId]: { state: "err", msg: e instanceof Error ? e.message : String(e) },
|
||||
}))
|
||||
}
|
||||
},
|
||||
[load]
|
||||
)
|
||||
|
||||
const openDetail = useCallback(async (id: string, kind: string) => {
|
||||
setDetailLoading(true)
|
||||
setDetailError("")
|
||||
@@ -267,7 +310,8 @@ export default function TaskBrowser() {
|
||||
<th className="py-2 pr-3">Typ</th>
|
||||
<th className="py-2 pr-3">Prio</th>
|
||||
<th className="py-2 pr-3">Status</th>
|
||||
<th className="py-2">Thema</th>
|
||||
<th className="py-2 pr-3">Thema</th>
|
||||
{tab === "dead-letter" && <th className="py-2">Aktion</th>}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="font-mono">
|
||||
@@ -290,13 +334,71 @@ export default function TaskBrowser() {
|
||||
<td className={`py-1.5 pr-3 ${prioClass(t.priority)}`}>{t.priority}</td>
|
||||
<td className="py-1.5 pr-3">{t.status_label}</td>
|
||||
<td className="py-1.5 max-w-[26rem] truncate" title={t.topic}>
|
||||
{t.re_dispatch_of !== "-" && t.re_dispatch_of !== "" && (
|
||||
<span
|
||||
className="mr-1 text-[var(--foreground-dim)]"
|
||||
title={`Re-Dispatch von ${t.re_dispatch_of}`}
|
||||
data-testid={`redispatch-of-${t.task_id}`}
|
||||
>
|
||||
↻
|
||||
</span>
|
||||
)}
|
||||
{t.topic}
|
||||
</td>
|
||||
{tab === "dead-letter" && (
|
||||
<td className="py-1.5 whitespace-nowrap" data-testid={`redispatch-${t.task_id}`}>
|
||||
{t.re_dispatched_to !== "-" && t.re_dispatched_to !== "" ? (
|
||||
<span
|
||||
className="text-[var(--foreground-dim)]"
|
||||
title={`Bereits erneut zugestellt an ${t.re_dispatched_to}`}
|
||||
data-testid={`redispatch-already-${t.task_id}`}
|
||||
>
|
||||
↻ zugestellt {t.re_dispatched_to.slice(0, 8)}
|
||||
</span>
|
||||
) : redis[t.task_id] ? (
|
||||
<span
|
||||
className={
|
||||
redis[t.task_id].state === "ok"
|
||||
? "text-emerald-400"
|
||||
: redis[t.task_id].state === "already"
|
||||
? "text-[var(--foreground-dim)]"
|
||||
: redis[t.task_id].state === "busy"
|
||||
? "text-[var(--foreground-dim)]"
|
||||
: "text-red-400"
|
||||
}
|
||||
title={redis[t.task_id].msg}
|
||||
>
|
||||
{redis[t.task_id].state === "ok"
|
||||
? "✔ "
|
||||
: redis[t.task_id].state === "already"
|
||||
? "✔ "
|
||||
: redis[t.task_id].state === "busy"
|
||||
? "… "
|
||||
: "✖ "}
|
||||
{redis[t.task_id].msg.slice(0, 42)}
|
||||
</span>
|
||||
) : (
|
||||
<button
|
||||
type="button"
|
||||
className="rounded border border-[var(--border)] px-2 py-0.5 text-[11px] hover:bg-[var(--background-tertiary)]"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
void redispatch(t.task_id)
|
||||
}}
|
||||
>
|
||||
Erneut zustellen
|
||||
</button>
|
||||
)}
|
||||
</td>
|
||||
)}
|
||||
</tr>
|
||||
))}
|
||||
{data && ((tab === "spool" ? data.spool : data.dead_letter).length === 0) && (
|
||||
<tr>
|
||||
<td colSpan={7} className="py-4 text-[var(--foreground-dim)]">
|
||||
<td
|
||||
colSpan={tab === "dead-letter" ? 8 : 7}
|
||||
className="py-4 text-[var(--foreground-dim)]"
|
||||
>
|
||||
{tab === "spool"
|
||||
? "Keine offenen Tasks — Spool leer."
|
||||
: "Keine fehlgeschlagenen Tasks in den letzten 7 Tagen."}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
* Beide Endpunkte sind fail-loud-lesend: eine tote Quelle macht den Endpunkt
|
||||
* NICHT 500, sondern sichtbar degraded (Uptime-Monitoring braucht eine Antwort).
|
||||
*/
|
||||
export const TOWER_VERSION = process.env.FLEET_TOWER_VERSION || "0.18"
|
||||
export const TOWER_VERSION = process.env.FLEET_TOWER_VERSION || "0.20"
|
||||
export const TOWER_STARTED_AT_MS = Date.now()
|
||||
|
||||
export type SourceState = {
|
||||
|
||||
@@ -55,6 +55,8 @@ export type TaskEnvelope = {
|
||||
vs: string
|
||||
claimed_at: string
|
||||
status_label: string
|
||||
re_dispatched_to: string
|
||||
re_dispatch_of: string
|
||||
file: string
|
||||
}
|
||||
|
||||
@@ -136,6 +138,8 @@ function normalizeEnvelope(doc: Record<string, unknown>, now: number, file: stri
|
||||
vs: str(doc.vs),
|
||||
claimed_at: claimedRaw === undefined || claimedRaw === null ? MISSING : iso(toEpoch(claimedRaw)),
|
||||
status_label: STATUS_LABEL[status] ?? (status || MISSING),
|
||||
re_dispatched_to: str(doc.re_dispatched_to),
|
||||
re_dispatch_of: str(doc.re_dispatch_of),
|
||||
file,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user