@flowdrop/flowdrop 2.0.1 → 2.1.1

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.
Files changed (35) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/commands/executor.js +4 -1
  3. package/dist/commands/types.d.ts +4 -0
  4. package/dist/components/App.svelte +122 -12
  5. package/dist/components/WorkflowInterfaceEditor.svelte +941 -0
  6. package/dist/components/WorkflowInterfaceEditor.svelte.d.ts +14 -0
  7. package/dist/components/form/FormPorts.svelte +34 -2
  8. package/dist/components/nodes/GatewayNode.svelte +13 -1
  9. package/dist/components/nodes/SimpleNode.svelte +11 -0
  10. package/dist/components/nodes/SquareNode.svelte +11 -0
  11. package/dist/components/nodes/TerminalNode.svelte +11 -0
  12. package/dist/components/nodes/WorkflowNode.svelte +11 -2
  13. package/dist/core/index.d.ts +1 -1
  14. package/dist/messages/defaults.d.ts +42 -0
  15. package/dist/messages/defaults.js +34 -0
  16. package/dist/openapi/v1/openapi.yaml +105 -0
  17. package/dist/schemas/v1/workflow.schema.json +109 -0
  18. package/dist/services/globalSave.js +9 -2
  19. package/dist/services/workflowLaunchService.d.ts +13 -1
  20. package/dist/services/workflowLaunchService.js +8 -0
  21. package/dist/stores/workflowStore.svelte.d.ts +22 -0
  22. package/dist/stores/workflowStore.svelte.js +18 -0
  23. package/dist/styles/base.css +10 -0
  24. package/dist/types/index.d.ts +58 -4
  25. package/dist/utils/colors.d.ts +1 -2
  26. package/dist/utils/colors.js +1 -2
  27. package/dist/utils/connections.d.ts +5 -0
  28. package/dist/utils/connections.js +1 -1
  29. package/dist/utils/nodeSwap.d.ts +9 -0
  30. package/dist/utils/nodeSwap.js +50 -2
  31. package/dist/utils/portUtils.d.ts +0 -2
  32. package/dist/utils/portUtils.js +0 -2
  33. package/dist/utils/workflowInterface.d.ts +208 -0
  34. package/dist/utils/workflowInterface.js +391 -0
  35. package/package.json +1 -1
@@ -0,0 +1,941 @@
1
+ <!--
2
+ WorkflowInterfaceEditor Component
3
+
4
+ The canonical panel editor for a workflow's public contract
5
+ (`Workflow.interface` — see `.claude/plans/workflow-interface.md`, decision 6:
6
+ "one canonical authoring surface, plus optional additions"). Two sections —
7
+ Inputs and Outputs — each a list of entries with add / remove / reorder, a
8
+ binding picker limited to the workflow's canvas-exposed ports for that
9
+ direction (decision 3: external ⊂ internal), and a per-entry, in-words
10
+ explanation of every `resolveInterface` status plus any `validateWorkflowInterface`
11
+ issue. This prose obligation is what makes this surface canonical — no other
12
+ authoring surface (the future rail, the port-row shortcut) carries it.
13
+
14
+ Follows `SwapMappingEditor.svelte` / `PortMappingRow.svelte` for the "pick a
15
+ port, show its type" interaction shape, and `FormPorts.svelte` for the
16
+ up/down reorder idiom.
17
+
18
+ Stateless: reads `workflow` as a prop and reports the next `WorkflowInterface`
19
+ via `onChange`. The caller (`App.svelte`) is responsible for routing that
20
+ through the workflow store (`fd.workflow.batchUpdate({ interface: next })`),
21
+ so every edit here goes through the store's normal history path.
22
+
23
+ `meta` is never editable here (design decision 4) — it round-trips verbatim
24
+ and is shown as a read-only JSON disclosure when present.
25
+ -->
26
+
27
+ <script lang="ts">
28
+ import Icon from '@iconify/svelte';
29
+ import { m } from '../messages/index.js';
30
+ import { buildHandleId } from '../utils/handleIds.js';
31
+ import { DEFAULT_PORT_CONFIG } from '../config/defaultPortConfig.js';
32
+ import type {
33
+ PortDataTypeConfig,
34
+ Workflow,
35
+ WorkflowInterface,
36
+ WorkflowInterfaceEntry
37
+ } from '../types/index.js';
38
+ import {
39
+ describeInterfaceEntryStatus,
40
+ listBindablePorts,
41
+ pullEntryFieldsFromPort,
42
+ resolveInterface,
43
+ validateWorkflowInterface,
44
+ type InterfaceIssue,
45
+ type ResolvedInterfaceEntry
46
+ } from '../utils/workflowInterface.js';
47
+
48
+ interface Props {
49
+ workflow: Workflow;
50
+ onChange: (next: WorkflowInterface | undefined) => void;
51
+ /**
52
+ * The data-type vocabulary offered by the dataType picker — the host's
53
+ * live `PortConfig.dataTypes` (pass `portCompatibility.getEnabledDataTypes()`).
54
+ * The wire format stays an open string; this only constrains *authoring*.
55
+ */
56
+ dataTypes?: PortDataTypeConfig[];
57
+ }
58
+
59
+ const {
60
+ workflow,
61
+ onChange,
62
+ dataTypes = DEFAULT_PORT_CONFIG.dataTypes.filter((dt) => dt.enabled !== false)
63
+ }: Props = $props();
64
+
65
+ /**
66
+ * Options for one entry's dataType select: the configured vocabulary, plus
67
+ * the entry's current value when it isn't in it (a host-custom or legacy
68
+ * type) — a select must never silently rewrite a stored value it can't list.
69
+ */
70
+ function dataTypeOptions(current: string): Array<{ id: string; name: string }> {
71
+ const options = dataTypes.map((dt) => ({ id: dt.id, name: dt.name }));
72
+ if (current && !dataTypes.some((dt) => dt.id === current || dt.aliases?.includes(current))) {
73
+ options.push({ id: current, name: current });
74
+ }
75
+ return options;
76
+ }
77
+
78
+ type Direction = 'inputs' | 'outputs';
79
+
80
+ const SECTIONS: Array<{ key: Direction; entryDirection: 'input' | 'output' }> = [
81
+ { key: 'inputs', entryDirection: 'input' },
82
+ { key: 'outputs', entryDirection: 'output' }
83
+ ];
84
+
85
+ function entriesFor(direction: Direction): WorkflowInterfaceEntry[] {
86
+ return (
87
+ (direction === 'inputs' ? workflow.interface?.inputs : workflow.interface?.outputs) ?? []
88
+ );
89
+ }
90
+
91
+ const resolved = $derived(resolveInterface(workflow));
92
+ const issues = $derived(validateWorkflowInterface(workflow));
93
+
94
+ function entryDirectionOf(direction: Direction): 'input' | 'output' {
95
+ return direction === 'inputs' ? 'input' : 'output';
96
+ }
97
+
98
+ function statusFor(direction: Direction, entryId: string): ResolvedInterfaceEntry | undefined {
99
+ const dir = entryDirectionOf(direction);
100
+ return resolved.find((r) => r.direction === dir && r.entry.id === entryId);
101
+ }
102
+
103
+ function issuesFor(direction: Direction, entryId: string): InterfaceIssue[] {
104
+ const dir = entryDirectionOf(direction);
105
+ return issues.filter((i) => i.direction === dir && i.entryId === entryId);
106
+ }
107
+
108
+ /**
109
+ * Issues rendered in the card's footer. Excludes what is already shown
110
+ * elsewhere in the card: the resolved status (validation re-emits every
111
+ * non-ok status as an `interface-<status>` issue — rendering both printed
112
+ * the same sentence twice) and the two issues that render inline next to
113
+ * their own field (type mismatch under Data type, already-connected under
114
+ * Bound port).
115
+ */
116
+ const INLINE_ISSUE_CODES = new Set([
117
+ 'interface-type-mismatch',
118
+ 'interface-input-already-connected'
119
+ ]);
120
+
121
+ function footerIssues(
122
+ direction: Direction,
123
+ entryId: string,
124
+ status: ResolvedInterfaceEntry | undefined
125
+ ): InterfaceIssue[] {
126
+ const statusEcho = status ? `interface-${status.status}` : '';
127
+ return issuesFor(direction, entryId).filter(
128
+ (issue) => issue.code !== statusEcho && !INLINE_ISSUE_CODES.has(issue.code)
129
+ );
130
+ }
131
+
132
+ /** The bound port's own dataType, when the single binding resolves. */
133
+ function boundPortType(status: ResolvedInterfaceEntry | undefined): string | undefined {
134
+ return status?.targets[0]?.port.dataType;
135
+ }
136
+
137
+ function hasIssue(direction: Direction, entryId: string, code: string): boolean {
138
+ return issuesFor(direction, entryId).some((issue) => issue.code === code);
139
+ }
140
+
141
+ /**
142
+ * For an input whose bound port already has an incoming edge: the label of
143
+ * the node feeding that edge, so the conflict message can name the actual
144
+ * competing source instead of describing it abstractly.
145
+ */
146
+ function conflictingSourceLabel(entry: WorkflowInterfaceEntry): string | undefined {
147
+ const binding = entry.bindings[0];
148
+ if (!binding) return undefined;
149
+ const handleId = buildHandleId(binding.nodeId, 'input', binding.portId);
150
+ const edge = workflow.edges.find((e) => e.targetHandle === handleId);
151
+ if (!edge) return undefined;
152
+ const source = workflow.nodes.find((n) => n.id === edge.source);
153
+ return source?.data?.label ?? edge.source;
154
+ }
155
+
156
+ /** Statuses still explained in the card footer (the rest render inline or as the dot). */
157
+ const FOOTER_STATUSES = new Set(['unbound', 'dangling', 'hidden', 'over-bound']);
158
+
159
+ function bindablePorts(direction: Direction) {
160
+ return listBindablePorts(workflow, entryDirectionOf(direction));
161
+ }
162
+
163
+ function bindingKey(nodeId: string, portId: string): string {
164
+ return `${nodeId}::${portId}`;
165
+ }
166
+
167
+ /** The entry's current single binding, as a picker value (`''` = unbound). */
168
+ function currentBindingValue(entry: WorkflowInterfaceEntry): string {
169
+ const binding = entry.bindings[0];
170
+ return binding ? bindingKey(binding.nodeId, binding.portId) : '';
171
+ }
172
+
173
+ function nextId(direction: Direction): string {
174
+ const prefix = direction === 'inputs' ? 'input' : 'output';
175
+ const existing = new Set(entriesFor(direction).map((e) => e.id));
176
+ let n = existing.size + 1;
177
+ let candidate = `${prefix}_${n}`;
178
+ while (existing.has(candidate)) {
179
+ n += 1;
180
+ candidate = `${prefix}_${n}`;
181
+ }
182
+ return candidate;
183
+ }
184
+
185
+ /**
186
+ * Commit a direction's entry list back to the workflow, collapsing to
187
+ * `undefined` when the whole interface ends up empty (decision 5: additive
188
+ * and optional — an interface nobody populated should not linger as `{}`).
189
+ */
190
+ function commit(direction: Direction, next: WorkflowInterfaceEntry[]): void {
191
+ const inputs = direction === 'inputs' ? next : (workflow.interface?.inputs ?? []);
192
+ const outputs = direction === 'outputs' ? next : (workflow.interface?.outputs ?? []);
193
+ const cleanedInputs = inputs.length > 0 ? inputs : undefined;
194
+ const cleanedOutputs = outputs.length > 0 ? outputs : undefined;
195
+ if (!cleanedInputs && !cleanedOutputs) {
196
+ onChange(undefined);
197
+ return;
198
+ }
199
+ onChange({ inputs: cleanedInputs, outputs: cleanedOutputs });
200
+ }
201
+
202
+ function addEntry(direction: Direction): void {
203
+ const entry: WorkflowInterfaceEntry = { id: nextId(direction), dataType: '', bindings: [] };
204
+ commit(direction, [...entriesFor(direction), entry]);
205
+ }
206
+
207
+ function removeEntry(direction: Direction, index: number): void {
208
+ commit(
209
+ direction,
210
+ entriesFor(direction).filter((_, i) => i !== index)
211
+ );
212
+ }
213
+
214
+ function moveEntry(direction: Direction, index: number, delta: -1 | 1): void {
215
+ const list = [...entriesFor(direction)];
216
+ const target = index + delta;
217
+ if (target < 0 || target >= list.length) return;
218
+ [list[index], list[target]] = [list[target], list[index]];
219
+ commit(direction, list);
220
+ }
221
+
222
+ function patchEntry(
223
+ direction: Direction,
224
+ index: number,
225
+ patch: Partial<WorkflowInterfaceEntry>
226
+ ): void {
227
+ const list = entriesFor(direction).map((entry, i) =>
228
+ i === index ? { ...entry, ...patch } : entry
229
+ );
230
+ commit(direction, list);
231
+ }
232
+
233
+ function handleBindingChange(direction: Direction, index: number, value: string): void {
234
+ if (!value) {
235
+ patchEntry(direction, index, { bindings: [] });
236
+ return;
237
+ }
238
+ const [nodeId, portId] = value.split('::');
239
+ const patch: Partial<WorkflowInterfaceEntry> = { bindings: [{ nodeId, portId }] };
240
+ // Convenience default: prefill an empty dataType from the picked port's own
241
+ // type. The field stays freely editable afterward — this only saves the
242
+ // common case of typing out what the port already declares.
243
+ const entry = entriesFor(direction)[index];
244
+ if (entry && !entry.dataType) {
245
+ const match = bindablePorts(direction).find(
246
+ (b) => b.nodeId === nodeId && b.port.id === portId
247
+ );
248
+ if (match) patch.dataType = match.port.dataType;
249
+ }
250
+ patchEntry(direction, index, patch);
251
+ }
252
+
253
+ /**
254
+ * Write one example slot back, dropping empties and collapsing an empty
255
+ * list to `undefined` so an untouched entry stores no `examples` key.
256
+ */
257
+ function patchExample(
258
+ direction: Direction,
259
+ index: number,
260
+ entry: WorkflowInterfaceEntry,
261
+ exampleIndex: number,
262
+ raw: string
263
+ ): void {
264
+ const next = [...(entry.examples ?? [])];
265
+ if (raw === '') next.splice(exampleIndex, 1);
266
+ else next[exampleIndex] = parseDefaultValue(raw);
267
+ patchEntry(direction, index, { examples: next.length > 0 ? next : undefined });
268
+ }
269
+
270
+ function addExample(direction: Direction, index: number, entry: WorkflowInterfaceEntry): void {
271
+ patchEntry(direction, index, { examples: [...(entry.examples ?? []), ''] });
272
+ }
273
+
274
+ function removeExample(
275
+ direction: Direction,
276
+ index: number,
277
+ entry: WorkflowInterfaceEntry,
278
+ exampleIndex: number
279
+ ): void {
280
+ const next = (entry.examples ?? []).filter((_, i) => i !== exampleIndex);
281
+ patchEntry(direction, index, { examples: next.length > 0 ? next : undefined });
282
+ }
283
+
284
+ function parseDefaultValue(raw: string): unknown {
285
+ if (raw === '') return undefined;
286
+ try {
287
+ return JSON.parse(raw);
288
+ } catch {
289
+ return raw;
290
+ }
291
+ }
292
+
293
+ function formatDefaultValue(value: unknown): string {
294
+ if (value === undefined) return '';
295
+ return typeof value === 'string' ? value : JSON.stringify(value);
296
+ }
297
+ </script>
298
+
299
+ <div class="wf-interface">
300
+ {#each SECTIONS as section (section.key)}
301
+ {@const list = entriesFor(section.key)}
302
+ <div class="wf-interface__section">
303
+ <div class="wf-interface__section-header">
304
+ <h4 class="wf-interface__section-title">
305
+ {section.key === 'inputs'
306
+ ? m().workflowInterface.inputsHeading
307
+ : m().workflowInterface.outputsHeading}
308
+ </h4>
309
+ <button type="button" class="wf-interface__add" onclick={() => addEntry(section.key)}>
310
+ <Icon icon="heroicons:plus" />
311
+ {section.key === 'inputs'
312
+ ? m().workflowInterface.addInput
313
+ : m().workflowInterface.addOutput}
314
+ </button>
315
+ </div>
316
+
317
+ {#if list.length === 0}
318
+ <p class="wf-interface__empty">
319
+ {section.key === 'inputs'
320
+ ? m().workflowInterface.noInputs
321
+ : m().workflowInterface.noOutputs}
322
+ </p>
323
+ {:else}
324
+ <ul class="wf-interface__list">
325
+ {#each list as entry, index (index)}
326
+ {@const status = statusFor(section.key, entry.id)}
327
+ <li
328
+ class="wf-interface__entry"
329
+ class:wf-interface__entry--error={status?.status &&
330
+ status.status !== 'ok' &&
331
+ status.status !== 'unbound'}
332
+ >
333
+ {#if status}
334
+ <span
335
+ class="wf-interface__dot wf-interface__dot--{status.status}"
336
+ title={describeInterfaceEntryStatus(status)}
337
+ ></span>
338
+ {/if}
339
+ <div class="wf-interface__reorder">
340
+ <button
341
+ type="button"
342
+ disabled={index === 0}
343
+ onclick={() => moveEntry(section.key, index, -1)}
344
+ aria-label={m().workflowInterface.moveUp({ id: entry.id })}
345
+ >
346
+ <Icon icon="heroicons:chevron-up" />
347
+ </button>
348
+ <button
349
+ type="button"
350
+ disabled={index === list.length - 1}
351
+ onclick={() => moveEntry(section.key, index, 1)}
352
+ aria-label={m().workflowInterface.moveDown({ id: entry.id })}
353
+ >
354
+ <Icon icon="heroicons:chevron-down" />
355
+ </button>
356
+ </div>
357
+
358
+ <div class="wf-interface__fields">
359
+ <div class="wf-interface__row">
360
+ <label class="wf-interface__field wf-interface__field--id">
361
+ <span class="wf-interface__label">{m().workflowInterface.idLabel}</span>
362
+ <input
363
+ type="text"
364
+ value={entry.id}
365
+ onchange={(e) =>
366
+ patchEntry(section.key, index, { id: e.currentTarget.value })}
367
+ />
368
+ </label>
369
+ <label class="wf-interface__field wf-interface__field--wide">
370
+ <span class="wf-interface__label">{m().workflowInterface.bindingLabel}</span>
371
+ <select
372
+ value={currentBindingValue(entry)}
373
+ onchange={(e) =>
374
+ handleBindingChange(section.key, index, e.currentTarget.value)}
375
+ >
376
+ <option value="">{m().workflowInterface.bindingUnbound}</option>
377
+ {#each bindablePorts(section.key) as candidate (bindingKey(candidate.nodeId, candidate.port.id))}
378
+ <option value={bindingKey(candidate.nodeId, candidate.port.id)}>
379
+ {candidate.nodeLabel} — {candidate.port.name} ({candidate.port.dataType})
380
+ </option>
381
+ {/each}
382
+ </select>
383
+ {#if section.key === 'inputs' && hasIssue(section.key, entry.id, 'interface-input-already-connected')}
384
+ <span class="wf-interface__inline wf-interface__inline--error">
385
+ {m().workflowInterface.alreadyConnectedInline({
386
+ source: conflictingSourceLabel(entry) ?? ''
387
+ })}
388
+ </span>
389
+ {/if}
390
+ </label>
391
+ {#if status?.targets[0]}
392
+ <button
393
+ type="button"
394
+ class="wf-interface__pull"
395
+ title={m().workflowInterface.pullFromPortTitle}
396
+ onclick={() =>
397
+ patchEntry(
398
+ section.key,
399
+ index,
400
+ pullEntryFieldsFromPort(status.targets[0].port)
401
+ )}
402
+ >
403
+ <Icon icon="heroicons:arrow-down-tray" />
404
+ {m().workflowInterface.pullFromPort}
405
+ </button>
406
+ {/if}
407
+ </div>
408
+
409
+ <details
410
+ class="wf-interface__more"
411
+ open={status?.status === 'type-mismatch' || undefined}
412
+ >
413
+ <summary>{m().workflowInterface.moreOptions}</summary>
414
+ <div class="wf-interface__row">
415
+ <label class="wf-interface__field">
416
+ <span class="wf-interface__label">{m().workflowInterface.nameLabel}</span>
417
+ <input
418
+ type="text"
419
+ value={entry.name ?? ''}
420
+ placeholder={m().workflowInterface.namePlaceholder}
421
+ onchange={(e) =>
422
+ patchEntry(section.key, index, {
423
+ name: e.currentTarget.value || undefined
424
+ })}
425
+ />
426
+ </label>
427
+ <label class="wf-interface__field">
428
+ <span class="wf-interface__label">{m().workflowInterface.dataTypeLabel}</span>
429
+ <select
430
+ value={entry.dataType}
431
+ onchange={(e) =>
432
+ patchEntry(section.key, index, { dataType: e.currentTarget.value })}
433
+ >
434
+ {#if !entry.dataType}
435
+ <option value="" disabled selected>
436
+ {m().workflowInterface.dataTypePlaceholder}
437
+ </option>
438
+ {/if}
439
+ {#each dataTypeOptions(entry.dataType) as option (option.id)}
440
+ <option value={option.id}>{option.name}</option>
441
+ {/each}
442
+ </select>
443
+ {#if status?.status === 'type-mismatch' && boundPortType(status)}
444
+ <span class="wf-interface__inline wf-interface__inline--warning">
445
+ {m().workflowInterface.typeMismatchInline({
446
+ portType: boundPortType(status) ?? ''
447
+ })}
448
+ <button
449
+ type="button"
450
+ class="wf-interface__quickfix"
451
+ onclick={() =>
452
+ patchEntry(section.key, index, {
453
+ dataType: boundPortType(status) ?? entry.dataType
454
+ })}
455
+ >
456
+ {m().workflowInterface.useMatchPortType}
457
+ </button>
458
+ </span>
459
+ {/if}
460
+ </label>
461
+ {#if section.key === 'inputs'}
462
+ <label class="wf-interface__field wf-interface__field--checkbox">
463
+ <input
464
+ type="checkbox"
465
+ checked={entry.required ?? false}
466
+ onchange={(e) =>
467
+ patchEntry(section.key, index, {
468
+ required: e.currentTarget.checked || undefined
469
+ })}
470
+ />
471
+ <span class="wf-interface__label"
472
+ >{m().workflowInterface.requiredLabel}</span
473
+ >
474
+ </label>
475
+ {/if}
476
+ </div>
477
+
478
+ <div class="wf-interface__row">
479
+ <label class="wf-interface__field wf-interface__field--wide">
480
+ <span class="wf-interface__label"
481
+ >{m().workflowInterface.descriptionLabel}</span
482
+ >
483
+ <input
484
+ type="text"
485
+ value={entry.description ?? ''}
486
+ onchange={(e) =>
487
+ patchEntry(section.key, index, {
488
+ description: e.currentTarget.value || undefined
489
+ })}
490
+ />
491
+ </label>
492
+ <label class="wf-interface__field">
493
+ <span class="wf-interface__label"
494
+ >{m().workflowInterface.defaultValueLabel}</span
495
+ >
496
+ <input
497
+ type="text"
498
+ value={formatDefaultValue(entry.defaultValue)}
499
+ onchange={(e) =>
500
+ patchEntry(section.key, index, {
501
+ defaultValue: parseDefaultValue(e.currentTarget.value)
502
+ })}
503
+ />
504
+ </label>
505
+ </div>
506
+
507
+ {#if section.key === 'inputs'}
508
+ <div class="wf-interface__examples">
509
+ <span class="wf-interface__label">
510
+ {m().workflowInterface.examplesLabel}
511
+ </span>
512
+ {#each entry.examples ?? [] as example, exampleIndex (exampleIndex)}
513
+ <div class="wf-interface__example-row">
514
+ <input
515
+ type="text"
516
+ value={formatDefaultValue(example)}
517
+ onchange={(e) =>
518
+ patchExample(
519
+ section.key,
520
+ index,
521
+ entry,
522
+ exampleIndex,
523
+ e.currentTarget.value
524
+ )}
525
+ />
526
+ <button
527
+ type="button"
528
+ class="wf-interface__example-remove"
529
+ onclick={() => removeExample(section.key, index, entry, exampleIndex)}
530
+ aria-label={m().workflowInterface.removeExample}
531
+ >
532
+ <Icon icon="heroicons:x-mark" />
533
+ </button>
534
+ </div>
535
+ {/each}
536
+ <button
537
+ type="button"
538
+ class="wf-interface__example-add"
539
+ onclick={() => addExample(section.key, index, entry)}
540
+ >
541
+ <Icon icon="heroicons:plus" />
542
+ {m().workflowInterface.addExample}
543
+ </button>
544
+ </div>
545
+ {/if}
546
+ </details>
547
+
548
+ <!-- Every resolveInterface status renders in words somewhere in
549
+ this card — the obligation that makes this surface
550
+ canonical. `ok` lives on the header dot; type-mismatch and
551
+ already-connected render inline next to their own field;
552
+ the rest are explained here. -->
553
+ {#if status && FOOTER_STATUSES.has(status.status)}
554
+ <p class="wf-interface__status wf-interface__status--{status.status}">
555
+ {describeInterfaceEntryStatus(status)}
556
+ </p>
557
+ {/if}
558
+ {#each footerIssues(section.key, entry.id, status) as issue (issue.code)}
559
+ <p class="wf-interface__status wf-interface__status--{issue.severity}">
560
+ {issue.message}
561
+ </p>
562
+ {/each}
563
+
564
+ {#if entry.meta && Object.keys(entry.meta).length > 0}
565
+ <details class="wf-interface__meta">
566
+ <summary>{m().workflowInterface.metaDisclosure}</summary>
567
+ <pre>{JSON.stringify(entry.meta, null, 2)}</pre>
568
+ </details>
569
+ {/if}
570
+ </div>
571
+
572
+ <button
573
+ type="button"
574
+ class="wf-interface__remove"
575
+ onclick={() => removeEntry(section.key, index)}
576
+ aria-label={m().workflowInterface.removeEntry({ id: entry.id })}
577
+ >
578
+ <Icon icon="heroicons:trash" />
579
+ </button>
580
+ </li>
581
+ {/each}
582
+ </ul>
583
+ {/if}
584
+ </div>
585
+ {/each}
586
+ </div>
587
+
588
+ <style>
589
+ .wf-interface {
590
+ display: flex;
591
+ flex-direction: column;
592
+ gap: var(--fd-space-lg, 1.5rem);
593
+ }
594
+
595
+ .wf-interface__section {
596
+ display: flex;
597
+ flex-direction: column;
598
+ gap: var(--fd-space-xs);
599
+ }
600
+
601
+ .wf-interface__section-header {
602
+ display: flex;
603
+ align-items: center;
604
+ justify-content: space-between;
605
+ }
606
+
607
+ .wf-interface__section-title {
608
+ margin: 0;
609
+ font-size: var(--fd-text-xs);
610
+ font-weight: 600;
611
+ color: var(--fd-muted-foreground);
612
+ text-transform: uppercase;
613
+ letter-spacing: 0.05em;
614
+ }
615
+
616
+ .wf-interface__add {
617
+ display: inline-flex;
618
+ align-items: center;
619
+ gap: 0.25rem;
620
+ padding: 0.25rem 0.5rem;
621
+ border-radius: var(--fd-radius-sm);
622
+ border: 1px solid var(--fd-border);
623
+ background: var(--fd-background);
624
+ color: var(--fd-foreground);
625
+ font-size: var(--fd-text-xs);
626
+ cursor: pointer;
627
+ }
628
+
629
+ .wf-interface__add:hover {
630
+ background: var(--fd-muted);
631
+ }
632
+
633
+ .wf-interface__empty {
634
+ margin: 0;
635
+ font-size: var(--fd-text-xs);
636
+ color: var(--fd-muted-foreground);
637
+ font-style: italic;
638
+ }
639
+
640
+ .wf-interface__list {
641
+ list-style: none;
642
+ margin: 0;
643
+ padding: 0;
644
+ display: flex;
645
+ flex-direction: column;
646
+ gap: var(--fd-space-xs);
647
+ }
648
+
649
+ .wf-interface__entry {
650
+ display: flex;
651
+ align-items: flex-start;
652
+ gap: var(--fd-space-xs);
653
+ padding: var(--fd-space-xs);
654
+ border: 1px solid var(--fd-border-muted);
655
+ border-radius: var(--fd-radius-md);
656
+ }
657
+
658
+ .wf-interface__entry--error {
659
+ border-color: color-mix(in srgb, var(--fd-error) 40%, var(--fd-border-muted));
660
+ }
661
+
662
+ .wf-interface__reorder {
663
+ display: flex;
664
+ flex-direction: column;
665
+ flex-shrink: 0;
666
+ }
667
+
668
+ .wf-interface__reorder button {
669
+ display: flex;
670
+ align-items: center;
671
+ justify-content: center;
672
+ padding: 0;
673
+ border: none;
674
+ background: none;
675
+ color: var(--fd-muted-foreground);
676
+ cursor: pointer;
677
+ }
678
+
679
+ .wf-interface__reorder button:disabled {
680
+ opacity: 0.3;
681
+ cursor: default;
682
+ }
683
+
684
+ .wf-interface__fields {
685
+ flex: 1;
686
+ min-width: 0;
687
+ display: flex;
688
+ flex-direction: column;
689
+ gap: var(--fd-space-xs);
690
+ }
691
+
692
+ .wf-interface__row {
693
+ display: flex;
694
+ flex-wrap: wrap;
695
+ gap: var(--fd-space-xs);
696
+ }
697
+
698
+ .wf-interface__field {
699
+ display: flex;
700
+ flex-direction: column;
701
+ gap: 0.125rem;
702
+ flex: 1;
703
+ min-width: 6rem;
704
+ }
705
+
706
+ .wf-interface__field--id {
707
+ flex: 0 0 8rem;
708
+ }
709
+
710
+ .wf-interface__field--wide {
711
+ flex: 1 1 100%;
712
+ }
713
+
714
+ .wf-interface__field--checkbox {
715
+ flex-direction: row;
716
+ align-items: center;
717
+ gap: 0.375rem;
718
+ flex: 0 0 auto;
719
+ }
720
+
721
+ .wf-interface__label {
722
+ font-size: var(--fd-text-xs);
723
+ color: var(--fd-muted-foreground);
724
+ }
725
+
726
+ .wf-interface__field input[type='text'],
727
+ .wf-interface__field select {
728
+ padding: 0.25rem 0.375rem;
729
+ border: 1px solid var(--fd-border);
730
+ border-radius: var(--fd-radius-sm);
731
+ background-color: var(--fd-background);
732
+ color: var(--fd-foreground);
733
+ font-size: var(--fd-text-xs);
734
+ }
735
+
736
+ /* Selects size to their longest option instead of truncating it. */
737
+ .wf-interface__field select {
738
+ min-width: 8rem;
739
+ width: max-content;
740
+ max-width: 100%;
741
+ }
742
+
743
+ /* Entry health at a glance; the title tooltip carries the words. */
744
+ .wf-interface__dot {
745
+ flex-shrink: 0;
746
+ width: 0.5rem;
747
+ height: 0.5rem;
748
+ margin-top: 0.5rem;
749
+ border-radius: 50%;
750
+ background-color: var(--fd-muted-foreground);
751
+ }
752
+
753
+ .wf-interface__dot--ok {
754
+ background-color: var(--fd-success);
755
+ }
756
+
757
+ .wf-interface__dot--type-mismatch,
758
+ .wf-interface__dot--unbound {
759
+ background-color: var(--fd-warning);
760
+ }
761
+
762
+ .wf-interface__dot--dangling,
763
+ .wf-interface__dot--hidden,
764
+ .wf-interface__dot--over-bound {
765
+ background-color: var(--fd-error);
766
+ }
767
+
768
+ /* Field-anchored feedback: one short line under the field it belongs to. */
769
+ .wf-interface__inline {
770
+ display: inline-flex;
771
+ align-items: baseline;
772
+ gap: 0.375rem;
773
+ font-size: var(--fd-text-xs);
774
+ line-height: 1.4;
775
+ }
776
+
777
+ .wf-interface__inline--warning {
778
+ color: var(--fd-warning);
779
+ }
780
+
781
+ .wf-interface__inline--error {
782
+ color: var(--fd-error);
783
+ }
784
+
785
+ .wf-interface__quickfix {
786
+ padding: 0 0.25rem;
787
+ border: 1px solid var(--fd-border);
788
+ border-radius: var(--fd-radius-sm);
789
+ background-color: var(--fd-background);
790
+ color: var(--fd-foreground);
791
+ font-size: var(--fd-text-xs);
792
+ cursor: pointer;
793
+ }
794
+
795
+ .wf-interface__quickfix:hover {
796
+ background-color: var(--fd-muted);
797
+ }
798
+
799
+ /* The secondary fields live behind a disclosure so a card's resting state
800
+ is just identity + binding. Auto-opened when a field inside needs eyes. */
801
+ .wf-interface__more {
802
+ font-size: var(--fd-text-xs);
803
+ }
804
+
805
+ .wf-interface__more > summary {
806
+ color: var(--fd-muted-foreground);
807
+ cursor: pointer;
808
+ user-select: none;
809
+ }
810
+
811
+ .wf-interface__more[open] > summary {
812
+ margin-bottom: var(--fd-space-xs);
813
+ }
814
+
815
+ .wf-interface__more > :global(.wf-interface__row + .wf-interface__row),
816
+ .wf-interface__more .wf-interface__examples {
817
+ margin-top: var(--fd-space-xs);
818
+ }
819
+
820
+ .wf-interface__pull {
821
+ display: inline-flex;
822
+ align-items: center;
823
+ gap: 0.25rem;
824
+ align-self: flex-end;
825
+ padding: 0.25rem 0.375rem;
826
+ border: 1px solid var(--fd-border);
827
+ border-radius: var(--fd-radius-sm);
828
+ background-color: var(--fd-background);
829
+ color: var(--fd-foreground);
830
+ font-size: var(--fd-text-xs);
831
+ white-space: nowrap;
832
+ cursor: pointer;
833
+ }
834
+
835
+ .wf-interface__pull:hover {
836
+ background-color: var(--fd-muted);
837
+ }
838
+
839
+ .wf-interface__examples {
840
+ display: flex;
841
+ flex-direction: column;
842
+ gap: 0.25rem;
843
+ }
844
+
845
+ .wf-interface__example-row {
846
+ display: flex;
847
+ align-items: center;
848
+ gap: 0.25rem;
849
+ }
850
+
851
+ .wf-interface__example-row input {
852
+ flex: 1;
853
+ padding: 0.25rem 0.375rem;
854
+ border: 1px solid var(--fd-border);
855
+ border-radius: var(--fd-radius-sm);
856
+ background-color: var(--fd-background);
857
+ color: var(--fd-foreground);
858
+ font-size: var(--fd-text-xs);
859
+ }
860
+
861
+ .wf-interface__example-remove {
862
+ display: inline-flex;
863
+ padding: 0.125rem;
864
+ border: none;
865
+ background: none;
866
+ color: var(--fd-muted-foreground);
867
+ cursor: pointer;
868
+ }
869
+
870
+ .wf-interface__example-remove:hover {
871
+ color: var(--fd-error);
872
+ }
873
+
874
+ .wf-interface__example-add {
875
+ display: inline-flex;
876
+ align-items: center;
877
+ gap: 0.25rem;
878
+ align-self: flex-start;
879
+ padding: 0.125rem 0.25rem;
880
+ border: none;
881
+ background: none;
882
+ color: var(--fd-muted-foreground);
883
+ font-size: var(--fd-text-xs);
884
+ cursor: pointer;
885
+ }
886
+
887
+ .wf-interface__example-add:hover {
888
+ color: var(--fd-foreground);
889
+ }
890
+
891
+ .wf-interface__status {
892
+ margin: 0;
893
+ font-size: var(--fd-text-xs);
894
+ line-height: 1.5;
895
+ color: var(--fd-muted-foreground);
896
+ }
897
+
898
+ .wf-interface__status--error,
899
+ .wf-interface__status--dangling,
900
+ .wf-interface__status--hidden,
901
+ .wf-interface__status--over-bound {
902
+ color: var(--fd-error);
903
+ }
904
+
905
+ .wf-interface__status--warning,
906
+ .wf-interface__status--unbound,
907
+ .wf-interface__status--type-mismatch {
908
+ color: var(--fd-warning);
909
+ }
910
+
911
+ .wf-interface__meta {
912
+ font-size: var(--fd-text-xs);
913
+ color: var(--fd-muted-foreground);
914
+ }
915
+
916
+ .wf-interface__meta pre {
917
+ margin: 0.25rem 0 0;
918
+ padding: 0.375rem;
919
+ background: var(--fd-muted);
920
+ border-radius: var(--fd-radius-sm);
921
+ overflow-x: auto;
922
+ }
923
+
924
+ .wf-interface__remove {
925
+ flex-shrink: 0;
926
+ display: flex;
927
+ align-items: center;
928
+ justify-content: center;
929
+ padding: 0.25rem;
930
+ border: none;
931
+ background: none;
932
+ color: var(--fd-muted-foreground);
933
+ cursor: pointer;
934
+ border-radius: var(--fd-radius-sm);
935
+ }
936
+
937
+ .wf-interface__remove:hover {
938
+ color: var(--fd-error);
939
+ background-color: color-mix(in srgb, var(--fd-error) 10%, transparent);
940
+ }
941
+ </style>