useFlowRun
fancy-flowExecutor hook.
Why
A workflow editor is useless without visibility into execution—no way to track which node runs, why it failed, what its output was. Without
useFlowRun, every host rebuilds a run harness (status tracking, live event log, cancellation) from scratch, leading to inconsistent UX and missed affordances like timeout enforcement or cycle detection.What
useFlowRun is a React hook that pairs with runFlow to manage live workflow execution. It returns statuses (keyed by node id for rendering status badges), statusText (error messages per node), a capped feed of execution events, running (run-in-progress flag), and lastResult (outputs or error); plus run(graph, executors, options?) to execute a graph, cancel() to abort, and reset() to clear state. Options include maxFeed (default 200 entries) to cap memory.How
Call
const { statuses, statusText, feed, running, run, cancel, reset } = useFlowRun(), pass statuses to applyStatusesToNodes(nodes, statuses, statusText) before rendering, then wire the run callback to a button (or <FlowRunControls>) and feed events to a log panel (<FlowRunFeed>). The hook emits topologically ordered execution with cycle detection, timeout support, and per-node executor registration—agents can monitor status changes and outputs via event subscriptions on an MCP bridge.