@burdenoff/microfe-subscriberbot 2026.1107.1 → 2026.1107.2
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WorkflowBuilderPage.d.ts","sourceRoot":"","sources":["../../../../src/subscriberbot/pages/workflows/WorkflowBuilderPage.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAmBH,OAAO,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"WorkflowBuilderPage.d.ts","sourceRoot":"","sources":["../../../../src/subscriberbot/pages/workflows/WorkflowBuilderPage.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAmBH,OAAO,8BAA8B,CAAC;AAs1BtC,wBAAgB,mBAAmB,gCAiDlC"}
|
|
@@ -12,10 +12,10 @@ import { AlertTriangle as x, ArrowLeft as S, CheckCircle2 as C, Clock as w, GitB
|
|
|
12
12
|
import { useParams as j } from "react-router";
|
|
13
13
|
import { Fragment as M, jsx as N, jsxs as P } from "react/jsx-runtime";
|
|
14
14
|
import { GlassCard as F } from "@burdenoff/fe-libs/ui";
|
|
15
|
-
import { Background as I, Controls as L, Handle as R, MarkerType as oe, Position as z, ReactFlow as se, applyNodeChanges as
|
|
15
|
+
import { Background as I, Controls as L, Handle as R, MarkerType as oe, Position as z, ReactFlow as se, applyNodeChanges as ce } from "@xyflow/react";
|
|
16
16
|
import "@xyflow/react/dist/style.css";
|
|
17
17
|
//#region src/subscriberbot/pages/workflows/WorkflowBuilderPage.tsx
|
|
18
|
-
var
|
|
18
|
+
var B = "w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] disabled:opacity-60", V = "mb-1 block text-xs font-medium text-text-secondary", H = "inline-flex items-center gap-1.5 rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-50", U = "inline-flex items-center gap-1.5 rounded-lg bg-action-primary-bg px-3 py-2 text-sm font-medium text-action-primary-text hover:opacity-90 disabled:opacity-50", W = {
|
|
19
19
|
TRIGGER: {
|
|
20
20
|
icon: A,
|
|
21
21
|
bar: "bg-[var(--color-accent-indigo)]",
|
|
@@ -51,7 +51,7 @@ var V = "w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2 t
|
|
|
51
51
|
fallback: "Branch",
|
|
52
52
|
hint: "Run two or more paths in parallel"
|
|
53
53
|
}
|
|
54
|
-
},
|
|
54
|
+
}, G = {
|
|
55
55
|
NOTIFY: "Notify",
|
|
56
56
|
ALERT: "Raise an alert",
|
|
57
57
|
CREATE_TASK: "Create a task",
|
|
@@ -59,13 +59,21 @@ var V = "w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2 t
|
|
|
59
59
|
CLASSIFY: "Classify with AI",
|
|
60
60
|
EVALUATE_POLICIES: "Evaluate agent policies",
|
|
61
61
|
CALL_ADAPTER: "Call the provider adapter"
|
|
62
|
-
},
|
|
62
|
+
}, le = [
|
|
63
|
+
"overflow-hidden rounded-lg border border-border-subtle",
|
|
64
|
+
"[--xy-controls-box-shadow:none]",
|
|
65
|
+
"[--xy-controls-button-background-color:var(--color-bg-elevated)]",
|
|
66
|
+
"[--xy-controls-button-background-color-hover:var(--color-bg-surface)]",
|
|
67
|
+
"[--xy-controls-button-border-color:var(--color-border-subtle)]",
|
|
68
|
+
"[--xy-controls-button-color:var(--color-text-secondary)]",
|
|
69
|
+
"[--xy-controls-button-color-hover:var(--color-text-primary)]"
|
|
70
|
+
].join(" "), K = {
|
|
63
71
|
background: "var(--color-text-secondary)",
|
|
64
72
|
width: 10,
|
|
65
73
|
height: 10
|
|
66
74
|
};
|
|
67
|
-
function
|
|
68
|
-
let r = t(), i =
|
|
75
|
+
function q({ data: e, selected: n }) {
|
|
76
|
+
let r = t(), i = W[e.kind], a = i.icon;
|
|
69
77
|
return /* @__PURE__ */ P("div", {
|
|
70
78
|
"data-testid": `workflow-node-${e.kind.toLowerCase()}`,
|
|
71
79
|
className: `w-52 overflow-hidden rounded-xl border bg-bg-surface shadow-sm ${n ? "border-[var(--color-focus-ring)] ring-2 ring-[var(--color-focus-ring)]" : e.hasIssue ? "border-status-warning-text" : "border-border-subtle"}`,
|
|
@@ -73,7 +81,7 @@ function J({ data: e, selected: n }) {
|
|
|
73
81
|
e.kind !== "TRIGGER" && /* @__PURE__ */ N(R, {
|
|
74
82
|
type: "target",
|
|
75
83
|
position: z.Left,
|
|
76
|
-
style:
|
|
84
|
+
style: K
|
|
77
85
|
}),
|
|
78
86
|
/* @__PURE__ */ N("div", {
|
|
79
87
|
className: `h-1 w-full ${i.bar}`,
|
|
@@ -116,7 +124,7 @@ function J({ data: e, selected: n }) {
|
|
|
116
124
|
type: "source",
|
|
117
125
|
position: z.Right,
|
|
118
126
|
style: {
|
|
119
|
-
...
|
|
127
|
+
...K,
|
|
120
128
|
top: "35%",
|
|
121
129
|
background: "var(--color-status-success-text)"
|
|
122
130
|
}
|
|
@@ -125,21 +133,21 @@ function J({ data: e, selected: n }) {
|
|
|
125
133
|
type: "source",
|
|
126
134
|
position: z.Right,
|
|
127
135
|
style: {
|
|
128
|
-
...
|
|
136
|
+
...K,
|
|
129
137
|
top: "70%",
|
|
130
138
|
background: "var(--color-status-error-text)"
|
|
131
139
|
}
|
|
132
140
|
})] }) : /* @__PURE__ */ N(R, {
|
|
133
141
|
type: "source",
|
|
134
142
|
position: z.Right,
|
|
135
|
-
style:
|
|
143
|
+
style: K
|
|
136
144
|
})
|
|
137
145
|
]
|
|
138
146
|
});
|
|
139
147
|
}
|
|
140
|
-
var
|
|
141
|
-
function
|
|
142
|
-
let a = t(), o =
|
|
148
|
+
var ue = { workflow: q };
|
|
149
|
+
function de({ node: e, readOnly: n, onChange: r, onDelete: i }) {
|
|
150
|
+
let a = t(), o = W[e.kind], s = (t) => r({ config: {
|
|
143
151
|
...e.config,
|
|
144
152
|
...t
|
|
145
153
|
} });
|
|
@@ -153,11 +161,11 @@ function le({ node: e, readOnly: n, onChange: r, onDelete: i }) {
|
|
|
153
161
|
}),
|
|
154
162
|
/* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("label", {
|
|
155
163
|
htmlFor: "wfb-label",
|
|
156
|
-
className:
|
|
164
|
+
className: V,
|
|
157
165
|
children: a("workflows.builder.inspector.label", "Label")
|
|
158
166
|
}), /* @__PURE__ */ N("input", {
|
|
159
167
|
id: "wfb-label",
|
|
160
|
-
className:
|
|
168
|
+
className: B,
|
|
161
169
|
value: e.label,
|
|
162
170
|
maxLength: 120,
|
|
163
171
|
disabled: n,
|
|
@@ -165,11 +173,11 @@ function le({ node: e, readOnly: n, onChange: r, onDelete: i }) {
|
|
|
165
173
|
})] }),
|
|
166
174
|
e.kind === "TRIGGER" && /* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("label", {
|
|
167
175
|
htmlFor: "wfb-event",
|
|
168
|
-
className:
|
|
176
|
+
className: V,
|
|
169
177
|
children: a("workflows.builder.inspector.event", "Trigger event")
|
|
170
178
|
}), /* @__PURE__ */ N("input", {
|
|
171
179
|
id: "wfb-event",
|
|
172
|
-
className:
|
|
180
|
+
className: B,
|
|
173
181
|
value: typeof e.config.event == "string" ? e.config.event : "",
|
|
174
182
|
maxLength: 120,
|
|
175
183
|
placeholder: a("workflows.form.triggerPlaceholder", "e.g. InvoiceReceived, RenewalDetected"),
|
|
@@ -178,11 +186,11 @@ function le({ node: e, readOnly: n, onChange: r, onDelete: i }) {
|
|
|
178
186
|
})] }),
|
|
179
187
|
e.kind === "ACTION" && /* @__PURE__ */ P(M, { children: [/* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("label", {
|
|
180
188
|
htmlFor: "wfb-action",
|
|
181
|
-
className:
|
|
189
|
+
className: V,
|
|
182
190
|
children: a("workflows.builder.inspector.action", "Action")
|
|
183
191
|
}), /* @__PURE__ */ P("select", {
|
|
184
192
|
id: "wfb-action",
|
|
185
|
-
className:
|
|
193
|
+
className: B,
|
|
186
194
|
value: typeof e.config.action == "string" ? e.config.action : "",
|
|
187
195
|
disabled: n,
|
|
188
196
|
onChange: (e) => s({ action: e.target.value || void 0 }),
|
|
@@ -191,16 +199,16 @@ function le({ node: e, readOnly: n, onChange: r, onDelete: i }) {
|
|
|
191
199
|
children: a("workflows.builder.inspector.chooseAction", "Choose an action…")
|
|
192
200
|
}), d.map((e) => /* @__PURE__ */ N("option", {
|
|
193
201
|
value: e,
|
|
194
|
-
children: a(`workflows.builder.action.${e.toLowerCase()}`,
|
|
202
|
+
children: a(`workflows.builder.action.${e.toLowerCase()}`, G[e])
|
|
195
203
|
}, e))]
|
|
196
204
|
})] }), /* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("label", {
|
|
197
205
|
htmlFor: "wfb-message",
|
|
198
|
-
className:
|
|
206
|
+
className: V,
|
|
199
207
|
children: a("workflows.builder.inspector.message", "Message (optional)")
|
|
200
208
|
}), /* @__PURE__ */ N("textarea", {
|
|
201
209
|
id: "wfb-message",
|
|
202
210
|
rows: 3,
|
|
203
|
-
className:
|
|
211
|
+
className: B,
|
|
204
212
|
maxLength: 1e3,
|
|
205
213
|
value: typeof e.config.message == "string" ? e.config.message : "",
|
|
206
214
|
disabled: n,
|
|
@@ -209,12 +217,12 @@ function le({ node: e, readOnly: n, onChange: r, onDelete: i }) {
|
|
|
209
217
|
e.kind === "CONDITION" && /* @__PURE__ */ P("div", { children: [
|
|
210
218
|
/* @__PURE__ */ N("label", {
|
|
211
219
|
htmlFor: "wfb-expression",
|
|
212
|
-
className:
|
|
220
|
+
className: V,
|
|
213
221
|
children: a("workflows.builder.inspector.expression", "Condition")
|
|
214
222
|
}),
|
|
215
223
|
/* @__PURE__ */ N("input", {
|
|
216
224
|
id: "wfb-expression",
|
|
217
|
-
className:
|
|
225
|
+
className: B,
|
|
218
226
|
maxLength: 500,
|
|
219
227
|
placeholder: a("workflows.builder.inspector.expressionPlaceholder", "e.g. monthlySpend > 100"),
|
|
220
228
|
value: typeof e.config.expression == "string" ? e.config.expression : "",
|
|
@@ -228,7 +236,7 @@ function le({ node: e, readOnly: n, onChange: r, onDelete: i }) {
|
|
|
228
236
|
] }),
|
|
229
237
|
e.kind === "DELAY" && /* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("label", {
|
|
230
238
|
htmlFor: "wfb-delay",
|
|
231
|
-
className:
|
|
239
|
+
className: V,
|
|
232
240
|
children: a("workflows.builder.inspector.delay", "Wait (minutes)")
|
|
233
241
|
}), /* @__PURE__ */ N("input", {
|
|
234
242
|
id: "wfb-delay",
|
|
@@ -236,7 +244,7 @@ function le({ node: e, readOnly: n, onChange: r, onDelete: i }) {
|
|
|
236
244
|
min: 1,
|
|
237
245
|
max: 525600,
|
|
238
246
|
step: 1,
|
|
239
|
-
className:
|
|
247
|
+
className: B,
|
|
240
248
|
value: typeof e.config.durationMinutes == "number" ? e.config.durationMinutes : "",
|
|
241
249
|
disabled: n,
|
|
242
250
|
onChange: (e) => {
|
|
@@ -261,10 +269,10 @@ function le({ node: e, readOnly: n, onChange: r, onDelete: i }) {
|
|
|
261
269
|
]
|
|
262
270
|
});
|
|
263
271
|
}
|
|
264
|
-
function
|
|
265
|
-
let n = t(), a = l(), o = s(), u = c(), [d, S] = b(() => h(e.graph)), [w, T] = b(e.graph.issues), [E, O] = b(!1), [j, R] = b(null), [z,
|
|
266
|
-
|
|
267
|
-
let
|
|
272
|
+
function J({ workflow: e }) {
|
|
273
|
+
let n = t(), a = l(), o = s(), u = c(), [d, S] = b(() => h(e.graph)), [w, T] = b(e.graph.issues), [E, O] = b(!1), [j, R] = b(null), [z, B] = b(null), [V, G] = b(null), [K, q] = b(1), J = e.status === "ACTIVE", Y = J || a.isPending, [fe, pe] = b(e.graph);
|
|
274
|
+
fe !== e.graph && (pe(e.graph), E || (S(h(e.graph)), T(e.graph.issues)));
|
|
275
|
+
let X = y(() => new Set(w.map((e) => e.nodeId).filter((e) => !!e)), [w]), me = y(() => d.nodes.map((e) => ({
|
|
268
276
|
id: e.id,
|
|
269
277
|
type: "workflow",
|
|
270
278
|
position: {
|
|
@@ -276,15 +284,15 @@ function Y({ workflow: e }) {
|
|
|
276
284
|
kind: e.kind,
|
|
277
285
|
label: e.label || n(`workflowBuilder.nodeLabel.${e.kind.toLowerCase()}`, m(e.kind)),
|
|
278
286
|
summary: ee(e, n),
|
|
279
|
-
hasIssue: !E &&
|
|
287
|
+
hasIssue: !E && X.has(e.id)
|
|
280
288
|
}
|
|
281
289
|
})), [
|
|
282
290
|
d.nodes,
|
|
283
291
|
j,
|
|
284
292
|
E,
|
|
285
|
-
|
|
293
|
+
X,
|
|
286
294
|
n
|
|
287
|
-
]),
|
|
295
|
+
]), Z = y(() => d.edges.map((e) => ({
|
|
288
296
|
id: e.id,
|
|
289
297
|
source: e.source,
|
|
290
298
|
target: e.target,
|
|
@@ -304,11 +312,11 @@ function Y({ workflow: e }) {
|
|
|
304
312
|
z,
|
|
305
313
|
n
|
|
306
314
|
]), Q = v((e) => {
|
|
307
|
-
S((t) => e(t)), O(!0),
|
|
308
|
-
}, []),
|
|
315
|
+
S((t) => e(t)), O(!0), G(null);
|
|
316
|
+
}, []), he = v((e) => {
|
|
309
317
|
let t = e.filter((e) => e.type === "position" && e.position), n = e.filter((e) => e.type === "remove");
|
|
310
|
-
|
|
311
|
-
let r =
|
|
318
|
+
Y || t.length === 0 && n.length === 0 || Q((e) => {
|
|
319
|
+
let r = ce(t, e.nodes.map((e) => ({
|
|
312
320
|
id: e.id,
|
|
313
321
|
position: {
|
|
314
322
|
x: e.x,
|
|
@@ -329,17 +337,17 @@ function Y({ workflow: e }) {
|
|
|
329
337
|
for (let e of n) e.type === "remove" && (i = _(i, e.id));
|
|
330
338
|
return i;
|
|
331
339
|
});
|
|
332
|
-
}, [Q,
|
|
340
|
+
}, [Q, Y]), ge = v((e) => {
|
|
333
341
|
let t = new Set(e.filter((e) => e.type === "remove").map((e) => e.id));
|
|
334
|
-
|
|
342
|
+
Y || t.size === 0 || Q((e) => ({
|
|
335
343
|
nodes: e.nodes,
|
|
336
344
|
edges: e.edges.filter((e) => !t.has(e.id))
|
|
337
345
|
}));
|
|
338
|
-
}, [Q,
|
|
339
|
-
if (
|
|
346
|
+
}, [Q, Y]), _e = v((e) => {
|
|
347
|
+
if (Y) return;
|
|
340
348
|
let t = e.sourceHandle ?? null, r = te(d, e.source, e.target, t, n);
|
|
341
349
|
if (r) {
|
|
342
|
-
|
|
350
|
+
G({
|
|
343
351
|
tone: "error",
|
|
344
352
|
text: r
|
|
345
353
|
});
|
|
@@ -358,11 +366,11 @@ function Y({ workflow: e }) {
|
|
|
358
366
|
}, [
|
|
359
367
|
Q,
|
|
360
368
|
d,
|
|
361
|
-
|
|
369
|
+
Y,
|
|
362
370
|
n
|
|
363
|
-
]),
|
|
364
|
-
let t = `new-${
|
|
365
|
-
|
|
371
|
+
]), ve = (e) => {
|
|
372
|
+
let t = `new-${K}`;
|
|
373
|
+
q((e) => e + 1);
|
|
366
374
|
let r = ne(d.nodes);
|
|
367
375
|
Q((i) => ({
|
|
368
376
|
nodes: [...i.nodes, {
|
|
@@ -374,42 +382,42 @@ function Y({ workflow: e }) {
|
|
|
374
382
|
y: r.y
|
|
375
383
|
}],
|
|
376
384
|
edges: i.edges
|
|
377
|
-
})), R(t),
|
|
378
|
-
}, $ = d.nodes.find((e) => e.id === j) ?? null,
|
|
385
|
+
})), R(t), B(null);
|
|
386
|
+
}, $ = d.nodes.find((e) => e.id === j) ?? null, ye = () => {
|
|
379
387
|
a.mutate({
|
|
380
388
|
workflowId: e.id,
|
|
381
389
|
input: re(d)
|
|
382
390
|
}, {
|
|
383
391
|
onSuccess: (e) => {
|
|
384
|
-
S(h(e)), T(e.issues), O(!1), R(null),
|
|
392
|
+
S(h(e)), T(e.issues), O(!1), R(null), B(null), G({
|
|
385
393
|
tone: "success",
|
|
386
394
|
text: e.valid ? n("workflows.builder.savedValid", "Saved. This workflow is ready to activate.") : n("workflows.builder.savedWithIssues", "Saved as a draft. Fix the issues below before activating.")
|
|
387
395
|
});
|
|
388
396
|
},
|
|
389
|
-
onError: (e) =>
|
|
397
|
+
onError: (e) => G({
|
|
390
398
|
tone: "error",
|
|
391
399
|
text: e instanceof Error ? e.message : n("common.error", "An error occurred")
|
|
392
400
|
})
|
|
393
401
|
});
|
|
394
|
-
},
|
|
395
|
-
onSuccess: () =>
|
|
402
|
+
}, be = () => o.mutate(e.id, {
|
|
403
|
+
onSuccess: () => G({
|
|
396
404
|
tone: "success",
|
|
397
405
|
text: n("workflows.builder.activated", "Workflow activated.")
|
|
398
406
|
}),
|
|
399
|
-
onError: (e) =>
|
|
407
|
+
onError: (e) => G({
|
|
400
408
|
tone: "error",
|
|
401
409
|
text: e instanceof Error ? e.message : n("common.error", "An error occurred")
|
|
402
410
|
})
|
|
403
|
-
}),
|
|
404
|
-
onSuccess: () =>
|
|
411
|
+
}), xe = () => u.mutate(e.id, {
|
|
412
|
+
onSuccess: () => G({
|
|
405
413
|
tone: "success",
|
|
406
414
|
text: n("workflows.builder.paused", "Workflow paused. You can edit it now.")
|
|
407
415
|
}),
|
|
408
|
-
onError: (e) =>
|
|
416
|
+
onError: (e) => G({
|
|
409
417
|
tone: "error",
|
|
410
418
|
text: e instanceof Error ? e.message : n("common.error", "An error occurred")
|
|
411
419
|
})
|
|
412
|
-
}),
|
|
420
|
+
}), Se = !J && !E && w.length === 0 && d.nodes.length > 0;
|
|
413
421
|
return /* @__PURE__ */ P(M, { children: [
|
|
414
422
|
/* @__PURE__ */ P("div", {
|
|
415
423
|
className: "flex flex-wrap items-center justify-between gap-3",
|
|
@@ -432,10 +440,10 @@ function Y({ workflow: e }) {
|
|
|
432
440
|
]
|
|
433
441
|
}), /* @__PURE__ */ N("div", {
|
|
434
442
|
className: "flex flex-wrap items-center gap-2",
|
|
435
|
-
children:
|
|
443
|
+
children: J ? /* @__PURE__ */ P("button", {
|
|
436
444
|
type: "button",
|
|
437
|
-
className:
|
|
438
|
-
onClick:
|
|
445
|
+
className: H,
|
|
446
|
+
onClick: xe,
|
|
439
447
|
disabled: u.isPending,
|
|
440
448
|
children: [
|
|
441
449
|
/* @__PURE__ */ N(D, { className: "h-4 w-4" }),
|
|
@@ -444,8 +452,8 @@ function Y({ workflow: e }) {
|
|
|
444
452
|
]
|
|
445
453
|
}) : /* @__PURE__ */ P(M, { children: [/* @__PURE__ */ P("button", {
|
|
446
454
|
type: "button",
|
|
447
|
-
className:
|
|
448
|
-
onClick:
|
|
455
|
+
className: H,
|
|
456
|
+
onClick: ye,
|
|
449
457
|
disabled: !E || a.isPending,
|
|
450
458
|
children: [
|
|
451
459
|
/* @__PURE__ */ N(ae, { className: "h-4 w-4" }),
|
|
@@ -454,9 +462,9 @@ function Y({ workflow: e }) {
|
|
|
454
462
|
]
|
|
455
463
|
}), /* @__PURE__ */ P("button", {
|
|
456
464
|
type: "button",
|
|
457
|
-
className:
|
|
458
|
-
onClick:
|
|
459
|
-
disabled: !
|
|
465
|
+
className: U,
|
|
466
|
+
onClick: be,
|
|
467
|
+
disabled: !Se || o.isPending,
|
|
460
468
|
title: E ? n("workflows.builder.saveFirst", "Save your changes first") : w.length > 0 ? n("workflows.builder.fixIssuesFirst", "Fix the issues first") : void 0,
|
|
461
469
|
children: [
|
|
462
470
|
/* @__PURE__ */ N(ie, { className: "h-4 w-4" }),
|
|
@@ -466,12 +474,12 @@ function Y({ workflow: e }) {
|
|
|
466
474
|
})] })
|
|
467
475
|
})]
|
|
468
476
|
}),
|
|
469
|
-
|
|
470
|
-
role:
|
|
471
|
-
className: `mt-3 rounded-lg border px-4 py-2 text-sm ${
|
|
472
|
-
children:
|
|
477
|
+
V && /* @__PURE__ */ N("div", {
|
|
478
|
+
role: V.tone === "error" ? "alert" : "status",
|
|
479
|
+
className: `mt-3 rounded-lg border px-4 py-2 text-sm ${V.tone === "error" ? "border-status-error-text/30 bg-status-error-bg-subtle text-status-error-text" : "border-status-success-text/30 bg-status-success-bg-subtle text-status-success-text"}`,
|
|
480
|
+
children: V.text
|
|
473
481
|
}),
|
|
474
|
-
|
|
482
|
+
J && /* @__PURE__ */ N("p", {
|
|
475
483
|
className: "mt-3 text-sm text-text-secondary",
|
|
476
484
|
children: n("workflows.builder.readOnlyActive", "This workflow is active, so it is shown read-only. Pause it to change its steps.")
|
|
477
485
|
}),
|
|
@@ -489,11 +497,11 @@ function Y({ workflow: e }) {
|
|
|
489
497
|
role: "group",
|
|
490
498
|
"aria-label": n("workflows.builder.palette", "Add a step"),
|
|
491
499
|
children: f.map((e) => {
|
|
492
|
-
let t =
|
|
500
|
+
let t = W[e], r = t.icon;
|
|
493
501
|
return /* @__PURE__ */ P("button", {
|
|
494
502
|
type: "button",
|
|
495
|
-
disabled:
|
|
496
|
-
onClick: () =>
|
|
503
|
+
disabled: Y || !p(e, d.nodes),
|
|
504
|
+
onClick: () => ve(e),
|
|
497
505
|
title: n(`${t.labelKey}Hint`, t.hint),
|
|
498
506
|
className: "flex items-center gap-2 rounded-lg border border-border-subtle bg-bg-surface px-2.5 py-2 text-start text-sm text-text-primary hover:bg-bg-sunken disabled:cursor-not-allowed disabled:opacity-50",
|
|
499
507
|
children: [/* @__PURE__ */ N(r, { className: "h-4 w-4 shrink-0 text-text-secondary" }), /* @__PURE__ */ N("span", {
|
|
@@ -515,24 +523,24 @@ function Y({ workflow: e }) {
|
|
|
515
523
|
description: n("workflows.builder.emptyDescription", "Add a trigger from the palette, then connect the steps that should follow it.")
|
|
516
524
|
})
|
|
517
525
|
}) : /* @__PURE__ */ P(se, {
|
|
518
|
-
nodes:
|
|
519
|
-
edges:
|
|
520
|
-
nodeTypes:
|
|
521
|
-
onNodesChange:
|
|
522
|
-
onEdgesChange:
|
|
523
|
-
onConnect:
|
|
526
|
+
nodes: me,
|
|
527
|
+
edges: Z,
|
|
528
|
+
nodeTypes: ue,
|
|
529
|
+
onNodesChange: he,
|
|
530
|
+
onEdgesChange: ge,
|
|
531
|
+
onConnect: _e,
|
|
524
532
|
onNodeClick: (e, t) => {
|
|
525
|
-
R(t.id),
|
|
533
|
+
R(t.id), B(null);
|
|
526
534
|
},
|
|
527
535
|
onEdgeClick: (e, t) => {
|
|
528
|
-
|
|
536
|
+
B(t.id), R(null);
|
|
529
537
|
},
|
|
530
538
|
onPaneClick: () => {
|
|
531
|
-
R(null),
|
|
539
|
+
R(null), B(null);
|
|
532
540
|
},
|
|
533
|
-
nodesDraggable: !
|
|
534
|
-
nodesConnectable: !
|
|
535
|
-
deleteKeyCode:
|
|
541
|
+
nodesDraggable: !Y,
|
|
542
|
+
nodesConnectable: !Y,
|
|
543
|
+
deleteKeyCode: Y ? null : ["Backspace", "Delete"],
|
|
536
544
|
fitView: !0,
|
|
537
545
|
fitViewOptions: {
|
|
538
546
|
padding: .2,
|
|
@@ -542,7 +550,10 @@ function Y({ workflow: e }) {
|
|
|
542
550
|
children: [/* @__PURE__ */ N(I, {
|
|
543
551
|
color: "var(--color-border-subtle)",
|
|
544
552
|
gap: 20
|
|
545
|
-
}), /* @__PURE__ */ N(L, {
|
|
553
|
+
}), /* @__PURE__ */ N(L, {
|
|
554
|
+
showInteractive: !1,
|
|
555
|
+
className: le
|
|
556
|
+
})]
|
|
546
557
|
})
|
|
547
558
|
}),
|
|
548
559
|
/* @__PURE__ */ P("div", {
|
|
@@ -550,9 +561,9 @@ function Y({ workflow: e }) {
|
|
|
550
561
|
children: [/* @__PURE__ */ N(F, {
|
|
551
562
|
treatment: "metric",
|
|
552
563
|
className: "p-4",
|
|
553
|
-
children: $ ? /* @__PURE__ */ N(
|
|
564
|
+
children: $ ? /* @__PURE__ */ N(de, {
|
|
554
565
|
node: $,
|
|
555
|
-
readOnly:
|
|
566
|
+
readOnly: Y,
|
|
556
567
|
onChange: (e) => Q((t) => ({
|
|
557
568
|
nodes: t.nodes.map((t) => t.id === $.id ? {
|
|
558
569
|
...t,
|
|
@@ -563,7 +574,7 @@ function Y({ workflow: e }) {
|
|
|
563
574
|
onDelete: () => {
|
|
564
575
|
Q((e) => _(e, $.id)), R(null);
|
|
565
576
|
}
|
|
566
|
-
}) : z && !
|
|
577
|
+
}) : z && !Y ? /* @__PURE__ */ P("div", {
|
|
567
578
|
className: "space-y-3",
|
|
568
579
|
children: [/* @__PURE__ */ N("p", {
|
|
569
580
|
className: "text-sm text-text-primary",
|
|
@@ -574,7 +585,7 @@ function Y({ workflow: e }) {
|
|
|
574
585
|
Q((e) => ({
|
|
575
586
|
nodes: e.nodes,
|
|
576
587
|
edges: e.edges.filter((e) => e.id !== z)
|
|
577
|
-
})),
|
|
588
|
+
})), B(null);
|
|
578
589
|
},
|
|
579
590
|
className: "inline-flex items-center gap-1.5 rounded-lg border border-status-error-text/40 px-3 py-1.5 text-xs font-medium text-status-error-text hover:bg-status-error-bg-subtle",
|
|
580
591
|
children: [
|
|
@@ -620,14 +631,14 @@ function Y({ workflow: e }) {
|
|
|
620
631
|
})
|
|
621
632
|
] });
|
|
622
633
|
}
|
|
623
|
-
function
|
|
634
|
+
function Y() {
|
|
624
635
|
let { id: r } = j(), s = t(), { navigateTo: c } = e(), { data: l, isLoading: d, isError: f, refetch: p } = u(r);
|
|
625
636
|
return /* @__PURE__ */ N(n, {
|
|
626
637
|
title: l?.name ?? s("workflows.builder.title", "Workflow builder"),
|
|
627
638
|
description: l ? s("workflows.builder.subtitle", "Visual builder · starts on {{trigger}}", { trigger: l.triggerEvent || "—" }) : void 0,
|
|
628
639
|
actions: /* @__PURE__ */ P("button", {
|
|
629
640
|
type: "button",
|
|
630
|
-
className:
|
|
641
|
+
className: H,
|
|
631
642
|
onClick: () => c(r ? `/workflows/${r}` : "/workflows"),
|
|
632
643
|
children: [
|
|
633
644
|
/* @__PURE__ */ N(S, { className: "rtl:rotate-180 h-4 w-4" }),
|
|
@@ -638,13 +649,13 @@ function X() {
|
|
|
638
649
|
children: d ? /* @__PURE__ */ N(o, { label: s("workflows.builder.loading", "Loading workflow…") }) : f ? /* @__PURE__ */ N(a, {
|
|
639
650
|
message: s("workflows.builder.error", "Could not load this workflow."),
|
|
640
651
|
onRetry: () => void p()
|
|
641
|
-
}) : l ? /* @__PURE__ */ N(
|
|
652
|
+
}) : l ? /* @__PURE__ */ N(J, { workflow: l }, l.id) : /* @__PURE__ */ N(i, {
|
|
642
653
|
title: s("workflows.builder.notFound", "Workflow not found"),
|
|
643
654
|
description: s("workflows.builder.notFoundDescription", "It may have been deleted, or it belongs to another workspace.")
|
|
644
655
|
})
|
|
645
656
|
});
|
|
646
657
|
}
|
|
647
658
|
//#endregion
|
|
648
|
-
export {
|
|
659
|
+
export { Y as WorkflowBuilderPage };
|
|
649
660
|
|
|
650
661
|
//# sourceMappingURL=WorkflowBuilderPage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WorkflowBuilderPage.js","names":[],"sources":["../../../../src/subscriberbot/pages/workflows/WorkflowBuilderPage.tsx"],"sourcesContent":["/**\n * Workflow builder (BOFF-4006)\n * @module subscriberbot/pages/workflows\n *\n * `/workflows/:id/builder` — the visual, node-based editor for one workflow.\n * A palette adds trigger / action / condition / delay / branch nodes, the\n * canvas connects and arranges them, and the inspector edits the selected\n * node's configuration. Edits stay local until Save, which replaces the\n * graph in one `subSaveWorkflowGraph` call; the svc re-validates it and\n * returns the issues that would stop the workflow from running. Activation\n * is refused while any issue remains.\n *\n * An ACTIVE workflow is shown read-only: the svc keeps active workflows valid\n * at all times, so the user pauses it to restructure it.\n */\n\nimport { type FC, useCallback, useMemo, useState } from 'react';\nimport { useParams } from 'react-router';\nimport {\n ReactFlow,\n Background,\n Controls,\n Handle,\n MarkerType,\n Position,\n applyNodeChanges,\n type Connection,\n type Edge,\n type EdgeChange,\n type Node,\n type NodeChange,\n type NodeProps,\n} from '@xyflow/react';\nimport '@xyflow/react/dist/style.css';\nimport {\n AlertTriangle,\n ArrowLeft,\n CheckCircle2,\n Clock,\n GitBranch,\n GitFork,\n Pause,\n Play,\n Save,\n Trash2,\n Zap,\n Sparkles,\n} from 'lucide-react';\nimport { GlassCard } from '@burdenoff/fe-libs/ui';\nimport { PageLayout, StatusBadge, LoadingView, ErrorView, EmptyState } from '../../components';\nimport {\n useWorkflow,\n useSaveWorkflowGraph,\n useActivateWorkflow,\n usePauseWorkflow,\n} from '../../hooks/useSubscriberBotApi';\nimport { useTr } from '../../hooks/useTr';\nimport { useSubscriberBot } from '../../context/SubscriberBotContext';\nimport type {\n SubWorkflowActionKind,\n SubWorkflowGraphIssue,\n SubWorkflowNodeConfig,\n SubWorkflowNodeKind,\n SubWorkflowWithGraph,\n} from '../../types';\nimport {\n ACTION_KINDS,\n NODE_KINDS,\n type BuilderGraph,\n type BuilderNode,\n canAddKind,\n configSummary,\n connectionError,\n defaultLabel,\n fromServerGraph,\n initialConfig,\n nextNodePosition,\n removeNode,\n toSaveInput,\n} from './workflowBuilderGraph';\n\nconst inputCls =\n 'w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] disabled:opacity-60';\nconst labelCls = 'mb-1 block text-xs font-medium text-text-secondary';\nconst secondaryBtn =\n 'inline-flex items-center gap-1.5 rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-50';\nconst primaryBtn =\n 'inline-flex items-center gap-1.5 rounded-lg bg-action-primary-bg px-3 py-2 text-sm font-medium text-action-primary-text hover:opacity-90 disabled:opacity-50';\n\nconst KIND_META: Record<\n SubWorkflowNodeKind,\n {\n icon: FC<{ className?: string }>;\n bar: string;\n labelKey: string;\n fallback: string;\n hint: string;\n }\n> = {\n TRIGGER: {\n icon: Zap,\n bar: 'bg-[var(--color-accent-indigo)]',\n labelKey: 'workflows.builder.kind.trigger',\n fallback: 'Trigger',\n hint: 'The event that starts the workflow',\n },\n ACTION: {\n icon: Sparkles,\n bar: 'bg-status-success-text',\n labelKey: 'workflows.builder.kind.action',\n fallback: 'Action',\n hint: 'Notify, alert, create a task, update, classify or call an adapter',\n },\n CONDITION: {\n icon: GitFork,\n bar: 'bg-status-warning-text',\n labelKey: 'workflows.builder.kind.condition',\n fallback: 'Condition',\n hint: 'Route through a true or false outlet',\n },\n DELAY: {\n icon: Clock,\n bar: 'bg-text-secondary',\n labelKey: 'workflows.builder.kind.delay',\n fallback: 'Delay',\n hint: 'Wait before the next step',\n },\n BRANCH: {\n icon: GitBranch,\n bar: 'bg-[var(--color-accent-indigo)]',\n labelKey: 'workflows.builder.kind.branch',\n fallback: 'Branch',\n hint: 'Run two or more paths in parallel',\n },\n};\n\nconst ACTION_LABELS: Record<SubWorkflowActionKind, string> = {\n NOTIFY: 'Notify',\n ALERT: 'Raise an alert',\n CREATE_TASK: 'Create a task',\n UPDATE_RELATIONSHIP: 'Update the relationship',\n CLASSIFY: 'Classify with AI',\n EVALUATE_POLICIES: 'Evaluate agent policies',\n CALL_ADAPTER: 'Call the provider adapter',\n};\n\nconst handleStyle = { background: 'var(--color-text-secondary)', width: 10, height: 10 };\n\ntype CanvasNodeData = {\n kind: SubWorkflowNodeKind;\n label: string;\n summary: string;\n hasIssue: boolean;\n};\ntype CanvasNode = Node<CanvasNodeData, 'workflow'>;\n\n/** A node card on the canvas: accent bar by kind, icon, label and config summary. */\nfunction WorkflowNodeCard({ data, selected }: NodeProps<CanvasNode>) {\n const tr = useTr();\n const meta = KIND_META[data.kind];\n const Icon = meta.icon;\n return (\n <div\n data-testid={`workflow-node-${data.kind.toLowerCase()}`}\n className={`w-52 overflow-hidden rounded-xl border bg-bg-surface shadow-sm ${\n selected\n ? 'border-[var(--color-focus-ring)] ring-2 ring-[var(--color-focus-ring)]'\n : data.hasIssue\n ? 'border-status-warning-text'\n : 'border-border-subtle'\n }`}\n >\n {data.kind !== 'TRIGGER' && (\n <Handle type=\"target\" position={Position.Left} style={handleStyle} />\n )}\n <div className={`h-1 w-full ${meta.bar}`} aria-hidden />\n <div className=\"p-3\">\n <div className=\"flex items-center gap-2\">\n <span className=\"flex size-8 shrink-0 items-center justify-center rounded-lg bg-[var(--color-accent-soft)] text-text-primary\">\n <Icon className=\"h-4 w-4\" />\n </span>\n <p className=\"text-[10px] font-medium uppercase tracking-wide text-text-secondary\">\n {tr(meta.labelKey, meta.fallback)}\n </p>\n {data.hasIssue && (\n <AlertTriangle\n className=\"ms-auto h-3.5 w-3.5 text-status-warning-text\"\n aria-label={tr('workflows.builder.nodeHasIssue', 'Needs attention')}\n />\n )}\n </div>\n <p className=\"mt-2 truncate text-sm font-semibold text-text-primary\" title={data.label}>\n {data.label}\n </p>\n <p className=\"mt-0.5 truncate text-xs text-text-secondary\" title={data.summary}>\n {data.summary}\n </p>\n </div>\n {data.kind === 'CONDITION' ? (\n <>\n <Handle\n id=\"true\"\n type=\"source\"\n position={Position.Right}\n style={{ ...handleStyle, top: '35%', background: 'var(--color-status-success-text)' }}\n />\n <Handle\n id=\"false\"\n type=\"source\"\n position={Position.Right}\n style={{ ...handleStyle, top: '70%', background: 'var(--color-status-error-text)' }}\n />\n </>\n ) : (\n <Handle type=\"source\" position={Position.Right} style={handleStyle} />\n )}\n </div>\n );\n}\n\nconst nodeTypes = { workflow: WorkflowNodeCard };\n\n/** Inspector form for the selected node. */\nfunction NodeInspector({\n node,\n readOnly,\n onChange,\n onDelete,\n}: {\n node: BuilderNode;\n readOnly: boolean;\n onChange: (patch: { label?: string; config?: SubWorkflowNodeConfig }) => void;\n onDelete: () => void;\n}) {\n const tr = useTr();\n const meta = KIND_META[node.kind];\n const setConfig = (patch: SubWorkflowNodeConfig) =>\n onChange({ config: { ...node.config, ...patch } });\n\n return (\n <div className=\"space-y-4\" data-testid=\"workflow-node-inspector\">\n <p className=\"text-xs font-medium uppercase tracking-wide text-text-secondary\">\n {tr(meta.labelKey, meta.fallback)}\n </p>\n <div>\n <label htmlFor=\"wfb-label\" className={labelCls}>\n {tr('workflows.builder.inspector.label', 'Label')}\n </label>\n <input\n id=\"wfb-label\"\n className={inputCls}\n value={node.label}\n maxLength={120}\n disabled={readOnly}\n onChange={(e) => onChange({ label: e.target.value })}\n />\n </div>\n\n {node.kind === 'TRIGGER' && (\n <div>\n <label htmlFor=\"wfb-event\" className={labelCls}>\n {tr('workflows.builder.inspector.event', 'Trigger event')}\n </label>\n <input\n id=\"wfb-event\"\n className={inputCls}\n value={typeof node.config.event === 'string' ? node.config.event : ''}\n maxLength={120}\n placeholder={tr(\n 'workflows.form.triggerPlaceholder',\n 'e.g. InvoiceReceived, RenewalDetected'\n )}\n disabled={readOnly}\n onChange={(e) => setConfig({ event: e.target.value })}\n />\n </div>\n )}\n\n {node.kind === 'ACTION' && (\n <>\n <div>\n <label htmlFor=\"wfb-action\" className={labelCls}>\n {tr('workflows.builder.inspector.action', 'Action')}\n </label>\n <select\n id=\"wfb-action\"\n className={inputCls}\n value={typeof node.config.action === 'string' ? node.config.action : ''}\n disabled={readOnly}\n onChange={(e) =>\n setConfig({\n action: (e.target.value || undefined) as SubWorkflowActionKind | undefined,\n })\n }\n >\n <option value=\"\">\n {tr('workflows.builder.inspector.chooseAction', 'Choose an action…')}\n </option>\n {ACTION_KINDS.map((a) => (\n <option key={a} value={a}>\n {tr(`workflows.builder.action.${a.toLowerCase()}`, ACTION_LABELS[a])}\n </option>\n ))}\n </select>\n </div>\n <div>\n <label htmlFor=\"wfb-message\" className={labelCls}>\n {tr('workflows.builder.inspector.message', 'Message (optional)')}\n </label>\n <textarea\n id=\"wfb-message\"\n rows={3}\n className={inputCls}\n maxLength={1000}\n value={typeof node.config.message === 'string' ? node.config.message : ''}\n disabled={readOnly}\n onChange={(e) => setConfig({ message: e.target.value })}\n />\n </div>\n </>\n )}\n\n {node.kind === 'CONDITION' && (\n <div>\n <label htmlFor=\"wfb-expression\" className={labelCls}>\n {tr('workflows.builder.inspector.expression', 'Condition')}\n </label>\n <input\n id=\"wfb-expression\"\n className={inputCls}\n maxLength={500}\n placeholder={tr(\n 'workflows.builder.inspector.expressionPlaceholder',\n 'e.g. monthlySpend > 100'\n )}\n value={typeof node.config.expression === 'string' ? node.config.expression : ''}\n disabled={readOnly}\n onChange={(e) => setConfig({ expression: e.target.value })}\n />\n <p className=\"mt-1 text-xs text-text-secondary\">\n {tr(\n 'workflows.builder.inspector.expressionHint',\n 'Connect the green outlet for when it holds and the red outlet for when it does not.'\n )}\n </p>\n </div>\n )}\n\n {node.kind === 'DELAY' && (\n <div>\n <label htmlFor=\"wfb-delay\" className={labelCls}>\n {tr('workflows.builder.inspector.delay', 'Wait (minutes)')}\n </label>\n <input\n id=\"wfb-delay\"\n type=\"number\"\n min={1}\n max={525600}\n step={1}\n className={inputCls}\n value={\n typeof node.config.durationMinutes === 'number' ? node.config.durationMinutes : ''\n }\n disabled={readOnly}\n onChange={(e) => {\n const n = Number.parseInt(e.target.value, 10);\n setConfig({ durationMinutes: Number.isFinite(n) ? n : undefined });\n }}\n />\n </div>\n )}\n\n {node.kind === 'BRANCH' && (\n <p className=\"text-xs text-text-secondary\">\n {tr(\n 'workflows.builder.inspector.branchHint',\n 'Connect two or more steps; they run in parallel.'\n )}\n </p>\n )}\n\n {!readOnly && (\n <button\n type=\"button\"\n onClick={onDelete}\n className=\"inline-flex items-center gap-1.5 rounded-lg border border-status-error-text/40 px-3 py-1.5 text-xs font-medium text-status-error-text hover:bg-status-error-bg-subtle\"\n >\n <Trash2 className=\"h-3.5 w-3.5\" />{' '}\n {tr('workflows.builder.inspector.deleteNode', 'Delete node')}\n </button>\n )}\n </div>\n );\n}\n\n/** The editor itself, mounted once the workflow has loaded. */\nfunction WorkflowBuilder({ workflow }: { workflow: SubWorkflowWithGraph }) {\n const tr = useTr();\n const save = useSaveWorkflowGraph();\n const activate = useActivateWorkflow();\n const pause = usePauseWorkflow();\n\n const [graph, setGraph] = useState<BuilderGraph>(() => fromServerGraph(workflow.graph));\n const [issues, setIssues] = useState<SubWorkflowGraphIssue[]>(workflow.graph.issues);\n const [dirty, setDirty] = useState(false);\n const [selectedNodeId, setSelectedNodeId] = useState<string | null>(null);\n const [selectedEdgeId, setSelectedEdgeId] = useState<string | null>(null);\n const [notice, setNotice] = useState<{ tone: 'error' | 'success'; text: string } | null>(null);\n const [placeholderSeq, setPlaceholderSeq] = useState(1);\n\n const readOnly = workflow.status === 'ACTIVE';\n // Editing pauses while a save is in flight: the response replaces the local\n // graph (placeholder ids become server ids), so an edit made in the meantime\n // would otherwise be overwritten and reported as saved.\n const editLocked = readOnly || save.isPending;\n\n // A refetch after save/activate/pause brings a fresh server graph; adopt it\n // unless the user has local edits in flight. Compared during render (the\n // \"store the previous prop\" pattern) so no effect has to mirror props into state.\n const [seenGraph, setSeenGraph] = useState(workflow.graph);\n if (seenGraph !== workflow.graph) {\n setSeenGraph(workflow.graph);\n if (!dirty) {\n setGraph(fromServerGraph(workflow.graph));\n setIssues(workflow.graph.issues);\n }\n }\n\n const issueNodeIds = useMemo(\n () => new Set(issues.map((i) => i.nodeId).filter((id): id is string => Boolean(id))),\n [issues]\n );\n\n const rfNodes: CanvasNode[] = useMemo(\n () =>\n graph.nodes.map((n) => ({\n id: n.id,\n type: 'workflow',\n position: { x: n.x, y: n.y },\n selected: n.id === selectedNodeId,\n data: {\n kind: n.kind,\n label:\n n.label ||\n tr(`workflowBuilder.nodeLabel.${n.kind.toLowerCase()}`, defaultLabel(n.kind)),\n summary: configSummary(n, tr),\n hasIssue: !dirty && issueNodeIds.has(n.id),\n },\n })),\n [graph.nodes, selectedNodeId, dirty, issueNodeIds, tr]\n );\n\n const rfEdges: Edge[] = useMemo(\n () =>\n graph.edges.map((e) => ({\n id: e.id,\n source: e.source,\n target: e.target,\n sourceHandle: e.handle,\n selected: e.id === selectedEdgeId,\n label:\n e.handle === 'true'\n ? tr('workflows.builder.yes', 'Yes')\n : e.handle === 'false'\n ? tr('workflows.builder.no', 'No')\n : undefined,\n markerEnd: { type: MarkerType.ArrowClosed, color: 'var(--color-text-secondary)' },\n style: {\n stroke:\n e.id === selectedEdgeId ? 'var(--color-focus-ring)' : 'var(--color-text-secondary)',\n strokeWidth: 2,\n },\n })),\n [graph.edges, selectedEdgeId, tr]\n );\n\n const edit = useCallback((next: (g: BuilderGraph) => BuilderGraph) => {\n setGraph((g) => next(g));\n setDirty(true);\n setNotice(null);\n }, []);\n\n const onNodesChange = useCallback(\n (changes: NodeChange<CanvasNode>[]) => {\n const moves = changes.filter((c) => c.type === 'position' && c.position);\n const removals = changes.filter((c) => c.type === 'remove');\n if (editLocked || (moves.length === 0 && removals.length === 0)) return;\n edit((g) => {\n const moved = applyNodeChanges(\n moves,\n g.nodes.map((n) => ({ id: n.id, position: { x: n.x, y: n.y }, data: {} }))\n );\n let next: BuilderGraph = {\n nodes: g.nodes.map((n) => {\n const m = moved.find((x) => x.id === n.id);\n return m ? { ...n, x: m.position.x, y: m.position.y } : n;\n }),\n edges: g.edges,\n };\n for (const r of removals) if (r.type === 'remove') next = removeNode(next, r.id);\n return next;\n });\n },\n [edit, editLocked]\n );\n\n const onEdgesChange = useCallback(\n (changes: EdgeChange[]) => {\n const removed = new Set(changes.filter((c) => c.type === 'remove').map((c) => c.id));\n if (editLocked || removed.size === 0) return;\n edit((g) => ({ nodes: g.nodes, edges: g.edges.filter((e) => !removed.has(e.id)) }));\n },\n [edit, editLocked]\n );\n\n const onConnect = useCallback(\n (c: Connection) => {\n if (editLocked) return;\n const handle = c.sourceHandle ?? null;\n const reason = connectionError(graph, c.source, c.target, handle, tr);\n if (reason) {\n setNotice({ tone: 'error', text: reason });\n return;\n }\n edit((g) => ({\n nodes: g.nodes,\n edges: [\n ...g.edges,\n {\n id: `edge-${c.source}-${handle ?? 'out'}-${c.target}`,\n source: c.source,\n target: c.target,\n handle,\n label: null,\n },\n ],\n }));\n },\n [edit, graph, editLocked, tr]\n );\n\n const addNode = (kind: SubWorkflowNodeKind) => {\n const id = `new-${placeholderSeq}`;\n setPlaceholderSeq((s) => s + 1);\n const pos = nextNodePosition(graph.nodes);\n edit((g) => ({\n nodes: [\n ...g.nodes,\n {\n id,\n kind,\n label: tr(`workflowBuilder.nodeLabel.${kind.toLowerCase()}`, defaultLabel(kind)),\n config: initialConfig(kind),\n x: pos.x,\n y: pos.y,\n },\n ],\n edges: g.edges,\n }));\n setSelectedNodeId(id);\n setSelectedEdgeId(null);\n };\n\n const selectedNode = graph.nodes.find((n) => n.id === selectedNodeId) ?? null;\n\n const handleSave = () => {\n save.mutate(\n { workflowId: workflow.id, input: toSaveInput(graph) },\n {\n onSuccess: (saved) => {\n setGraph(fromServerGraph(saved));\n setIssues(saved.issues);\n setDirty(false);\n setSelectedNodeId(null);\n setSelectedEdgeId(null);\n setNotice({\n tone: 'success',\n text: saved.valid\n ? tr('workflows.builder.savedValid', 'Saved. This workflow is ready to activate.')\n : tr(\n 'workflows.builder.savedWithIssues',\n 'Saved as a draft. Fix the issues below before activating.'\n ),\n });\n },\n onError: (err) =>\n setNotice({\n tone: 'error',\n text: err instanceof Error ? err.message : tr('common.error', 'An error occurred'),\n }),\n }\n );\n };\n\n const handleActivate = () =>\n activate.mutate(workflow.id, {\n onSuccess: () =>\n setNotice({\n tone: 'success',\n text: tr('workflows.builder.activated', 'Workflow activated.'),\n }),\n onError: (err) =>\n setNotice({\n tone: 'error',\n text: err instanceof Error ? err.message : tr('common.error', 'An error occurred'),\n }),\n });\n\n const handlePause = () =>\n pause.mutate(workflow.id, {\n onSuccess: () =>\n setNotice({\n tone: 'success',\n text: tr('workflows.builder.paused', 'Workflow paused. You can edit it now.'),\n }),\n onError: (err) =>\n setNotice({\n tone: 'error',\n text: err instanceof Error ? err.message : tr('common.error', 'An error occurred'),\n }),\n });\n\n const canActivate = !readOnly && !dirty && issues.length === 0 && graph.nodes.length > 0;\n\n return (\n <>\n <div className=\"flex flex-wrap items-center justify-between gap-3\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <StatusBadge status={workflow.status} />\n {dirty && (\n <span className=\"rounded-full bg-status-warning-bg-subtle px-2 py-0.5 text-xs font-medium text-status-warning-text\">\n {tr('workflows.builder.unsaved', 'Unsaved changes')}\n </span>\n )}\n {!dirty && issues.length === 0 && graph.nodes.length > 0 && (\n <span className=\"inline-flex items-center gap-1 text-xs text-status-success-text\">\n <CheckCircle2 className=\"h-3.5 w-3.5\" />{' '}\n {tr('workflows.builder.valid', 'Ready to run')}\n </span>\n )}\n </div>\n <div className=\"flex flex-wrap items-center gap-2\">\n {readOnly ? (\n <button\n type=\"button\"\n className={secondaryBtn}\n onClick={handlePause}\n disabled={pause.isPending}\n >\n <Pause className=\"h-4 w-4\" /> {tr('workflows.builder.pauseToEdit', 'Pause to edit')}\n </button>\n ) : (\n <>\n <button\n type=\"button\"\n className={secondaryBtn}\n onClick={handleSave}\n disabled={!dirty || save.isPending}\n >\n <Save className=\"h-4 w-4\" />{' '}\n {save.isPending\n ? tr('workflows.builder.saving', 'Saving…')\n : tr('workflows.builder.save', 'Save')}\n </button>\n <button\n type=\"button\"\n className={primaryBtn}\n onClick={handleActivate}\n disabled={!canActivate || activate.isPending}\n title={\n dirty\n ? tr('workflows.builder.saveFirst', 'Save your changes first')\n : issues.length > 0\n ? tr('workflows.builder.fixIssuesFirst', 'Fix the issues first')\n : undefined\n }\n >\n <Play className=\"h-4 w-4\" />{' '}\n {activate.isPending\n ? tr('common.activating', 'Activating…')\n : tr('workflows.flow.activate', 'Activate workflow')}\n </button>\n </>\n )}\n </div>\n </div>\n\n {notice && (\n <div\n role={notice.tone === 'error' ? 'alert' : 'status'}\n className={`mt-3 rounded-lg border px-4 py-2 text-sm ${\n notice.tone === 'error'\n ? 'border-status-error-text/30 bg-status-error-bg-subtle text-status-error-text'\n : 'border-status-success-text/30 bg-status-success-bg-subtle text-status-success-text'\n }`}\n >\n {notice.text}\n </div>\n )}\n {readOnly && (\n <p className=\"mt-3 text-sm text-text-secondary\">\n {tr(\n 'workflows.builder.readOnlyActive',\n 'This workflow is active, so it is shown read-only. Pause it to change its steps.'\n )}\n </p>\n )}\n\n <div className=\"mt-4 grid grid-cols-1 gap-4 lg:grid-cols-[13rem_minmax(0,1fr)_18rem]\">\n {/* Palette */}\n <GlassCard treatment=\"metric\" className=\"p-3\">\n <p className=\"mb-2 text-xs font-medium uppercase tracking-wide text-text-secondary\">\n {tr('workflows.builder.palette', 'Add a step')}\n </p>\n <div\n className=\"grid grid-cols-2 gap-2 lg:grid-cols-1\"\n role=\"group\"\n aria-label={tr('workflows.builder.palette', 'Add a step')}\n >\n {NODE_KINDS.map((kind) => {\n const meta = KIND_META[kind];\n const Icon = meta.icon;\n const disabled = editLocked || !canAddKind(kind, graph.nodes);\n return (\n <button\n key={kind}\n type=\"button\"\n disabled={disabled}\n onClick={() => addNode(kind)}\n title={tr(`${meta.labelKey}Hint`, meta.hint)}\n className=\"flex items-center gap-2 rounded-lg border border-border-subtle bg-bg-surface px-2.5 py-2 text-start text-sm text-text-primary hover:bg-bg-sunken disabled:cursor-not-allowed disabled:opacity-50\"\n >\n <Icon className=\"h-4 w-4 shrink-0 text-text-secondary\" />\n <span className=\"truncate\">{tr(meta.labelKey, meta.fallback)}</span>\n </button>\n );\n })}\n </div>\n </GlassCard>\n\n {/* Canvas */}\n <div\n className=\"h-[60vh] min-h-[420px] overflow-hidden rounded-xl border border-border-subtle bg-bg-sunken\"\n data-testid=\"workflow-canvas\"\n >\n {graph.nodes.length === 0 ? (\n <div className=\"flex h-full items-center justify-center p-6\">\n <EmptyState\n icon={<Zap className=\"h-10 w-10\" />}\n title={tr('workflows.builder.emptyTitle', 'Start with a trigger')}\n description={tr(\n 'workflows.builder.emptyDescription',\n 'Add a trigger from the palette, then connect the steps that should follow it.'\n )}\n />\n </div>\n ) : (\n <ReactFlow\n nodes={rfNodes}\n edges={rfEdges}\n nodeTypes={nodeTypes}\n onNodesChange={onNodesChange}\n onEdgesChange={onEdgesChange}\n onConnect={onConnect}\n onNodeClick={(_e, n) => {\n setSelectedNodeId(n.id);\n setSelectedEdgeId(null);\n }}\n onEdgeClick={(_e, e) => {\n setSelectedEdgeId(e.id);\n setSelectedNodeId(null);\n }}\n onPaneClick={() => {\n setSelectedNodeId(null);\n setSelectedEdgeId(null);\n }}\n nodesDraggable={!editLocked}\n nodesConnectable={!editLocked}\n deleteKeyCode={editLocked ? null : ['Backspace', 'Delete']}\n fitView\n fitViewOptions={{ padding: 0.2, maxZoom: 1.1 }}\n proOptions={{ hideAttribution: true }}\n >\n <Background color=\"var(--color-border-subtle)\" gap={20} />\n <Controls showInteractive={false} />\n </ReactFlow>\n )}\n </div>\n\n {/* Inspector + issues */}\n <div className=\"space-y-4\">\n <GlassCard treatment=\"metric\" className=\"p-4\">\n {selectedNode ? (\n <NodeInspector\n node={selectedNode}\n readOnly={editLocked}\n onChange={(patch) =>\n edit((g) => ({\n nodes: g.nodes.map((n) => (n.id === selectedNode.id ? { ...n, ...patch } : n)),\n edges: g.edges,\n }))\n }\n onDelete={() => {\n edit((g) => removeNode(g, selectedNode.id));\n setSelectedNodeId(null);\n }}\n />\n ) : selectedEdgeId && !editLocked ? (\n <div className=\"space-y-3\">\n <p className=\"text-sm text-text-primary\">\n {tr('workflows.builder.edgeSelected', 'Connection selected')}\n </p>\n <button\n type=\"button\"\n onClick={() => {\n edit((g) => ({\n nodes: g.nodes,\n edges: g.edges.filter((e) => e.id !== selectedEdgeId),\n }));\n setSelectedEdgeId(null);\n }}\n className=\"inline-flex items-center gap-1.5 rounded-lg border border-status-error-text/40 px-3 py-1.5 text-xs font-medium text-status-error-text hover:bg-status-error-bg-subtle\"\n >\n <Trash2 className=\"h-3.5 w-3.5\" />{' '}\n {tr('workflows.builder.deleteEdge', 'Delete connection')}\n </button>\n </div>\n ) : (\n <p className=\"text-sm text-text-secondary\">\n {tr(\n 'workflows.builder.inspectorEmpty',\n 'Select a node to edit it. Drag from a node’s right edge to another node to connect them.'\n )}\n </p>\n )}\n </GlassCard>\n\n <GlassCard treatment=\"metric\" className=\"p-4\" data-testid=\"workflow-issues\">\n <p className=\"mb-2 text-xs font-medium uppercase tracking-wide text-text-secondary\">\n {tr('workflows.builder.issues', 'Validation')}\n </p>\n {dirty ? (\n <p className=\"text-sm text-text-secondary\">\n {tr('workflows.builder.issuesAfterSave', 'Save to check the workflow.')}\n </p>\n ) : issues.length === 0 ? (\n <p className=\"inline-flex items-center gap-1.5 text-sm text-status-success-text\">\n <CheckCircle2 className=\"h-4 w-4\" />{' '}\n {tr('workflows.builder.noIssues', 'No issues found')}\n </p>\n ) : (\n <ul className=\"space-y-2\">\n {issues.map((issue, i) => (\n <li key={`${issue.code}-${issue.nodeId ?? issue.edgeId ?? i}`}>\n <button\n type=\"button\"\n className=\"flex w-full items-start gap-2 text-start text-sm text-text-primary hover:underline disabled:no-underline\"\n disabled={!issue.nodeId}\n onClick={() => issue.nodeId && setSelectedNodeId(issue.nodeId)}\n >\n <AlertTriangle className=\"mt-0.5 h-4 w-4 shrink-0 text-status-warning-text\" />\n <span>{issue.message}</span>\n </button>\n </li>\n ))}\n </ul>\n )}\n </GlassCard>\n </div>\n </div>\n </>\n );\n}\n\nexport function WorkflowBuilderPage() {\n const { id } = useParams<{ id: string }>();\n const tr = useTr();\n const { navigateTo } = useSubscriberBot();\n const { data, isLoading, isError, refetch } = useWorkflow(id);\n\n return (\n <PageLayout\n title={data?.name ?? tr('workflows.builder.title', 'Workflow builder')}\n description={\n data\n ? tr('workflows.builder.subtitle', 'Visual builder · starts on {{trigger}}', {\n trigger: data.triggerEvent || '—',\n })\n : undefined\n }\n actions={\n <button\n type=\"button\"\n className={secondaryBtn}\n onClick={() => navigateTo(id ? `/workflows/${id}` : '/workflows')}\n >\n <ArrowLeft className=\"rtl:rotate-180 h-4 w-4\" />{' '}\n {tr('workflows.builder.back', 'Workflows')}\n </button>\n }\n >\n {isLoading ? (\n <LoadingView label={tr('workflows.builder.loading', 'Loading workflow…')} />\n ) : isError ? (\n <ErrorView\n message={tr('workflows.builder.error', 'Could not load this workflow.')}\n onRetry={() => void refetch()}\n />\n ) : !data ? (\n <EmptyState\n title={tr('workflows.builder.notFound', 'Workflow not found')}\n description={tr(\n 'workflows.builder.notFoundDescription',\n 'It may have been deleted, or it belongs to another workspace.'\n )}\n />\n ) : (\n // Keyed by workflow id so moving to another workflow starts a fresh\n // editor instead of carrying the previous workflow's unsaved graph.\n <WorkflowBuilder key={data.id} workflow={data} />\n )}\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAiFA,IAAM,IACJ,4NACI,IAAW,sDACX,IACJ,kKACI,IACJ,gKAEI,IASF;CACF,SAAS;EACP,MAAM;EACN,KAAK;EACL,UAAU;EACV,UAAU;EACV,MAAM;CACR;CACA,QAAQ;EACN,MAAM;EACN,KAAK;EACL,UAAU;EACV,UAAU;EACV,MAAM;CACR;CACA,WAAW;EACT,MAAM;EACN,KAAK;EACL,UAAU;EACV,UAAU;EACV,MAAM;CACR;CACA,OAAO;EACL,MAAM;EACN,KAAK;EACL,UAAU;EACV,UAAU;EACV,MAAM;CACR;CACA,QAAQ;EACN,MAAM;EACN,KAAK;EACL,UAAU;EACV,UAAU;EACV,MAAM;CACR;AACF,GAEM,IAAuD;CAC3D,QAAQ;CACR,OAAO;CACP,aAAa;CACb,qBAAqB;CACrB,UAAU;CACV,mBAAmB;CACnB,cAAc;AAChB,GAEM,IAAc;CAAE,YAAY;CAA+B,OAAO;CAAI,QAAQ;AAAG;AAWvF,SAAS,EAAiB,EAAE,SAAM,eAAmC;CACnE,IAAM,IAAK,EAAM,GACX,IAAO,EAAU,EAAK,OACtB,IAAO,EAAK;CAClB,OACE,kBAAC,OAAD;EACE,eAAa,iBAAiB,EAAK,KAAK,YAAY;EACpD,WAAW,kEACT,IACI,2EACA,EAAK,WACH,+BACA;YAPV;GAUG,EAAK,SAAS,aACb,kBAAC,GAAD;IAAQ,MAAK;IAAS,UAAU,EAAS;IAAM,OAAO;GAAc,CAAA;GAEtE,kBAAC,OAAD;IAAK,WAAW,cAAc,EAAK;IAAO,eAAA;GAAa,CAAA;GACvD,kBAAC,OAAD;IAAK,WAAU;cAAf;KACE,kBAAC,OAAD;MAAK,WAAU;gBAAf;OACE,kBAAC,QAAD;QAAM,WA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,GAAD,EAAa,OAAO,EAAG,6BAA6B,mBAAmB,EAAI,CAAA,IACzE,IACF,kBAAC,GAAD;GACE,SAAS,EAAG,2BAA2B,+BAA+B;GACtE,eAAe,KAAK,EAAQ;EAC7B,CAAA,IACE,IAWH,kBAAC,GAAD,EAA+B,UAAU,EAAO,GAA1B,EAAK,EAAqB,IAVhD,kBAAC,GAAD;GACE,OAAO,EAAG,8BAA8B,oBAAoB;GAC5D,aAAa,EACX,yCACA,+DACF;EACD,CAAA;CAMO,CAAA;AAEhB"}
|
|
1
|
+
{"version":3,"file":"WorkflowBuilderPage.js","names":[],"sources":["../../../../src/subscriberbot/pages/workflows/WorkflowBuilderPage.tsx"],"sourcesContent":["/**\n * Workflow builder (BOFF-4006)\n * @module subscriberbot/pages/workflows\n *\n * `/workflows/:id/builder` — the visual, node-based editor for one workflow.\n * A palette adds trigger / action / condition / delay / branch nodes, the\n * canvas connects and arranges them, and the inspector edits the selected\n * node's configuration. Edits stay local until Save, which replaces the\n * graph in one `subSaveWorkflowGraph` call; the svc re-validates it and\n * returns the issues that would stop the workflow from running. Activation\n * is refused while any issue remains.\n *\n * An ACTIVE workflow is shown read-only: the svc keeps active workflows valid\n * at all times, so the user pauses it to restructure it.\n */\n\nimport { type FC, useCallback, useMemo, useState } from 'react';\nimport { useParams } from 'react-router';\nimport {\n ReactFlow,\n Background,\n Controls,\n Handle,\n MarkerType,\n Position,\n applyNodeChanges,\n type Connection,\n type Edge,\n type EdgeChange,\n type Node,\n type NodeChange,\n type NodeProps,\n} from '@xyflow/react';\nimport '@xyflow/react/dist/style.css';\nimport {\n AlertTriangle,\n ArrowLeft,\n CheckCircle2,\n Clock,\n GitBranch,\n GitFork,\n Pause,\n Play,\n Save,\n Trash2,\n Zap,\n Sparkles,\n} from 'lucide-react';\nimport { GlassCard } from '@burdenoff/fe-libs/ui';\nimport { PageLayout, StatusBadge, LoadingView, ErrorView, EmptyState } from '../../components';\nimport {\n useWorkflow,\n useSaveWorkflowGraph,\n useActivateWorkflow,\n usePauseWorkflow,\n} from '../../hooks/useSubscriberBotApi';\nimport { useTr } from '../../hooks/useTr';\nimport { useSubscriberBot } from '../../context/SubscriberBotContext';\nimport type {\n SubWorkflowActionKind,\n SubWorkflowGraphIssue,\n SubWorkflowNodeConfig,\n SubWorkflowNodeKind,\n SubWorkflowWithGraph,\n} from '../../types';\nimport {\n ACTION_KINDS,\n NODE_KINDS,\n type BuilderGraph,\n type BuilderNode,\n canAddKind,\n configSummary,\n connectionError,\n defaultLabel,\n fromServerGraph,\n initialConfig,\n nextNodePosition,\n removeNode,\n toSaveInput,\n} from './workflowBuilderGraph';\n\nconst inputCls =\n 'w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] disabled:opacity-60';\nconst labelCls = 'mb-1 block text-xs font-medium text-text-secondary';\nconst secondaryBtn =\n 'inline-flex items-center gap-1.5 rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-50';\nconst primaryBtn =\n 'inline-flex items-center gap-1.5 rounded-lg bg-action-primary-bg px-3 py-2 text-sm font-medium text-action-primary-text hover:opacity-90 disabled:opacity-50';\n\nconst KIND_META: Record<\n SubWorkflowNodeKind,\n {\n icon: FC<{ className?: string }>;\n bar: string;\n labelKey: string;\n fallback: string;\n hint: string;\n }\n> = {\n TRIGGER: {\n icon: Zap,\n bar: 'bg-[var(--color-accent-indigo)]',\n labelKey: 'workflows.builder.kind.trigger',\n fallback: 'Trigger',\n hint: 'The event that starts the workflow',\n },\n ACTION: {\n icon: Sparkles,\n bar: 'bg-status-success-text',\n labelKey: 'workflows.builder.kind.action',\n fallback: 'Action',\n hint: 'Notify, alert, create a task, update, classify or call an adapter',\n },\n CONDITION: {\n icon: GitFork,\n bar: 'bg-status-warning-text',\n labelKey: 'workflows.builder.kind.condition',\n fallback: 'Condition',\n hint: 'Route through a true or false outlet',\n },\n DELAY: {\n icon: Clock,\n bar: 'bg-text-secondary',\n labelKey: 'workflows.builder.kind.delay',\n fallback: 'Delay',\n hint: 'Wait before the next step',\n },\n BRANCH: {\n icon: GitBranch,\n bar: 'bg-[var(--color-accent-indigo)]',\n labelKey: 'workflows.builder.kind.branch',\n fallback: 'Branch',\n hint: 'Run two or more paths in parallel',\n },\n};\n\nconst ACTION_LABELS: Record<SubWorkflowActionKind, string> = {\n NOTIFY: 'Notify',\n ALERT: 'Raise an alert',\n CREATE_TASK: 'Create a task',\n UPDATE_RELATIONSHIP: 'Update the relationship',\n CLASSIFY: 'Classify with AI',\n EVALUATE_POLICIES: 'Evaluate agent policies',\n CALL_ADAPTER: 'Call the provider adapter',\n};\n\n// React Flow ships light-only control colours (near-white buttons), which\n// render as blank white squares in dark mode. Point its documented\n// --xy-controls-* variables at the shell's semantic tokens so the zoom\n// controls follow the active theme.\nconst controlsCls = [\n 'overflow-hidden rounded-lg border border-border-subtle',\n '[--xy-controls-box-shadow:none]',\n '[--xy-controls-button-background-color:var(--color-bg-elevated)]',\n '[--xy-controls-button-background-color-hover:var(--color-bg-surface)]',\n '[--xy-controls-button-border-color:var(--color-border-subtle)]',\n '[--xy-controls-button-color:var(--color-text-secondary)]',\n '[--xy-controls-button-color-hover:var(--color-text-primary)]',\n].join(' ');\nconst handleStyle = { background: 'var(--color-text-secondary)', width: 10, height: 10 };\n\ntype CanvasNodeData = {\n kind: SubWorkflowNodeKind;\n label: string;\n summary: string;\n hasIssue: boolean;\n};\ntype CanvasNode = Node<CanvasNodeData, 'workflow'>;\n\n/** A node card on the canvas: accent bar by kind, icon, label and config summary. */\nfunction WorkflowNodeCard({ data, selected }: NodeProps<CanvasNode>) {\n const tr = useTr();\n const meta = KIND_META[data.kind];\n const Icon = meta.icon;\n return (\n <div\n data-testid={`workflow-node-${data.kind.toLowerCase()}`}\n className={`w-52 overflow-hidden rounded-xl border bg-bg-surface shadow-sm ${\n selected\n ? 'border-[var(--color-focus-ring)] ring-2 ring-[var(--color-focus-ring)]'\n : data.hasIssue\n ? 'border-status-warning-text'\n : 'border-border-subtle'\n }`}\n >\n {data.kind !== 'TRIGGER' && (\n <Handle type=\"target\" position={Position.Left} style={handleStyle} />\n )}\n <div className={`h-1 w-full ${meta.bar}`} aria-hidden />\n <div className=\"p-3\">\n <div className=\"flex items-center gap-2\">\n <span className=\"flex size-8 shrink-0 items-center justify-center rounded-lg bg-[var(--color-accent-soft)] text-text-primary\">\n <Icon className=\"h-4 w-4\" />\n </span>\n <p className=\"text-[10px] font-medium uppercase tracking-wide text-text-secondary\">\n {tr(meta.labelKey, meta.fallback)}\n </p>\n {data.hasIssue && (\n <AlertTriangle\n className=\"ms-auto h-3.5 w-3.5 text-status-warning-text\"\n aria-label={tr('workflows.builder.nodeHasIssue', 'Needs attention')}\n />\n )}\n </div>\n <p className=\"mt-2 truncate text-sm font-semibold text-text-primary\" title={data.label}>\n {data.label}\n </p>\n <p className=\"mt-0.5 truncate text-xs text-text-secondary\" title={data.summary}>\n {data.summary}\n </p>\n </div>\n {data.kind === 'CONDITION' ? (\n <>\n <Handle\n id=\"true\"\n type=\"source\"\n position={Position.Right}\n style={{ ...handleStyle, top: '35%', background: 'var(--color-status-success-text)' }}\n />\n <Handle\n id=\"false\"\n type=\"source\"\n position={Position.Right}\n style={{ ...handleStyle, top: '70%', background: 'var(--color-status-error-text)' }}\n />\n </>\n ) : (\n <Handle type=\"source\" position={Position.Right} style={handleStyle} />\n )}\n </div>\n );\n}\n\nconst nodeTypes = { workflow: WorkflowNodeCard };\n\n/** Inspector form for the selected node. */\nfunction NodeInspector({\n node,\n readOnly,\n onChange,\n onDelete,\n}: {\n node: BuilderNode;\n readOnly: boolean;\n onChange: (patch: { label?: string; config?: SubWorkflowNodeConfig }) => void;\n onDelete: () => void;\n}) {\n const tr = useTr();\n const meta = KIND_META[node.kind];\n const setConfig = (patch: SubWorkflowNodeConfig) =>\n onChange({ config: { ...node.config, ...patch } });\n\n return (\n <div className=\"space-y-4\" data-testid=\"workflow-node-inspector\">\n <p className=\"text-xs font-medium uppercase tracking-wide text-text-secondary\">\n {tr(meta.labelKey, meta.fallback)}\n </p>\n <div>\n <label htmlFor=\"wfb-label\" className={labelCls}>\n {tr('workflows.builder.inspector.label', 'Label')}\n </label>\n <input\n id=\"wfb-label\"\n className={inputCls}\n value={node.label}\n maxLength={120}\n disabled={readOnly}\n onChange={(e) => onChange({ label: e.target.value })}\n />\n </div>\n\n {node.kind === 'TRIGGER' && (\n <div>\n <label htmlFor=\"wfb-event\" className={labelCls}>\n {tr('workflows.builder.inspector.event', 'Trigger event')}\n </label>\n <input\n id=\"wfb-event\"\n className={inputCls}\n value={typeof node.config.event === 'string' ? node.config.event : ''}\n maxLength={120}\n placeholder={tr(\n 'workflows.form.triggerPlaceholder',\n 'e.g. InvoiceReceived, RenewalDetected'\n )}\n disabled={readOnly}\n onChange={(e) => setConfig({ event: e.target.value })}\n />\n </div>\n )}\n\n {node.kind === 'ACTION' && (\n <>\n <div>\n <label htmlFor=\"wfb-action\" className={labelCls}>\n {tr('workflows.builder.inspector.action', 'Action')}\n </label>\n <select\n id=\"wfb-action\"\n className={inputCls}\n value={typeof node.config.action === 'string' ? node.config.action : ''}\n disabled={readOnly}\n onChange={(e) =>\n setConfig({\n action: (e.target.value || undefined) as SubWorkflowActionKind | undefined,\n })\n }\n >\n <option value=\"\">\n {tr('workflows.builder.inspector.chooseAction', 'Choose an action…')}\n </option>\n {ACTION_KINDS.map((a) => (\n <option key={a} value={a}>\n {tr(`workflows.builder.action.${a.toLowerCase()}`, ACTION_LABELS[a])}\n </option>\n ))}\n </select>\n </div>\n <div>\n <label htmlFor=\"wfb-message\" className={labelCls}>\n {tr('workflows.builder.inspector.message', 'Message (optional)')}\n </label>\n <textarea\n id=\"wfb-message\"\n rows={3}\n className={inputCls}\n maxLength={1000}\n value={typeof node.config.message === 'string' ? node.config.message : ''}\n disabled={readOnly}\n onChange={(e) => setConfig({ message: e.target.value })}\n />\n </div>\n </>\n )}\n\n {node.kind === 'CONDITION' && (\n <div>\n <label htmlFor=\"wfb-expression\" className={labelCls}>\n {tr('workflows.builder.inspector.expression', 'Condition')}\n </label>\n <input\n id=\"wfb-expression\"\n className={inputCls}\n maxLength={500}\n placeholder={tr(\n 'workflows.builder.inspector.expressionPlaceholder',\n 'e.g. monthlySpend > 100'\n )}\n value={typeof node.config.expression === 'string' ? node.config.expression : ''}\n disabled={readOnly}\n onChange={(e) => setConfig({ expression: e.target.value })}\n />\n <p className=\"mt-1 text-xs text-text-secondary\">\n {tr(\n 'workflows.builder.inspector.expressionHint',\n 'Connect the green outlet for when it holds and the red outlet for when it does not.'\n )}\n </p>\n </div>\n )}\n\n {node.kind === 'DELAY' && (\n <div>\n <label htmlFor=\"wfb-delay\" className={labelCls}>\n {tr('workflows.builder.inspector.delay', 'Wait (minutes)')}\n </label>\n <input\n id=\"wfb-delay\"\n type=\"number\"\n min={1}\n max={525600}\n step={1}\n className={inputCls}\n value={\n typeof node.config.durationMinutes === 'number' ? node.config.durationMinutes : ''\n }\n disabled={readOnly}\n onChange={(e) => {\n const n = Number.parseInt(e.target.value, 10);\n setConfig({ durationMinutes: Number.isFinite(n) ? n : undefined });\n }}\n />\n </div>\n )}\n\n {node.kind === 'BRANCH' && (\n <p className=\"text-xs text-text-secondary\">\n {tr(\n 'workflows.builder.inspector.branchHint',\n 'Connect two or more steps; they run in parallel.'\n )}\n </p>\n )}\n\n {!readOnly && (\n <button\n type=\"button\"\n onClick={onDelete}\n className=\"inline-flex items-center gap-1.5 rounded-lg border border-status-error-text/40 px-3 py-1.5 text-xs font-medium text-status-error-text hover:bg-status-error-bg-subtle\"\n >\n <Trash2 className=\"h-3.5 w-3.5\" />{' '}\n {tr('workflows.builder.inspector.deleteNode', 'Delete node')}\n </button>\n )}\n </div>\n );\n}\n\n/** The editor itself, mounted once the workflow has loaded. */\nfunction WorkflowBuilder({ workflow }: { workflow: SubWorkflowWithGraph }) {\n const tr = useTr();\n const save = useSaveWorkflowGraph();\n const activate = useActivateWorkflow();\n const pause = usePauseWorkflow();\n\n const [graph, setGraph] = useState<BuilderGraph>(() => fromServerGraph(workflow.graph));\n const [issues, setIssues] = useState<SubWorkflowGraphIssue[]>(workflow.graph.issues);\n const [dirty, setDirty] = useState(false);\n const [selectedNodeId, setSelectedNodeId] = useState<string | null>(null);\n const [selectedEdgeId, setSelectedEdgeId] = useState<string | null>(null);\n const [notice, setNotice] = useState<{ tone: 'error' | 'success'; text: string } | null>(null);\n const [placeholderSeq, setPlaceholderSeq] = useState(1);\n\n const readOnly = workflow.status === 'ACTIVE';\n // Editing pauses while a save is in flight: the response replaces the local\n // graph (placeholder ids become server ids), so an edit made in the meantime\n // would otherwise be overwritten and reported as saved.\n const editLocked = readOnly || save.isPending;\n\n // A refetch after save/activate/pause brings a fresh server graph; adopt it\n // unless the user has local edits in flight. Compared during render (the\n // \"store the previous prop\" pattern) so no effect has to mirror props into state.\n const [seenGraph, setSeenGraph] = useState(workflow.graph);\n if (seenGraph !== workflow.graph) {\n setSeenGraph(workflow.graph);\n if (!dirty) {\n setGraph(fromServerGraph(workflow.graph));\n setIssues(workflow.graph.issues);\n }\n }\n\n const issueNodeIds = useMemo(\n () => new Set(issues.map((i) => i.nodeId).filter((id): id is string => Boolean(id))),\n [issues]\n );\n\n const rfNodes: CanvasNode[] = useMemo(\n () =>\n graph.nodes.map((n) => ({\n id: n.id,\n type: 'workflow',\n position: { x: n.x, y: n.y },\n selected: n.id === selectedNodeId,\n data: {\n kind: n.kind,\n label:\n n.label ||\n tr(`workflowBuilder.nodeLabel.${n.kind.toLowerCase()}`, defaultLabel(n.kind)),\n summary: configSummary(n, tr),\n hasIssue: !dirty && issueNodeIds.has(n.id),\n },\n })),\n [graph.nodes, selectedNodeId, dirty, issueNodeIds, tr]\n );\n\n const rfEdges: Edge[] = useMemo(\n () =>\n graph.edges.map((e) => ({\n id: e.id,\n source: e.source,\n target: e.target,\n sourceHandle: e.handle,\n selected: e.id === selectedEdgeId,\n label:\n e.handle === 'true'\n ? tr('workflows.builder.yes', 'Yes')\n : e.handle === 'false'\n ? tr('workflows.builder.no', 'No')\n : undefined,\n markerEnd: { type: MarkerType.ArrowClosed, color: 'var(--color-text-secondary)' },\n style: {\n stroke:\n e.id === selectedEdgeId ? 'var(--color-focus-ring)' : 'var(--color-text-secondary)',\n strokeWidth: 2,\n },\n })),\n [graph.edges, selectedEdgeId, tr]\n );\n\n const edit = useCallback((next: (g: BuilderGraph) => BuilderGraph) => {\n setGraph((g) => next(g));\n setDirty(true);\n setNotice(null);\n }, []);\n\n const onNodesChange = useCallback(\n (changes: NodeChange<CanvasNode>[]) => {\n const moves = changes.filter((c) => c.type === 'position' && c.position);\n const removals = changes.filter((c) => c.type === 'remove');\n if (editLocked || (moves.length === 0 && removals.length === 0)) return;\n edit((g) => {\n const moved = applyNodeChanges(\n moves,\n g.nodes.map((n) => ({ id: n.id, position: { x: n.x, y: n.y }, data: {} }))\n );\n let next: BuilderGraph = {\n nodes: g.nodes.map((n) => {\n const m = moved.find((x) => x.id === n.id);\n return m ? { ...n, x: m.position.x, y: m.position.y } : n;\n }),\n edges: g.edges,\n };\n for (const r of removals) if (r.type === 'remove') next = removeNode(next, r.id);\n return next;\n });\n },\n [edit, editLocked]\n );\n\n const onEdgesChange = useCallback(\n (changes: EdgeChange[]) => {\n const removed = new Set(changes.filter((c) => c.type === 'remove').map((c) => c.id));\n if (editLocked || removed.size === 0) return;\n edit((g) => ({ nodes: g.nodes, edges: g.edges.filter((e) => !removed.has(e.id)) }));\n },\n [edit, editLocked]\n );\n\n const onConnect = useCallback(\n (c: Connection) => {\n if (editLocked) return;\n const handle = c.sourceHandle ?? null;\n const reason = connectionError(graph, c.source, c.target, handle, tr);\n if (reason) {\n setNotice({ tone: 'error', text: reason });\n return;\n }\n edit((g) => ({\n nodes: g.nodes,\n edges: [\n ...g.edges,\n {\n id: `edge-${c.source}-${handle ?? 'out'}-${c.target}`,\n source: c.source,\n target: c.target,\n handle,\n label: null,\n },\n ],\n }));\n },\n [edit, graph, editLocked, tr]\n );\n\n const addNode = (kind: SubWorkflowNodeKind) => {\n const id = `new-${placeholderSeq}`;\n setPlaceholderSeq((s) => s + 1);\n const pos = nextNodePosition(graph.nodes);\n edit((g) => ({\n nodes: [\n ...g.nodes,\n {\n id,\n kind,\n label: tr(`workflowBuilder.nodeLabel.${kind.toLowerCase()}`, defaultLabel(kind)),\n config: initialConfig(kind),\n x: pos.x,\n y: pos.y,\n },\n ],\n edges: g.edges,\n }));\n setSelectedNodeId(id);\n setSelectedEdgeId(null);\n };\n\n const selectedNode = graph.nodes.find((n) => n.id === selectedNodeId) ?? null;\n\n const handleSave = () => {\n save.mutate(\n { workflowId: workflow.id, input: toSaveInput(graph) },\n {\n onSuccess: (saved) => {\n setGraph(fromServerGraph(saved));\n setIssues(saved.issues);\n setDirty(false);\n setSelectedNodeId(null);\n setSelectedEdgeId(null);\n setNotice({\n tone: 'success',\n text: saved.valid\n ? tr('workflows.builder.savedValid', 'Saved. This workflow is ready to activate.')\n : tr(\n 'workflows.builder.savedWithIssues',\n 'Saved as a draft. Fix the issues below before activating.'\n ),\n });\n },\n onError: (err) =>\n setNotice({\n tone: 'error',\n text: err instanceof Error ? err.message : tr('common.error', 'An error occurred'),\n }),\n }\n );\n };\n\n const handleActivate = () =>\n activate.mutate(workflow.id, {\n onSuccess: () =>\n setNotice({\n tone: 'success',\n text: tr('workflows.builder.activated', 'Workflow activated.'),\n }),\n onError: (err) =>\n setNotice({\n tone: 'error',\n text: err instanceof Error ? err.message : tr('common.error', 'An error occurred'),\n }),\n });\n\n const handlePause = () =>\n pause.mutate(workflow.id, {\n onSuccess: () =>\n setNotice({\n tone: 'success',\n text: tr('workflows.builder.paused', 'Workflow paused. You can edit it now.'),\n }),\n onError: (err) =>\n setNotice({\n tone: 'error',\n text: err instanceof Error ? err.message : tr('common.error', 'An error occurred'),\n }),\n });\n\n const canActivate = !readOnly && !dirty && issues.length === 0 && graph.nodes.length > 0;\n\n return (\n <>\n <div className=\"flex flex-wrap items-center justify-between gap-3\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <StatusBadge status={workflow.status} />\n {dirty && (\n <span className=\"rounded-full bg-status-warning-bg-subtle px-2 py-0.5 text-xs font-medium text-status-warning-text\">\n {tr('workflows.builder.unsaved', 'Unsaved changes')}\n </span>\n )}\n {!dirty && issues.length === 0 && graph.nodes.length > 0 && (\n <span className=\"inline-flex items-center gap-1 text-xs text-status-success-text\">\n <CheckCircle2 className=\"h-3.5 w-3.5\" />{' '}\n {tr('workflows.builder.valid', 'Ready to run')}\n </span>\n )}\n </div>\n <div className=\"flex flex-wrap items-center gap-2\">\n {readOnly ? (\n <button\n type=\"button\"\n className={secondaryBtn}\n onClick={handlePause}\n disabled={pause.isPending}\n >\n <Pause className=\"h-4 w-4\" /> {tr('workflows.builder.pauseToEdit', 'Pause to edit')}\n </button>\n ) : (\n <>\n <button\n type=\"button\"\n className={secondaryBtn}\n onClick={handleSave}\n disabled={!dirty || save.isPending}\n >\n <Save className=\"h-4 w-4\" />{' '}\n {save.isPending\n ? tr('workflows.builder.saving', 'Saving…')\n : tr('workflows.builder.save', 'Save')}\n </button>\n <button\n type=\"button\"\n className={primaryBtn}\n onClick={handleActivate}\n disabled={!canActivate || activate.isPending}\n title={\n dirty\n ? tr('workflows.builder.saveFirst', 'Save your changes first')\n : issues.length > 0\n ? tr('workflows.builder.fixIssuesFirst', 'Fix the issues first')\n : undefined\n }\n >\n <Play className=\"h-4 w-4\" />{' '}\n {activate.isPending\n ? tr('common.activating', 'Activating…')\n : tr('workflows.flow.activate', 'Activate workflow')}\n </button>\n </>\n )}\n </div>\n </div>\n\n {notice && (\n <div\n role={notice.tone === 'error' ? 'alert' : 'status'}\n className={`mt-3 rounded-lg border px-4 py-2 text-sm ${\n notice.tone === 'error'\n ? 'border-status-error-text/30 bg-status-error-bg-subtle text-status-error-text'\n : 'border-status-success-text/30 bg-status-success-bg-subtle text-status-success-text'\n }`}\n >\n {notice.text}\n </div>\n )}\n {readOnly && (\n <p className=\"mt-3 text-sm text-text-secondary\">\n {tr(\n 'workflows.builder.readOnlyActive',\n 'This workflow is active, so it is shown read-only. Pause it to change its steps.'\n )}\n </p>\n )}\n\n <div className=\"mt-4 grid grid-cols-1 gap-4 lg:grid-cols-[13rem_minmax(0,1fr)_18rem]\">\n {/* Palette */}\n <GlassCard treatment=\"metric\" className=\"p-3\">\n <p className=\"mb-2 text-xs font-medium uppercase tracking-wide text-text-secondary\">\n {tr('workflows.builder.palette', 'Add a step')}\n </p>\n <div\n className=\"grid grid-cols-2 gap-2 lg:grid-cols-1\"\n role=\"group\"\n aria-label={tr('workflows.builder.palette', 'Add a step')}\n >\n {NODE_KINDS.map((kind) => {\n const meta = KIND_META[kind];\n const Icon = meta.icon;\n const disabled = editLocked || !canAddKind(kind, graph.nodes);\n return (\n <button\n key={kind}\n type=\"button\"\n disabled={disabled}\n onClick={() => addNode(kind)}\n title={tr(`${meta.labelKey}Hint`, meta.hint)}\n className=\"flex items-center gap-2 rounded-lg border border-border-subtle bg-bg-surface px-2.5 py-2 text-start text-sm text-text-primary hover:bg-bg-sunken disabled:cursor-not-allowed disabled:opacity-50\"\n >\n <Icon className=\"h-4 w-4 shrink-0 text-text-secondary\" />\n <span className=\"truncate\">{tr(meta.labelKey, meta.fallback)}</span>\n </button>\n );\n })}\n </div>\n </GlassCard>\n\n {/* Canvas */}\n <div\n className=\"h-[60vh] min-h-[420px] overflow-hidden rounded-xl border border-border-subtle bg-bg-sunken\"\n data-testid=\"workflow-canvas\"\n >\n {graph.nodes.length === 0 ? (\n <div className=\"flex h-full items-center justify-center p-6\">\n <EmptyState\n icon={<Zap className=\"h-10 w-10\" />}\n title={tr('workflows.builder.emptyTitle', 'Start with a trigger')}\n description={tr(\n 'workflows.builder.emptyDescription',\n 'Add a trigger from the palette, then connect the steps that should follow it.'\n )}\n />\n </div>\n ) : (\n <ReactFlow\n nodes={rfNodes}\n edges={rfEdges}\n nodeTypes={nodeTypes}\n onNodesChange={onNodesChange}\n onEdgesChange={onEdgesChange}\n onConnect={onConnect}\n onNodeClick={(_e, n) => {\n setSelectedNodeId(n.id);\n setSelectedEdgeId(null);\n }}\n onEdgeClick={(_e, e) => {\n setSelectedEdgeId(e.id);\n setSelectedNodeId(null);\n }}\n onPaneClick={() => {\n setSelectedNodeId(null);\n setSelectedEdgeId(null);\n }}\n nodesDraggable={!editLocked}\n nodesConnectable={!editLocked}\n deleteKeyCode={editLocked ? null : ['Backspace', 'Delete']}\n fitView\n fitViewOptions={{ padding: 0.2, maxZoom: 1.1 }}\n proOptions={{ hideAttribution: true }}\n >\n <Background color=\"var(--color-border-subtle)\" gap={20} />\n <Controls showInteractive={false} className={controlsCls} />\n </ReactFlow>\n )}\n </div>\n\n {/* Inspector + issues */}\n <div className=\"space-y-4\">\n <GlassCard treatment=\"metric\" className=\"p-4\">\n {selectedNode ? (\n <NodeInspector\n node={selectedNode}\n readOnly={editLocked}\n onChange={(patch) =>\n edit((g) => ({\n nodes: g.nodes.map((n) => (n.id === selectedNode.id ? { ...n, ...patch } : n)),\n edges: g.edges,\n }))\n }\n onDelete={() => {\n edit((g) => removeNode(g, selectedNode.id));\n setSelectedNodeId(null);\n }}\n />\n ) : selectedEdgeId && !editLocked ? (\n <div className=\"space-y-3\">\n <p className=\"text-sm text-text-primary\">\n {tr('workflows.builder.edgeSelected', 'Connection selected')}\n </p>\n <button\n type=\"button\"\n onClick={() => {\n edit((g) => ({\n nodes: g.nodes,\n edges: g.edges.filter((e) => e.id !== selectedEdgeId),\n }));\n setSelectedEdgeId(null);\n }}\n className=\"inline-flex items-center gap-1.5 rounded-lg border border-status-error-text/40 px-3 py-1.5 text-xs font-medium text-status-error-text hover:bg-status-error-bg-subtle\"\n >\n <Trash2 className=\"h-3.5 w-3.5\" />{' '}\n {tr('workflows.builder.deleteEdge', 'Delete connection')}\n </button>\n </div>\n ) : (\n <p className=\"text-sm text-text-secondary\">\n {tr(\n 'workflows.builder.inspectorEmpty',\n 'Select a node to edit it. Drag from a node’s right edge to another node to connect them.'\n )}\n </p>\n )}\n </GlassCard>\n\n <GlassCard treatment=\"metric\" className=\"p-4\" data-testid=\"workflow-issues\">\n <p className=\"mb-2 text-xs font-medium uppercase tracking-wide text-text-secondary\">\n {tr('workflows.builder.issues', 'Validation')}\n </p>\n {dirty ? (\n <p className=\"text-sm text-text-secondary\">\n {tr('workflows.builder.issuesAfterSave', 'Save to check the workflow.')}\n </p>\n ) : issues.length === 0 ? (\n <p className=\"inline-flex items-center gap-1.5 text-sm text-status-success-text\">\n <CheckCircle2 className=\"h-4 w-4\" />{' '}\n {tr('workflows.builder.noIssues', 'No issues found')}\n </p>\n ) : (\n <ul className=\"space-y-2\">\n {issues.map((issue, i) => (\n <li key={`${issue.code}-${issue.nodeId ?? issue.edgeId ?? i}`}>\n <button\n type=\"button\"\n className=\"flex w-full items-start gap-2 text-start text-sm text-text-primary hover:underline disabled:no-underline\"\n disabled={!issue.nodeId}\n onClick={() => issue.nodeId && setSelectedNodeId(issue.nodeId)}\n >\n <AlertTriangle className=\"mt-0.5 h-4 w-4 shrink-0 text-status-warning-text\" />\n <span>{issue.message}</span>\n </button>\n </li>\n ))}\n </ul>\n )}\n </GlassCard>\n </div>\n </div>\n </>\n );\n}\n\nexport function WorkflowBuilderPage() {\n const { id } = useParams<{ id: string }>();\n const tr = useTr();\n const { navigateTo } = useSubscriberBot();\n const { data, isLoading, isError, refetch } = useWorkflow(id);\n\n return (\n <PageLayout\n title={data?.name ?? tr('workflows.builder.title', 'Workflow builder')}\n description={\n data\n ? tr('workflows.builder.subtitle', 'Visual builder · starts on {{trigger}}', {\n trigger: data.triggerEvent || '—',\n })\n : undefined\n }\n actions={\n <button\n type=\"button\"\n className={secondaryBtn}\n onClick={() => navigateTo(id ? `/workflows/${id}` : '/workflows')}\n >\n <ArrowLeft className=\"rtl:rotate-180 h-4 w-4\" />{' '}\n {tr('workflows.builder.back', 'Workflows')}\n </button>\n }\n >\n {isLoading ? (\n <LoadingView label={tr('workflows.builder.loading', 'Loading workflow…')} />\n ) : isError ? (\n <ErrorView\n message={tr('workflows.builder.error', 'Could not load this workflow.')}\n onRetry={() => void refetch()}\n />\n ) : !data ? (\n <EmptyState\n title={tr('workflows.builder.notFound', 'Workflow not found')}\n description={tr(\n 'workflows.builder.notFoundDescription',\n 'It may have been deleted, or it belongs to another workspace.'\n )}\n />\n ) : (\n // Keyed by workflow id so moving to another workflow starts a fresh\n // editor instead of carrying the previous workflow's unsaved graph.\n <WorkflowBuilder key={data.id} workflow={data} />\n )}\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAiFA,IAAM,IACJ,4NACI,IAAW,sDACX,IACJ,kKACI,IACJ,gKAEI,IASF;CACF,SAAS;EACP,MAAM;EACN,KAAK;EACL,UAAU;EACV,UAAU;EACV,MAAM;CACR;CACA,QAAQ;EACN,MAAM;EACN,KAAK;EACL,UAAU;EACV,UAAU;EACV,MAAM;CACR;CACA,WAAW;EACT,MAAM;EACN,KAAK;EACL,UAAU;EACV,UAAU;EACV,MAAM;CACR;CACA,OAAO;EACL,MAAM;EACN,KAAK;EACL,UAAU;EACV,UAAU;EACV,MAAM;CACR;CACA,QAAQ;EACN,MAAM;EACN,KAAK;EACL,UAAU;EACV,UAAU;EACV,MAAM;CACR;AACF,GAEM,IAAuD;CAC3D,QAAQ;CACR,OAAO;CACP,aAAa;CACb,qBAAqB;CACrB,UAAU;CACV,mBAAmB;CACnB,cAAc;AAChB,GAMM,KAAc;CAClB;CACA;CACA;CACA;CACA;CACA;CACA;AACF,EAAE,KAAK,GAAG,GACJ,IAAc;CAAE,YAAY;CAA+B,OAAO;CAAI,QAAQ;AAAG;AAWvF,SAAS,EAAiB,EAAE,SAAM,eAAmC;CACnE,IAAM,IAAK,EAAM,GACX,IAAO,EAAU,EAAK,OACtB,IAAO,EAAK;CAClB,OACE,kBAAC,OAAD;EACE,eAAa,iBAAiB,EAAK,KAAK,YAAY;E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