Act on a run, and read Home top-down

Runs: a run can now be deleted (DELETE /runs/{id}, cancelling a live one
first), exported as csv from the screen's own filters, and its flow label
opens the flow. Its "Parameters" panel became "Inputs" and lists every
input the flow declares, marking the ones that took the flow's own value
rather than the run's — the comparison table resolves the same defaults
instead of printing "unset".

Home reads brain, dashboards, health, flows: the mosaic is one full-width
scrolling strip, and the flows list and the flow-activity rollups merged
into a single left-joined table so a flow's state and its numbers sit on
one row.

Charts take a drag to narrow the x window and a double click or tap to
come back out. UplotChart holds the scale and passes resetScales:false
while a window is held, which is what the old comment said made this
impossible.
This commit is contained in:
2026-08-29 08:37:11 +02:00
parent 4a1ddcca3f
commit 8fa66039ce
18 changed files with 1082 additions and 365 deletions
+78 -194
View File
@@ -1,9 +1,6 @@
import { useQuery } from "@tanstack/react-query"
import { Link } from "@tanstack/react-router"
import type { FlowRollup, HistoryPoint } from "@/client"
import { type Range, RangePicker } from "@/components/Common/RangePicker"
import { Sparkline } from "@/components/Common/Sparkline"
import { PANEL_SECTION } from "@/components/Flow/SidePanel"
import { runOverviewQueryOptions } from "@/components/Runs/queries"
import { Badge } from "@/components/ui/badge"
@@ -37,40 +34,11 @@ function Tile({
}
/**
* A flow's execution trend, drawn from the 60 slices the rollup carries.
* How the engine is doing: the standing state, as tiles.
*
* Sixty slices of whatever window is selected, so the curve stays the same
* width and only its resolution moves. The same curve the node panel and the
* edge popover draw, dot included, in the chart ramp this page's other graphs
* use. The dot marks the newest slice rather than this instant: the server
* holds the slice that is still filling back, so the curve ends on one that is
* all there.
*/
function Spark({ counts }: { counts: number[] }) {
const points: HistoryPoint[] = counts.map((value, index) => ({
ts: index,
value,
}))
if (points.every((point) => point.value === 0)) {
return <span className="text-xs text-muted-foreground">nothing yet</span>
}
return (
<Sparkline
points={points}
color="var(--chart-1)"
height="h-6"
readout={false}
/>
)
}
/**
* How the engine is doing, and how each flow has been doing over the window.
*
* The tiles are the standing state; the table below is the same window the
* charts cover, one row per flow. The range control sits on this heading
* because it governs the whole health block, the activity below included —
* one window, not one per card.
* The range control sits on this heading because it governs everything under
* it — the flow table, the charts and the lists — rather than this block
* alone. One window, not one per card.
*/
export function HealthOverview({
range,
@@ -96,169 +64,85 @@ export function HealthOverview({
const queued = (runs ?? []).reduce((total, row) => total + row.queued, 0)
return (
<>
<section className="grid gap-3">
<div className="flex flex-wrap items-center gap-3">
<h2 className={PANEL_SECTION}>Health</h2>
<Badge variant={degraded ? "destructive" : "secondary"}>
{degraded ? "Degraded" : "Running normally"}
</Badge>
<div className="ml-auto">
<RangePicker value={range} onChange={onRangeChange} />
</div>
<section className="grid gap-3">
<div className="flex flex-wrap items-center gap-3">
<h2 className={PANEL_SECTION}>Health</h2>
<Badge variant={degraded ? "destructive" : "secondary"}>
{degraded ? "Degraded" : "Running normally"}
</Badge>
<div className="ml-auto">
<RangePicker value={range} onChange={onRangeChange} />
</div>
{summary?.problems.length ? (
<p className="text-sm text-muted-foreground">
{summary.problems.join(" · ")}
</p>
) : null}
</div>
{summary?.problems.length ? (
<p className="text-sm text-muted-foreground">
{summary.problems.join(" · ")}
</p>
) : null}
<div
className={`grid gap-3 sm:grid-cols-2 ${runs?.length ? "lg:grid-cols-6" : "lg:grid-cols-5"}`}
>
<div
className={`grid gap-3 sm:grid-cols-2 ${runs?.length ? "lg:grid-cols-6" : "lg:grid-cols-5"}`}
>
<Tile
label="Nodes"
value={String(summary?.nodes.total ?? 0)}
note={
summary?.nodes.error
? `${summary.nodes.error} failed to load`
: "all loaded"
}
/>
<Tile
label="Flows running"
value={`${summary?.flows.running ?? 0}/${summary?.flows.total ?? 0}`}
// Worst first, but all of them: a quarantine used to hide the
// flows validation blocks, so the tile disagreed with the count
// beside it. Zero and undefined both drop out of the filter.
note={
[
summary?.flows.quarantined &&
`${summary.flows.quarantined} quarantined`,
summary?.flows.invalid && `${summary.flows.invalid} cannot run`,
summary?.flows.paused && `${summary.flows.paused} paused`,
]
.filter(Boolean)
.join(" · ") || "none paused"
}
/>
{runs?.length ? (
<Tile
label="Nodes"
value={String(summary?.nodes.total ?? 0)}
note={
summary?.nodes.error
? `${summary.nodes.error} failed to load`
: "all loaded"
}
label="Runs running"
value={String(running)}
note={queued ? `${queued} queued` : "none queued"}
/>
<Tile
label="Flows running"
value={`${summary?.flows.running ?? 0}/${summary?.flows.total ?? 0}`}
// Worst first, but all of them: a quarantine used to hide the
// flows validation blocks, so the tile disagreed with the count
// beside it. Zero and undefined both drop out of the filter.
note={
[
summary?.flows.quarantined &&
`${summary.flows.quarantined} quarantined`,
summary?.flows.invalid && `${summary.flows.invalid} cannot run`,
summary?.flows.paused && `${summary.flows.paused} paused`,
]
.filter(Boolean)
.join(" · ") || "none paused"
}
/>
{runs?.length ? (
<Tile
label="Runs running"
value={String(running)}
note={queued ? `${queued} queued` : "none queued"}
/>
) : null}
<Tile
label={`Failures (${range.label})`}
// Summed from the rollups the table below is drawn from, so the
// tile, the Errors column and the chart's error line all count the
// same thing over the same window. Narrower than the list beside
// it, which also carries quarantines and crashed tasks.
value={si(errors)}
note={
failures?.length
? `latest ${ago(failures[0].ts)}`
: "nothing recorded"
}
/>
{/* Backlog leads: what is waiting is what says the engine is
) : null}
<Tile
label={`Failures (${range.label})`}
// Summed from the rollups the table below is drawn from, so the
// tile, the Errors column and the chart's error line all count the
// same thing over the same window. Narrower than the list beside
// it, which also carries quarantines and crashed tasks.
value={si(errors)}
note={
failures?.length
? `latest ${ago(failures[0].ts)}`
: "nothing recorded"
}
/>
{/* Backlog leads: what is waiting is what says the engine is
behind. `pending` is work already running, which reads as idle
on an engine hours behind. */}
<Tile
label="Queue backlog"
value={si(queue.backlog ?? 0)}
note={`${queue.pending ?? 0} in flight · ${queue.delayed ?? 0} delayed · ${queue.parked ?? 0} parked`}
/>
<Tile
label="Loop lag"
value={dur(summary?.loop_lag.ewma ?? 0)}
note={`peak ${dur(summary?.loop_lag.max_60s ?? 0)} in the last minute`}
/>
</div>
</section>
<section className="grid gap-3">
<h2 className={PANEL_SECTION}>Flow activity ({range.label})</h2>
<div className={`${CARD} overflow-x-auto`}>
{/* The name anchors the left, the numbers read down their own
centre, and the trend closes the row on the right. */}
<table className="w-full text-sm">
<thead className="text-xs text-muted-foreground">
<tr>
<th className="pb-2 text-left font-medium">Flow</th>
<th className="px-3 pb-2 text-center font-medium">
Executions
</th>
<th className="px-3 pb-2 text-center font-medium">Errors</th>
<th className="px-3 pb-2 text-center font-medium">Avg</th>
<th className="px-3 pb-2 text-center font-medium">Lag</th>
{/* A bounded share rather than all the slack: the columns
beside it grow with their own content, so the numbers
spread across the middle instead of huddling on the left.
Its 128px floor is more than a phone has to spare, and a
curve that narrow says nothing, so it goes below `sm`. */}
<th className="hidden w-1/3 pb-2 pl-3 text-right font-medium sm:table-cell sm:min-w-32">
Trend
</th>
</tr>
</thead>
<tbody>
{(flows ?? []).map((row: FlowRollup) => (
<tr key={row.flow} className="border-t border-border">
<td className="max-w-0 py-2 pr-3 sm:min-w-32">
{/* `max-w-0` is what lets a cell truncate at all: without
it the table sizes to the longest name and pushes the
page sideways. The floor beside it keeps an ordinary
name readable where there is room for one; a phone has
none to spare, so it starts at `sm` like the trend. */}
<Link
to="/flows/$flowName"
params={{ flowName: row.flow }}
className="block truncate font-mono hover:underline"
>
{row.flow || "—"}
</Link>
</td>
<td className="px-3 py-2 text-center">
{si(row.executions)}
</td>
<td className="px-3 py-2 text-center">
{row.errors ? (
<Badge variant="destructive">
{si(row.errors)} failed
</Badge>
) : (
<span className="text-muted-foreground">none</span>
)}
</td>
<td className="whitespace-nowrap px-3 py-2 text-center">
{dur(row.avg_ms)}
</td>
<td className="whitespace-nowrap px-3 py-2 text-center">
{dur(row.avg_lag_ms)}
</td>
{/* The dot straddles the curve's right edge, so the cell
keeps a little room for the half that hangs out. */}
<td className="hidden py-2 pr-2 pl-3 text-right sm:table-cell">
<Spark counts={row.spark} />
</td>
</tr>
))}
{flows?.length === 0 ? (
<tr>
<td
colSpan={6}
className="py-6 text-center text-muted-foreground"
>
No flow has run in the last {range.label}.
</td>
</tr>
) : null}
</tbody>
</table>
</div>
</section>
</>
<Tile
label="Queue backlog"
value={si(queue.backlog ?? 0)}
note={`${queue.pending ?? 0} in flight · ${queue.delayed ?? 0} delayed · ${queue.parked ?? 0} parked`}
/>
<Tile
label="Loop lag"
value={dur(summary?.loop_lag.ewma ?? 0)}
note={`peak ${dur(summary?.loop_lag.max_60s ?? 0)} in the last minute`}
/>
</div>
</section>
)
}