Start, stop and pause flows, and show what their nodes print

Flows can now be taken off the engine and put back. Stopped state lives in a
runtime.json beside the flow, not in the flow document: the canvas autosaves
that document, so a stopped flow would otherwise start itself again on the
next edit. A stopped flow gets no subscriptions, schedules or webhooks, its
nodes are skipped by the scheduler, and running it answers 409. Pausing holds
a flow's nodes while its values keep arriving, so the canvas still shows what
is coming in.

Node code is user code and print is how it says things, so stdout is teed
through a contextvar sink active only during a node execution — one event per
execution, capped, so a chatty node cannot outrun the stream. A node that
fails sends its traceback the same way, trimmed to the author's own frames.
The dock gains a logs panel and a pause control; the dashboard replaces its
placeholder with what is running, stopped or failing; the edge inspector can
send the last message again.

Single-stepping is deferred and noted: the scheduler keeps no progress between
calls, so a step button would re-run the same node rather than advance.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Melvin Strobl
2026-08-15 23:35:08 +02:00
co-authored by Claude Fable 5
parent 606ab3c423
commit 7344eac262
29 changed files with 1410 additions and 48 deletions
+17 -3
View File
@@ -2,7 +2,7 @@ import { useQueryClient } from "@tanstack/react-query"
import { useEffect, useRef } from "react"
import { OpenAPI } from "@/client"
import { liveStore } from "./liveStore"
import { type LogLine, liveStore } from "./liveStore"
import { flowKeys } from "./queries"
const RECONNECT_MIN = 1000
@@ -13,14 +13,19 @@ type FlowEvent =
type: "snapshot"
values: Record<string, { value: unknown; ts: number | null }>
nodes: { id: string; status: string; error?: string | null }[]
paused?: string[]
logs?: LogLine[]
}
| { type: "message_value"; name: string; value: unknown; ts: number }
| { type: "node_executed"; node: string; outputs: number }
| { type: "node_error"; node: string; error: string }
| { type: "node_status"; node: string; status: string; error?: string | null }
| ({ type: "node_log" } & LogLine)
| { type: "flow_paused"; flow: string; paused: boolean }
| {
type: "pipeline_rebuilt"
nodes: { id: string; status: string; error?: string | null }[]
paused?: string[]
}
function socketUrl(): string {
@@ -65,6 +70,8 @@ export function useFlowSocket(onAuthFailure?: () => void): void {
case "snapshot":
liveStore.setValues(message.values)
liveStore.setStatuses(message.nodes)
liveStore.setPausedFlows(message.paused ?? [])
liveStore.setLogs(message.logs ?? [])
break
case "message_value":
liveStore.setValue(message.name, {
@@ -88,10 +95,17 @@ export function useFlowSocket(onAuthFailure?: () => void): void {
error: message.error,
})
break
case "node_log":
liveStore.appendLog(message)
break
case "flow_paused":
liveStore.setPaused(message.flow, message.paused)
break
case "pipeline_rebuilt":
liveStore.setStatuses(message.nodes)
// Someone published, here or in another tab: the draft markers on
// the flow chips are stale until the list is fetched again.
liveStore.setPausedFlows(message.paused ?? [])
// Someone published or started a flow, here or in another tab: the
// markers on the flow chips are stale until the list is refetched.
queryClient.invalidateQueries({ queryKey: flowKeys.all })
break
}