Let a node's failure outlive the run that followed it
A node's error cleared the moment it ran again, so a failure that genuinely fired an alert could leave no trace on the canvas by the time anyone looked. The engine records it now — on the node's status, so it survives a reload and every client agrees — and reading the traceback is what clears it. The seam is the event bus, which is where every failing path already meets: a queued live run, an explicit run, a preview, and a single triggered node all publish `node_error`, while the controller's own observer would have seen only one of them. That was half the confusion. The other half: clicking a failed neuron on Home often landed on a flow where everything looked fine. Nodes merge into one neuron by instance key — every InfluxDB node pointing at the same bucket is one neuron — and the click went to whichever flow contributed a member first, not the one that failed. It now goes to the failing member and selects it, and the canvas marks a failing node rather than leaving it to the dot alone. The inject node emitted one payload to every port it declared, whatever their types, so an inject on a bool port carrying the text "true" raised at publish time. Each port gets its own field now, typed and parsed by that port's dtype, and remembers what it last sent. A port that is renamed carries its value with it; one that is removed takes its value with it. An inject written before this keeps emitting exactly what it did. The derived-cron chip also appeared on the delay node, where `interval` is a rate limit and a schedule derived from it means nothing. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uq8mtNb97A7praJLyeEYgs
This commit is contained in:
@@ -38,6 +38,7 @@ import { Switch } from "@/components/ui/switch"
|
||||
import useCustomToast from "@/hooks/useCustomToast"
|
||||
import { inCodeEditor, useShortcuts } from "@/lib/shortcuts"
|
||||
import { cn } from "@/lib/utils"
|
||||
import { DtypeValue } from "./FlowBoundary"
|
||||
import { MessageSparkline } from "./MessageSparkline"
|
||||
import {
|
||||
flowKeys,
|
||||
@@ -219,6 +220,7 @@ function PortList({
|
||||
suggestions,
|
||||
onChange,
|
||||
onRenamed,
|
||||
onRemoved,
|
||||
streamable = false,
|
||||
}: {
|
||||
title: string
|
||||
@@ -228,6 +230,8 @@ function PortList({
|
||||
suggestions: string[]
|
||||
onChange: (next: MessageSpec[]) => void
|
||||
onRenamed?: (previous: string, next: string) => void
|
||||
/** The port about to be dropped, reported just before the shorter list. */
|
||||
onRemoved?: (spec: MessageSpec) => void
|
||||
/** Outputs only: a port a node publishes on repeatedly while it runs. */
|
||||
streamable?: boolean
|
||||
}) {
|
||||
@@ -355,7 +359,10 @@ function PortList({
|
||||
size="icon-sm"
|
||||
className="text-muted-foreground"
|
||||
aria-label="Remove port"
|
||||
onClick={() => onChange(specs.filter((_, i) => i !== index))}
|
||||
onClick={() => {
|
||||
onRemoved?.(spec)
|
||||
onChange(specs.filter((_, i) => i !== index))
|
||||
}}
|
||||
>
|
||||
<X />
|
||||
</Button>
|
||||
@@ -565,9 +572,15 @@ function cronFromInterval(seconds: unknown): string | null {
|
||||
/** What the five fields mean, and the schedule the interval beside them asks for. */
|
||||
function CronHelp({
|
||||
params,
|
||||
derivable,
|
||||
onPick,
|
||||
}: {
|
||||
params: Record<string, unknown>
|
||||
/**
|
||||
* Whether `interval` beside it is a schedule at all. On a delay it is a rate
|
||||
* limit, and a cron built from it would say something the node never does.
|
||||
*/
|
||||
derivable: boolean
|
||||
onPick: (expression: string) => void
|
||||
}) {
|
||||
const derived = cronFromInterval(params.interval)
|
||||
@@ -583,7 +596,7 @@ function CronHelp({
|
||||
<span className="font-mono">*/5</span> every fifth,{" "}
|
||||
<span className="font-mono">1-5</span> a range.
|
||||
</p>
|
||||
{derived && params.cron !== derived ? (
|
||||
{derivable && derived && params.cron !== derived ? (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
@@ -599,16 +612,85 @@ function CronHelp({
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* What an inject publishes, one field per port it publishes on.
|
||||
*
|
||||
* Each port is its own message with its own type, so the value follows the
|
||||
* port rather than the node — and since what an inject emits is also what it
|
||||
* remembers, the field is where that default lives. A port with nothing of its
|
||||
* own reads through to `payload`, which is what a flow written before this had.
|
||||
*/
|
||||
function InjectPayloads({
|
||||
provides,
|
||||
params,
|
||||
onChange,
|
||||
}: {
|
||||
provides: MessageSpec[]
|
||||
params: Record<string, unknown>
|
||||
onChange: (next: Record<string, unknown>) => void
|
||||
}) {
|
||||
const payloads = (params.payloads ?? {}) as Record<string, unknown>
|
||||
const ports = provides.filter((spec) => portName(spec))
|
||||
|
||||
const set = (port: string, value: unknown) => {
|
||||
const next = { ...payloads }
|
||||
// An empty field means the current time, which is having no value at all.
|
||||
if (value === null) delete next[port]
|
||||
else next[port] = value
|
||||
onChange({ ...params, payloads: next })
|
||||
}
|
||||
|
||||
if (ports.length === 0) {
|
||||
return (
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Add a port for this to publish on.
|
||||
</p>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{ports.map((spec) => {
|
||||
const port = portName(spec)
|
||||
return (
|
||||
<div key={port} className="grid gap-1.5">
|
||||
<Label
|
||||
htmlFor={`payload-${port}`}
|
||||
className="font-mono text-sm font-normal"
|
||||
>
|
||||
{port}
|
||||
</Label>
|
||||
<DtypeValue
|
||||
id={`payload-${port}`}
|
||||
dtype={spec.dtype}
|
||||
value={
|
||||
port in payloads ? payloads[port] : (params.payload ?? null)
|
||||
}
|
||||
label={`What to emit on ${port}`}
|
||||
placeholder="now"
|
||||
className="text-sm"
|
||||
onChange={(value) => set(port, value)}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
/** A small form built from the node type's declared parameters. */
|
||||
function ParamsForm({
|
||||
type,
|
||||
schema,
|
||||
params,
|
||||
provides,
|
||||
onChange,
|
||||
}: {
|
||||
type: string | undefined
|
||||
schema: Record<string, unknown> | undefined
|
||||
params: Record<string, unknown>
|
||||
/** The ports an inject's payload fields follow; unused by every other type. */
|
||||
provides: MessageSpec[]
|
||||
onChange: (next: Record<string, unknown>) => void
|
||||
}) {
|
||||
const properties = (schema?.properties ?? {}) as Record<
|
||||
@@ -637,6 +719,19 @@ function ParamsForm({
|
||||
<div className="grid gap-3">
|
||||
<span className={SECTION}>Settings</span>
|
||||
{entries.map(([key, property]) => {
|
||||
// In the schema's own place, so the payload keeps its position in the
|
||||
// form even though it is now one field per port.
|
||||
if (type === "inject" && key === "payload") {
|
||||
return (
|
||||
<InjectPayloads
|
||||
key={key}
|
||||
provides={provides}
|
||||
params={params}
|
||||
onChange={onChange}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
const value = params[key] ?? property.default ?? ""
|
||||
const label = property.title ?? key
|
||||
|
||||
@@ -718,6 +813,7 @@ function ParamsForm({
|
||||
{key === "cron" ? (
|
||||
<CronHelp
|
||||
params={params}
|
||||
derivable={type === "inject"}
|
||||
onPick={(expression) => set(key, expression)}
|
||||
/>
|
||||
) : null}
|
||||
@@ -927,6 +1023,9 @@ function PanelBody({
|
||||
})
|
||||
|
||||
const [code, setCode] = useState<string | null>(null)
|
||||
// The port the X is dropping, noted just before the shorter list arrives:
|
||||
// both are one edit, and a second one would only overwrite the first.
|
||||
const dropped = useRef<string | null>(null)
|
||||
const timer = useRef<ReturnType<typeof setTimeout> | null>(null)
|
||||
const pending = useRef<string | null>(null)
|
||||
const save = useRef(onSaveSource)
|
||||
@@ -966,6 +1065,33 @@ function PanelBody({
|
||||
if (current !== wanted && SCAFFOLD_SHAPE.test(current)) editCode(wanted)
|
||||
}
|
||||
|
||||
/**
|
||||
* A per-port inject value belongs to its port, so it follows it: carried
|
||||
* along by a finished rename, dropped with the port itself (`to` of null).
|
||||
* A node holding none of them — every other type — comes back untouched,
|
||||
* which is what makes the same reference a fair test for "nothing to do".
|
||||
*/
|
||||
const repoint = (next: NodeDef_Input, from: string, to: string | null) => {
|
||||
const payloads = (next.params?.payloads ?? {}) as Record<string, unknown>
|
||||
if (!from || from === to || !(from in payloads)) return next
|
||||
const moved = { ...payloads }
|
||||
if (to) moved[to] = moved[from]
|
||||
delete moved[from]
|
||||
return { ...next, params: { ...next.params, payloads: moved } }
|
||||
}
|
||||
|
||||
const renamePort = (previous: string, next: string) => {
|
||||
onRenameMessage(previous, next)
|
||||
// Only a finished rename moves a value; per keystroke it would delete it
|
||||
// on the first character typed.
|
||||
const moved = repoint(
|
||||
node,
|
||||
portName({ name: previous }),
|
||||
portName({ name: next }),
|
||||
)
|
||||
if (moved !== node) editNode(moved)
|
||||
}
|
||||
|
||||
// ⌘S in the editor means "apply this code"; the editor's own state is here,
|
||||
// so the binding is too. Anywhere else on the canvas it publishes the flow.
|
||||
useShortcuts(
|
||||
@@ -1016,16 +1142,24 @@ function PanelBody({
|
||||
flow={flow}
|
||||
emptyHint="Nothing yet. Add a message this node publishes."
|
||||
suggestions={suggestions.provides}
|
||||
onChange={(provides) => editNode({ ...node, provides })}
|
||||
onChange={(provides) => {
|
||||
const port = dropped.current
|
||||
dropped.current = null
|
||||
editNode(repoint({ ...node, provides }, port ?? "", null))
|
||||
}}
|
||||
streamable
|
||||
// Only the publishing side names a message; an input is as often
|
||||
// re-pointed at a different one as it is renamed.
|
||||
onRenamed={onRenameMessage}
|
||||
onRenamed={renamePort}
|
||||
onRemoved={(spec) => {
|
||||
dropped.current = portName(spec)
|
||||
}}
|
||||
/>
|
||||
<ParamsForm
|
||||
type={node.type}
|
||||
schema={nodeType?.params_schema}
|
||||
params={node.params ?? {}}
|
||||
provides={node.provides ?? []}
|
||||
onChange={(params) => editNode({ ...node, params })}
|
||||
/>
|
||||
{nodeType?.free_params ? (
|
||||
|
||||
Reference in New Issue
Block a user