@dudousxd/nestjs-catalog-react 0.19.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,8 +7,8 @@ import { Background, BackgroundVariant, ConnectionLineType, Controls, MiniMap, N
7
7
  // See src/styles.d.ts for why `tsc` tolerates this import.
8
8
  import '@xyflow/react/dist/style.css';
9
9
  import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
10
- import { ArrowRight, CircleAlert, CircleDashed, Code2, Database, ExternalLink, GitBranch, LayoutGrid, Link2, Loader2, Plug, Plus, Repeat, Save, Trash2, TriangleAlert, Unplug, } from 'lucide-react';
11
- import { useReducedMotion } from 'motion/react';
10
+ import { ArrowRight, CircleAlert, CircleDashed, Code2, Database, ExternalLink, Filter, GitBranch, Info, LayoutGrid, Link2, Loader2, PanelRight, Plug, Plus, Repeat, Save, Trash2, TriangleAlert, Unplug, X, } from 'lucide-react';
11
+ import { AnimatePresence, motion, useReducedMotion } from 'motion/react';
12
12
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
13
13
  import { connectionOptionsFor } from './ConnectionPanel';
14
14
  import { TransformEditor } from './TransformEditor';
@@ -27,6 +27,7 @@ import { Switch } from './ui/switch';
27
27
  import { Tooltip, TooltipProvider } from './ui/tooltip';
28
28
  import { WorkflowEdgeProvider, workflowEdgeTypes } from './workflow/edges';
29
29
  import { NODE_HEIGHT, NODE_WIDTH, defaultLabel, describeFilterPredicate, flowingEdgeIds, layout, layoutIfUnarranged, nextPosition, toFlowEdges, toFlowNodes, } from './workflow/graph';
30
+ import { HistoryControls, keepKnown, namesOf, nodeEditAction, reverted, snapshotOf, undone, useUndoShortcut, useUnsavedGuard, withEdit, } from './workflow/history';
30
31
  import { PublishControls, RunControls, SchedulePanel, ShrinkRefusalNote, WorkflowStatusBadge, } from './workflow/lifecycle';
31
32
  import { WORKFLOW_BRANCH_LABELS, WORKFLOW_FILTER_MAX_DEPTH, WORKFLOW_FILTER_MAX_VALUES, WORKFLOW_FILTER_OPERATORS, WORKFLOW_NODE_KINDS, callableWorkflowBlock, describeDurability, isWorkflowBranchLabel, isWorkflowFilterOperator, isWorkflowFilterPredicateKind, isWorkflowNodeKind, isWorkflowPredicateKind, newLocalId, nodeName, producedTypes, unreachableFilterPredicateKind, unreachableNodeKind, unreachablePredicateKind, workflowNarrowedTypes, } from './workflow/model';
32
33
  import { WORKFLOW_NAME } from './workflow/name';
@@ -37,6 +38,123 @@ import { PendingWireLine, WiringHint, useClickWiring, } from './workflow/wiring'
37
38
  const MUTED = 'text-zinc-400 dark:text-zinc-500';
38
39
  const RULE = 'border-zinc-200 dark:border-zinc-800';
39
40
  const PANEL = 'bg-white dark:bg-zinc-900';
41
+ /**
42
+ * A card INSIDE a floating panel.
43
+ *
44
+ * Deliberately not {@link PANEL}. An opaque white card on a translucent panel
45
+ * cancels the blur it is sitting on and the rail stops reading as one surface —
46
+ * it becomes four white boxes with a frosted gap between them.
47
+ */
48
+ const SUBPANEL = 'bg-zinc-50/60 dark:bg-zinc-950/40';
49
+ /**
50
+ * What a thing floating ON the canvas looks like.
51
+ *
52
+ * Translucent with a blur rather than opaque, and that is the whole point of the
53
+ * layout this belongs to: a panel that blanks out what is behind it turns the
54
+ * canvas back into a box with a border, only now the box is a worse shape. The
55
+ * graph stays perceptible through the chrome, so the surface reads as continuous
56
+ * and the panels read as sitting on it.
57
+ */
58
+ const FLOATING = cn('rounded-xl border shadow-lg shadow-zinc-950/5 dark:shadow-zinc-950/40', 'border-zinc-200/80 bg-white/85 backdrop-blur-md', 'dark:border-zinc-800/80 dark:bg-zinc-900/85');
59
+ /**
60
+ * How much of the canvas the floating chrome covers, per edge, in CSS pixels.
61
+ *
62
+ * ONE definition, read by two things that would otherwise drift: the Tailwind
63
+ * insets the chrome is positioned with, and the per-side `fitView` padding the
64
+ * graph is fitted into. That second use is what makes a full-bleed canvas
65
+ * honest — React Flow fits the graph to the *viewport*, so without this it
66
+ * would happily centre a node underneath the action cluster and leave somebody
67
+ * dragging a box out from under a panel to read it.
68
+ *
69
+ * Deliberately generous rather than measured. Measuring the real panels every
70
+ * frame would be a ResizeObserver feeding a value into a fit that then moves
71
+ * the panels' backdrop, and the loop that produces is worse than 20px of slack.
72
+ */
73
+ const CHROME = {
74
+ top: 150,
75
+ bottom: 90,
76
+ side: 28,
77
+ /** The rail's width plus its gutter, when it is open. */
78
+ rail: 336,
79
+ };
80
+ /** {@link CHROME} as the padding `fitView` wants. The right edge is the only side that moves. */
81
+ function chromeFitPadding(railOpen) {
82
+ return {
83
+ top: `${CHROME.top}px`,
84
+ bottom: `${CHROME.bottom}px`,
85
+ left: `${CHROME.side}px`,
86
+ right: `${railOpen ? CHROME.rail : CHROME.side}px`,
87
+ };
88
+ }
89
+ /**
90
+ * Whether the details rail starts on screen.
91
+ *
92
+ * Read once, from the width at mount, rather than subscribed to. A live media
93
+ * query would reopen a panel somebody had just closed because they turned their
94
+ * tablet, which is worse than the panel being open on a narrow screen they can
95
+ * shut it on.
96
+ *
97
+ * `typeof window` guards server rendering, where there is no width to ask about
98
+ * and a bare `window` is a crash rather than a layout bug. Open is the right
99
+ * answer there: it is what hydrates into on a desktop, and a panel that appears
100
+ * after hydration is a worse first paint than one that was always there.
101
+ */
102
+ function railOpenByDefault() {
103
+ return typeof window === 'undefined' ? true : window.innerWidth >= 1024;
104
+ }
105
+ /**
106
+ * Every kind of node, and how it is offered.
107
+ *
108
+ * A `Record` over `WorkflowNodeKind` rather than a hand-written row of buttons,
109
+ * and that is a bug fix rather than a tidy-up: `filter` shipped complete — model,
110
+ * validator, executor, inspector, its own colour on the canvas — and could not be
111
+ * added from this screen at all, because the row that offers the kinds was six
112
+ * JSX elements somebody had typed out and only five of them had been typed. Every
113
+ * other exhaustiveness guard in this file caught its case; none of them could
114
+ * catch a list maintained by hand.
115
+ *
116
+ * So the row maps {@link WORKFLOW_NODE_KINDS} and looks each kind up here. A new
117
+ * kind now fails to compile in this file until somebody says how it is offered,
118
+ * which is the only way a palette stays complete.
119
+ *
120
+ * The icons match `KIND_STYLE` in `workflow/nodes.tsx` on purpose — the thing you
121
+ * press to make a box should wear the box's own mark — and `if` and `filter` keep
122
+ * the distinction that file argues for: a fork decides which boxes run, a funnel
123
+ * takes rows away. They are the two that must never be confused at a glance, so
124
+ * they never share an icon or a sentence.
125
+ */
126
+ const ADD_NODE = {
127
+ source: {
128
+ icon: Plug,
129
+ label: 'Source',
130
+ hint: 'Reads records out of a system: a kind, an optional named connection, and a config.',
131
+ },
132
+ transform: {
133
+ icon: Repeat,
134
+ label: 'Transform',
135
+ hint: 'Code that reshapes whatever is wired into it.',
136
+ },
137
+ sink: {
138
+ icon: Database,
139
+ label: 'Sink',
140
+ hint: 'Writes and commits one object type. Several are fine — each commits independently.',
141
+ },
142
+ call: {
143
+ icon: ExternalLink,
144
+ label: 'Call',
145
+ hint: 'Hands this step to a durable workflow that already exists, by name and pinned version. It runs as a child of this load, with its own retries.',
146
+ },
147
+ if: {
148
+ icon: GitBranch,
149
+ label: 'If',
150
+ hint: 'Sends the rows down one of two branches, depending on an environment variable where the load runs. The other branch is skipped — a sink on it commits nothing and leaves what is published alone.',
151
+ },
152
+ filter: {
153
+ icon: Filter,
154
+ label: 'Filter',
155
+ hint: 'Drops the rows that fail a test you write here. Unlike an If, every box still runs — there are simply fewer rows in them from this point on.',
156
+ },
157
+ };
40
158
  /**
41
159
  * The value the workflow picker uses for "start a fresh one".
42
160
  *
@@ -69,10 +187,14 @@ const ARIA_LABELS = {
69
187
  'minimap.ariaLabel': `Overview of the ${WORKFLOW_NAME.singular}`,
70
188
  };
71
189
  function blankDraft() {
72
- return { name: '', description: '', nodes: [], edges: [], dirty: false };
190
+ const empty = { name: '', description: '', nodes: [], edges: [] };
191
+ // A blank canvas has a baseline too, and it is the blank canvas: Reset on a
192
+ // never-saved graph means "clear it", which is exactly what going back to
193
+ // "nothing has been stored" should mean.
194
+ return { ...empty, dirty: false, past: [], baseline: snapshotOf(empty) };
73
195
  }
74
196
  function draftFrom(workflow) {
75
- return {
197
+ const loaded = {
76
198
  id: workflow.id,
77
199
  name: workflow.name,
78
200
  description: workflow.description ?? '',
@@ -93,7 +215,12 @@ function draftFrom(workflow) {
93
215
  edges: workflow.edges.map((edge) => ({ from: edge.from, to: edge.to })),
94
216
  version: workflow.version,
95
217
  dirty: false,
218
+ past: [],
96
219
  };
220
+ // The baseline holds the SAME arrays the draft starts with, which is what
221
+ // makes undoing all the way back compare equal to it and go genuinely clean.
222
+ // See `sameSnapshot`.
223
+ return { ...loaded, baseline: snapshotOf(loaded) };
97
224
  }
98
225
  /**
99
226
  * Transforms wired to each other, ending at one or more sinks.
@@ -536,20 +663,36 @@ function saveHint(blocked, unfinished) {
536
663
  * list beside the canvas is empty and the real answer is "two boxes are not
537
664
  * finished", so that case gets its own sentence and names them.
538
665
  */
539
- function CanvasActions({ draft, stored, canEdit, blocked, unfinished, saving, running, durabilityDetail, acknowledging, onAcknowledgingChange, onSave, onRun, onLifecycleChange, onAskDelete, }) {
540
- return (_jsxs("div", { className: "flex flex-wrap items-start gap-2 self-end pb-1", children: [_jsx(Tooltip, { content: saveHint(blocked, unfinished), children: _jsxs("button", { type: "button", onClick: onSave, disabled: !canEdit ||
666
+ function CanvasActions({ draft, stored, canEdit, blocked, unfinished, saving, running, durabilityDetail, acknowledging, reducedMotion, resetting, onAcknowledgingChange, onResettingChange, onUndo, onReset, onSave, onRun, onLifecycleChange, onAskDelete, }) {
667
+ return (_jsxs("div", { className: "flex flex-wrap items-center gap-1.5", children: [_jsx(HistoryControls, { draft: draft, canEdit: canEdit, reducedMotion: reducedMotion, resetting: resetting, onResettingChange: onResettingChange, onUndo: onUndo, onReset: onReset }), _jsx(Tooltip, { content: saveHint(blocked, unfinished), children: _jsxs(Button, { size: "sm", onClick: onSave, disabled: !canEdit ||
541
668
  saving ||
542
669
  draft.name.trim().length === 0 ||
543
- (!draft.dirty && Boolean(draft.id)), className: cn('flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs disabled:opacity-40', blocked
544
- ? 'bg-amber-600 text-white'
545
- : 'bg-zinc-950 text-zinc-50 dark:bg-zinc-100 dark:text-zinc-950'), children: [saving ? _jsx(Loader2, { size: 12, className: "animate-spin" }) : _jsx(Save, { size: 12 }), draft.dirty ? 'Save' : 'Saved'] }) }), stored && (_jsx(PublishControls, { workflow: stored, dirty: draft.dirty, canEdit: canEdit, onPublished: onLifecycleChange })), _jsx(RunControls, { workflowId: draft.id, dirty: draft.dirty, canEdit: canEdit, running: running, durabilityDetail: durabilityDetail, acknowledging: acknowledging, onAcknowledgingChange: onAcknowledgingChange, onRun: onRun }), draft.id && canEdit && (_jsx(Tooltip, { content: `Delete this ${WORKFLOW_NAME.singular}, and the connector it runs as with it.`, children: _jsx(Button, { variant: "outline", size: "icon", onClick: onAskDelete, "aria-label": `Delete this ${WORKFLOW_NAME.singular}`, className: "text-zinc-400 hover:text-red-600", children: _jsx(Trash2, { size: 12 }) }) }))] }));
670
+ (!draft.dirty && Boolean(draft.id)),
671
+ // The amber is the whole signal — a graph that would never run says so
672
+ // on the button before it is pressed — so it has to survive the
673
+ // variant's own background. `cn` is tailwind-merge, so the later
674
+ // `bg-*` wins rather than fighting.
675
+ className: cn('shrink-0', blocked
676
+ ? 'bg-amber-600 text-white hover:bg-amber-500 dark:bg-amber-600 dark:text-white dark:hover:bg-amber-500'
677
+ : 'bg-zinc-950 text-zinc-50 hover:bg-zinc-800 dark:bg-zinc-100 dark:text-zinc-950 dark:hover:bg-zinc-200'), children: [saving ? _jsx(Loader2, { size: 12, className: "animate-spin" }) : _jsx(Save, { size: 12 }), draft.dirty ? 'Save' : 'Saved'] }) }), stored && (_jsx(PublishControls, { workflow: stored, dirty: draft.dirty, canEdit: canEdit, onPublished: onLifecycleChange })), _jsx(RunControls, { workflowId: draft.id, dirty: draft.dirty, canEdit: canEdit, running: running, durabilityDetail: durabilityDetail, acknowledging: acknowledging, onAcknowledgingChange: onAcknowledgingChange, onRun: onRun }), draft.id && canEdit && (_jsx(Tooltip, { content: `Delete this ${WORKFLOW_NAME.singular}, and the connector it runs as with it.`, children: _jsx(Button, { variant: "outline", size: "icon", onClick: onAskDelete, "aria-label": `Delete this ${WORKFLOW_NAME.singular}`, className: "text-zinc-400 hover:text-red-600", children: _jsx(Trash2, { size: 12 }) }) }))] }));
546
678
  }
547
- /** The four things that can be put on the canvas, and the button that tidies them. */
679
+ /**
680
+ * The tool dock: every kind that can be put on the canvas, and the tidy control.
681
+ *
682
+ * Bottom centre, floating, because it is the one piece of chrome somebody
683
+ * touches continuously while drawing and the bottom edge is where every canvas
684
+ * tool that has ever been good keeps its tools. It is also the only corner React
685
+ * Flow's own overlays do not claim.
686
+ *
687
+ * The kinds come from {@link WORKFLOW_NODE_KINDS} through {@link ADD_NODE}, so
688
+ * the dock cannot fall behind the model — see the note on `ADD_NODE` for the bug
689
+ * that made that necessary.
690
+ */
548
691
  function AddNodeBar({ refreshing, onAdd, onTidy, }) {
549
- return (_jsxs("div", { className: "flex shrink-0 flex-wrap items-center gap-2 px-6 pt-3", children: [_jsx(AddButton, { icon: Plug, label: "Source", hint: "Reads records out of a system: a kind, an optional named connection, and a config.", onClick: () => onAdd('source') }), _jsx(AddButton, { icon: Repeat, label: "Transform", hint: "Code that reshapes whatever is wired into it.", onClick: () => onAdd('transform') }), _jsx(AddButton, { icon: Database, label: "Sink", hint: "Writes and commits one object type. Several are fine \u2014 each commits independently.", onClick: () => onAdd('sink') }), _jsx(AddButton, { icon: ExternalLink, label: "Call", hint: "Hands this step to a durable workflow that already exists, by name and pinned version. It runs as a child of this load, with its own retries.", onClick: () => onAdd('call') }), _jsx(AddButton, { icon: GitBranch, label: "If", hint: "Sends the rows down one of two branches, depending on an environment variable where the load runs. The other branch is skipped \u2014 a sink on it commits nothing and leaves what is published alone.", onClick: () => onAdd('if') }), _jsx(Tooltip, { content: "Lay the nodes out left to right by dependency, with every sink in the last column.", children: _jsxs("button", { type: "button", onClick: onTidy, className: cn('flex items-center gap-1.5 rounded-md border px-2.5 py-1.5 text-xs', RULE, MUTED, 'hover:bg-zinc-50 dark:hover:bg-zinc-800'), children: [_jsx(LayoutGrid, { size: 12 }), "Tidy"] }) }), refreshing && (
692
+ return (_jsxs("div", { className: cn('pointer-events-auto flex max-w-full items-center gap-1 overflow-x-auto p-1.5', FLOATING), children: [WORKFLOW_NODE_KINDS.map((kind) => (_jsx(AddButton, { kind: kind, onClick: () => onAdd(kind) }, kind))), _jsx("span", { className: cn('mx-1 h-6 w-px shrink-0 bg-zinc-200 dark:bg-zinc-800'), "aria-hidden": true }), _jsx(Tooltip, { content: "Lay the nodes out left to right by dependency, with every sink in the last column.", children: _jsxs(Button, { variant: "ghost", size: "sm", onClick: onTidy, "aria-label": "Tidy the layout", className: "shrink-0", children: [_jsx(LayoutGrid, { size: 12 }), _jsx("span", { className: "hidden md:inline", children: "Tidy" })] }) }), refreshing && (
550
693
  // A background refetch says so without replacing anything: the graph on
551
694
  // screen stays exactly where it is.
552
- _jsx("span", { className: cn('ml-auto font-mono text-[10px]', MUTED), children: "refreshing\u2026" }))] }));
695
+ _jsx("span", { className: cn('shrink-0 px-1 font-mono text-[10px]', MUTED), children: "refreshing\u2026" }))] }));
553
696
  }
554
697
  /**
555
698
  * Which workflow the screen should be showing.
@@ -607,8 +750,25 @@ function miniMapColor(data) {
607
750
  * place of the screen, so the header and its controls stay put while a refetch
608
751
  * resolves — and a failed read never looks like an empty workflow.
609
752
  */
610
- function GraphSurface({ loading, failed, error, onRetry, canEdit, draft, flowNodes, flowEdges, onInspect, onEditCode, onNodesChange, onEdgesChange, onConnect, isValidConnection, onConnectEnd, onNodeEnter, onNodeLeave, onPaneClick, onDisconnect, wiring, wiringRefusal, nodeMenu, }) {
611
- return (_jsxs("div", { className: cn('relative h-[55vh] min-h-[15rem] shrink-0 overflow-hidden rounded-lg border', 'lg:h-auto lg:min-h-0 lg:flex-1 lg:shrink', RULE), children: [loading && _jsx(CanvasSkeleton, {}), failed && _jsx(CanvasFailure, { error: error, onRetry: onRetry }), !loading && !failed && (_jsx(WorkflowNodeProvider, { handlers: { onInspect, onEditCode, canEdit, wiring }, children: _jsx(WorkflowEdgeProvider, { handlers: { onDisconnect, canEdit }, children: _jsxs(ReactFlow, { className: CANVAS_THEME, nodes: flowNodes, edges: flowEdges, nodeTypes: workflowNodeTypes, edgeTypes: workflowEdgeTypes, onNodesChange: onNodesChange, onEdgesChange: onEdgesChange, onConnect: onConnect, isValidConnection: isValidConnection, onConnectEnd: onConnectEnd, onNodeMouseEnter: (_event, node) => onNodeEnter(node.id), onNodeMouseLeave: onNodeLeave, onPaneClick: onPaneClick, connectionLineType: ConnectionLineType.SmoothStep,
753
+ function GraphSurface({ loading, failed, error, onRetry, canEdit, draft, flowNodes, flowEdges, onInspect, onEditCode, onNodesChange, onEdgesChange, onConnect, isValidConnection, onConnectEnd, onNodeEnter, onNodeLeave, onPaneClick, onDisconnect, wiring, wiringRefusal, nodeMenu, fitPadding, }) {
754
+ /*
755
+ * Memoised because they are context values read by every node and every edge
756
+ * on the canvas. Written inline, as they were, each of these was a fresh
757
+ * object on every render of the screen — and this screen now re-renders for
758
+ * things the graph does not care about, like opening the rail. A new context
759
+ * value re-renders every consumer, which on a large graph is every box and
760
+ * every wire, for a panel sliding in at the side.
761
+ */
762
+ const nodeHandlers = useMemo(() => ({ onInspect, onEditCode, canEdit, wiring }), [onInspect, onEditCode, canEdit, wiring]);
763
+ const edgeHandlers = useMemo(() => ({ onDisconnect, canEdit }), [onDisconnect, canEdit]);
764
+ return (
765
+ /*
766
+ * The surface IS the screen: pinned to all four edges, with the chrome
767
+ * layered over it by a sibling. Nothing here is a box in a column any more,
768
+ * so there is no border and no rounded corner — a full-bleed canvas that
769
+ * draws its own frame is a canvas pretending to still be a widget.
770
+ */
771
+ _jsxs("div", { className: "absolute inset-0", children: [loading && _jsx(CanvasSkeleton, {}), failed && _jsx(CanvasFailure, { error: error, onRetry: onRetry }), !loading && !failed && (_jsx(WorkflowNodeProvider, { handlers: nodeHandlers, children: _jsx(WorkflowEdgeProvider, { handlers: edgeHandlers, children: _jsxs(ReactFlow, { className: CANVAS_THEME, nodes: flowNodes, edges: flowEdges, nodeTypes: workflowNodeTypes, edgeTypes: workflowEdgeTypes, onNodesChange: onNodesChange, onEdgesChange: onEdgesChange, onConnect: onConnect, isValidConnection: isValidConnection, onConnectEnd: onConnectEnd, onNodeMouseEnter: (_event, node) => onNodeEnter(node.id), onNodeMouseLeave: onNodeLeave, onPaneClick: onPaneClick, connectionLineType: ConnectionLineType.SmoothStep,
612
772
  // Off, so there is exactly ONE click path through a handle and it
613
773
  // is the one in `workflow/wiring.tsx`. React Flow's own click
614
774
  // wiring connects but draws nothing while it is open and cannot
@@ -618,7 +778,14 @@ function GraphSurface({ loading, failed, error, onRetry, canEdit, draft, flowNod
618
778
  // A wider drop zone than the 20px default, because these handles are
619
779
  // the only drop target on the screen and missing one reads as the
620
780
  // canvas ignoring you.
621
- connectionRadius: 28, proOptions: { hideAttribution: false }, ariaLabelConfig: ARIA_LABELS, "aria-label": `${WORKFLOW_NAME.title} canvas. ${draft.nodes.length} nodes, ${draft.edges.length} connections.`, fitView: true, children: [_jsx(Background, { variant: BackgroundVariant.Dots, gap: 18, size: 1 }), _jsx(Controls, { showInteractive: false, className: "!overflow-hidden !rounded-lg !border !border-zinc-200 !shadow-sm dark:!border-zinc-800 [&>button]:!border-none" }), _jsx(MiniMap, { pannable: true, zoomable: true, nodeColor: (node) => miniMapColor(node.data), className: "!overflow-hidden !rounded-lg !border !border-zinc-200 !shadow-sm dark:!border-zinc-800" }), _jsx(PendingWireLine, { pending: wiring.pending }), _jsx(WiringHint, { pending: wiring.pending, refusal: wiringRefusal, nodes: draft.nodes, onCancel: wiring.cancel }), nodeMenu] }) }) }))] }));
781
+ connectionRadius: 28, proOptions: { hideAttribution: false }, ariaLabelConfig: ARIA_LABELS, "aria-label": `${WORKFLOW_NAME.title} canvas. ${draft.nodes.length} nodes, ${draft.edges.length} connections.`, fitView: true, fitViewOptions: { padding: fitPadding }, children: [_jsx(Background, { variant: BackgroundVariant.Dots, gap: 18, size: 1 }), _jsx(Controls, { showInteractive: false, position: "bottom-left", className: cn('!bottom-[9.5rem] !overflow-hidden !rounded-lg !border !border-zinc-200', '!shadow-sm dark:!border-zinc-800 [&>button]:!border-none',
782
+ // Below `lg` the minimap is gone, so the zoom controls drop
783
+ // back down into the corner it vacated.
784
+ '!bottom-0 lg:!bottom-[9.5rem]') }), _jsx(MiniMap, { pannable: true, zoomable: true, position: "bottom-left", nodeColor: (node) => miniMapColor(node.data),
785
+ // An overview is worth least on the screen with least room for
786
+ // it: below `lg` it would cover a sixth of the canvas to
787
+ // describe the other five.
788
+ className: cn('!hidden lg:!block', '!overflow-hidden !rounded-lg !border !border-zinc-200 !shadow-sm dark:!border-zinc-800') }), _jsx(PendingWireLine, { pending: wiring.pending }), _jsx(WiringHint, { pending: wiring.pending, refusal: wiringRefusal, nodes: draft.nodes, onCancel: wiring.cancel }), nodeMenu] }) }) }))] }));
622
789
  }
623
790
  /**
624
791
  * The wiring control that lives on a node, and the menu behind it.
@@ -900,7 +1067,50 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
900
1067
  const [inspecting, setInspecting] = useState(null);
901
1068
  const [editingCodeFor, setEditingCodeFor] = useState(null);
902
1069
  const [confirmingDelete, setConfirmingDelete] = useState(false);
1070
+ /**
1071
+ * Whether the "throw away every unsaved edit" dialog is open.
1072
+ *
1073
+ * Held here rather than inside the controls because Reset is destructive of
1074
+ * work in exactly the way deleting the workflow is destructive of the
1075
+ * workflow, and this screen keeps every "are you sure" at the level that owns
1076
+ * the thing being destroyed.
1077
+ */
1078
+ const [resetting, setResetting] = useState(false);
903
1079
  const [run, setRun] = useState(null);
1080
+ /**
1081
+ * Whether the details rail is on screen.
1082
+ *
1083
+ * Open by default where there is room for it, and that default is the answer
1084
+ * to "the problems have to stay visible": they are visible, in full, from the
1085
+ * first paint on any screen that can afford 19rem. Closing it is a choice
1086
+ * somebody makes to get the room back, and the toggle then carries the problem
1087
+ * count so the *fact* of a problem never depends on the panel being open.
1088
+ *
1089
+ * Read once, from the width at mount, rather than subscribed to. A live media
1090
+ * query would reopen a panel somebody had just closed because they turned
1091
+ * their tablet, which is worse than the panel being open on a narrow screen
1092
+ * they can shut it on. `globalThis.innerWidth` guards the case where there is
1093
+ * no window at all — this component is rendered on a server by anybody using
1094
+ * SSR, and a bare `window` there is a crash rather than a layout bug.
1095
+ */
1096
+ const [railOpen, setRailOpen] = useState(railOpenByDefault);
1097
+ /**
1098
+ * The region of the viewport the graph should be fitted into.
1099
+ *
1100
+ * See {@link CHROME}. The right edge is the only side that moves, because the
1101
+ * rail is the only panel that comes and goes.
1102
+ *
1103
+ * Declared up here with the state rather than beside its use, because both
1104
+ * `fitView` call sites below name it in a dependency array — and a `const` read
1105
+ * by a hook that runs earlier in the body is a temporal-dead-zone crash, not a
1106
+ * lint warning.
1107
+ *
1108
+ * Toggling the rail deliberately does NOT re-fit. That would throw away a
1109
+ * viewport somebody had panned to, in response to an action about a panel; the
1110
+ * new padding applies at the next fit that was going to happen anyway —
1111
+ * opening a graph, or pressing Tidy.
1112
+ */
1113
+ const fitPadding = useMemo(() => chromeFitPadding(railOpen), [railOpen]);
904
1114
  /**
905
1115
  * Whether the "this load is expected to shrink" dialog is open.
906
1116
  *
@@ -983,13 +1193,32 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
983
1193
  // `draftId` is the trigger, not a value the body reads — which is exactly why
984
1194
  // the rule calls it unnecessary. Dropping it would fit the view once on mount
985
1195
  // and never again, leaving every workflow opened afterwards off-screen.
986
- // biome-ignore lint/correctness/useExhaustiveDependencies: draftId is what the effect watches for, not something its body uses
1196
+ // `fitPadding` is read by the body but deliberately kept OUT of the deps: it
1197
+ // changes when the rail is toggled, and re-fitting there would yank the
1198
+ // viewport away from wherever somebody had panned to, as the side effect of
1199
+ // opening a panel. The padding it fits with is whatever is current at the next
1200
+ // graph swap, which is the moment a fit is wanted.
1201
+ // biome-ignore lint/correctness/useExhaustiveDependencies: draftId is what the effect watches for, not something its body uses; fitPadding is read but must not re-trigger it
987
1202
  useEffect(() => {
988
- const frame = window.requestAnimationFrame(() => fitView({ padding: 0.25, duration: 200 }));
1203
+ const frame = window.requestAnimationFrame(() => fitView({ padding: fitPadding, duration: 200 }));
989
1204
  return () => window.cancelAnimationFrame(frame);
990
1205
  }, [draftId, fitView]);
991
- const edit = useCallback((change) => {
992
- setDraft((current) => ({ ...change(current), dirty: true }));
1206
+ /**
1207
+ * Every change to the drawing, through one door — and every one of them
1208
+ * recorded so it can be taken back.
1209
+ *
1210
+ * The action is REQUIRED rather than optional, which is the only thing keeping
1211
+ * the undo announcement honest: a default would let a new call site add an
1212
+ * entry that reverts something and says nothing about what.
1213
+ *
1214
+ * It may be a function of the current draft, for the labels that need to name
1215
+ * a node. Computing those here would mean this callback depends on
1216
+ * `draft.nodes` and is rebuilt on every graph change, which React Flow feels;
1217
+ * computing them inside the updater keeps the dependency list empty and keeps
1218
+ * the whole thing pure.
1219
+ */
1220
+ const edit = useCallback((change, action) => {
1221
+ setDraft((current) => withEdit(current, change(current), typeof action === 'function' ? action(current) : action));
993
1222
  }, []);
994
1223
  const transformIds = useMemo(() => new Set(transforms.map((transform) => transform.id)), [transforms]);
995
1224
  /**
@@ -1068,6 +1297,11 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
1068
1297
  const { positions, removed } = nodeMovesAndRemovals(changes);
1069
1298
  if (positions.size === 0 && removed.size === 0)
1070
1299
  return;
1300
+ // The drag's own answer to "is this still one gesture". React Flow sets it
1301
+ // on every frame while the pointer is down and clears it on the frame that
1302
+ // drops the node, so a drag across the canvas is one undo step however
1303
+ // many hundred position changes it emitted and however long it took.
1304
+ const dragging = changes.some((change) => change.type === 'position' && change.dragging === true);
1071
1305
  edit((current) => ({
1072
1306
  ...current,
1073
1307
  nodes: current.nodes
@@ -1080,7 +1314,16 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
1080
1314
  // would produce edges pointing at nothing, which React Flow silently
1081
1315
  // drops from the canvas while the save still sends them.
1082
1316
  edges: current.edges.filter((edge) => !removed.has(edge.from) && !removed.has(edge.to)),
1083
- }));
1317
+ }), (current) => removed.size > 0
1318
+ ? // A deletion is never folded into a move: it is the one change on
1319
+ // this canvas somebody is most likely to want back, and it must
1320
+ // not disappear into the drag that happened just before it.
1321
+ { label: `deleting ${namesOf(current.nodes, removed)}` }
1322
+ : {
1323
+ label: `moving ${namesOf(current.nodes, positions.keys())}`,
1324
+ run: 'move',
1325
+ continuing: dragging,
1326
+ });
1084
1327
  if (removed.size > 0) {
1085
1328
  // Housekeeping, not a rule: a node that no longer exists cannot be
1086
1329
  // unfinished, and leaving its id behind would hold back a later node
@@ -1097,7 +1340,9 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
1097
1340
  edit((current) => ({
1098
1341
  ...current,
1099
1342
  edges: current.edges.filter((edge) => !removed.has(edgeId(edge))),
1100
- }));
1343
+ }), {
1344
+ label: `removing ${removed.size} connection${removed.size === 1 ? '' : 's'}`,
1345
+ });
1101
1346
  setAnnouncement(`${removed.size} connection${removed.size === 1 ? '' : 's'} removed.`);
1102
1347
  }, [edit]);
1103
1348
  /**
@@ -1140,6 +1385,8 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
1140
1385
  edit((current) => ({
1141
1386
  ...current,
1142
1387
  edges: current.edges.filter((candidate) => edgeId(candidate) !== id),
1388
+ }), (current) => ({
1389
+ label: `disconnecting ${namesOf(current.nodes, [edge.from])} from ${namesOf(current.nodes, [edge.to])}`,
1143
1390
  }));
1144
1391
  markStarted(edge.from, edge.to);
1145
1392
  setAnnouncement('Connection removed.');
@@ -1153,7 +1400,9 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
1153
1400
  * can make here: it inverts which half of the pipeline runs.
1154
1401
  */
1155
1402
  const setBranch = useCallback((edge, branch) => {
1156
- edit((current) => ({ ...current, edges: edgeOnBranch(current.edges, edge, branch) }));
1403
+ edit((current) => ({ ...current, edges: edgeOnBranch(current.edges, edge, branch) }), (current) => ({
1404
+ label: `putting ${namesOf(current.nodes, [edge.to])} on the "${branch}" branch`,
1405
+ }));
1157
1406
  markStarted(edge.from, edge.to);
1158
1407
  setAnnouncement(`${nodeLabelIn(draft.nodes, edge.to)} is now on the "${branch}" branch of ${nodeLabelIn(draft.nodes, edge.from)}.`);
1159
1408
  }, [draft.nodes, edit, markStarted]);
@@ -1169,6 +1418,8 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
1169
1418
  edit((current) => ({
1170
1419
  ...current,
1171
1420
  edges: [...current.edges, newEdge(current.nodes, current.edges, from, to)],
1421
+ }), (current) => ({
1422
+ label: `connecting ${namesOf(current.nodes, [from])} to ${namesOf(current.nodes, [to])}`,
1172
1423
  }));
1173
1424
  markStarted(from, to);
1174
1425
  setAnnouncement(`${nodeLabelIn(draft.nodes, from)} now feeds ${nodeLabelIn(draft.nodes, to)}.`);
@@ -1254,6 +1505,11 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
1254
1505
  mutationFn: ({ id, options }) => client.runWorkflow(id, options),
1255
1506
  onSuccess: (result) => {
1256
1507
  setRun(result);
1508
+ // The answer to a run is written in the rail, so a run that finishes while
1509
+ // the rail is put away would report itself into a panel nobody can see.
1510
+ // Pressing Run is the clearest possible statement that somebody wants the
1511
+ // outcome, so this is the one place the screen opens it on their behalf.
1512
+ setRailOpen(true);
1257
1513
  // A run writes rows, so the catalog snapshot every other screen reads is
1258
1514
  // now stale. Invalidating it here is what stops the object explorer
1259
1515
  // showing yesterday's counts beside a run that just finished.
@@ -1305,6 +1561,12 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
1305
1561
  edit((current) => ({
1306
1562
  ...current,
1307
1563
  nodes: runningTransform(current.nodes, nodeId, created.id),
1564
+ }),
1565
+ // Only the half of this that lives in the draft. The transform itself
1566
+ // was created on the server and stays there — undoing this unpicks the
1567
+ // node from it, which is the part of the act this canvas owns.
1568
+ (current) => ({
1569
+ label: `pointing ${namesOf(current.nodes, [nodeId])} at "${created.name}"`,
1308
1570
  }));
1309
1571
  markStarted(nodeId);
1310
1572
  // Written into the cache as well as invalidated: the code sheet below
@@ -1331,14 +1593,14 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
1331
1593
  });
1332
1594
  const addNode = useCallback((kind) => {
1333
1595
  const id = newLocalId(kind);
1334
- setDraft((current) => {
1596
+ edit((current) => {
1335
1597
  const node = newNodeOfKind(kind, id, nextPosition(current.nodes), uniqueName(current.nodes, kind));
1336
- return { ...current, nodes: [...current.nodes, node], dirty: true };
1337
- });
1598
+ return { ...current, nodes: [...current.nodes, node] };
1599
+ }, { label: `adding a ${kind} node` });
1338
1600
  setUnstarted((current) => new Set([...current, id]));
1339
1601
  setInspecting(id);
1340
1602
  setAnnouncement(`A ${kind} node was added. Its inspector is open.`);
1341
- }, []);
1603
+ }, [edit]);
1342
1604
  /**
1343
1605
  * Make the next node and wire it in, as one action.
1344
1606
  *
@@ -1368,7 +1630,11 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
1368
1630
  ...current,
1369
1631
  nodes: [...current.nodes, node],
1370
1632
  edges: [...current.edges, newEdge(current.nodes, current.edges, fromId, node.id)],
1371
- }));
1633
+ }),
1634
+ // ONE entry, for two graph changes. The node and the wire are a single
1635
+ // gesture — "put the next box here" — and undoing them separately would
1636
+ // leave a node somebody never asked for on its own on the canvas.
1637
+ { label: `adding ${nodeName(node)} wired from ${nodeName(from)}` });
1372
1638
  setUnstarted((current) => new Set([...current, node.id]));
1373
1639
  menu.close();
1374
1640
  setInspecting(node.id);
@@ -1378,10 +1644,63 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
1378
1644
  edit((current) => ({
1379
1645
  ...current,
1380
1646
  nodes: layout(current.nodes, current.edges),
1381
- }));
1382
- window.requestAnimationFrame(() => fitView({ padding: 0.25, duration: 200 }));
1647
+ }),
1648
+ // One entry, and a big one: Tidy moves every node at once, and it is
1649
+ // precisely the control somebody presses on a layout they had arranged by
1650
+ // hand and then wants back.
1651
+ { label: 'tidying the layout' });
1652
+ window.requestAnimationFrame(() => fitView({ padding: fitPadding, duration: 200 }));
1383
1653
  setAnnouncement('The nodes were laid out left to right by dependency, with every sink in the last column.');
1384
- }, [edit, fitView]);
1654
+ }, [edit, fitView, fitPadding]);
1655
+ /**
1656
+ * One action back.
1657
+ *
1658
+ * Announced with the name of what it took back, because undo is the one
1659
+ * control here whose effect is routinely invisible: the node it just put back
1660
+ * may be off screen, and a revert nobody can see is indistinguishable from a
1661
+ * button that did nothing.
1662
+ *
1663
+ * The step is computed out here rather than inside the updater so the label is
1664
+ * available to say — and so nothing sets state from inside a `setState`
1665
+ * updater, which React is free to replay.
1666
+ */
1667
+ const undo = useCallback(() => {
1668
+ const step = undone(draft);
1669
+ if (!step) {
1670
+ setAnnouncement('There is nothing to take back — this drawing is as it was loaded.');
1671
+ return;
1672
+ }
1673
+ setDraft(step.draft);
1674
+ // The inspector is open on a node that may have just stopped existing, and
1675
+ // a sheet describing a deleted node is worse than no sheet.
1676
+ setInspecting((current) => current && step.draft.nodes.some((node) => node.id === current) ? current : null);
1677
+ setUnstarted((current) => keepKnown(current, step.draft.nodes));
1678
+ const left = step.draft.past.length;
1679
+ setAnnouncement(`Undone: ${step.label}. ${left === 0 ? 'Nothing left to take back.' : `${left} ${left === 1 ? 'action' : 'actions'} left to take back.`}`);
1680
+ }, [draft]);
1681
+ /**
1682
+ * All the way back to the version the server last stored.
1683
+ *
1684
+ * Deliberately NOT "undo until the stack is empty". Save halfway through a
1685
+ * session and the baseline moves to that save, so this returns to the saved
1686
+ * v2 — whereas undoing forty times would walk straight past it back to the v1
1687
+ * the tab was opened on. Which of the two somebody means by "reset" is not in
1688
+ * doubt, and the confirmation says which one this is.
1689
+ */
1690
+ const reset = useCallback(() => {
1691
+ const back = reverted(draft);
1692
+ setDraft(back);
1693
+ setResetting(false);
1694
+ setInspecting(null);
1695
+ setSelectedNodeIds([]);
1696
+ setSelectedEdgeIds([]);
1697
+ setUnstarted(new Set());
1698
+ setAnnouncement(draft.id
1699
+ ? `Reset. The drawing is back to v${draft.version ?? 1}, as the server stored it. Nothing on the server was changed.`
1700
+ : 'Reset. The canvas is empty again, which is where this unsaved workflow started.');
1701
+ }, [draft]);
1702
+ useUndoShortcut({ enabled: canEdit, onUndo: undo, onSay: setAnnouncement });
1703
+ useUnsavedGuard(draft.dirty);
1385
1704
  const durability = describeDurability(capabilities?.durable);
1386
1705
  // Asked about EVERY problem, not about `live`. This is the guarantee: a graph
1387
1706
  // that would silently do nothing is coloured as unsaveable from the moment it
@@ -1484,29 +1803,45 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
1484
1803
  }), [client]);
1485
1804
  return (
1486
1805
  /*
1487
- * The screen lives inside the viewport: a header sized to its content and a
1488
- * canvas that takes whatever is left.
1806
+ * THE CANVAS IS THE SCREEN.
1807
+ *
1808
+ * One positioned box filling whatever the host gives it, with exactly two
1809
+ * layers in it: the graph, pinned to all four edges, and the chrome floating
1810
+ * over the graph. Nothing is in normal flow and nothing scrolls — a
1811
+ * full-bleed canvas that can be scrolled away from is a canvas that is not
1812
+ * actually the screen.
1489
1813
  *
1490
- * `min-h-0` on both this column and the row below it is the load-bearing
1491
- * part. A flex child defaults to `min-height: auto`, which means "at least
1492
- * as tall as my content" and makes it refuse to shrink — so a canvas with a
1493
- * minimum height pushed itself past the bottom of a `main` that does not
1494
- * scroll, and there was no way to reach the lower half of it. Fit View could
1495
- * not save that: it fits the graph into a box, and half the box was off
1496
- * screen. See `QueryConsole` for the same pattern.
1814
+ * What that buys, and it is the whole point: the drawing surface is now the
1815
+ * entire viewport instead of the ~55% left over after a header, a button row
1816
+ * and a column of panels had taken their share.
1817
+ *
1818
+ * What it costs is occlusion — a panel over the canvas covers graph. Three
1819
+ * things pay that back. The chrome is compact and translucent, so what is
1820
+ * behind it stays perceptible. Everything permanent is either an
1821
+ * always-needed control or dismissible. And `fitView` is given the chrome's
1822
+ * own insets (see `CHROME`), so the graph is fitted into the region nothing
1823
+ * covers rather than into the raw viewport — which is what stops a node
1824
+ * being centred underneath the action cluster.
1497
1825
  */
1498
- _jsxs("div", { className: "flex h-full min-h-0 flex-col", children: [_jsxs("div", { className: "shrink-0 px-6 pt-5", children: [_jsxs("div", { className: "flex flex-wrap items-baseline gap-x-3 gap-y-1", children: [_jsx("p", { className: cn('font-mono text-[11px] uppercase tracking-[0.18em]', MUTED), children: eyebrow }), _jsx("h1", { className: "text-xl font-semibold tracking-tight", children: title }), stored && _jsx(WorkflowStatusBadge, { workflow: stored }), _jsx(CommitsBadge, { produces: produces })] }), _jsx("p", { className: "mt-0.5 max-w-3xl text-xs text-zinc-500 dark:text-zinc-400", children: intro }), _jsx(DurabilityBanner, { durability: durability }), workflows.isSuccess && workflows.data.length === 0 && _jsx(NothingDrawnYet, {}), _jsxs("div", { className: "mt-2.5 grid gap-3 sm:grid-cols-2 lg:grid-cols-3", children: [_jsx(SelectField, { label: WORKFLOW_NAME.title, ariaLabel: `Which ${WORKFLOW_NAME.singular} to edit`, value: selected, onValueChange: (value) => {
1826
+ _jsxs("div", { className: "relative h-full min-h-0 w-full overflow-hidden", children: [_jsxs("div", { className: "pointer-events-none absolute inset-0 z-20 flex flex-col gap-3 p-3 sm:p-4", children: [_jsxs("div", { className: "flex flex-wrap items-start justify-between gap-3", children: [_jsx(WorkflowCard, { eyebrow: eyebrow, title: title, intro: intro, stored: stored, produces: produces, durability: durability, selected: selected, workflowOptions: workflowOptions, workflowsPending: workflows.isPending, draftName: draft.name, canEdit: canEdit, onSelect: (value) => {
1499
1827
  loadedRef.current = null;
1500
1828
  setSelected(value);
1501
- }, options: workflowOptions, disabled: workflows.isPending }), _jsx(TextField, { label: "Name", value: draft.name, onChange: (name) => edit((current) => ({ ...current, name })), placeholder: "Fleet readiness", disabled: !canEdit }), _jsx(CanvasActions, { draft: draft, stored: stored, canEdit: canEdit, blocked: blocked, unfinished: unfinished, saving: save.isPending, running: runIt.isPending, durabilityDetail: durability.detail, acknowledging: acknowledging, onAcknowledgingChange: setAcknowledging, onSave: saveNow, onRun: runNow, onLifecycleChange: onLifecycleChange, onAskDelete: () => setConfirmingDelete(true) })] }), save.error && _jsx(RefusalNote, { lead: "The server refused it:", error: save.error }), runIt.error && _jsx(RefusalNote, { lead: "The run could not start:", error: runIt.error }), _jsx(ShrinkRefusalNote, { run: run, error: runIt.error, onAcknowledge: () => setAcknowledging(true) })] }), canEdit && (_jsx(AddNodeBar, { refreshing: workflows.isFetching && !workflows.isPending, onAdd: addNode, onTidy: tidy })), _jsxs("div", { className: "flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto px-6 pb-5 pt-3 lg:flex-row lg:overflow-hidden", children: [_jsx(GraphSurface, { loading: workflows.isPending, failed: workflows.isError, error: workflows.error, onRetry: () => workflows.refetch(), canEdit: canEdit, draft: draft, flowNodes: flowNodes, flowEdges: flowEdges, onInspect: setInspecting, onEditCode: setEditingCodeFor, onNodesChange: onNodesChange, onEdgesChange: onEdgesChange, onConnect: onConnect, isValidConnection: isValidConnection, onConnectEnd: announceRefusedDrop, onNodeEnter: menu.onNodeEnter, onNodeLeave: menu.onNodeLeave,
1502
- // Clicking empty canvas puts away everything that is half-open: the
1503
- // wiring menu, and a wire that was started and never landed. React
1504
- // Flow only fires this for clicks on the pane ITSELF, so finishing a
1505
- // wire on a handle does not also cancel it on the way past.
1506
- onPaneClick: () => {
1507
- menu.close();
1508
- wiring.cancel();
1509
- }, onDisconnect: disconnect, wiring: wiring, wiringRefusal: wiringRefusal, nodeMenu: _jsx(NodeWiringMenu, { node: menu.anchor, draft: draft, canEdit: canEdit, open: menu.open, onOpenChange: menu.onOpenChange, onHoverChange: menu.onHoverChange, onConnect: connect, onConnectToNew: connectToNew, onDisconnect: disconnect }) }), _jsx(WiringRail, { draft: draft, problems: live, pending: pending, run: run, canEdit: canEdit, onInspect: setInspecting, onDisconnect: disconnect, children: stored && (_jsxs(_Fragment, { children: [_jsx(SchedulePanel, { workflow: stored, canEdit: canEdit, onScheduled: onLifecycleChange }, stored.id), _jsx(RunsAsPanel, { workflowId: stored.id, status: stored.status, transforms: graphTransforms })] })) })] }), _jsx("output", { "aria-live": "polite", className: "sr-only", children: announcement }), _jsx(NodeInspector, { node: inspectingNode, draft: draft, transforms: transforms, connections: connections, typeOptions: typeOptions, canEdit: canEdit, modelHref: modelHref, problems: problemsOf(problemsFor, inspectingNode), pending: problemsOf(pendingFor, inspectingNode), discovery: discovery, discoverable: { ...discoveryTarget(draft), onSave: saveNow, saving: save.isPending }, onDiscovered: rememberShape, onClose: () => setInspecting(null), onChange: (next) => {
1829
+ },
1830
+ // Typing is one action, not one per keystroke: consecutive edits
1831
+ // sharing the `rename` run fold together while the run is open. See
1832
+ // `RUN_WINDOW_MS`.
1833
+ onRename: (name) => edit((current) => ({ ...current, name }), {
1834
+ label: 'renaming this workflow',
1835
+ run: 'rename',
1836
+ }) }), _jsxs("div", { className: "flex max-w-full flex-col items-end gap-2", children: [_jsxs("div", { className: cn('pointer-events-auto flex items-start gap-2 p-1.5', FLOATING), children: [_jsx(CanvasActions, { draft: draft, stored: stored, canEdit: canEdit, blocked: blocked, unfinished: unfinished, saving: save.isPending, running: runIt.isPending, durabilityDetail: durability.detail, acknowledging: acknowledging, reducedMotion: reducedMotion, resetting: resetting, onAcknowledgingChange: setAcknowledging, onResettingChange: setResetting, onUndo: undo, onReset: reset, onSave: saveNow, onRun: runNow, onLifecycleChange: onLifecycleChange, onAskDelete: () => setConfirmingDelete(true) }), _jsx("span", { className: "h-6 w-px shrink-0 bg-zinc-200 dark:bg-zinc-800", "aria-hidden": true }), _jsx(RailToggle, { open: railOpen, problems: live, onToggle: () => setRailOpen((o) => !o) })] }), _jsxs("div", { className: "pointer-events-auto w-[min(26rem,100%)] empty:hidden", children: [save.error && _jsx(RefusalNote, { lead: "The server refused it:", error: save.error }), runIt.error && _jsx(RefusalNote, { lead: "The run could not start:", error: runIt.error }), _jsx(ShrinkRefusalNote, { run: run, error: runIt.error, onAcknowledge: () => setAcknowledging(true) })] })] })] }), canEdit && (_jsx("div", { className: "absolute inset-x-0 bottom-3 flex justify-center px-3 sm:bottom-4 sm:px-4", children: _jsx(AddNodeBar, { refreshing: workflows.isFetching && !workflows.isPending, onAdd: addNode, onTidy: tidy }) })), _jsx("div", { className: "flex min-h-0 flex-1 justify-end pb-14", children: _jsx(AnimatePresence, { initial: false, children: railOpen && (_jsx(WiringRail, { draft: draft, problems: live, pending: pending, run: run, canEdit: canEdit, reducedMotion: reducedMotion, onInspect: setInspecting, onDisconnect: disconnect, onClose: () => setRailOpen(false), children: stored && (_jsxs(_Fragment, { children: [_jsx(SchedulePanel, { workflow: stored, canEdit: canEdit, onScheduled: onLifecycleChange }, stored.id), _jsx(RunsAsPanel, { workflowId: stored.id, status: stored.status, transforms: graphTransforms })] })) })) }) })] }), _jsx(GraphSurface, { loading: workflows.isPending, failed: workflows.isError, error: workflows.error, onRetry: () => workflows.refetch(), canEdit: canEdit, draft: draft, flowNodes: flowNodes, flowEdges: flowEdges, onInspect: setInspecting, onEditCode: setEditingCodeFor, onNodesChange: onNodesChange, onEdgesChange: onEdgesChange, onConnect: onConnect, isValidConnection: isValidConnection, onConnectEnd: announceRefusedDrop, onNodeEnter: menu.onNodeEnter, onNodeLeave: menu.onNodeLeave,
1837
+ // Clicking empty canvas puts away everything that is half-open: the
1838
+ // wiring menu, and a wire that was started and never landed. React
1839
+ // Flow only fires this for clicks on the pane ITSELF, so finishing a
1840
+ // wire on a handle does not also cancel it on the way past.
1841
+ onPaneClick: () => {
1842
+ menu.close();
1843
+ wiring.cancel();
1844
+ }, onDisconnect: disconnect, wiring: wiring, wiringRefusal: wiringRefusal, nodeMenu: _jsx(NodeWiringMenu, { node: menu.anchor, draft: draft, canEdit: canEdit, open: menu.open, onOpenChange: menu.onOpenChange, onHoverChange: menu.onHoverChange, onConnect: connect, onConnectToNew: connectToNew, onDisconnect: disconnect }), fitPadding: fitPadding }), workflows.isSuccess && workflows.data.length === 0 && _jsx(NothingDrawnYet, {}), _jsx("output", { "aria-live": "polite", className: "sr-only", children: announcement }), _jsx(NodeInspector, { node: inspectingNode, draft: draft, transforms: transforms, connections: connections, typeOptions: typeOptions, canEdit: canEdit, modelHref: modelHref, problems: problemsOf(problemsFor, inspectingNode), pending: problemsOf(pendingFor, inspectingNode), discovery: discovery, discoverable: { ...discoveryTarget(draft), onSave: saveNow, saving: save.isPending }, onDiscovered: rememberShape, onClose: () => setInspecting(null), onChange: (next) => {
1510
1845
  // Editing any field is the clearest statement there is that somebody
1511
1846
  // is working on this node rather than looking at one they just made.
1512
1847
  markStarted(next.id);
@@ -1522,19 +1857,20 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
1522
1857
  // updater below: an updater is called again on every re-render React
1523
1858
  // decides to replay, and a `setState` in one is a side effect that
1524
1859
  // would fire with it.
1525
- if (readsDifferently(draft.nodes.find((node) => node.id === next.id), next)) {
1860
+ const before = draft.nodes.find((node) => node.id === next.id);
1861
+ if (readsDifferently(before, next)) {
1526
1862
  forgetShape(next.id);
1527
1863
  }
1528
1864
  edit((current) => ({
1529
1865
  ...current,
1530
1866
  nodes: current.nodes.map((node) => (node.id === next.id ? next : node)),
1531
- }));
1867
+ }), nodeEditAction(before, next));
1532
1868
  }, onConnect: connect, onConnectToNew: connectToNew, onDisconnect: disconnect, onBranch: setBranch, onCreateTransform: (nodeId) => createTransform.mutate(nodeId), creatingTransform: createTransform.isPending, createTransformError: createTransform.error, onDelete: (nodeId) => {
1533
1869
  edit((current) => ({
1534
1870
  ...current,
1535
1871
  nodes: current.nodes.filter((node) => node.id !== nodeId),
1536
1872
  edges: current.edges.filter((edge) => edge.from !== nodeId && edge.to !== nodeId),
1537
- }));
1873
+ }), (current) => ({ label: `deleting ${namesOf(current.nodes, [nodeId])}` }));
1538
1874
  setInspecting(null);
1539
1875
  setAnnouncement('Node removed, along with its connections.');
1540
1876
  }, onEditCode: (nodeId) => setEditingCodeFor(nodeId) }), _jsx(Sheet, { open: editingCodeFor !== null, onOpenChange: (open) => {
@@ -1547,8 +1883,21 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
1547
1883
  });
1548
1884
  } })) : (_jsx("p", { className: cn('py-8 text-center text-xs', MUTED), children: "This node does not name a transform yet. Choose one in the inspector first \u2014 there is no code to open until it does." })) }), _jsx(ConfirmDialog, { open: confirmingDelete, onOpenChange: setConfirmingDelete, title: `Delete "${draft.name || WORKFLOW_NAME.singular}"?`, description: `The connector it runs as goes with it, and the run history keyed on that connector goes too — including the incremental watermark, so anything rebuilt later reads its source from the beginning. The snapshots it already committed stay where they are. The transforms and connections it wired together are not touched: they are shared, and other ${WORKFLOW_NAME.plural} may use them.`, confirmLabel: "Delete", pending: remove.isPending, error: remove.error instanceof Error ? remove.error.message : undefined, onConfirm: () => draft.id && remove.mutate(draft.id) })] }));
1549
1885
  }
1550
- function AddButton({ icon: Icon, label, hint, onClick, }) {
1551
- return (_jsx(Tooltip, { content: hint, children: _jsxs("button", { type: "button", onClick: onClick, "aria-label": `Add a ${label.toLowerCase()} node`, className: cn('flex items-center gap-1.5 rounded-md border px-2.5 py-1.5 text-xs', RULE, 'hover:bg-zinc-50 dark:hover:bg-zinc-800'), children: [_jsx(Plus, { size: 11 }), _jsx(Icon, { size: 12 }), label] }) }));
1886
+ /**
1887
+ * "a" or "an", for a name that is now generated rather than typed out.
1888
+ *
1889
+ * Worth the three lines: the row used to carry six hand-written labels, and the
1890
+ * moment they were derived from the kind the sixth one read "Add a if node".
1891
+ * That string is not decoration — it is the whole accessible name of the button,
1892
+ * so the only person it is wrong for is the one who cannot see the icon.
1893
+ */
1894
+ function article(word) {
1895
+ return /^[aeiou]/i.test(word) ? 'an' : 'a';
1896
+ }
1897
+ function AddButton({ kind, onClick }) {
1898
+ const { icon: Icon, label, hint } = ADD_NODE[kind];
1899
+ const noun = label.toLowerCase();
1900
+ return (_jsx(Tooltip, { content: hint, children: _jsxs(Button, { variant: "ghost", size: "sm", onClick: onClick, "aria-label": `Add ${article(noun)} ${noun} node`, className: "shrink-0 text-zinc-600 dark:text-zinc-300", children: [_jsx(Plus, { size: 11 }), _jsx(Icon, { size: 12 }), _jsx("span", { className: "hidden md:inline", children: label })] }) }));
1552
1901
  }
1553
1902
  /**
1554
1903
  * Whether a failed run resumes or restarts, stated on the screen that implies
@@ -1578,6 +1927,71 @@ function DurabilityBanner({ durability, }) {
1578
1927
  function CanvasSkeleton() {
1579
1928
  return (_jsx("div", { className: "flex h-full w-full items-center justify-center bg-zinc-50 dark:bg-zinc-950", children: _jsxs("div", { className: "flex items-center gap-3", children: [_jsx("div", { className: "h-16 w-48 animate-pulse rounded-lg bg-zinc-200 dark:bg-zinc-800" }), _jsx(ArrowRight, { size: 14, className: MUTED }), _jsx("div", { className: "h-16 w-48 animate-pulse rounded-lg bg-zinc-200 dark:bg-zinc-800" }), _jsx(ArrowRight, { size: 14, className: MUTED }), _jsx("div", { className: "h-16 w-48 animate-pulse rounded-lg bg-zinc-200 dark:bg-zinc-800" })] }) }));
1580
1929
  }
1930
+ /**
1931
+ * Show or hide the details rail, and say what is in it while it is hidden.
1932
+ *
1933
+ * The count is the load-bearing part. A rail that can be closed is a rail that
1934
+ * can hide the problems list, and "there are two errors" is not something
1935
+ * somebody should have to open a panel to discover — so the closed state carries
1936
+ * the number and the colour, and opening it is what gets the sentences. The
1937
+ * accessible name says the same thing in words, because a red 2 on a button is
1938
+ * not information if you cannot see it.
1939
+ */
1940
+ function RailToggle({ open, problems, onToggle, }) {
1941
+ const badge = problemBadge(problems);
1942
+ const hint = open
1943
+ ? 'Hide the wiring, problems, schedule and run history, and give the canvas the room.'
1944
+ : `Show the wiring, problems, schedule and run history.${badge ? ` ${badge.sentence}` : ''}`;
1945
+ const name = open
1946
+ ? 'Hide the details panel'
1947
+ : `Show the details panel${badge ? `, ${badge.summary}` : ''}`;
1948
+ return (_jsx(Tooltip, { content: hint, children: _jsxs(Button, { variant: "ghost", size: "sm", onClick: onToggle, "aria-expanded": open, "aria-label": name, className: "shrink-0", children: [_jsx(PanelRight, { size: 12 }), !open && badge && (_jsx("span", { className: cn('rounded px-1 font-mono text-[10px]', badge.tone), children: badge.count }))] }) }));
1949
+ }
1950
+ /**
1951
+ * The one number a closed rail has to carry, or nothing at all.
1952
+ *
1953
+ * Errors win over warnings rather than being summed: a graph with one error and
1954
+ * six warnings is an error, and "7" beside a neutral chip would be the button
1955
+ * averaging two different facts into one that is neither.
1956
+ *
1957
+ * Split out of {@link RailToggle} because the three shapes it produces — a
1958
+ * count, a colour and two grammatical forms — were four nested ternaries inside
1959
+ * JSX, which is how a badge ends up saying "1 errors".
1960
+ */
1961
+ function problemBadge(problems) {
1962
+ const errors = problems.filter((problem) => problem.level === 'error').length;
1963
+ const warnings = problems.length - errors;
1964
+ if (errors > 0) {
1965
+ return {
1966
+ count: errors,
1967
+ summary: `${errors} ${errors === 1 ? 'error' : 'errors'}`,
1968
+ sentence: `There ${errors === 1 ? 'is' : 'are'} ${errors} ${errors === 1 ? 'error' : 'errors'}.`,
1969
+ tone: 'bg-red-100 text-red-700 dark:bg-red-950 dark:text-red-300',
1970
+ };
1971
+ }
1972
+ if (warnings > 0) {
1973
+ return {
1974
+ count: warnings,
1975
+ summary: `${warnings} ${warnings === 1 ? 'warning' : 'warnings'}`,
1976
+ sentence: `There ${warnings === 1 ? 'is' : 'are'} ${warnings} ${warnings === 1 ? 'warning' : 'warnings'}.`,
1977
+ tone: 'bg-amber-100 text-amber-700 dark:bg-amber-950 dark:text-amber-300',
1978
+ };
1979
+ }
1980
+ return null;
1981
+ }
1982
+ /**
1983
+ * Which graph this is, and the two fields that name it — top-left, floating.
1984
+ *
1985
+ * The corner a document's identity lives in, in every tool shaped like this one.
1986
+ * What is deliberately NOT here is the description paragraph: it explains the
1987
+ * screen to somebody arriving at it and says nothing to somebody mid-draw, so it
1988
+ * costs three lines of canvas forever to be read once. It is still reachable
1989
+ * from the button beside the title, and still read out in full to a screen
1990
+ * reader, which is the one audience a tooltip would have failed.
1991
+ */
1992
+ function WorkflowCard({ eyebrow, title, intro, stored, produces, durability, selected, workflowOptions, workflowsPending, draftName, canEdit, onSelect, onRename, }) {
1993
+ return (_jsxs("div", { className: cn('pointer-events-auto w-[min(24rem,100%)] p-3', FLOATING), children: [_jsxs("div", { className: "flex flex-wrap items-baseline gap-x-2 gap-y-1", children: [_jsx("p", { className: cn('font-mono text-[10px] uppercase tracking-[0.18em]', MUTED), children: eyebrow }), _jsx("h1", { className: "text-sm font-semibold tracking-tight", children: title }), stored && _jsx(WorkflowStatusBadge, { workflow: stored }), _jsx(CommitsBadge, { produces: produces }), _jsx(Tooltip, { content: intro, children: _jsx(Button, { variant: "ghost", size: "icon", "aria-label": "What this screen is for", className: "ml-auto h-5 w-5", children: _jsx(Info, { size: 11 }) }) })] }), _jsx("p", { className: "sr-only", children: intro }), _jsxs("div", { className: "mt-2.5 grid gap-2", children: [_jsx(SelectField, { label: WORKFLOW_NAME.title, ariaLabel: `Which ${WORKFLOW_NAME.singular} to edit`, value: selected, onValueChange: onSelect, options: workflowOptions, disabled: workflowsPending }), _jsx(TextField, { label: "Name", value: draftName, onChange: onRename, placeholder: "Fleet readiness", disabled: !canEdit })] }), _jsx(DurabilityBanner, { durability: durability })] }));
1994
+ }
1581
1995
  /**
1582
1996
  * That there are none, said rather than drawn as a blank canvas.
1583
1997
  *
@@ -1599,10 +2013,21 @@ function CanvasSkeleton() {
1599
2013
  * wondering whether the two do different things.
1600
2014
  */
1601
2015
  function NothingDrawnYet() {
1602
- return (_jsxs("div", { className: cn('mt-2.5 flex flex-wrap items-baseline gap-x-2 rounded-md border border-dashed px-2.5 py-1.5', RULE), children: [_jsxs("p", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: ["No ", WORKFLOW_NAME.plural, " yet"] }), _jsxs("p", { className: cn('text-[11px] leading-relaxed', MUTED), children: ["Nothing is missing \u2014 this deployment has never had one drawn. Add a source, wire it into a sink and save, and it becomes the first. If this deployment has connectors already loading data, they are not shown here and nothing turns them into ", WORKFLOW_NAME.plural, "automatically."] })] }));
2016
+ return (
2017
+ /*
2018
+ * Centred ON the canvas rather than stated above it, now that the canvas is
2019
+ * the screen. An empty surface is where somebody is already looking, and it
2020
+ * is the thing being explained.
2021
+ *
2022
+ * `pointer-events-none` throughout: it carries no control — the one that
2023
+ * creates a workflow is the picker in the card — and a plate over the middle
2024
+ * of the canvas that swallowed a pan would make the empty state feel like a
2025
+ * broken canvas, which is precisely the reading it exists to prevent.
2026
+ */
2027
+ _jsx("div", { className: "pointer-events-none absolute inset-0 z-10 flex items-center justify-center p-6", children: _jsxs("div", { className: cn('max-w-md rounded-xl border border-dashed px-4 py-3 text-center backdrop-blur-sm', RULE), children: [_jsxs("p", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: ["No ", WORKFLOW_NAME.plural, " yet"] }), _jsxs("p", { className: cn('mt-1.5 text-[11px] leading-relaxed', MUTED), children: ["Nothing is missing \u2014 this deployment has never had one drawn. Add a source, wire it into a sink and save, and it becomes the first. If this deployment has connectors already loading data, they are not shown here and nothing turns them into ", WORKFLOW_NAME.plural, ' ', "automatically."] })] }) }));
1603
2028
  }
1604
2029
  function CanvasFailure({ error, onRetry, }) {
1605
- return (_jsx("div", { className: "flex h-full w-full items-center justify-center bg-red-50 px-6 dark:bg-red-950/30", children: _jsxs("div", { className: "max-w-md text-center", children: [_jsx(CircleAlert, { size: 18, className: "mx-auto text-red-600" }), _jsxs("p", { className: "mt-2 text-sm text-red-700 dark:text-red-300", children: ["The ", WORKFLOW_NAME.plural, " could not be read, so nothing below is drawn. This is not an empty ", WORKFLOW_NAME.singular, "."] }), _jsx("p", { className: "mt-1 font-mono text-[11px] text-red-600 dark:text-red-400", children: error instanceof Error ? error.message : 'No reason was given.' }), _jsx("button", { type: "button", onClick: onRetry, className: "mt-3 rounded-md border border-red-300 px-3 py-1 text-xs text-red-700 dark:border-red-800 dark:text-red-300", children: "Try again" })] }) }));
2030
+ return (_jsx("div", { className: "flex h-full w-full items-center justify-center bg-red-50 px-6 dark:bg-red-950/30", children: _jsxs("div", { className: "max-w-md text-center", children: [_jsx(CircleAlert, { size: 18, className: "mx-auto text-red-600" }), _jsxs("p", { className: "mt-2 text-sm text-red-700 dark:text-red-300", children: ["The ", WORKFLOW_NAME.plural, " could not be read, so nothing below is drawn. This is not an empty ", WORKFLOW_NAME.singular, "."] }), _jsx("p", { className: "mt-1 font-mono text-[11px] text-red-600 dark:text-red-400", children: error instanceof Error ? error.message : 'No reason was given.' }), _jsx(Button, { variant: "outline", size: "sm", onClick: onRetry, className: "mt-3 border-red-300 text-red-700 dark:border-red-800 dark:text-red-300", children: "Try again" })] }) }));
1606
2031
  }
1607
2032
  /**
1608
2033
  * The graph as a list, beside the graph as a picture.
@@ -1616,7 +2041,7 @@ function CanvasFailure({ error, onRetry, }) {
1616
2041
  * The problems list sits in the same rail for the same reason: a red ring
1617
2042
  * around a node off the left edge of the viewport communicates nothing.
1618
2043
  */
1619
- function WiringRail({ draft, problems, pending, run, canEdit, onInspect, onDisconnect, children, }) {
2044
+ function WiringRail({ draft, problems, pending, run, canEdit, reducedMotion, onInspect, onDisconnect, onClose, children, }) {
1620
2045
  const label = (id) => {
1621
2046
  const node = draft.nodes.find((n) => n.id === id);
1622
2047
  return node ? nodeName(node) : id;
@@ -1624,19 +2049,38 @@ function WiringRail({ draft, problems, pending, run, canEdit, onInspect, onDisco
1624
2049
  const errors = problems.filter((problem) => problem.level === 'error');
1625
2050
  const warnings = problems.filter((problem) => problem.level === 'warning');
1626
2051
  const sinks = draft.nodes.filter((node) => node.kind === 'sink');
1627
- return (_jsxs("aside", { className: "flex w-full shrink-0 flex-col gap-3 lg:w-72 lg:min-h-0 lg:overflow-y-auto", "aria-label": `${WORKFLOW_NAME.title} wiring and problems`, children: [_jsxs("section", { className: cn('rounded-lg border p-3', RULE, PANEL), children: [_jsx("h2", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Wiring" }), draft.edges.length === 0 ? (_jsx("p", { className: cn('mt-2 text-[11px]', MUTED), children: "Nothing is wired together yet." })) : (_jsx("ul", { className: "mt-2 space-y-1", children: draft.edges.map((edge) => (_jsxs("li", { className: "flex items-center gap-1.5 text-[11px]", children: [_jsx("button", { type: "button", onClick: () => onInspect(edge.from), className: "truncate hover:underline", children: label(edge.from) }), _jsx(ArrowRight, { size: 10, className: cn('shrink-0', MUTED) }), _jsx("button", { type: "button", onClick: () => onInspect(edge.to), className: "truncate hover:underline", children: label(edge.to) }), canEdit && (_jsx(Tooltip, { content: "Remove this connection.", children: _jsx("button", { type: "button", onClick: () => onDisconnect(edge), "aria-label": `Disconnect ${label(edge.from)} from ${label(edge.to)}`, className: "ml-auto shrink-0 rounded p-0.5 text-zinc-400 hover:text-red-600", children: _jsx(Unplug, { size: 11 }) }) }))] }, edgeId(edge)))) }))] }), children, _jsx(PendingWork, { pending: pending, label: label, onInspect: onInspect }), _jsxs("section", { className: cn('rounded-lg border p-3', RULE, PANEL), children: [_jsx("h2", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Problems" }), problems.length === 0 ? (_jsx("p", { className: cn('mt-2 text-[11px]', MUTED), children: "Nothing to flag here. The server checks it again on save." })) : (_jsx("ul", { className: "mt-2 space-y-2", children: [...errors, ...warnings].map((problem) => (_jsxs("li", { className: "flex gap-1.5 text-[11px] leading-relaxed", children: [problem.level === 'error' ? (_jsx(CircleAlert, { size: 11, className: "mt-0.5 shrink-0 text-red-500" })) : (_jsx(TriangleAlert, { size: 11, className: "mt-0.5 shrink-0 text-amber-500" })), _jsxs("span", { children: [problem.message, problem.nodeIds.length > 0 && (_jsx("span", { className: "ml-1", children: problem.nodeIds.map((nodeId) => (_jsx("button", { type: "button", onClick: () => onInspect(nodeId), className: cn('mr-1 rounded border px-1 font-mono text-[9px]', RULE, MUTED), children: label(nodeId) }, nodeId))) }))] })] }, `${problem.code}:${problem.nodeIds.join(',')}`))) }))] }), run && (_jsxs("section", { className: cn('rounded-lg border p-3', RULE, PANEL), children: [_jsx("h2", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Last run" }), _jsxs("p", { className: "mt-1 text-[11px]", children: [run.status, _jsx("span", { className: cn('ml-1 font-mono text-[10px]', MUTED), children: run.durable ? 'checkpointed per node' : 'ran inline, no checkpoints' })] }), sinks.length > 0 && (_jsxs("div", { className: "mt-2", children: [_jsx("h3", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Committed" }), _jsx("ul", { className: "mt-1 space-y-1", children: sinks.map((sink) => {
1628
- const outcome = run.nodes.find((node) => node.nodeId === sink.id);
1629
- const type = sink.kind === 'sink' && sink.targetType ? sink.targetType : 'no type';
1630
- return (_jsxs("li", { className: "flex items-center gap-1.5 text-[11px]", children: [_jsx("span", { className: "truncate font-mono text-[10px]", children: type }), _jsx("span", { className: cn('ml-auto shrink-0 font-mono text-[10px]', outcome?.status === 'failed'
1631
- ? 'text-red-500'
1632
- : outcome?.status === 'succeeded'
1633
- ? 'text-emerald-600 dark:text-emerald-400'
1634
- : MUTED), children: outcome
1635
- ? outcome.status === 'succeeded' && typeof outcome.rows === 'number'
1636
- ? `${outcome.rows} rows`
1637
- : outcome.status
1638
- : 'no outcome recorded' })] }, sink.id));
1639
- }) }), _jsx("p", { className: cn('mt-1 text-[10px] leading-relaxed', MUTED), children: "Each sink commits on its own. One committing and another failing is a failed run that nevertheless wrote something, not a partial success that will be rolled back." })] })), _jsx("ul", { className: "mt-2 space-y-1", children: run.nodes.map((node) => (_jsxs("li", { className: "flex items-center gap-1.5 font-mono text-[10px]", children: [_jsx("span", { className: "truncate", children: label(node.nodeId) }), _jsx("span", { className: cn('ml-auto shrink-0', node.status === 'failed' ? 'text-red-500' : MUTED), children: node.replayed ? 'replayed' : node.status })] }, node.nodeId))) }), run.error && _jsx("p", { className: "mt-2 text-[11px] text-red-600", children: run.error })] }))] }));
2052
+ return (
2053
+ /*
2054
+ * Floating over the right edge of the canvas rather than beside it in a
2055
+ * column, and NOT a modal sheet.
2056
+ *
2057
+ * The distinction matters for exactly one reason, which `ui/sheet.tsx` spells
2058
+ * out from the other direction: a panel that covers the canvas while a
2059
+ * keyboard user tabs into what is behind it leaks focus onto controls they
2060
+ * cannot see. That argument is about a panel that HIDES things. This one
2061
+ * hides nothing — it is always open when it is rendered, everything in it is
2062
+ * operable, and Tab flowing between it and the canvas is the correct order
2063
+ * rather than a leak. So no focus trap, and deliberately no Escape handler
2064
+ * either: Escape on this screen already means "put the half-drawn wire away"
2065
+ * (see `workflow/wiring.tsx`), and a second meaning would take that key away
2066
+ * from the gesture that needs it most.
2067
+ *
2068
+ * `dismissible` is the whole reason it may float: an always-on 19rem panel is
2069
+ * 19rem of canvas somebody never agreed to spend.
2070
+ */
2071
+ _jsxs(motion.aside, { initial: reducedMotion ? false : { opacity: 0, x: 24 }, animate: { opacity: 1, x: 0 }, exit: reducedMotion ? { opacity: 0 } : { opacity: 0, x: 24 }, transition: reducedMotion ? { duration: 0 } : { type: 'spring', stiffness: 420, damping: 34 }, className: cn('pointer-events-auto flex max-h-full w-[min(19rem,calc(100vw-2rem))] flex-col', 'overflow-y-auto p-3', FLOATING), "aria-label": `${WORKFLOW_NAME.title} wiring and problems`, children: [_jsxs("div", { className: "mb-2 flex shrink-0 items-center gap-2", children: [_jsx("p", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Details" }), _jsx(Tooltip, { content: "Put this panel away and give the canvas the room.", children: _jsx(Button, { variant: "ghost", size: "icon", onClick: onClose, "aria-label": "Hide the details panel", className: "ml-auto h-5 w-5", children: _jsx(X, { size: 11 }) }) })] }), _jsxs("div", { className: "flex flex-col gap-3", children: [_jsx(PendingWork, { pending: pending, label: label, onInspect: onInspect }), _jsxs("section", { className: cn('rounded-lg border p-3', RULE, SUBPANEL), children: [_jsx("h2", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Problems" }), problems.length === 0 ? (_jsx("p", { className: cn('mt-2 text-[11px]', MUTED), children: "Nothing to flag here. The server checks it again on save." })) : (_jsx("ul", { className: "mt-2 space-y-2", children: [...errors, ...warnings].map((problem) => (_jsxs("li", { className: "flex gap-1.5 text-[11px] leading-relaxed", children: [problem.level === 'error' ? (_jsx(CircleAlert, { size: 11, className: "mt-0.5 shrink-0 text-red-500" })) : (_jsx(TriangleAlert, { size: 11, className: "mt-0.5 shrink-0 text-amber-500" })), _jsxs("span", { children: [problem.message, problem.nodeIds.length > 0 && (_jsx("span", { className: "ml-1", children: problem.nodeIds.map((nodeId) => (_jsx("button", { type: "button", onClick: () => onInspect(nodeId), className: cn('mr-1 rounded border px-1 font-mono text-[9px]', RULE, MUTED), children: label(nodeId) }, nodeId))) }))] })] }, `${problem.code}:${problem.nodeIds.join(',')}`))) }))] }), run && (_jsxs("section", { className: cn('rounded-lg border p-3', RULE, SUBPANEL), children: [_jsx("h2", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Last run" }), _jsxs("p", { className: "mt-1 text-[11px]", children: [run.status, _jsx("span", { className: cn('ml-1 font-mono text-[10px]', MUTED), children: run.durable ? 'checkpointed per node' : 'ran inline, no checkpoints' })] }), sinks.length > 0 && (_jsxs("div", { className: "mt-2", children: [_jsx("h3", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Committed" }), _jsx("ul", { className: "mt-1 space-y-1", children: sinks.map((sink) => {
2072
+ const outcome = run.nodes.find((node) => node.nodeId === sink.id);
2073
+ const type = sink.kind === 'sink' && sink.targetType ? sink.targetType : 'no type';
2074
+ return (_jsxs("li", { className: "flex items-center gap-1.5 text-[11px]", children: [_jsx("span", { className: "truncate font-mono text-[10px]", children: type }), _jsx("span", { className: cn('ml-auto shrink-0 font-mono text-[10px]', outcome?.status === 'failed'
2075
+ ? 'text-red-500'
2076
+ : outcome?.status === 'succeeded'
2077
+ ? 'text-emerald-600 dark:text-emerald-400'
2078
+ : MUTED), children: outcome
2079
+ ? outcome.status === 'succeeded' && typeof outcome.rows === 'number'
2080
+ ? `${outcome.rows} rows`
2081
+ : outcome.status
2082
+ : 'no outcome recorded' })] }, sink.id));
2083
+ }) }), _jsx("p", { className: cn('mt-1 text-[10px] leading-relaxed', MUTED), children: "Each sink commits on its own. One committing and another failing is a failed run that nevertheless wrote something, not a partial success that will be rolled back." })] })), _jsx("ul", { className: "mt-2 space-y-1", children: run.nodes.map((node) => (_jsxs("li", { className: "flex items-center gap-1.5 font-mono text-[10px]", children: [_jsx("span", { className: "truncate", children: label(node.nodeId) }), _jsx("span", { className: cn('ml-auto shrink-0', node.status === 'failed' ? 'text-red-500' : MUTED), children: node.replayed ? 'replayed' : node.status })] }, node.nodeId))) }), run.error && _jsx("p", { className: "mt-2 text-[11px] text-red-600", children: run.error })] })), _jsxs("section", { className: cn('rounded-lg border p-3', RULE, SUBPANEL), children: [_jsx("h2", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Wiring" }), draft.edges.length === 0 ? (_jsx("p", { className: cn('mt-2 text-[11px]', MUTED), children: "Nothing is wired together yet." })) : (_jsx("ul", { className: "mt-2 space-y-1", children: draft.edges.map((edge) => (_jsxs("li", { className: "flex items-center gap-1.5 text-[11px]", children: [_jsx("button", { type: "button", onClick: () => onInspect(edge.from), className: "truncate hover:underline", children: label(edge.from) }), _jsx(ArrowRight, { size: 10, className: cn('shrink-0', MUTED) }), _jsx("button", { type: "button", onClick: () => onInspect(edge.to), className: "truncate hover:underline", children: label(edge.to) }), canEdit && (_jsx(Tooltip, { content: "Remove this connection.", children: _jsx("button", { type: "button", onClick: () => onDisconnect(edge), "aria-label": `Disconnect ${label(edge.from)} from ${label(edge.to)}`, className: "ml-auto shrink-0 rounded p-0.5 text-zinc-400 hover:text-red-600", children: _jsx(Unplug, { size: 11 }) }) }))] }, edgeId(edge)))) }))] }), children] })] }));
1640
2084
  }
1641
2085
  /**
1642
2086
  * What is left to do on the nodes nobody has finished.
@@ -1656,7 +2100,7 @@ function PendingWork({ pending, label, onInspect, }) {
1656
2100
  const byNode = useMemo(() => problemsByNode(pending), [pending]);
1657
2101
  if (byNode.size === 0)
1658
2102
  return null;
1659
- return (_jsxs("section", { className: cn('rounded-lg border p-3', RULE, PANEL), children: [_jsx("h2", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Still to do" }), _jsx("ul", { className: "mt-2 space-y-1.5", children: [...byNode.entries()].map(([nodeId, items]) => (_jsxs("li", { className: "flex gap-1.5 text-[11px] leading-relaxed", children: [_jsx(CircleDashed, { size: 11, className: cn('mt-0.5 shrink-0', MUTED) }), _jsxs("span", { children: [_jsx("button", { type: "button", onClick: () => onInspect(nodeId), className: "font-medium hover:underline", children: label(nodeId) }), _jsxs("span", { className: MUTED, children: [' — ', items.map((problem) => todoFor(problem)).join('; '), "."] })] })] }, nodeId))) }), _jsx("p", { className: cn('mt-2 text-[10px] leading-relaxed', MUTED), children: "These are not problems yet \u2014 a node that was just added is unwired and unconfigured by construction. They are checked in full the moment you save." })] }));
2103
+ return (_jsxs("section", { className: cn('rounded-lg border p-3', RULE, SUBPANEL), children: [_jsx("h2", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Still to do" }), _jsx("ul", { className: "mt-2 space-y-1.5", children: [...byNode.entries()].map(([nodeId, items]) => (_jsxs("li", { className: "flex gap-1.5 text-[11px] leading-relaxed", children: [_jsx(CircleDashed, { size: 11, className: cn('mt-0.5 shrink-0', MUTED) }), _jsxs("span", { children: [_jsx("button", { type: "button", onClick: () => onInspect(nodeId), className: "font-medium hover:underline", children: label(nodeId) }), _jsxs("span", { className: MUTED, children: [' — ', items.map((problem) => todoFor(problem)).join('; '), "."] })] })] }, nodeId))) }), _jsx("p", { className: cn('mt-2 text-[10px] leading-relaxed', MUTED), children: "These are not problems yet \u2014 a node that was just added is unwired and unconfigured by construction. They are checked in full the moment you save." })] }));
1660
2104
  }
1661
2105
  /**
1662
2106
  * One end of a node's wiring — everything feeding it, or everything it feeds.