Frontend addresses flows and dashboards by id: routes /flows/$flowId, /dashboards/$id and /view/$id, query keys, saves, lists, device pickers, search, brain and endpoint links and generated results dashboards go by id, while live values, issues, pauses and message names keep the key; tabs take the title from the document; creating uses POST and opens the issued id; the flow and dashboard panels show key and id with a copy button and a served HTTP or WebSocket node shows its hook URL under the flow id; specs create by POST and ids.spec.ts exercises issued ids

This commit is contained in:
2026-11-02 19:57:43 +01:00
parent fd637e0f1e
commit fa15522cb0
65 changed files with 1380 additions and 784 deletions
+26 -6
View File
@@ -35,6 +35,11 @@ const AUTH_ATTEMPTS = 3
*/
const HEALTH_FLOOR = 60_000
/**
* An engine event names its flow by key (`flow`), which node ids and live
* values are qualified with, and by id (`flow_id`), which a query or a route
* takes. Snapshot lists stay keyed by key.
*/
type FlowEvent =
| {
type: "snapshot"
@@ -58,6 +63,7 @@ type FlowEvent =
| {
type: "node_queued"
flow?: string
flow_id?: string
node: string
run?: string
detail?: string
@@ -66,6 +72,7 @@ type FlowEvent =
| {
type: "node_executed"
flow?: string
flow_id?: string
node: string
outputs: number
duration_ms?: number
@@ -73,6 +80,7 @@ type FlowEvent =
| {
type: "node_error"
flow?: string
flow_id?: string
node: string
error: string
ts?: number
@@ -80,21 +88,29 @@ type FlowEvent =
| { type: "node_status"; node: string; status: string; error?: string | null }
| { type: "node_error_acknowledged"; node: string; ts?: number }
| ({ type: "node_log" } & LogLine)
| { type: "flow_paused"; flow: string; paused: boolean }
| { type: "flow_paused"; flow: string; flow_id?: string; paused: boolean }
| {
type: "node_health"
flow?: string
flow_id?: string
node: string
health: "ok" | "degraded" | "down" | "unknown"
detail?: string | null
ts?: number
}
| { type: "flow_quarantined"; flow: string; error?: string; ts?: number }
| {
type: "flow_quarantined"
flow: string
flow_id?: string
error?: string
ts?: number
}
| { type: "engine_degraded"; reason?: string; ts?: number }
| { type: "engine_fatal"; reason?: string; ts?: number }
| {
type: "cascade_dropped"
flow?: string
flow_id?: string
node?: string
deliveries?: number
ts?: number
@@ -102,6 +118,7 @@ type FlowEvent =
| {
type: "queue_unavailable"
flow?: string
flow_id?: string
node?: string
error?: string
ts?: number
@@ -111,6 +128,7 @@ type FlowEvent =
nodes: { id: string; status: string; error?: string | null }[]
paused?: string[]
}
/** `dashboard` is an id, or empty when only device assignments changed. */
| { type: "dashboard_changed"; dashboard?: string; ts?: number }
| {
type: "device_status"
@@ -122,6 +140,7 @@ type FlowEvent =
| {
type: "run_started" | "run_finished"
flow: string
flow_id?: string
run: string
status?: string
group?: string
@@ -130,6 +149,7 @@ type FlowEvent =
| {
type: "run_metric"
flow: string
flow_id?: string
run: string
names: string[]
ts?: number
@@ -231,11 +251,11 @@ function endLive() {
}
/** Everything a node's health shows up in, which is two unrelated keys. */
function invalidateHealth(flow: string | undefined) {
function invalidateHealth(flowId: string | undefined) {
// `graph` is a sibling of the flow's own key rather than a child, so the
// detail invalidation alone never reaches Home's fault rings.
for (const queryKey of [
flow ? flowKeys.detail(flow) : flowKeys.all,
flowId ? flowKeys.detail(flowId) : flowKeys.all,
flowKeys.graph,
]) {
client?.invalidateQueries({ queryKey })
@@ -387,7 +407,7 @@ function open(url: string) {
// the server derives — so the screen only moved on mount, navigation
// or a rebuild, never when health actually flipped. The store had a
// health map of its own and nothing ever read it.
invalidateHealth(message.flow)
invalidateHealth(message.flow_id)
// Degraded is held back by the same floor, as a warning rather than
// a fault.
if (message.health === "down" || message.health === "degraded") {
@@ -402,7 +422,7 @@ function open(url: string) {
message.node,
setTimeout(() => {
healthTimers.delete(message.node)
invalidateHealth(message.flow)
invalidateHealth(message.flow_id)
}, HEALTH_FLOOR),
)
}