@flowdrop/flowdrop 2.10.0 → 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 (175) hide show
  1. package/CHANGELOG.md +175 -0
  2. package/dist/components/App.svelte +112 -29
  3. package/dist/components/CanvasController.svelte +1 -1
  4. package/dist/components/ConfigForm.svelte +5 -5
  5. package/dist/components/ConfigModal.svelte +2 -2
  6. package/dist/components/ConfigModal.svelte.d.ts +1 -1
  7. package/dist/components/ConnectionLine.svelte +1 -1
  8. package/dist/components/EdgeRefresher.svelte +1 -1
  9. package/dist/components/FlowDropZone.svelte +11 -7
  10. package/dist/components/FlowDropZone.svelte.d.ts +12 -0
  11. package/dist/components/LogsSidebar.svelte +15 -12
  12. package/dist/components/MarkdownDisplay.svelte +1 -1
  13. package/dist/components/PipelineStatus.svelte +5 -18
  14. package/dist/components/PortCoordinateTracker.svelte +1 -1
  15. package/dist/components/SchemaForm.svelte +1 -1
  16. package/dist/components/SettingsModal.svelte +1 -1
  17. package/dist/components/SettingsPanel.svelte +1 -1
  18. package/dist/components/WorkflowEditor.svelte +200 -174
  19. package/dist/components/WorkflowInterfaceEditor.svelte +43 -8
  20. package/dist/components/WorkflowInterfaceEditor.svelte.d.ts +12 -1
  21. package/dist/components/WorkflowInterfaceEntryCard.svelte +117 -44
  22. package/dist/components/WorkflowInterfaceEntryCard.svelte.d.ts +14 -1
  23. package/dist/components/WorkflowPlaygroundSettings.svelte +551 -0
  24. package/dist/components/WorkflowPlaygroundSettings.svelte.d.ts +20 -0
  25. package/dist/components/chat/AIChatPanel.svelte +1 -1
  26. package/dist/components/form/index.d.ts +2 -2
  27. package/dist/components/form/index.js +2 -2
  28. package/dist/components/nodes/ToolNode.svelte +1 -1
  29. package/dist/components/playground/ControlPanel.svelte +30 -0
  30. package/dist/components/playground/ControlPanel.svelte.d.ts +5 -0
  31. package/dist/components/playground/Playground.svelte +94 -42
  32. package/dist/components/playground/PlaygroundApp.svelte +1 -1
  33. package/dist/components/playground/PlaygroundModal.svelte +1 -1
  34. package/dist/components/playground/PlaygroundStudio.svelte +1 -1
  35. package/dist/core/index.d.ts +1 -1
  36. package/dist/helpers/workflowEditorHelper.d.ts +12 -0
  37. package/dist/helpers/workflowEditorHelper.js +31 -0
  38. package/dist/messages/defaults.d.ts +53 -0
  39. package/dist/messages/defaults.js +48 -2
  40. package/dist/openapi/v1/openapi.yaml +113 -5
  41. package/dist/playground/index.d.ts +3 -1
  42. package/dist/playground/index.js +2 -1
  43. package/dist/playground/mount.d.ts +6 -10
  44. package/dist/playground/mount.js +43 -24
  45. package/dist/schemas/index.js +1 -1
  46. package/dist/schemas/v1/workflow.schema.json +140 -2
  47. package/dist/services/globalSave.js +11 -1
  48. package/dist/services/playgroundService.d.ts +6 -1
  49. package/dist/services/playgroundService.js +5 -0
  50. package/dist/skins/default.d.ts +1 -1
  51. package/dist/skins/drafter.d.ts +1 -1
  52. package/dist/skins/index.d.ts +4 -4
  53. package/dist/skins/index.js +3 -3
  54. package/dist/skins/slate.d.ts +1 -1
  55. package/dist/stores/instanceContainer.svelte.d.ts +15 -0
  56. package/dist/stores/instanceContainer.svelte.js +11 -1
  57. package/dist/stores/playgroundStore.svelte.d.ts +8 -0
  58. package/dist/stores/playgroundStore.svelte.js +18 -4
  59. package/dist/stores/workflowStore.svelte.d.ts +4 -1
  60. package/dist/stores/workflowStore.svelte.js +8 -1
  61. package/dist/styles/base.css +14 -3
  62. package/dist/styles/tokenAliases.d.ts +13 -0
  63. package/dist/styles/tokenAliases.js +89 -0
  64. package/dist/themes/scopedSkinCss.d.ts +30 -0
  65. package/dist/themes/scopedSkinCss.js +95 -0
  66. package/dist/types/index.d.ts +86 -4
  67. package/dist/types/index.js +15 -3
  68. package/dist/types/skin.d.ts +2 -2
  69. package/dist/utils/playgroundChat.d.ts +121 -0
  70. package/dist/utils/playgroundChat.js +275 -0
  71. package/dist/utils/portal.d.ts +8 -0
  72. package/dist/utils/portal.js +15 -0
  73. package/dist/utils/workflowInterface.d.ts +88 -20
  74. package/dist/utils/workflowInterface.js +179 -18
  75. package/dist/webmcp/WebMCPConfirm.svelte +68 -18
  76. package/dist/webmcp/gate.d.ts +6 -0
  77. package/dist/webmcp/gate.js +4 -0
  78. package/dist/webmcp/runtime.js +2 -1
  79. package/package.json +8 -7
  80. package/dist/components/Button.stories.svelte +0 -65
  81. package/dist/components/Button.stories.svelte.d.ts +0 -19
  82. package/dist/components/CanvasBanner.stories.svelte +0 -30
  83. package/dist/components/CanvasBanner.stories.svelte.d.ts +0 -27
  84. package/dist/components/CanvasContextMenu.stories.svelte +0 -63
  85. package/dist/components/CanvasContextMenu.stories.svelte.d.ts +0 -19
  86. package/dist/components/ConfigPanel.stories.svelte +0 -47
  87. package/dist/components/ConfigPanel.stories.svelte.d.ts +0 -27
  88. package/dist/components/EditorStatusBar.stories.svelte +0 -44
  89. package/dist/components/EditorStatusBar.stories.svelte.d.ts +0 -27
  90. package/dist/components/FlowDropEdge.stories.svelte +0 -197
  91. package/dist/components/FlowDropEdge.stories.svelte.d.ts +0 -26
  92. package/dist/components/LoadingSpinner.stories.svelte +0 -30
  93. package/dist/components/LoadingSpinner.stories.svelte.d.ts +0 -27
  94. package/dist/components/Logo.stories.svelte +0 -22
  95. package/dist/components/Logo.stories.svelte.d.ts +0 -27
  96. package/dist/components/MarkdownDisplay.stories.svelte +0 -38
  97. package/dist/components/MarkdownDisplay.stories.svelte.d.ts +0 -27
  98. package/dist/components/Navbar.stories.svelte +0 -58
  99. package/dist/components/Navbar.stories.svelte.d.ts +0 -27
  100. package/dist/components/NodeStatusOverlay.stories.svelte +0 -85
  101. package/dist/components/NodeStatusOverlay.stories.svelte.d.ts +0 -27
  102. package/dist/components/SchemaForm.stories.svelte +0 -122
  103. package/dist/components/SchemaForm.stories.svelte.d.ts +0 -27
  104. package/dist/components/StatusIcon.stories.svelte +0 -60
  105. package/dist/components/StatusIcon.stories.svelte.d.ts +0 -27
  106. package/dist/components/StatusLabel.stories.svelte +0 -17
  107. package/dist/components/StatusLabel.stories.svelte.d.ts +0 -27
  108. package/dist/components/ThemeToggle.stories.svelte +0 -25
  109. package/dist/components/ThemeToggle.stories.svelte.d.ts +0 -27
  110. package/dist/components/console/CommandConsole.stories.svelte +0 -111
  111. package/dist/components/console/CommandConsole.stories.svelte.d.ts +0 -27
  112. package/dist/components/form/FormCheckboxGroup.stories.svelte +0 -28
  113. package/dist/components/form/FormCheckboxGroup.stories.svelte.d.ts +0 -27
  114. package/dist/components/form/FormFieldWrapper.stories.svelte +0 -53
  115. package/dist/components/form/FormFieldWrapper.stories.svelte.d.ts +0 -27
  116. package/dist/components/form/FormNumberField.stories.svelte +0 -36
  117. package/dist/components/form/FormNumberField.stories.svelte.d.ts +0 -27
  118. package/dist/components/form/FormRangeField.stories.svelte +0 -31
  119. package/dist/components/form/FormRangeField.stories.svelte.d.ts +0 -27
  120. package/dist/components/form/FormSelect.stories.svelte +0 -50
  121. package/dist/components/form/FormSelect.stories.svelte.d.ts +0 -27
  122. package/dist/components/form/FormTextField.stories.svelte +0 -30
  123. package/dist/components/form/FormTextField.stories.svelte.d.ts +0 -27
  124. package/dist/components/form/FormTextarea.stories.svelte +0 -34
  125. package/dist/components/form/FormTextarea.stories.svelte.d.ts +0 -27
  126. package/dist/components/form/FormToggle.stories.svelte +0 -30
  127. package/dist/components/form/FormToggle.stories.svelte.d.ts +0 -27
  128. package/dist/components/interrupt/ChoicePrompt.stories.svelte +0 -68
  129. package/dist/components/interrupt/ChoicePrompt.stories.svelte.d.ts +0 -27
  130. package/dist/components/interrupt/ConfirmationPrompt.stories.svelte +0 -71
  131. package/dist/components/interrupt/ConfirmationPrompt.stories.svelte.d.ts +0 -27
  132. package/dist/components/interrupt/ReviewPrompt.stories.svelte +0 -77
  133. package/dist/components/interrupt/ReviewPrompt.stories.svelte.d.ts +0 -27
  134. package/dist/components/interrupt/TextInputPrompt.stories.svelte +0 -51
  135. package/dist/components/interrupt/TextInputPrompt.stories.svelte.d.ts +0 -27
  136. package/dist/components/nodes/CaptionNode.stories.svelte +0 -65
  137. package/dist/components/nodes/CaptionNode.stories.svelte.d.ts +0 -18
  138. package/dist/components/nodes/GatewayNode.stories.svelte +0 -108
  139. package/dist/components/nodes/GatewayNode.stories.svelte.d.ts +0 -26
  140. package/dist/components/nodes/IdeaNode.stories.svelte +0 -52
  141. package/dist/components/nodes/IdeaNode.stories.svelte.d.ts +0 -26
  142. package/dist/components/nodes/NotesNode.stories.svelte +0 -76
  143. package/dist/components/nodes/NotesNode.stories.svelte.d.ts +0 -26
  144. package/dist/components/nodes/SimpleNode.stories.svelte +0 -223
  145. package/dist/components/nodes/SimpleNode.stories.svelte.d.ts +0 -26
  146. package/dist/components/nodes/SquareNode.stories.svelte +0 -127
  147. package/dist/components/nodes/SquareNode.stories.svelte.d.ts +0 -26
  148. package/dist/components/nodes/TerminalNode.stories.svelte +0 -25
  149. package/dist/components/nodes/TerminalNode.stories.svelte.d.ts +0 -26
  150. package/dist/components/nodes/ToolNode.stories.svelte +0 -189
  151. package/dist/components/nodes/ToolNode.stories.svelte.d.ts +0 -26
  152. package/dist/components/nodes/WorkflowNode.stories.svelte +0 -188
  153. package/dist/components/nodes/WorkflowNode.stories.svelte.d.ts +0 -26
  154. package/dist/components/playground/MessageBubble.stories.svelte +0 -151
  155. package/dist/components/playground/MessageBubble.stories.svelte.d.ts +0 -27
  156. package/dist/mocks/app-environment.d.ts +0 -8
  157. package/dist/mocks/app-environment.js +0 -16
  158. package/dist/mocks/app-forms.d.ts +0 -6
  159. package/dist/mocks/app-forms.js +0 -29
  160. package/dist/mocks/app-navigation.d.ts +0 -5
  161. package/dist/mocks/app-navigation.js +0 -36
  162. package/dist/mocks/app-stores.d.ts +0 -14
  163. package/dist/mocks/app-stores.js +0 -26
  164. package/dist/stories/CanvasDecorator.svelte +0 -49
  165. package/dist/stories/CanvasDecorator.svelte.d.ts +0 -8
  166. package/dist/stories/EdgeDecorator.svelte +0 -125
  167. package/dist/stories/EdgeDecorator.svelte.d.ts +0 -17
  168. package/dist/stories/NodeDecorator.svelte +0 -75
  169. package/dist/stories/NodeDecorator.svelte.d.ts +0 -8
  170. package/dist/stories/WebMCPFakeAgent.svelte +0 -229
  171. package/dist/stories/WebMCPFakeAgent.svelte.d.ts +0 -10
  172. package/dist/stories/utils.d.ts +0 -93
  173. package/dist/stories/utils.js +0 -156
  174. package/dist/webmcp/WebMCP.stories.svelte +0 -101
  175. package/dist/webmcp/WebMCP.stories.svelte.d.ts +0 -18
@@ -1,7 +1,7 @@
1
1
  <!--
2
2
  Port Coordinate Tracker Component
3
3
  Bridge component that exposes SvelteFlow's getInternalNode to the parent.
4
- Must be rendered inside SvelteFlowProvider context.
4
+ Must be rendered inside <SvelteFlow> (not beside it under a provider).
5
5
 
6
6
  Uses the same pattern as EdgeRefresher - a renderless component that hooks
7
7
  into the SvelteFlow context.
@@ -327,7 +327,7 @@
327
327
  {#if schema?.properties}
328
328
  <form
329
329
  bind:this={formRef}
330
- class="schema-form {className}"
330
+ class="flowdrop-scope schema-form {className}"
331
331
  class:schema-form--loading={loading}
332
332
  class:schema-form--disabled={disabled}
333
333
  onsubmit={(e) => {
@@ -126,7 +126,7 @@
126
126
  <!-- native <dialog> backdrop click-to-close pattern -->
127
127
  <dialog
128
128
  bind:this={dialogRef}
129
- class="flowdrop-settings-modal {className}"
129
+ class="flowdrop-scope flowdrop-settings-modal {className}"
130
130
  onclick={handleBackdropClick}
131
131
  onkeydown={handleKeydown}
132
132
  onclose={handleDialogClose}
@@ -420,7 +420,7 @@
420
420
  }
421
421
  </script>
422
422
 
423
- <div class="flowdrop-settings-panel {className}">
423
+ <div class="flowdrop-scope flowdrop-settings-panel {className}">
424
424
  <!-- Tab Navigation -->
425
425
  <div
426
426
  class="flowdrop-settings-panel__tabs"
@@ -12,7 +12,6 @@
12
12
  Background,
13
13
  BackgroundVariant,
14
14
  MiniMap,
15
- SvelteFlowProvider,
16
15
  type ColorMode
17
16
  } from '@xyflow/svelte';
18
17
  import '@xyflow/svelte/dist/style.css';
@@ -200,8 +199,16 @@
200
199
  let flowEdges = $state.raw<WorkflowEdge[]>([]);
201
200
 
202
201
  // Execution info loading state
203
- let loadExecutionInfoTimeout: number | null = null;
202
+ /** Cancels the scheduled (not yet started) execution-info load, if any. */
203
+ let cancelScheduledExecutionInfo: (() => void) | null = null;
204
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;
205
212
 
206
213
  /**
207
214
  * Key for SvelteFlow component — changes when workflow ID changes.
@@ -248,7 +255,11 @@
248
255
  } {
249
256
  const nodesWithCallbacks = workflow.nodes.map(withNodeCallbacks);
250
257
  const styledEdges = EdgeStylingHelper.updateEdgeStyles(workflow.edges, nodesWithCallbacks);
251
- 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 };
252
263
  }
253
264
 
254
265
  // ---------------------------------------------------------------------------
@@ -290,6 +301,9 @@
290
301
 
291
302
  const isNewWorkflow = storeValue.id !== previousSyncedWorkflowId;
292
303
 
304
+ // A different workflow never inherits the previous one's run status.
305
+ if (isNewWorkflow) latestExecutionInfo = null;
306
+
293
307
  if (isNewWorkflow) {
294
308
  untrack(() =>
295
309
  machine.send(previousSyncedWorkflowId ? 'WORKFLOW_SWITCHED' : 'WORKFLOW_LOADED')
@@ -302,8 +316,10 @@
302
316
  flowEdges = derived.edges;
303
317
  previousSyncedWorkflowId = storeValue.id;
304
318
 
305
- // Trigger port coordinate rebuild after workflow load
306
- 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)) {
307
323
  portCoordRebuildTrigger = Date.now();
308
324
  }
309
325
 
@@ -315,6 +331,14 @@
315
331
  // ---------------------------------------------------------------------------
316
332
  // Execution info effect (separate — async, depends on workflow + pipeline ID)
317
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
+
318
342
  let previousExecWorkflowId: string | null = null;
319
343
  let previousExecPipelineId: string | undefined = undefined;
320
344
 
@@ -322,7 +346,13 @@
322
346
  const storeValue = fd.workflow.current;
323
347
  const pipelineId = props.pipelineId;
324
348
 
325
- 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
+ }
326
356
 
327
357
  const workflowChanged = storeValue.id !== previousExecWorkflowId;
328
358
  const pipelineChanged = pipelineId !== previousExecPipelineId;
@@ -332,31 +362,36 @@
332
362
  previousExecWorkflowId = storeValue.id;
333
363
  previousExecPipelineId = pipelineId;
334
364
 
335
- // Cancel any pending idle/timeout schedule. In-flight fetches are
336
- // cancelled by loadNodeExecutionInfo() itself when it's re-entered.
337
- if (loadExecutionInfoTimeout) {
338
- clearTimeout(loadExecutionInfoTimeout);
339
- loadExecutionInfoTimeout = null;
340
- }
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();
341
370
 
342
371
  // Schedule loading with requestIdleCallback (falls back to setTimeout)
343
372
  if (typeof requestIdleCallback !== 'undefined') {
344
- loadExecutionInfoTimeout = requestIdleCallback(
345
- () => {
346
- loadNodeExecutionInfo();
347
- },
348
- { timeout: 500 }
349
- ) as unknown as number;
373
+ const id = requestIdleCallback(() => loadNodeExecutionInfo(), { timeout: 500 });
374
+ cancelScheduledExecutionInfo = () => cancelIdleCallback(id);
350
375
  } else {
351
- loadExecutionInfoTimeout = setTimeout(() => {
352
- loadNodeExecutionInfo();
353
- }, 300) as unknown as number;
376
+ const id = setTimeout(() => loadNodeExecutionInfo(), 300);
377
+ cancelScheduledExecutionInfo = () => clearTimeout(id);
354
378
  }
355
379
  });
356
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
+
357
389
  // Re-fetch node execution info when the parent bumps refreshTrigger
358
390
  // (poll ticks, chat-message arrivals, manual refresh). loadNodeExecutionInfo()
359
- // 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.
360
395
  // svelte-ignore state_referenced_locally
361
396
  let _prevExecRefreshTrigger = props.refreshTrigger ?? 0;
362
397
  $effect(() => {
@@ -417,20 +452,10 @@
417
452
 
418
453
  if (controller.signal.aborted) return;
419
454
 
420
- const defaultExecutionInfo: NodeExecutionInfo = {
421
- status: 'idle' as const,
422
- executionCount: 0,
423
- isExecuting: false
424
- };
425
-
426
- // Update flowNodes with execution info (visual-only, no store sync needed)
427
- flowNodes = flowNodes.map((node) => ({
428
- ...node,
429
- data: {
430
- ...node.data,
431
- executionInfo: executionInfo[node.id] || defaultExecutionInfo
432
- }
433
- }));
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);
434
459
 
435
460
  if (executionInfoAbortController === controller) {
436
461
  executionInfoAbortController = null;
@@ -1051,7 +1076,8 @@
1051
1076
  */
1052
1077
  let nodeIdToRefresh = $state<string | null>(null);
1053
1078
 
1054
- // Canvas viewport controller ref (rendered inside SvelteFlowProvider)
1079
+ // Canvas viewport controller ref. Rendered inside <SvelteFlow>, so it is
1080
+ // remounted with the canvas and always talks to the live instance's store.
1055
1081
  let canvasControllerRef: CanvasController | undefined = $state();
1056
1082
 
1057
1083
  /**
@@ -1099,7 +1125,7 @@
1099
1125
  nodeIdToRefresh = nodeId;
1100
1126
  }
1101
1127
 
1102
- // Canvas viewport methods (forwarded to CanvasController inside SvelteFlowProvider)
1128
+ // Canvas viewport methods (forwarded to CanvasController inside <SvelteFlow>)
1103
1129
 
1104
1130
  export function canvasFitView(): void {
1105
1131
  canvasControllerRef?.canvasFitView();
@@ -1193,156 +1219,156 @@
1193
1219
 
1194
1220
  <svelte:window onkeydown={handleKeydown} />
1195
1221
 
1196
- <SvelteFlowProvider>
1197
- <!-- Canvas viewport controller - provides fitView, zoom, pan methods -->
1198
- <CanvasController bind:this={canvasControllerRef} />
1199
-
1200
- <!-- EdgeRefresher component - handles updateNodeInternals calls -->
1201
- <EdgeRefresher {nodeIdToRefresh} onRefreshComplete={handleEdgeRefreshComplete} />
1202
-
1203
- <!-- Port Coordinate Tracker - maintains port positions for proximity connect -->
1204
- <PortCoordinateTracker
1205
- nodeToUpdate={portCoordNodeToUpdate}
1206
- rebuildTrigger={portCoordRebuildTrigger}
1207
- nodes={flowNodes}
1208
- />
1209
-
1210
- <div class="flowdrop-workflow-editor">
1211
- <!-- Main Editor Area -->
1212
- <div class="flowdrop-workflow-editor__main">
1213
- <!-- Flow Canvas.
1222
+ <div class="flowdrop-scope flowdrop-workflow-editor">
1223
+ <!-- Main Editor Area -->
1224
+ <div class="flowdrop-workflow-editor__main">
1225
+ <!-- Flow Canvas.
1214
1226
  Capture-phase mousedown so dragging from a port never turns into a
1215
1227
  WebKit text-selection drag — see suppressPortDragSelection. -->
1216
- <div
1217
- class="flowdrop-canvas"
1218
- bind:this={canvasEl}
1219
- onmousedowncapture={suppressPortDragSelection}
1228
+ <div
1229
+ class="flowdrop-canvas"
1230
+ bind:this={canvasEl}
1231
+ onmousedowncapture={suppressPortDragSelection}
1232
+ >
1233
+ <FlowDropZone
1234
+ ondrop={handleNodeDrop}
1235
+ onfiledrop={handleWorkflowFileDrop}
1236
+ toFlowPosition={(point) => canvasControllerRef?.canvasScreenToFlow(point) ?? null}
1220
1237
  >
1221
- <FlowDropZone ondrop={handleNodeDrop} onfiledrop={handleWorkflowFileDrop}>
1222
- {#key svelteFlowKey}
1223
- <SvelteFlow
1224
- id={fd.id}
1225
- bind:nodes={flowNodes}
1226
- bind:edges={flowEdges}
1227
- {nodeTypes}
1228
- {edgeTypes}
1229
- {defaultEdgeOptions}
1230
- onconnect={() => void handleConnect()}
1231
- onbeforedelete={handleBeforeDelete}
1232
- ondelete={handleNodesDelete}
1233
- onnodedragstart={handleNodeDragStart}
1234
- onnodedrag={handleNodeDrag}
1235
- onnodedragstop={handleNodeDragStop}
1236
- onnodecontextmenu={handleNodeContextMenu}
1237
- onselectioncontextmenu={handleSelectionContextMenu}
1238
- onpanecontextmenu={handlePaneContextMenu}
1239
- minZoom={0.2}
1240
- maxZoom={3}
1241
- clickConnect={true}
1242
- elevateEdgesOnSelect={true}
1243
- connectionLineType={ConnectionLineType.Bezier}
1244
- connectionLineComponent={ConnectionLine}
1245
- {snapGrid}
1246
- {initialViewport}
1247
- colorMode={getResolvedTheme() as ColorMode}
1248
- fitView={getEditorSettings().fitViewOnLoad}
1249
- nodesDraggable={canvasEditable}
1250
- nodesConnectable={canvasEditable}
1251
- elementsSelectable={canvasEditable}
1252
- >
1253
- <Controls />
1254
- {#if canvasEditable && props.onToggleConsole}
1255
- <CanvasIconButton
1256
- class="flowdrop-console-toggle"
1257
- label={props.consoleToggleLabel ?? m().layout.commandConsole}
1258
- active={props.consoleOpen}
1259
- onclick={props.onToggleConsole}
1260
- >
1261
- {#snippet icon()}
1262
- <CommandLineIcon />
1263
- {/snippet}
1264
- </CanvasIconButton>
1265
- {/if}
1266
- <!-- Always render Background for consistent bg color in dark/light mode -->
1267
- <Background
1268
- gap={getEditorSettings().gridSize}
1269
- bgColor="var(--fd-canvas-bg)"
1270
- variant={gridVariant}
1271
- lineWidth={1}
1272
- patternColor={getEditorSettings().showGrid
1273
- ? 'var(--fd-grid-pattern-color)'
1274
- : 'transparent'}
1275
- />
1276
- {#if getEditorSettings().showMinimap}
1277
- <MiniMap />
1278
- {/if}
1279
- </SvelteFlow>
1280
- {/key}
1281
- <!-- Drop Zone Indicator -->
1282
- {#if flowNodes.length === 0}
1283
- <CanvasBanner
1284
- title="Drag components here to start building"
1285
- description="Use the sidebar to add components to your workflow"
1286
- >
1287
- {#snippet icon()}
1288
- <svg
1289
- xmlns="http://www.w3.org/2000/svg"
1290
- width="1em"
1291
- height="1em"
1292
- viewBox="0 0 24 24"
1293
- fill="none"
1294
- stroke="currentColor"
1295
- stroke-width="1.5"
1296
- stroke-linecap="round"
1297
- stroke-linejoin="round"
1298
- >
1299
- <circle cx="18" cy="5" r="3" />
1300
- <circle cx="6" cy="12" r="3" />
1301
- <circle cx="18" cy="19" r="3" />
1302
- <line x1="8.59" y1="13.51" x2="15.42" y2="17.49" />
1303
- <line x1="15.41" y1="6.51" x2="8.59" y2="10.49" />
1304
- </svg>
1305
- {/snippet}
1306
- </CanvasBanner>
1307
- {/if}
1308
- </FlowDropZone>
1309
-
1310
- {#if openMenu}
1311
- <CanvasContextMenu
1312
- entries={openMenu.entries}
1313
- x={openMenu.x}
1314
- y={openMenu.y}
1315
- onselect={selectContextMenuEntry}
1316
- onclose={closeContextMenu}
1317
- />
1238
+ {#key svelteFlowKey}
1239
+ <SvelteFlow
1240
+ id={fd.id}
1241
+ bind:nodes={flowNodes}
1242
+ bind:edges={flowEdges}
1243
+ {nodeTypes}
1244
+ {edgeTypes}
1245
+ {defaultEdgeOptions}
1246
+ onconnect={() => void handleConnect()}
1247
+ onbeforedelete={handleBeforeDelete}
1248
+ ondelete={handleNodesDelete}
1249
+ onnodedragstart={handleNodeDragStart}
1250
+ onnodedrag={handleNodeDrag}
1251
+ onnodedragstop={handleNodeDragStop}
1252
+ onnodecontextmenu={handleNodeContextMenu}
1253
+ onselectioncontextmenu={handleSelectionContextMenu}
1254
+ onpanecontextmenu={handlePaneContextMenu}
1255
+ minZoom={0.2}
1256
+ maxZoom={3}
1257
+ clickConnect={true}
1258
+ elevateEdgesOnSelect={true}
1259
+ connectionLineType={ConnectionLineType.Bezier}
1260
+ connectionLineComponent={ConnectionLine}
1261
+ {snapGrid}
1262
+ {initialViewport}
1263
+ colorMode={getResolvedTheme() as ColorMode}
1264
+ fitView={getEditorSettings().fitViewOnLoad}
1265
+ nodesDraggable={canvasEditable}
1266
+ nodesConnectable={canvasEditable}
1267
+ elementsSelectable={canvasEditable}
1268
+ >
1269
+ <!-- Renderless helpers. They live inside <SvelteFlow>, not beside it
1270
+ under a provider: @xyflow/svelte >= 1.6.6 replaces the provider's
1271
+ store with an empty one when a SvelteFlow is destroyed, so after
1272
+ the {#key} remount a helper outside would act on that empty
1273
+ store (context-menu Delete silently did nothing). -->
1274
+ <CanvasController bind:this={canvasControllerRef} />
1275
+ <EdgeRefresher {nodeIdToRefresh} onRefreshComplete={handleEdgeRefreshComplete} />
1276
+ <PortCoordinateTracker
1277
+ nodeToUpdate={portCoordNodeToUpdate}
1278
+ rebuildTrigger={portCoordRebuildTrigger}
1279
+ nodes={flowNodes}
1280
+ />
1281
+ <Controls />
1282
+ {#if canvasEditable && props.onToggleConsole}
1283
+ <CanvasIconButton
1284
+ class="flowdrop-console-toggle"
1285
+ label={props.consoleToggleLabel ?? m().layout.commandConsole}
1286
+ active={props.consoleOpen}
1287
+ onclick={props.onToggleConsole}
1288
+ >
1289
+ {#snippet icon()}
1290
+ <CommandLineIcon />
1291
+ {/snippet}
1292
+ </CanvasIconButton>
1293
+ {/if}
1294
+ <!-- Always render Background for consistent bg color in dark/light mode -->
1295
+ <Background
1296
+ gap={getEditorSettings().gridSize}
1297
+ bgColor="var(--fd-canvas-bg)"
1298
+ variant={gridVariant}
1299
+ lineWidth={1}
1300
+ patternColor={getEditorSettings().showGrid
1301
+ ? 'var(--fd-grid-pattern-color)'
1302
+ : 'transparent'}
1303
+ />
1304
+ {#if getEditorSettings().showMinimap}
1305
+ <MiniMap />
1306
+ {/if}
1307
+ </SvelteFlow>
1308
+ {/key}
1309
+ <!-- Drop Zone Indicator -->
1310
+ {#if flowNodes.length === 0}
1311
+ <CanvasBanner
1312
+ title="Drag components here to start building"
1313
+ description="Use the sidebar to add components to your workflow"
1314
+ >
1315
+ {#snippet icon()}
1316
+ <svg
1317
+ xmlns="http://www.w3.org/2000/svg"
1318
+ width="1em"
1319
+ height="1em"
1320
+ viewBox="0 0 24 24"
1321
+ fill="none"
1322
+ stroke="currentColor"
1323
+ stroke-width="1.5"
1324
+ stroke-linecap="round"
1325
+ stroke-linejoin="round"
1326
+ >
1327
+ <circle cx="18" cy="5" r="3" />
1328
+ <circle cx="6" cy="12" r="3" />
1329
+ <circle cx="18" cy="19" r="3" />
1330
+ <line x1="8.59" y1="13.51" x2="15.42" y2="17.49" />
1331
+ <line x1="15.41" y1="6.51" x2="8.59" y2="10.49" />
1332
+ </svg>
1333
+ {/snippet}
1334
+ </CanvasBanner>
1318
1335
  {/if}
1319
- </div>
1336
+ </FlowDropZone>
1337
+
1338
+ {#if openMenu}
1339
+ <CanvasContextMenu
1340
+ entries={openMenu.entries}
1341
+ x={openMenu.x}
1342
+ y={openMenu.y}
1343
+ onselect={selectContextMenuEntry}
1344
+ onclose={closeContextMenu}
1345
+ />
1346
+ {/if}
1347
+ </div>
1348
+
1349
+ <!-- Status Bar: aria-live announces dynamic changes (node/edge counts, cycle warnings) -->
1350
+ <div class="flowdrop-status-bar" aria-live="polite" aria-atomic="true">
1351
+ <div class="flowdrop-status-bar__content">
1352
+ <div class="flowdrop-flex flowdrop-gap--4">
1353
+ <span class="flowdrop-text--xs flowdrop-text--gray">{flowNodes.length} nodes</span>
1354
+ <span class="flowdrop-text--xs flowdrop-text--gray">•</span>
1355
+ <span class="flowdrop-text--xs flowdrop-text--gray">{flowEdges.length} connections</span>
1320
1356
 
1321
- <!-- Status Bar: aria-live announces dynamic changes (node/edge counts, cycle warnings) -->
1322
- <div class="flowdrop-status-bar" aria-live="polite" aria-atomic="true">
1323
- <div class="flowdrop-status-bar__content">
1324
- <div class="flowdrop-flex flowdrop-gap--4">
1325
- <span class="flowdrop-text--xs flowdrop-text--gray">{flowNodes.length} nodes</span>
1357
+ {#if hasCycles}
1326
1358
  <span class="flowdrop-text--xs flowdrop-text--gray">•</span>
1327
- <span class="flowdrop-text--xs flowdrop-text--gray">{flowEdges.length} connections</span
1359
+ <span class="flowdrop-text--xs flowdrop-font--medium flowdrop-text--error"
1360
+ >⚠️ Cycles detected</span
1328
1361
  >
1329
-
1330
- {#if hasCycles}
1331
- <span class="flowdrop-text--xs flowdrop-text--gray">•</span>
1332
- <span class="flowdrop-text--xs flowdrop-font--medium flowdrop-text--error"
1333
- >⚠️ Cycles detected</span
1334
- >
1335
- {/if}
1336
- </div>
1362
+ {/if}
1337
1363
  </div>
1338
1364
  </div>
1339
1365
  </div>
1340
1366
  </div>
1341
- </SvelteFlowProvider>
1367
+ </div>
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()`).