@flowdrop/flowdrop 2.10.1 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/CHANGELOG.md +162 -0
  2. package/dist/components/App.svelte +112 -29
  3. package/dist/components/ConfigForm.svelte +5 -5
  4. package/dist/components/ConfigModal.svelte +2 -2
  5. package/dist/components/ConfigModal.svelte.d.ts +1 -1
  6. package/dist/components/ConnectionLine.svelte +1 -1
  7. package/dist/components/LogsSidebar.svelte +15 -12
  8. package/dist/components/MarkdownDisplay.svelte +1 -1
  9. package/dist/components/PipelineStatus.svelte +5 -18
  10. package/dist/components/SchemaForm.svelte +1 -1
  11. package/dist/components/SettingsModal.svelte +1 -1
  12. package/dist/components/SettingsPanel.svelte +1 -1
  13. package/dist/components/WorkflowEditor.svelte +63 -37
  14. package/dist/components/WorkflowInterfaceEditor.svelte +43 -8
  15. package/dist/components/WorkflowInterfaceEditor.svelte.d.ts +12 -1
  16. package/dist/components/WorkflowInterfaceEntryCard.svelte +117 -44
  17. package/dist/components/WorkflowInterfaceEntryCard.svelte.d.ts +14 -1
  18. package/dist/components/WorkflowPlaygroundSettings.svelte +551 -0
  19. package/dist/components/WorkflowPlaygroundSettings.svelte.d.ts +20 -0
  20. package/dist/components/chat/AIChatPanel.svelte +1 -1
  21. package/dist/components/form/index.d.ts +2 -2
  22. package/dist/components/form/index.js +2 -2
  23. package/dist/components/nodes/ToolNode.svelte +1 -1
  24. package/dist/components/playground/ControlPanel.svelte +30 -0
  25. package/dist/components/playground/ControlPanel.svelte.d.ts +5 -0
  26. package/dist/components/playground/Playground.svelte +94 -42
  27. package/dist/components/playground/PlaygroundApp.svelte +1 -1
  28. package/dist/components/playground/PlaygroundModal.svelte +1 -1
  29. package/dist/components/playground/PlaygroundStudio.svelte +1 -1
  30. package/dist/core/index.d.ts +1 -1
  31. package/dist/helpers/workflowEditorHelper.d.ts +12 -0
  32. package/dist/helpers/workflowEditorHelper.js +31 -0
  33. package/dist/messages/defaults.d.ts +53 -0
  34. package/dist/messages/defaults.js +48 -2
  35. package/dist/openapi/v1/openapi.yaml +113 -5
  36. package/dist/playground/index.d.ts +3 -1
  37. package/dist/playground/index.js +2 -1
  38. package/dist/playground/mount.d.ts +6 -10
  39. package/dist/playground/mount.js +43 -24
  40. package/dist/schemas/index.js +1 -1
  41. package/dist/schemas/v1/workflow.schema.json +140 -2
  42. package/dist/services/globalSave.js +11 -1
  43. package/dist/services/playgroundService.d.ts +6 -1
  44. package/dist/services/playgroundService.js +5 -0
  45. package/dist/skins/default.d.ts +1 -1
  46. package/dist/skins/drafter.d.ts +1 -1
  47. package/dist/skins/index.d.ts +4 -4
  48. package/dist/skins/index.js +3 -3
  49. package/dist/skins/slate.d.ts +1 -1
  50. package/dist/stores/instanceContainer.svelte.d.ts +15 -0
  51. package/dist/stores/instanceContainer.svelte.js +11 -1
  52. package/dist/stores/playgroundStore.svelte.d.ts +8 -0
  53. package/dist/stores/playgroundStore.svelte.js +18 -4
  54. package/dist/stores/workflowStore.svelte.d.ts +4 -1
  55. package/dist/stores/workflowStore.svelte.js +8 -1
  56. package/dist/styles/base.css +14 -3
  57. package/dist/styles/tokenAliases.d.ts +13 -0
  58. package/dist/styles/tokenAliases.js +89 -0
  59. package/dist/themes/scopedSkinCss.d.ts +30 -0
  60. package/dist/themes/scopedSkinCss.js +95 -0
  61. package/dist/types/index.d.ts +86 -4
  62. package/dist/types/index.js +15 -3
  63. package/dist/types/skin.d.ts +2 -2
  64. package/dist/utils/playgroundChat.d.ts +121 -0
  65. package/dist/utils/playgroundChat.js +275 -0
  66. package/dist/utils/portal.d.ts +8 -0
  67. package/dist/utils/portal.js +15 -0
  68. package/dist/utils/workflowInterface.d.ts +88 -20
  69. package/dist/utils/workflowInterface.js +179 -18
  70. package/dist/webmcp/WebMCPConfirm.svelte +68 -18
  71. package/dist/webmcp/gate.d.ts +6 -0
  72. package/dist/webmcp/gate.js +4 -0
  73. package/dist/webmcp/runtime.js +2 -1
  74. package/package.json +7 -6
  75. package/dist/components/Button.stories.svelte +0 -65
  76. package/dist/components/Button.stories.svelte.d.ts +0 -19
  77. package/dist/components/CanvasBanner.stories.svelte +0 -30
  78. package/dist/components/CanvasBanner.stories.svelte.d.ts +0 -27
  79. package/dist/components/CanvasContextMenu.stories.svelte +0 -63
  80. package/dist/components/CanvasContextMenu.stories.svelte.d.ts +0 -19
  81. package/dist/components/ConfigPanel.stories.svelte +0 -47
  82. package/dist/components/ConfigPanel.stories.svelte.d.ts +0 -27
  83. package/dist/components/EditorStatusBar.stories.svelte +0 -44
  84. package/dist/components/EditorStatusBar.stories.svelte.d.ts +0 -27
  85. package/dist/components/FlowDropEdge.stories.svelte +0 -197
  86. package/dist/components/FlowDropEdge.stories.svelte.d.ts +0 -26
  87. package/dist/components/LoadingSpinner.stories.svelte +0 -30
  88. package/dist/components/LoadingSpinner.stories.svelte.d.ts +0 -27
  89. package/dist/components/Logo.stories.svelte +0 -22
  90. package/dist/components/Logo.stories.svelte.d.ts +0 -27
  91. package/dist/components/MarkdownDisplay.stories.svelte +0 -38
  92. package/dist/components/MarkdownDisplay.stories.svelte.d.ts +0 -27
  93. package/dist/components/Navbar.stories.svelte +0 -58
  94. package/dist/components/Navbar.stories.svelte.d.ts +0 -27
  95. package/dist/components/NodeStatusOverlay.stories.svelte +0 -85
  96. package/dist/components/NodeStatusOverlay.stories.svelte.d.ts +0 -27
  97. package/dist/components/SchemaForm.stories.svelte +0 -122
  98. package/dist/components/SchemaForm.stories.svelte.d.ts +0 -27
  99. package/dist/components/StatusIcon.stories.svelte +0 -60
  100. package/dist/components/StatusIcon.stories.svelte.d.ts +0 -27
  101. package/dist/components/StatusLabel.stories.svelte +0 -17
  102. package/dist/components/StatusLabel.stories.svelte.d.ts +0 -27
  103. package/dist/components/ThemeToggle.stories.svelte +0 -25
  104. package/dist/components/ThemeToggle.stories.svelte.d.ts +0 -27
  105. package/dist/components/console/CommandConsole.stories.svelte +0 -111
  106. package/dist/components/console/CommandConsole.stories.svelte.d.ts +0 -27
  107. package/dist/components/form/FormCheckboxGroup.stories.svelte +0 -28
  108. package/dist/components/form/FormCheckboxGroup.stories.svelte.d.ts +0 -27
  109. package/dist/components/form/FormFieldWrapper.stories.svelte +0 -53
  110. package/dist/components/form/FormFieldWrapper.stories.svelte.d.ts +0 -27
  111. package/dist/components/form/FormNumberField.stories.svelte +0 -36
  112. package/dist/components/form/FormNumberField.stories.svelte.d.ts +0 -27
  113. package/dist/components/form/FormRangeField.stories.svelte +0 -31
  114. package/dist/components/form/FormRangeField.stories.svelte.d.ts +0 -27
  115. package/dist/components/form/FormSelect.stories.svelte +0 -50
  116. package/dist/components/form/FormSelect.stories.svelte.d.ts +0 -27
  117. package/dist/components/form/FormTextField.stories.svelte +0 -30
  118. package/dist/components/form/FormTextField.stories.svelte.d.ts +0 -27
  119. package/dist/components/form/FormTextarea.stories.svelte +0 -34
  120. package/dist/components/form/FormTextarea.stories.svelte.d.ts +0 -27
  121. package/dist/components/form/FormToggle.stories.svelte +0 -30
  122. package/dist/components/form/FormToggle.stories.svelte.d.ts +0 -27
  123. package/dist/components/interrupt/ChoicePrompt.stories.svelte +0 -68
  124. package/dist/components/interrupt/ChoicePrompt.stories.svelte.d.ts +0 -27
  125. package/dist/components/interrupt/ConfirmationPrompt.stories.svelte +0 -71
  126. package/dist/components/interrupt/ConfirmationPrompt.stories.svelte.d.ts +0 -27
  127. package/dist/components/interrupt/ReviewPrompt.stories.svelte +0 -77
  128. package/dist/components/interrupt/ReviewPrompt.stories.svelte.d.ts +0 -27
  129. package/dist/components/interrupt/TextInputPrompt.stories.svelte +0 -51
  130. package/dist/components/interrupt/TextInputPrompt.stories.svelte.d.ts +0 -27
  131. package/dist/components/nodes/CaptionNode.stories.svelte +0 -65
  132. package/dist/components/nodes/CaptionNode.stories.svelte.d.ts +0 -18
  133. package/dist/components/nodes/GatewayNode.stories.svelte +0 -108
  134. package/dist/components/nodes/GatewayNode.stories.svelte.d.ts +0 -26
  135. package/dist/components/nodes/IdeaNode.stories.svelte +0 -52
  136. package/dist/components/nodes/IdeaNode.stories.svelte.d.ts +0 -26
  137. package/dist/components/nodes/NotesNode.stories.svelte +0 -76
  138. package/dist/components/nodes/NotesNode.stories.svelte.d.ts +0 -26
  139. package/dist/components/nodes/SimpleNode.stories.svelte +0 -223
  140. package/dist/components/nodes/SimpleNode.stories.svelte.d.ts +0 -26
  141. package/dist/components/nodes/SquareNode.stories.svelte +0 -127
  142. package/dist/components/nodes/SquareNode.stories.svelte.d.ts +0 -26
  143. package/dist/components/nodes/TerminalNode.stories.svelte +0 -25
  144. package/dist/components/nodes/TerminalNode.stories.svelte.d.ts +0 -26
  145. package/dist/components/nodes/ToolNode.stories.svelte +0 -189
  146. package/dist/components/nodes/ToolNode.stories.svelte.d.ts +0 -26
  147. package/dist/components/nodes/WorkflowNode.stories.svelte +0 -188
  148. package/dist/components/nodes/WorkflowNode.stories.svelte.d.ts +0 -26
  149. package/dist/components/playground/MessageBubble.stories.svelte +0 -151
  150. package/dist/components/playground/MessageBubble.stories.svelte.d.ts +0 -27
  151. package/dist/mocks/app-environment.d.ts +0 -8
  152. package/dist/mocks/app-environment.js +0 -16
  153. package/dist/mocks/app-forms.d.ts +0 -6
  154. package/dist/mocks/app-forms.js +0 -29
  155. package/dist/mocks/app-navigation.d.ts +0 -5
  156. package/dist/mocks/app-navigation.js +0 -36
  157. package/dist/mocks/app-stores.d.ts +0 -14
  158. package/dist/mocks/app-stores.js +0 -26
  159. package/dist/stories/CanvasDecorator.svelte +0 -49
  160. package/dist/stories/CanvasDecorator.svelte.d.ts +0 -8
  161. package/dist/stories/EdgeDecorator.svelte +0 -125
  162. package/dist/stories/EdgeDecorator.svelte.d.ts +0 -17
  163. package/dist/stories/NodeDecorator.svelte +0 -75
  164. package/dist/stories/NodeDecorator.svelte.d.ts +0 -8
  165. package/dist/stories/WebMCPFakeAgent.svelte +0 -229
  166. package/dist/stories/WebMCPFakeAgent.svelte.d.ts +0 -10
  167. package/dist/stories/utils.d.ts +0 -93
  168. package/dist/stories/utils.js +0 -156
  169. package/dist/webmcp/WebMCP.stories.svelte +0 -101
  170. package/dist/webmcp/WebMCP.stories.svelte.d.ts +0 -18
@@ -199,8 +199,16 @@
199
199
  let flowEdges = $state.raw<WorkflowEdge[]>([]);
200
200
 
201
201
  // Execution info loading state
202
- let loadExecutionInfoTimeout: number | null = null;
202
+ /** Cancels the scheduled (not yet started) execution-info load, if any. */
203
+ let cancelScheduledExecutionInfo: (() => void) | null = null;
203
204
  let executionInfoAbortController: AbortController | null = null;
205
+ /**
206
+ * The last execution info that loaded for the shown pipeline. Plain (not
207
+ * reactive) on purpose: it is only read when flowNodes is rebuilt from the
208
+ * store, which has no executionInfo of its own. Cleared whenever the
209
+ * pipeline or workflow changes, so it can never paint another run.
210
+ */
211
+ let latestExecutionInfo: Record<string, NodeExecutionInfo> | null = null;
204
212
 
205
213
  /**
206
214
  * Key for SvelteFlow component — changes when workflow ID changes.
@@ -247,7 +255,11 @@
247
255
  } {
248
256
  const nodesWithCallbacks = workflow.nodes.map(withNodeCallbacks);
249
257
  const styledEdges = EdgeStylingHelper.updateEdgeStyles(workflow.edges, nodesWithCallbacks);
250
- return { nodes: nodesWithCallbacks, edges: styledEdges };
258
+ // Re-apply the loaded run status: a rebuild must not drop the badges.
259
+ const nodes = latestExecutionInfo
260
+ ? NodeOperationsHelper.applyExecutionInfo(nodesWithCallbacks, latestExecutionInfo)
261
+ : nodesWithCallbacks;
262
+ return { nodes, edges: styledEdges };
251
263
  }
252
264
 
253
265
  // ---------------------------------------------------------------------------
@@ -289,6 +301,9 @@
289
301
 
290
302
  const isNewWorkflow = storeValue.id !== previousSyncedWorkflowId;
291
303
 
304
+ // A different workflow never inherits the previous one's run status.
305
+ if (isNewWorkflow) latestExecutionInfo = null;
306
+
292
307
  if (isNewWorkflow) {
293
308
  untrack(() =>
294
309
  machine.send(previousSyncedWorkflowId ? 'WORKFLOW_SWITCHED' : 'WORKFLOW_LOADED')
@@ -301,8 +316,10 @@
301
316
  flowEdges = derived.edges;
302
317
  previousSyncedWorkflowId = storeValue.id;
303
318
 
304
- // Trigger port coordinate rebuild after workflow load
305
- if (getEditorSettings().proximityConnect) {
319
+ // Trigger port coordinate rebuild after workflow load. Untracked: the
320
+ // setting must not re-run this effect, or any settings change (even the
321
+ // theme) would rebuild flowNodes from the store.
322
+ if (untrack(() => getEditorSettings().proximityConnect)) {
306
323
  portCoordRebuildTrigger = Date.now();
307
324
  }
308
325
 
@@ -314,6 +331,14 @@
314
331
  // ---------------------------------------------------------------------------
315
332
  // Execution info effect (separate — async, depends on workflow + pipeline ID)
316
333
  // ---------------------------------------------------------------------------
334
+ /** Forget the loaded run status and take it off the canvas nodes. */
335
+ function resetExecutionInfo(): void {
336
+ latestExecutionInfo = null;
337
+ untrack(() => {
338
+ flowNodes = NodeOperationsHelper.applyExecutionInfo(flowNodes, null);
339
+ });
340
+ }
341
+
317
342
  let previousExecWorkflowId: string | null = null;
318
343
  let previousExecPipelineId: string | undefined = undefined;
319
344
 
@@ -321,7 +346,13 @@
321
346
  const storeValue = fd.workflow.current;
322
347
  const pipelineId = props.pipelineId;
323
348
 
324
- if (!storeValue || !pipelineId) return;
349
+ if (!storeValue || !pipelineId) {
350
+ // Nothing to show a run for: forget the previous run entirely.
351
+ resetExecutionInfo();
352
+ previousExecWorkflowId = null;
353
+ previousExecPipelineId = undefined;
354
+ return;
355
+ }
325
356
 
326
357
  const workflowChanged = storeValue.id !== previousExecWorkflowId;
327
358
  const pipelineChanged = pipelineId !== previousExecPipelineId;
@@ -331,31 +362,36 @@
331
362
  previousExecWorkflowId = storeValue.id;
332
363
  previousExecPipelineId = pipelineId;
333
364
 
334
- // Cancel any pending idle/timeout schedule. In-flight fetches are
335
- // cancelled by loadNodeExecutionInfo() itself when it's re-entered.
336
- if (loadExecutionInfoTimeout) {
337
- clearTimeout(loadExecutionInfoTimeout);
338
- loadExecutionInfoTimeout = null;
339
- }
365
+ // Cancel any pending schedule and any in-flight fetch (it belongs to the
366
+ // previous pipeline), and drop the previous run's status.
367
+ cancelScheduledExecutionInfo?.();
368
+ executionInfoAbortController?.abort();
369
+ resetExecutionInfo();
340
370
 
341
371
  // Schedule loading with requestIdleCallback (falls back to setTimeout)
342
372
  if (typeof requestIdleCallback !== 'undefined') {
343
- loadExecutionInfoTimeout = requestIdleCallback(
344
- () => {
345
- loadNodeExecutionInfo();
346
- },
347
- { timeout: 500 }
348
- ) as unknown as number;
373
+ const id = requestIdleCallback(() => loadNodeExecutionInfo(), { timeout: 500 });
374
+ cancelScheduledExecutionInfo = () => cancelIdleCallback(id);
349
375
  } else {
350
- loadExecutionInfoTimeout = setTimeout(() => {
351
- loadNodeExecutionInfo();
352
- }, 300) as unknown as number;
376
+ const id = setTimeout(() => loadNodeExecutionInfo(), 300);
377
+ cancelScheduledExecutionInfo = () => clearTimeout(id);
353
378
  }
354
379
  });
355
380
 
381
+ // On unmount: drop a scheduled load and discard an in-flight one, so
382
+ // nothing writes flowNodes after the editor is gone.
383
+ $effect(() => () => {
384
+ cancelScheduledExecutionInfo?.();
385
+ executionInfoAbortController?.abort();
386
+ latestExecutionInfo = null;
387
+ });
388
+
356
389
  // Re-fetch node execution info when the parent bumps refreshTrigger
357
390
  // (poll ticks, chat-message arrivals, manual refresh). loadNodeExecutionInfo()
358
- // is the single writer of executionInfo on flowNodes — no parallel channel.
391
+ // is the single loader of executionInfo: it keeps the result in
392
+ // latestExecutionInfo and paints it onto flowNodes. buildFlowNodesFromStore
393
+ // re-applies that map on every rebuild, so a store change or a settings
394
+ // change never drops the badges. No parallel channel.
359
395
  // svelte-ignore state_referenced_locally
360
396
  let _prevExecRefreshTrigger = props.refreshTrigger ?? 0;
361
397
  $effect(() => {
@@ -416,20 +452,10 @@
416
452
 
417
453
  if (controller.signal.aborted) return;
418
454
 
419
- const defaultExecutionInfo: NodeExecutionInfo = {
420
- status: 'idle' as const,
421
- executionCount: 0,
422
- isExecuting: false
423
- };
424
-
425
- // Update flowNodes with execution info (visual-only, no store sync needed)
426
- flowNodes = flowNodes.map((node) => ({
427
- ...node,
428
- data: {
429
- ...node.data,
430
- executionInfo: executionInfo[node.id] || defaultExecutionInfo
431
- }
432
- }));
455
+ // Keep the map for later rebuilds, and paint it now (visual-only, no
456
+ // store sync needed).
457
+ latestExecutionInfo = executionInfo;
458
+ flowNodes = NodeOperationsHelper.applyExecutionInfo(flowNodes, executionInfo);
433
459
 
434
460
  if (executionInfoAbortController === controller) {
435
461
  executionInfoAbortController = null;
@@ -1193,7 +1219,7 @@
1193
1219
 
1194
1220
  <svelte:window onkeydown={handleKeydown} />
1195
1221
 
1196
- <div class="flowdrop-workflow-editor">
1222
+ <div class="flowdrop-scope flowdrop-workflow-editor">
1197
1223
  <!-- Main Editor Area -->
1198
1224
  <div class="flowdrop-workflow-editor__main">
1199
1225
  <!-- Flow Canvas.
@@ -1342,7 +1368,7 @@
1342
1368
 
1343
1369
  <!-- Toast notifications container -->
1344
1370
  <!-- aria-live="polite" ensures screen readers announce toast messages without interrupting -->
1345
- <div aria-live="polite" aria-atomic="true">
1371
+ <div class="flowdrop-scope" aria-live="polite" aria-atomic="true">
1346
1372
  <Toaster
1347
1373
  position="bottom-center"
1348
1374
  containerClassName={FLOWDROP_TOASTER_CLASS}
@@ -18,7 +18,10 @@
18
18
  Stateless: reads `workflow` as a prop and reports the next `WorkflowInterface`
19
19
  via `onChange`. The caller (`App.svelte`) is responsible for routing that
20
20
  through the workflow store (`fd.workflow.batchUpdate({ interface: next })`),
21
- so every edit here goes through the store's normal history path.
21
+ so every edit here goes through the store's normal history path. When an
22
+ edit renames or removes an input id, `onChange` also says so, so the caller
23
+ can carry the workflow's chat binding (`playground.chat`, which names inputs
24
+ by id) along in the same update (`followInterfaceInputEdit`).
22
25
 
23
26
  `meta` is never editable here (design decision 4) — it round-trips verbatim
24
27
  and is shown as a read-only JSON disclosure when present. One exception: the
@@ -40,6 +43,7 @@
40
43
  WorkflowInterface,
41
44
  WorkflowInterfaceEntry
42
45
  } from '../types/index.js';
46
+ import type { InterfaceInputEdit } from '../utils/playgroundChat.js';
43
47
  import {
44
48
  entryFromBindablePort,
45
49
  rankBindablePorts,
@@ -53,7 +57,17 @@
53
57
 
54
58
  interface Props {
55
59
  workflow: Workflow;
56
- onChange: (next: WorkflowInterface | undefined) => void;
60
+ /**
61
+ * The next interface, after an edit. `edit` is set when the edit renamed
62
+ * or removed an input id (and no other input still has the old one), so
63
+ * the caller can follow it in the chat binding.
64
+ */
65
+ onChange: (next: WorkflowInterface | undefined, edit?: InterfaceInputEdit) => void;
66
+ /**
67
+ * Opens the workflow's Playground settings. Entries that still carry the
68
+ * deprecated chat `turn` link there; omit when the host has none.
69
+ */
70
+ onOpenPlaygroundSettings?: () => void;
57
71
  /**
58
72
  * The data-type vocabulary offered by the dataType picker — the host's
59
73
  * live `PortConfig.dataTypes` (pass `portCompatibility.getEnabledDataTypes()`).
@@ -72,6 +86,7 @@
72
86
  const {
73
87
  workflow,
74
88
  onChange,
89
+ onOpenPlaygroundSettings,
75
90
  dataTypes = DEFAULT_PORT_CONFIG.dataTypes.filter((dt) => dt.enabled !== false),
76
91
  checker = new PortCompatibilityChecker(DEFAULT_PORT_CONFIG)
77
92
  }: Props = $props();
@@ -230,13 +245,24 @@
230
245
  * not linger as `{}`) still holds: a workflow nobody has authored an
231
246
  * interface for never reaches this function, and keeps its absent key.
232
247
  */
233
- function commit(direction: Direction, next: WorkflowInterfaceEntry[]): void {
248
+ function commit(
249
+ direction: Direction,
250
+ next: WorkflowInterfaceEntry[],
251
+ edit?: InterfaceInputEdit
252
+ ): void {
234
253
  const inputs = direction === 'inputs' ? next : (workflow.interface?.inputs ?? []);
235
254
  const outputs = direction === 'outputs' ? next : (workflow.interface?.outputs ?? []);
236
- onChange({
255
+ const nextInterface = {
237
256
  inputs: inputs.length > 0 ? inputs : undefined,
238
257
  outputs: outputs.length > 0 ? outputs : undefined
239
- });
258
+ };
259
+ // An id another input still carries is still on the interface: nothing
260
+ // the binding names went away.
261
+ if (direction === 'inputs' && edit && !inputs.some((entry) => entry.id === edit.id)) {
262
+ onChange(nextInterface, edit);
263
+ } else {
264
+ onChange(nextInterface);
265
+ }
240
266
  }
241
267
 
242
268
  /**
@@ -276,10 +302,12 @@
276
302
  function removeEntry(direction: Direction, index: number): void {
277
303
  // Dropping the row id destroys that card's component, and its disclosure
278
304
  // state with it — no bookkeeping to keep in step.
305
+ const removed = entriesFor(direction)[index];
279
306
  rowIds[direction].splice(index, 1);
280
307
  commit(
281
308
  direction,
282
- entriesFor(direction).filter((_, i) => i !== index)
309
+ entriesFor(direction).filter((_, i) => i !== index),
310
+ removed && { kind: 'remove', id: removed.id }
283
311
  );
284
312
  }
285
313
 
@@ -300,10 +328,15 @@
300
328
  index: number,
301
329
  patch: Partial<WorkflowInterfaceEntry>
302
330
  ): void {
331
+ const before = entriesFor(direction)[index];
303
332
  const list = entriesFor(direction).map((entry, i) =>
304
333
  i === index ? applyPatch(entry, patch) : entry
305
334
  );
306
- commit(direction, list);
335
+ const renamed: InterfaceInputEdit | undefined =
336
+ before && typeof patch.id === 'string' && patch.id !== before.id
337
+ ? { kind: 'rename', id: before.id, to: patch.id }
338
+ : undefined;
339
+ commit(direction, list, renamed);
307
340
  }
308
341
 
309
342
  /**
@@ -363,9 +396,11 @@
363
396
  'interface-input-already-connected'
364
397
  )}
365
398
  conflictingSource={conflictingSourceLabel(entry)}
366
- turnTakenBy={section.key === 'inputs'
399
+ turnTakenBy={section.key === 'inputs' && !workflow.playground?.chat
367
400
  ? turnTakenBy(entriesFor('inputs'), entry)
368
401
  : undefined}
402
+ {onOpenPlaygroundSettings}
403
+ turnSelector={workflow.playground === undefined}
369
404
  isFirst={index === 0}
370
405
  isLast={index === list.length - 1}
371
406
  onPatch={(patch: Partial<WorkflowInterfaceEntry>) =>
@@ -1,8 +1,19 @@
1
1
  import { PortCompatibilityChecker } from '../utils/connections.js';
2
2
  import type { PortDataTypeConfig, Workflow, WorkflowInterface } from '../types/index.js';
3
+ import type { InterfaceInputEdit } from '../utils/playgroundChat.js';
3
4
  interface Props {
4
5
  workflow: Workflow;
5
- onChange: (next: WorkflowInterface | undefined) => void;
6
+ /**
7
+ * The next interface, after an edit. `edit` is set when the edit renamed
8
+ * or removed an input id (and no other input still has the old one), so
9
+ * the caller can follow it in the chat binding.
10
+ */
11
+ onChange: (next: WorkflowInterface | undefined, edit?: InterfaceInputEdit) => void;
12
+ /**
13
+ * Opens the workflow's Playground settings. Entries that still carry the
14
+ * deprecated chat `turn` link there; omit when the host has none.
15
+ */
16
+ onOpenPlaygroundSettings?: () => void;
6
17
  /**
7
18
  * The data-type vocabulary offered by the dataType picker — the host's
8
19
  * live `PortConfig.dataTypes` (pass `portCompatibility.getEnabledDataTypes()`).
@@ -64,8 +64,21 @@
64
64
  alreadyConnected?: boolean;
65
65
  /** Label of the node feeding that competing edge, when there is one. */
66
66
  conflictingSource?: string;
67
- /** Input side only: the id of another input that already has this entry's turn. */
67
+ /** Input side only: the id of another input that already has this entry's (deprecated) turn. */
68
68
  turnTakenBy?: string;
69
+ /**
70
+ * Opens the workflow's Playground settings, where the chat is set up now.
71
+ * Linked from the deprecated `turn` notice; omit when the host has no
72
+ * Playground settings (the notice then says where without a link).
73
+ */
74
+ onOpenPlaygroundSettings?: () => void;
75
+ /**
76
+ * Offer the deprecated Chat turn selector (and the history limit).
77
+ * Only for a workflow without Playground settings (a server before
78
+ * FlowDrop 2.7.0), where `turn` is still the only way to set the chat
79
+ * up. With settings, a stored `turn` shows as a deprecated chip instead.
80
+ */
81
+ turnSelector?: boolean;
69
82
  isFirst: boolean;
70
83
  isLast: boolean;
71
84
  onPatch: (patch: Partial<WorkflowInterfaceEntry>) => void;
@@ -84,6 +97,8 @@
84
97
  alreadyConnected = false,
85
98
  conflictingSource,
86
99
  turnTakenBy,
100
+ onOpenPlaygroundSettings,
101
+ turnSelector = false,
87
102
  isFirst,
88
103
  isLast,
89
104
  onPatch,
@@ -118,10 +133,20 @@
118
133
  return options;
119
134
  }
120
135
 
136
+ /** The entry's deprecated `turn`, as a label. */
137
+ const turnLabel = $derived(
138
+ entry.turn === undefined
139
+ ? undefined
140
+ : isKnownTurn(entry.turn)
141
+ ? m().workflowInterface.turns[entry.turn]
142
+ : entry.turn
143
+ );
144
+
121
145
  /**
122
- * Chat turn options for this direction. A stored value outside them — one
123
- * from a newer server, or a value of the other direction — is listed too,
124
- * so the select shows what is stored and never silently rewrites it.
146
+ * Chat turn options for this direction (the selector, `turnSelector` only).
147
+ * A stored value outside them — one from a newer server, or a value of the
148
+ * other direction — is listed too, so the select shows what is stored and
149
+ * never silently rewrites it.
125
150
  */
126
151
  const turnOptions = $derived.by(() => {
127
152
  const options: Array<{ value: string; label: string }> = turnsFor(
@@ -262,7 +287,12 @@
262
287
  size="sm"
263
288
  type="text"
264
289
  value={entry.id}
265
- onchange={(e) => onPatch({ id: e.currentTarget.value })}
290
+ onchange={(e) => {
291
+ // An input needs an id: an emptied field goes back to the old one
292
+ // (else the chat binding would lose the input for good).
293
+ if (e.currentTarget.value.trim() === '') e.currentTarget.value = entry.id;
294
+ else onPatch({ id: e.currentTarget.value });
295
+ }}
266
296
  />
267
297
  </label>
268
298
  <div class="wf-interface__field wf-interface__field--binding">
@@ -358,52 +388,78 @@
358
388
  <summary>
359
389
  <Icon icon="heroicons:chevron-right" />
360
390
  {m().workflowInterface.moreOptions}
361
- {#if entry.turn !== undefined}
362
- <span class="wf-interface__turn-chip">
363
- {isKnownTurn(entry.turn) ? m().workflowInterface.turns[entry.turn] : entry.turn}
391
+ {#if turnLabel !== undefined}
392
+ <span
393
+ class="wf-interface__turn-chip"
394
+ class:wf-interface__turn-chip--deprecated={!turnSelector}
395
+ >
396
+ {turnLabel}
364
397
  </span>
365
398
  {/if}
366
399
  </summary>
367
400
  <div class="wf-interface__more-body">
368
- <div class="wf-interface__row">
369
- <label class="wf-interface__field">
370
- <span class="wf-interface__label">{m().workflowInterface.turnLabel}</span>
371
- <Select
372
- size="sm"
373
- invalid={turnTakenBy !== undefined}
374
- value={entry.turn ?? ''}
375
- onchange={(e) => setTurn(e.currentTarget.value)}
376
- >
377
- <option value="">{m().workflowInterface.turnNone}</option>
378
- {#each turnOptions as option (option.value)}
379
- <option value={option.value}>{option.label}</option>
380
- {/each}
381
- </Select>
382
- {#if turnTakenBy !== undefined}
383
- <span class="wf-interface__inline wf-interface__inline--warning">
384
- {m().workflowInterface.turnTakenInline({ id: turnTakenBy })}
385
- </span>
386
- {:else if turnDescription}
387
- <span class="wf-interface__hint">{turnDescription}</span>
388
- {/if}
389
- </label>
390
- {#if entry.turn === 'history'}
401
+ {#if turnSelector}
402
+ <div class="wf-interface__row">
391
403
  <label class="wf-interface__field">
392
- <span class="wf-interface__label">{m().workflowInterface.historyLimitLabel}</span>
393
- <Input
404
+ <span class="wf-interface__label">{m().workflowInterface.turnLabel}</span>
405
+ <Select
394
406
  size="sm"
395
- type="number"
396
- min="1"
397
- step="1"
398
- value={historyLimitOf(entry) ?? ''}
399
- placeholder={m().workflowInterface.historyLimitPlaceholder({
400
- limit: DEFAULT_HISTORY_TURN_LIMIT
401
- })}
402
- onchange={(e) => onPatch(historyLimitPatch(entry, e.currentTarget.value))}
403
- />
407
+ invalid={turnTakenBy !== undefined}
408
+ value={entry.turn ?? ''}
409
+ onchange={(e) => setTurn(e.currentTarget.value)}
410
+ >
411
+ <option value="">{m().workflowInterface.turnNone}</option>
412
+ {#each turnOptions as option (option.value)}
413
+ <option value={option.value}>{option.label}</option>
414
+ {/each}
415
+ </Select>
416
+ {#if turnTakenBy !== undefined}
417
+ <span class="wf-interface__inline wf-interface__inline--warning">
418
+ {m().workflowInterface.turnTakenInline({ id: turnTakenBy })}
419
+ </span>
420
+ {:else if turnDescription}
421
+ <span class="wf-interface__hint">{turnDescription}</span>
422
+ {/if}
404
423
  </label>
405
- {/if}
406
- </div>
424
+ {#if entry.turn === 'history'}
425
+ <label class="wf-interface__field">
426
+ <span class="wf-interface__label">{m().workflowInterface.historyLimitLabel}</span>
427
+ <Input
428
+ size="sm"
429
+ type="number"
430
+ min="1"
431
+ step="1"
432
+ value={historyLimitOf(entry) ?? ''}
433
+ placeholder={m().workflowInterface.historyLimitPlaceholder({
434
+ limit: DEFAULT_HISTORY_TURN_LIMIT
435
+ })}
436
+ onchange={(e) => onPatch(historyLimitPatch(entry, e.currentTarget.value))}
437
+ />
438
+ </label>
439
+ {/if}
440
+ </div>
441
+ {:else if turnLabel !== undefined}
442
+ <div class="wf-interface__turn-deprecated" role="note">
443
+ <span>
444
+ {m().workflowInterface.turnDeprecated({
445
+ turn: turnLabel,
446
+ limit: entry.turn === 'history' ? historyLimitOf(entry) : undefined
447
+ })}
448
+ {#if turnTakenBy !== undefined}
449
+ {m().workflowInterface.turnTakenInline({ id: turnTakenBy })}
450
+ {/if}
451
+ </span>
452
+ {#if onOpenPlaygroundSettings}
453
+ <button
454
+ type="button"
455
+ class="wf-interface__quickfix"
456
+ onclick={onOpenPlaygroundSettings}
457
+ >
458
+ {m().workflowInterface.turnOpenPlayground}
459
+ </button>
460
+ {/if}
461
+ </div>
462
+ {/if}
407
463
 
408
464
  {#if boundTarget}
409
465
  <div class="wf-interface__pull-row">
@@ -847,6 +903,23 @@
847
903
  line-height: 1.5;
848
904
  }
849
905
 
906
+ /* A deprecated `turn` reads as a warning, not as a choice. */
907
+ .wf-interface__turn-chip--deprecated {
908
+ border-color: color-mix(in srgb, var(--fd-warning) 45%, var(--fd-border));
909
+ color: var(--fd-warning);
910
+ text-decoration: line-through;
911
+ }
912
+
913
+ .wf-interface__turn-deprecated {
914
+ display: flex;
915
+ flex-wrap: wrap;
916
+ align-items: baseline;
917
+ gap: var(--fd-space-xs);
918
+ font-size: var(--fd-text-xs);
919
+ line-height: 1.4;
920
+ color: var(--fd-warning);
921
+ }
922
+
850
923
  .wf-interface__inline--warning {
851
924
  color: var(--fd-warning);
852
925
  }
@@ -17,8 +17,21 @@ interface Props {
17
17
  alreadyConnected?: boolean;
18
18
  /** Label of the node feeding that competing edge, when there is one. */
19
19
  conflictingSource?: string;
20
- /** Input side only: the id of another input that already has this entry's turn. */
20
+ /** Input side only: the id of another input that already has this entry's (deprecated) turn. */
21
21
  turnTakenBy?: string;
22
+ /**
23
+ * Opens the workflow's Playground settings, where the chat is set up now.
24
+ * Linked from the deprecated `turn` notice; omit when the host has no
25
+ * Playground settings (the notice then says where without a link).
26
+ */
27
+ onOpenPlaygroundSettings?: () => void;
28
+ /**
29
+ * Offer the deprecated Chat turn selector (and the history limit).
30
+ * Only for a workflow without Playground settings (a server before
31
+ * FlowDrop 2.7.0), where `turn` is still the only way to set the chat
32
+ * up. With settings, a stored `turn` shows as a deprecated chip instead.
33
+ */
34
+ turnSelector?: boolean;
22
35
  isFirst: boolean;
23
36
  isLast: boolean;
24
37
  onPatch: (patch: Partial<WorkflowInterfaceEntry>) => void;