@flowdrop/flowdrop 2.11.0 → 2.13.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 (455) hide show
  1. package/CHANGELOG.md +233 -0
  2. package/dist/adapters/agentspec/autoLayout.d.ts +18 -36
  3. package/dist/adapters/agentspec/autoLayout.js +75 -93
  4. package/dist/chat/activity.d.ts +49 -0
  5. package/dist/chat/activity.js +65 -0
  6. package/dist/chat/commandClassifier.js +2 -1
  7. package/dist/commands/executor.js +186 -27
  8. package/dist/commands/index.d.ts +2 -1
  9. package/dist/commands/index.js +2 -0
  10. package/dist/commands/parser.js +43 -3
  11. package/dist/commands/session.d.ts +60 -0
  12. package/dist/commands/session.js +332 -0
  13. package/dist/commands/storeIntegration.svelte.js +18 -1
  14. package/dist/commands/types.d.ts +77 -4
  15. package/dist/components/App.svelte +976 -226
  16. package/dist/components/App.svelte.d.ts +34 -2
  17. package/dist/components/BindablePortListbox.svelte +68 -369
  18. package/dist/components/Button.svelte +17 -14
  19. package/dist/components/Button.svelte.d.ts +2 -2
  20. package/dist/components/CanvasContextMenu.svelte +31 -10
  21. package/dist/components/CanvasController.svelte +146 -3
  22. package/dist/components/CanvasController.svelte.d.ts +25 -33
  23. package/dist/components/CanvasIconButton.svelte +6 -6
  24. package/dist/components/CanvasToolbar.svelte +103 -0
  25. package/dist/components/CanvasToolbar.svelte.d.ts +23 -0
  26. package/dist/components/CanvasZoomControls.svelte +122 -0
  27. package/dist/components/CanvasZoomControls.svelte.d.ts +15 -0
  28. package/dist/components/ConfigForm.svelte +159 -121
  29. package/dist/components/ConfigModal.svelte +11 -54
  30. package/dist/components/ConfigPanel.svelte +98 -228
  31. package/dist/components/ConfigPanel.svelte.d.ts +2 -2
  32. package/dist/components/ConnectPortPicker.svelte +153 -0
  33. package/dist/components/ConnectPortPicker.svelte.d.ts +22 -0
  34. package/dist/components/DoctorMenu.svelte +422 -0
  35. package/dist/components/DoctorMenu.svelte.d.ts +7 -0
  36. package/dist/components/ExternalLinkRow.svelte +82 -0
  37. package/dist/components/ExternalLinkRow.svelte.d.ts +14 -0
  38. package/dist/components/FlowDropEdge.svelte +52 -2
  39. package/dist/components/FlowDropEdge.svelte.d.ts +5 -1
  40. package/dist/components/InterfaceNameInput.svelte +103 -0
  41. package/dist/components/InterfaceNameInput.svelte.d.ts +13 -0
  42. package/dist/components/InterfaceTag.svelte +215 -0
  43. package/dist/components/InterfaceTag.svelte.d.ts +20 -0
  44. package/dist/components/InterfaceTagAnchor.svelte +103 -0
  45. package/dist/components/InterfaceTagAnchor.svelte.d.ts +12 -0
  46. package/dist/components/InterfaceTagLayer.svelte +314 -0
  47. package/dist/components/InterfaceTagLayer.svelte.d.ts +28 -0
  48. package/dist/components/LogsSidebar.svelte +43 -43
  49. package/dist/components/LoopbackLanes.svelte +54 -0
  50. package/dist/components/LoopbackLanes.svelte.d.ts +8 -0
  51. package/dist/components/Navbar.svelte +539 -169
  52. package/dist/components/Navbar.svelte.d.ts +20 -1
  53. package/dist/components/NodeInspector.svelte +153 -0
  54. package/dist/components/NodeInspector.svelte.d.ts +19 -0
  55. package/dist/components/NodeLastRun.svelte +212 -0
  56. package/dist/components/NodeLastRun.svelte.d.ts +13 -0
  57. package/dist/components/NodeSidebar.svelte +279 -23
  58. package/dist/components/NodeSidebar.svelte.d.ts +11 -0
  59. package/dist/components/NodeStatusOverlay.svelte +144 -353
  60. package/dist/components/NodeStatusOverlay.svelte.d.ts +4 -1
  61. package/dist/components/PortMappingRow.svelte +28 -44
  62. package/dist/components/PortPickerListbox.svelte +475 -0
  63. package/dist/components/PortPickerListbox.svelte.d.ts +73 -0
  64. package/dist/components/ReadOnlyDetails.svelte +52 -89
  65. package/dist/components/RunBar.svelte +222 -0
  66. package/dist/components/RunBar.svelte.d.ts +20 -0
  67. package/dist/components/RunsMenu.svelte +649 -0
  68. package/dist/components/RunsMenu.svelte.d.ts +14 -0
  69. package/dist/components/SettingsModal.svelte +27 -59
  70. package/dist/components/SettingsPanel.svelte +515 -241
  71. package/dist/components/StraightGuides.svelte +46 -0
  72. package/dist/components/StraightGuides.svelte.d.ts +7 -0
  73. package/dist/components/ThemeToggle.svelte +14 -4
  74. package/dist/components/UniversalNode.svelte +152 -51
  75. package/dist/components/WebMCPBridgeMenu.svelte +336 -0
  76. package/dist/components/WebMCPBridgeMenu.svelte.d.ts +3 -0
  77. package/dist/components/WorkflowEditor.svelte +789 -136
  78. package/dist/components/WorkflowEditor.svelte.d.ts +43 -1
  79. package/dist/components/WorkflowInterfaceEditor.svelte +63 -92
  80. package/dist/components/WorkflowInterfaceEntryCard.svelte +478 -549
  81. package/dist/components/WorkflowInterfaceEntryComposer.svelte +23 -67
  82. package/dist/components/WorkflowPlaygroundSettings.svelte +48 -85
  83. package/dist/components/WorkflowSettingsPanel.svelte +311 -0
  84. package/dist/components/WorkflowSettingsPanel.svelte.d.ts +20 -0
  85. package/dist/components/ZoomTier.svelte +56 -0
  86. package/dist/components/ZoomTier.svelte.d.ts +4 -0
  87. package/dist/components/chat/AIChatPanel.svelte +463 -312
  88. package/dist/components/chat/ActivityList.svelte +130 -0
  89. package/dist/components/chat/ActivityList.svelte.d.ts +11 -0
  90. package/dist/components/chat/ActivityRow.svelte +179 -0
  91. package/dist/components/chat/ActivityRow.svelte.d.ts +16 -0
  92. package/dist/components/chat/CommandPreview.svelte +42 -64
  93. package/dist/components/console/CommandConsole.svelte +106 -41
  94. package/dist/components/console/CommandConsole.svelte.d.ts +2 -0
  95. package/dist/components/console/ConsoleAutocomplete.svelte +14 -13
  96. package/dist/components/console/ConsoleInput.svelte +60 -27
  97. package/dist/components/console/ConsoleOutput.svelte +86 -24
  98. package/dist/components/console/ConsoleStrip.svelte +80 -0
  99. package/dist/components/console/ConsoleStrip.svelte.d.ts +13 -0
  100. package/dist/components/form/FieldFactory.svelte +30 -4
  101. package/dist/components/form/FormArray.svelte +306 -339
  102. package/dist/components/form/FormArray.svelte.d.ts +10 -0
  103. package/dist/components/form/FormArrayRows.svelte +443 -0
  104. package/dist/components/form/FormArrayRows.svelte.d.ts +18 -0
  105. package/dist/components/form/FormAutocomplete.svelte +2 -2
  106. package/dist/components/form/FormCheckboxGroup.svelte +10 -85
  107. package/dist/components/form/FormCodeEditor.svelte +3 -3
  108. package/dist/components/form/FormFieldWrapper.svelte +98 -18
  109. package/dist/components/form/FormFieldWrapper.svelte.d.ts +10 -0
  110. package/dist/components/form/FormFieldset.svelte +44 -28
  111. package/dist/components/form/FormMarkdownEditor.svelte +6 -6
  112. package/dist/components/form/FormPorts.svelte +437 -141
  113. package/dist/components/form/FormSelect.svelte +1 -1
  114. package/dist/components/form/FormTemplateEditor.svelte +22 -26
  115. package/dist/components/form/FormToggle.svelte +15 -106
  116. package/dist/components/form/FormToggle.svelte.d.ts +3 -2
  117. package/dist/components/form/FormUISchemaRenderer.svelte +38 -3
  118. package/dist/components/form/humanizeKey.d.ts +7 -0
  119. package/dist/components/form/humanizeKey.js +21 -0
  120. package/dist/components/form/types.d.ts +6 -0
  121. package/dist/components/icons/MenuOpenIcon.svelte +8 -1
  122. package/dist/components/interrupt/ChoicePrompt.svelte +51 -152
  123. package/dist/components/interrupt/ChoicePrompt.svelte.d.ts +0 -2
  124. package/dist/components/interrupt/ConfirmationPrompt.svelte +18 -201
  125. package/dist/components/interrupt/ConfirmationPrompt.svelte.d.ts +0 -4
  126. package/dist/components/interrupt/FormPrompt.svelte +22 -147
  127. package/dist/components/interrupt/FormPrompt.svelte.d.ts +0 -4
  128. package/dist/components/interrupt/InterruptBubble.svelte +198 -355
  129. package/dist/components/interrupt/InterruptBubble.svelte.d.ts +0 -2
  130. package/dist/components/interrupt/ReviewPrompt.svelte +0 -10
  131. package/dist/components/interrupt/TextInputPrompt.svelte +23 -120
  132. package/dist/components/interrupt/TextInputPrompt.svelte.d.ts +0 -2
  133. package/dist/components/layouts/MainLayout.svelte +110 -75
  134. package/dist/components/layouts/MainLayout.svelte.d.ts +17 -0
  135. package/dist/components/nodes/CaptionNode.svelte +7 -0
  136. package/dist/components/nodes/GatewayNode.svelte +66 -431
  137. package/dist/components/nodes/IdeaNode.svelte +6 -5
  138. package/dist/components/nodes/NodeCard.svelte +1051 -0
  139. package/dist/components/nodes/NodeCard.svelte.d.ts +30 -0
  140. package/dist/components/nodes/NodeConfigButton.svelte +28 -9
  141. package/dist/components/nodes/NodeProblemMark.svelte +113 -0
  142. package/dist/components/nodes/NodeProblemMark.svelte.d.ts +8 -0
  143. package/dist/components/nodes/NodeTip.svelte +104 -0
  144. package/dist/components/nodes/NodeTip.svelte.d.ts +15 -0
  145. package/dist/components/nodes/NotesNode.svelte +183 -150
  146. package/dist/components/nodes/SimpleNode.svelte +176 -44
  147. package/dist/components/nodes/SquareNode.svelte +127 -34
  148. package/dist/components/nodes/TerminalNode.svelte +232 -88
  149. package/dist/components/nodes/ToolNode.svelte +49 -381
  150. package/dist/components/nodes/WorkflowNode.svelte +40 -399
  151. package/dist/components/playground/ChatBubble.svelte +248 -62
  152. package/dist/components/playground/ChatInput.svelte +134 -297
  153. package/dist/components/playground/ChatInput.svelte.d.ts +17 -0
  154. package/dist/components/playground/ControlPanel.svelte +290 -190
  155. package/dist/components/playground/ControlPanel.svelte.d.ts +10 -2
  156. package/dist/components/playground/DockedPlayground.svelte +82 -0
  157. package/dist/components/playground/DockedPlayground.svelte.d.ts +30 -0
  158. package/dist/components/playground/ExecutionConsole.svelte +54 -36
  159. package/dist/components/playground/ExecutionConsole.svelte.d.ts +12 -0
  160. package/dist/components/playground/ExecutionLogs.svelte +4 -0
  161. package/dist/components/playground/HeaderMenu.svelte +170 -0
  162. package/dist/components/playground/HeaderMenu.svelte.d.ts +22 -0
  163. package/dist/components/playground/InputCollector.svelte +8 -32
  164. package/dist/components/playground/InputFields.svelte +246 -0
  165. package/dist/components/playground/InputFields.svelte.d.ts +16 -0
  166. package/dist/components/playground/InterfaceInputForm.svelte +285 -30
  167. package/dist/components/playground/InterfaceInputForm.svelte.d.ts +20 -0
  168. package/dist/components/playground/InterfaceJsonInput.svelte +92 -0
  169. package/dist/components/playground/InterfaceJsonInput.svelte.d.ts +10 -0
  170. package/dist/components/playground/LogRow.svelte +12 -12
  171. package/dist/components/playground/MessageMarkdown.svelte +11 -11
  172. package/dist/components/playground/MessageStream.svelte +154 -182
  173. package/dist/components/playground/Playground.svelte +17 -1139
  174. package/dist/components/playground/PlaygroundApp.svelte +12 -2
  175. package/dist/components/playground/PlaygroundApp.svelte.d.ts +2 -1
  176. package/dist/components/playground/PlaygroundHeader.svelte +309 -0
  177. package/dist/components/playground/PlaygroundHeader.svelte.d.ts +22 -0
  178. package/dist/components/playground/PlaygroundModal.svelte +6 -0
  179. package/dist/components/playground/PlaygroundStudio.svelte +30 -32
  180. package/dist/components/playground/PlaygroundSurface.svelte +648 -0
  181. package/dist/components/playground/PlaygroundSurface.svelte.d.ts +79 -0
  182. package/dist/components/playground/StepsSummary.svelte +312 -0
  183. package/dist/components/playground/StepsSummary.svelte.d.ts +11 -0
  184. package/dist/components/playground/messageDisplay.d.ts +9 -0
  185. package/dist/components/playground/messageDisplay.js +24 -2
  186. package/dist/components/playground/stepSummary.d.ts +71 -0
  187. package/dist/components/playground/stepSummary.js +152 -0
  188. package/dist/components/ports/PortTypeBadge.svelte +13 -1
  189. package/dist/components/primitives/Button.svelte +226 -0
  190. package/dist/components/primitives/Button.svelte.d.ts +31 -0
  191. package/dist/components/primitives/Card.svelte +110 -0
  192. package/dist/components/primitives/Card.svelte.d.ts +20 -0
  193. package/dist/components/primitives/Checkbox.svelte +126 -0
  194. package/dist/components/primitives/Checkbox.svelte.d.ts +15 -0
  195. package/dist/components/primitives/Chip.svelte +143 -0
  196. package/dist/components/primitives/Chip.svelte.d.ts +22 -0
  197. package/dist/components/primitives/Combobox.svelte +444 -0
  198. package/dist/components/primitives/Combobox.svelte.d.ts +22 -0
  199. package/dist/components/primitives/Composer.svelte +293 -0
  200. package/dist/components/primitives/Composer.svelte.d.ts +47 -0
  201. package/dist/components/primitives/EmptyState.svelte +113 -0
  202. package/dist/components/primitives/EmptyState.svelte.d.ts +18 -0
  203. package/dist/components/primitives/Field.svelte +178 -0
  204. package/dist/components/primitives/Field.svelte.d.ts +30 -0
  205. package/dist/components/primitives/IconButton.svelte +156 -0
  206. package/dist/components/primitives/IconButton.svelte.d.ts +27 -0
  207. package/dist/components/primitives/Menu.svelte +435 -0
  208. package/dist/components/primitives/Menu.svelte.d.ts +61 -0
  209. package/dist/components/primitives/Notice.svelte +161 -0
  210. package/dist/components/primitives/Notice.svelte.d.ts +22 -0
  211. package/dist/components/primitives/PanelHeader.svelte +134 -0
  212. package/dist/components/primitives/PanelHeader.svelte.d.ts +23 -0
  213. package/dist/components/primitives/Segmented.svelte +198 -0
  214. package/dist/components/primitives/Segmented.svelte.d.ts +32 -0
  215. package/dist/components/primitives/Select.svelte +130 -0
  216. package/dist/components/primitives/Select.svelte.d.ts +26 -0
  217. package/dist/components/primitives/StatusPill.svelte +218 -0
  218. package/dist/components/primitives/StatusPill.svelte.d.ts +24 -0
  219. package/dist/components/primitives/Switch.svelte +113 -0
  220. package/dist/components/primitives/Switch.svelte.d.ts +14 -0
  221. package/dist/components/primitives/Tabs.svelte +209 -0
  222. package/dist/components/primitives/Tabs.svelte.d.ts +32 -0
  223. package/dist/components/primitives/Toolbar.svelte +94 -0
  224. package/dist/components/primitives/Toolbar.svelte.d.ts +14 -0
  225. package/dist/components/primitives/ToolbarSeparator.svelte +40 -0
  226. package/dist/components/primitives/ToolbarSeparator.svelte.d.ts +7 -0
  227. package/dist/components/surfaces/SurfaceOverlay.svelte +10 -40
  228. package/dist/components/surfaces/TabbedSurface.svelte +49 -39
  229. package/dist/components/surfaces/TabbedSurface.svelte.d.ts +8 -0
  230. package/dist/components/toast/DismissibleToast.svelte +94 -32
  231. package/dist/components/toast/DismissibleToast.svelte.d.ts +17 -7
  232. package/dist/config/endpoints.d.ts +43 -1
  233. package/dist/config/endpoints.js +21 -3
  234. package/dist/core/index.d.ts +8 -5
  235. package/dist/core/index.js +1 -1
  236. package/dist/editor/connectCandidates.d.ts +56 -0
  237. package/dist/editor/connectCandidates.js +131 -0
  238. package/dist/editor/contextMenu.d.ts +31 -2
  239. package/dist/editor/contextMenu.js +96 -9
  240. package/dist/editor/index.d.ts +4 -1
  241. package/dist/editor/index.js +1 -0
  242. package/dist/editor/interfaceMenu.d.ts +35 -0
  243. package/dist/editor/interfaceMenu.js +47 -0
  244. package/dist/editor/portMenu.d.ts +23 -0
  245. package/dist/editor/portMenu.js +34 -0
  246. package/dist/editor/tidy.d.ts +30 -0
  247. package/dist/editor/tidy.js +66 -0
  248. package/dist/helpers/workflowEditorHelper.d.ts +3 -0
  249. package/dist/helpers/workflowEditorHelper.js +8 -3
  250. package/dist/layout/fromWorkflow.d.ts +42 -0
  251. package/dist/layout/fromWorkflow.js +135 -0
  252. package/dist/layout/geometry.d.ts +102 -0
  253. package/dist/layout/geometry.js +317 -0
  254. package/dist/layout/index.d.ts +21 -0
  255. package/dist/layout/index.js +14 -0
  256. package/dist/layout/inspect.d.ts +18 -0
  257. package/dist/layout/inspect.js +81 -0
  258. package/dist/layout/lanePath.d.ts +23 -0
  259. package/dist/layout/lanePath.js +47 -0
  260. package/dist/layout/measure.d.ts +141 -0
  261. package/dist/layout/measure.js +477 -0
  262. package/dist/layout/primitives.d.ts +124 -0
  263. package/dist/layout/primitives.js +461 -0
  264. package/dist/layout/sweep.d.ts +59 -0
  265. package/dist/layout/sweep.js +257 -0
  266. package/dist/layout/toWorkflow.d.ts +43 -0
  267. package/dist/layout/toWorkflow.js +131 -0
  268. package/dist/layout/types.d.ts +93 -0
  269. package/dist/layout/types.js +35 -0
  270. package/dist/messages/defaults.d.ts +641 -26
  271. package/dist/messages/defaults.js +578 -25
  272. package/dist/messages/types.d.ts +21 -1
  273. package/dist/openapi/v1/openapi.yaml +109 -0
  274. package/dist/playground/index.d.ts +28 -1
  275. package/dist/playground/index.js +29 -0
  276. package/dist/playground/mount.d.ts +28 -2
  277. package/dist/playground/mount.js +41 -15
  278. package/dist/playground/runAction.d.ts +29 -0
  279. package/dist/playground/runAction.js +38 -0
  280. package/dist/services/doctorService.d.ts +52 -0
  281. package/dist/services/doctorService.js +113 -0
  282. package/dist/services/globalSave.js +12 -29
  283. package/dist/services/nodeExecutionService.d.ts +12 -1
  284. package/dist/services/nodeExecutionService.js +58 -58
  285. package/dist/services/playgroundService.d.ts +17 -2
  286. package/dist/services/playgroundService.js +48 -5
  287. package/dist/services/runsService.d.ts +42 -0
  288. package/dist/services/runsService.js +87 -0
  289. package/dist/services/toastQueue.d.ts +33 -0
  290. package/dist/services/toastQueue.js +38 -0
  291. package/dist/services/toastService.d.ts +30 -9
  292. package/dist/services/toastService.js +81 -46
  293. package/dist/settings/index.d.ts +1 -0
  294. package/dist/skins/graphite.d.ts +26 -0
  295. package/dist/skins/graphite.js +473 -0
  296. package/dist/skins/index.d.ts +2 -1
  297. package/dist/skins/index.js +4 -2
  298. package/dist/skins/slate.js +4 -4
  299. package/dist/stores/attachedRunStore.svelte.d.ts +35 -0
  300. package/dist/stores/attachedRunStore.svelte.js +47 -0
  301. package/dist/stores/connectDragStore.svelte.d.ts +39 -0
  302. package/dist/stores/connectDragStore.svelte.js +42 -0
  303. package/dist/stores/doctorStore.svelte.d.ts +79 -0
  304. package/dist/stores/doctorStore.svelte.js +244 -0
  305. package/dist/stores/editedNodesStore.svelte.d.ts +42 -0
  306. package/dist/stores/editedNodesStore.svelte.js +84 -0
  307. package/dist/stores/editorModeStore.svelte.d.ts +34 -0
  308. package/dist/stores/editorModeStore.svelte.js +55 -0
  309. package/dist/stores/instanceContainer.svelte.d.ts +53 -0
  310. package/dist/stores/instanceContainer.svelte.js +38 -1
  311. package/dist/stores/loopbackLanesStore.svelte.d.ts +18 -0
  312. package/dist/stores/loopbackLanesStore.svelte.js +25 -0
  313. package/dist/stores/nodeHighlightStore.svelte.d.ts +34 -0
  314. package/dist/stores/nodeHighlightStore.svelte.js +56 -0
  315. package/dist/stores/playgroundStore.svelte.d.ts +66 -2
  316. package/dist/stores/playgroundStore.svelte.js +164 -2
  317. package/dist/stores/runController.svelte.d.ts +382 -0
  318. package/dist/stores/runController.svelte.js +1217 -0
  319. package/dist/stores/settingsStore.svelte.d.ts +80 -18
  320. package/dist/stores/settingsStore.svelte.js +180 -62
  321. package/dist/stores/workflowStore.svelte.d.ts +14 -0
  322. package/dist/stores/workflowStore.svelte.js +22 -1
  323. package/dist/styles/base.css +286 -25
  324. package/dist/styles/fonts/Inter-LICENSE.txt +93 -0
  325. package/dist/styles/fonts/inter-latin-wght-normal.woff2 +0 -0
  326. package/dist/styles/fonts/inter.css +19 -0
  327. package/dist/styles/toast.css +100 -20
  328. package/dist/styles/tokenAliases.js +118 -1
  329. package/dist/styles/tokens.css +586 -14
  330. package/dist/svelte-app.d.ts +47 -5
  331. package/dist/svelte-app.js +15 -3
  332. package/dist/themes/graphite.d.ts +2 -0
  333. package/dist/themes/graphite.js +15 -0
  334. package/dist/themes/index.d.ts +2 -1
  335. package/dist/themes/index.js +22 -3
  336. package/dist/themes/minimal.js +10 -0
  337. package/dist/themes/scopedSkinCss.d.ts +22 -5
  338. package/dist/themes/scopedSkinCss.js +136 -11
  339. package/dist/types/chat.d.ts +6 -0
  340. package/dist/types/doctor.d.ts +82 -0
  341. package/dist/types/doctor.js +11 -0
  342. package/dist/types/events.d.ts +35 -0
  343. package/dist/types/events.js +4 -1
  344. package/dist/types/index.d.ts +17 -2
  345. package/dist/types/navbar.d.ts +36 -0
  346. package/dist/types/playground.d.ts +75 -0
  347. package/dist/types/settings.d.ts +120 -7
  348. package/dist/types/settings.js +35 -3
  349. package/dist/types/skin.d.ts +21 -8
  350. package/dist/types/theme.d.ts +40 -2
  351. package/dist/utils/appearance.d.ts +19 -0
  352. package/dist/utils/appearance.js +13 -0
  353. package/dist/utils/canvasFit.d.ts +41 -0
  354. package/dist/utils/canvasFit.js +44 -0
  355. package/dist/utils/chipTitles.d.ts +9 -0
  356. package/dist/utils/chipTitles.js +19 -0
  357. package/dist/utils/connections.js +8 -0
  358. package/dist/utils/consoleHighlight.d.ts +28 -0
  359. package/dist/utils/consoleHighlight.js +269 -0
  360. package/dist/utils/deprecation.d.ts +17 -0
  361. package/dist/utils/deprecation.js +29 -0
  362. package/dist/utils/doctorOperations.d.ts +40 -0
  363. package/dist/utils/doctorOperations.js +237 -0
  364. package/dist/utils/duration.d.ts +13 -0
  365. package/dist/utils/duration.js +40 -0
  366. package/dist/utils/inspectorContext.d.ts +19 -0
  367. package/dist/utils/inspectorContext.js +12 -0
  368. package/dist/utils/inspectorSections.d.ts +20 -0
  369. package/dist/utils/inspectorSections.js +44 -0
  370. package/dist/utils/inspectorSurface.d.ts +46 -0
  371. package/dist/utils/inspectorSurface.js +51 -0
  372. package/dist/utils/interfaceTags.d.ts +102 -0
  373. package/dist/utils/interfaceTags.js +211 -0
  374. package/dist/utils/itemRef.d.ts +86 -0
  375. package/dist/utils/itemRef.js +106 -0
  376. package/dist/utils/lastRun.d.ts +35 -0
  377. package/dist/utils/lastRun.js +73 -0
  378. package/dist/utils/messageNodeLink.d.ts +17 -0
  379. package/dist/utils/messageNodeLink.js +16 -0
  380. package/dist/utils/minimapVisibility.d.ts +28 -0
  381. package/dist/utils/minimapVisibility.js +34 -0
  382. package/dist/utils/nodeAriaLabel.d.ts +12 -0
  383. package/dist/utils/nodeAriaLabel.js +17 -0
  384. package/dist/utils/nodeFingerprint.d.ts +27 -0
  385. package/dist/utils/nodeFingerprint.js +66 -0
  386. package/dist/utils/nodeFormSchema.d.ts +10 -0
  387. package/dist/utils/nodeFormSchema.js +2 -2
  388. package/dist/utils/nodeGeometry.d.ts +168 -0
  389. package/dist/utils/nodeGeometry.js +204 -0
  390. package/dist/utils/nodeProblem.d.ts +19 -0
  391. package/dist/utils/nodeProblem.js +9 -0
  392. package/dist/utils/nodeStatus.d.ts +38 -3
  393. package/dist/utils/nodeStatus.js +67 -39
  394. package/dist/utils/nodeSwap.js +9 -1
  395. package/dist/utils/nodeWrapper.d.ts +1 -0
  396. package/dist/utils/playgroundHistory.d.ts +48 -0
  397. package/dist/utils/playgroundHistory.js +38 -0
  398. package/dist/utils/playgroundInputRuns.d.ts +26 -0
  399. package/dist/utils/playgroundInputRuns.js +50 -0
  400. package/dist/utils/portExposure.d.ts +49 -0
  401. package/dist/utils/portExposure.js +122 -0
  402. package/dist/utils/portUtils.d.ts +16 -0
  403. package/dist/utils/portUtils.js +37 -0
  404. package/dist/utils/portal.d.ts +0 -19
  405. package/dist/utils/portal.js +8 -1
  406. package/dist/utils/reservedPorts.d.ts +59 -0
  407. package/dist/utils/reservedPorts.js +60 -0
  408. package/dist/utils/runEdges.d.ts +24 -0
  409. package/dist/utils/runEdges.js +35 -0
  410. package/dist/utils/runsList.d.ts +69 -0
  411. package/dist/utils/runsList.js +134 -0
  412. package/dist/utils/selectOptions.d.ts +62 -0
  413. package/dist/utils/selectOptions.js +137 -0
  414. package/dist/utils/sessionRuns.d.ts +62 -0
  415. package/dist/utils/sessionRuns.js +123 -0
  416. package/dist/utils/sheetWidths.d.ts +29 -0
  417. package/dist/utils/sheetWidths.js +41 -0
  418. package/dist/utils/sidebarWidths.d.ts +34 -0
  419. package/dist/utils/sidebarWidths.js +47 -0
  420. package/dist/utils/straightWires.d.ts +73 -0
  421. package/dist/utils/straightWires.js +99 -0
  422. package/dist/utils/themeScope.svelte.d.ts +10 -0
  423. package/dist/utils/themeScope.svelte.js +80 -0
  424. package/dist/utils/wiredHandles.d.ts +10 -0
  425. package/dist/utils/wiredHandles.js +14 -0
  426. package/dist/utils/workflowDraft.d.ts +9 -0
  427. package/dist/utils/workflowDraft.js +39 -0
  428. package/dist/utils/workflowInterface.d.ts +40 -7
  429. package/dist/utils/workflowInterface.js +66 -16
  430. package/dist/utils/zoomTier.d.ts +43 -0
  431. package/dist/utils/zoomTier.js +107 -0
  432. package/dist/utils/zoomTierRows.d.ts +41 -0
  433. package/dist/utils/zoomTierRows.js +103 -0
  434. package/dist/webmcp/WebMCPConfirm.svelte +1 -1
  435. package/dist/webmcp/bridge.d.ts +5 -0
  436. package/dist/webmcp/bridge.js +8 -0
  437. package/dist/webmcp/bridgeController.svelte.d.ts +84 -0
  438. package/dist/webmcp/bridgeController.svelte.js +224 -0
  439. package/dist/webmcp/descriptors.d.ts +1 -1
  440. package/dist/webmcp/descriptors.js +66 -5
  441. package/dist/webmcp/fakeWidget.d.ts +34 -0
  442. package/dist/webmcp/fakeWidget.js +75 -0
  443. package/dist/webmcp/gate.js +4 -0
  444. package/dist/webmcp/index.d.ts +2 -0
  445. package/dist/webmcp/index.js +1 -0
  446. package/dist/webmcp/runtime.js +4 -1
  447. package/dist/webmcp/types.d.ts +2 -0
  448. package/dist/webmcp/validate.js +5 -1
  449. package/package.json +8 -2
  450. package/dist/components/Select.svelte +0 -53
  451. package/dist/components/Select.svelte.d.ts +0 -15
  452. package/dist/components/icons/CommandLineIcon.svelte +0 -15
  453. package/dist/components/icons/CommandLineIcon.svelte.d.ts +0 -26
  454. package/dist/components/toast/WarningIcon.svelte +0 -28
  455. package/dist/components/toast/WarningIcon.svelte.d.ts +0 -26
@@ -8,11 +8,11 @@
8
8
  import {
9
9
  SvelteFlow,
10
10
  ConnectionLineType,
11
- Controls,
12
11
  Background,
13
12
  BackgroundVariant,
14
13
  MiniMap,
15
- type ColorMode
14
+ type ColorMode,
15
+ type OnConnectStart
16
16
  } from '@xyflow/svelte';
17
17
  import '@xyflow/svelte/dist/style.css';
18
18
  import {
@@ -22,7 +22,15 @@
22
22
  } from '../stores/settingsStore.svelte.js';
23
23
  import type { WorkflowNode as WorkflowNodeType, Workflow, WorkflowEdge } from '../types/index.js';
24
24
  import CanvasBanner from './CanvasBanner.svelte';
25
+ import CanvasToolbar from './CanvasToolbar.svelte';
25
26
  import CanvasController from './CanvasController.svelte';
27
+ import StraightGuides from './StraightGuides.svelte';
28
+ import { snapToStraight, type StraightGuide } from '../utils/straightWires.js';
29
+ import { createStoreCommandContext } from '../commands/storeIntegration.svelte.js';
30
+ import { executeCommand } from '../commands/executor.js';
31
+ import type { CommandResult, LayoutResultData } from '../commands/types.js';
32
+ import { describeTidy, tweenPositions, TIDY_ANIMATION_MS } from '../editor/tidy.js';
33
+ import CanvasZoomControls from './CanvasZoomControls.svelte';
26
34
  import CanvasContextMenu from './CanvasContextMenu.svelte';
27
35
  import {
28
36
  resolveContextMenuEntries,
@@ -35,6 +43,7 @@
35
43
  } from '../editor/contextMenu.js';
36
44
  import type { NodeMetadata } from '../types/index.js';
37
45
  import { resolveComponentName } from '../utils/nodeTypes.js';
46
+ import { nodeAriaLabel } from '../utils/nodeAriaLabel.js';
38
47
  import { decideInlineCommit } from '../utils/captionText.js';
39
48
  import FlowDropZone from './FlowDropZone.svelte';
40
49
  import EdgeRefresher from './EdgeRefresher.svelte';
@@ -43,7 +52,8 @@
43
52
  import type { AuthProvider } from '../types/auth.js';
44
53
  import ConnectionLine from './ConnectionLine.svelte';
45
54
  import FlowDropEdge from './FlowDropEdge.svelte';
46
- import { m, getMessages } from '../messages/index.js';
55
+ import LoopbackLanes from './LoopbackLanes.svelte';
56
+ import { getMessages } from '../messages/index.js';
47
57
  import { provideInstance } from '../stores/getInstance.svelte.js';
48
58
  import type { FlowDropInstance } from '../stores/instanceContainer.svelte.js';
49
59
  import type { FlowDropGridVariant } from '../types/theme.js';
@@ -54,31 +64,67 @@
54
64
  WorkflowOperationsHelper,
55
65
  ConfigurationHelper
56
66
  } from '../helpers/workflowEditorHelper.js';
57
- import type { NodeExecutionInfo } from '../types/index.js';
58
67
  import { Toaster } from 'svelte-5-french-toast';
59
68
  import {
60
69
  flowdropToastOptions,
61
70
  FLOWDROP_TOASTER_CLASS,
62
- apiToasts
71
+ apiToasts,
72
+ showError,
73
+ showInfo,
74
+ showSuccess
63
75
  } from '../services/toastService.js';
64
76
  import {
65
77
  ProximityConnectHelper,
66
78
  type ProximityEdgeCandidate
67
79
  } from '../helpers/proximityConnect.js';
68
80
  import PortCoordinateTracker from './PortCoordinateTracker.svelte';
81
+ import { interfaceTagReserve } from '../utils/interfaceTags.js';
82
+ import ZoomTier from './ZoomTier.svelte';
83
+ import InterfaceTagLayer, { type InterfaceTagEdit } from './InterfaceTagLayer.svelte';
84
+ import type { InterfaceMenuActions, PortTarget } from '../editor/interfaceMenu.js';
85
+ import { buildPortMenuEntries, type PortMenuActions } from '../editor/portMenu.js';
86
+ import {
87
+ buildConnectEdge,
88
+ connectPickerGroups,
89
+ listConnectCandidates,
90
+ type ConnectCandidate
91
+ } from '../editor/connectCandidates.js';
92
+ import ConnectPortPicker from './ConnectPortPicker.svelte';
93
+ import {
94
+ applyPortExposure,
95
+ exposureCandidates,
96
+ type PortExposureMode
97
+ } from '../utils/portExposure.js';
98
+ import {
99
+ entryAtPort,
100
+ exposePortAsEntry,
101
+ removeInterfaceEntry,
102
+ renameInterfaceEntry
103
+ } from '../utils/interfaceTags.js';
104
+ import { extractDirection, extractPortId } from '../utils/handleIds.js';
69
105
  import { logger } from '../utils/logger.js';
70
106
  import { validateWorkflowData } from '../utils/validation.js';
71
107
  import { suppressPortDragSelection } from '../utils/canvasSelection.js';
108
+ import {
109
+ MINIMAP_WIDTH,
110
+ MINIMAP_HEIGHT,
111
+ MINIMAP_BORDER,
112
+ shouldShowMinimap
113
+ } from '../utils/minimapVisibility.js';
72
114
  import { createEditorStateMachine } from '../stores/editorStateMachine.svelte.js';
73
- import CanvasIconButton from './CanvasIconButton.svelte';
74
- import CommandLineIcon from './icons/CommandLineIcon.svelte';
75
115
  import { DEV } from 'esm-env';
116
+ import { CANVAS_FIT_PADDING } from '../utils/canvasFit.js';
117
+ import { isEventInputConnection } from '../utils/reservedPorts.js';
76
118
 
77
119
  interface Props {
78
120
  endpointConfig?: EndpointConfig;
79
121
  /** Auth provider applied to this instance's API requests. */
80
122
  authProvider?: AuthProvider;
81
123
  openConfigSidebar?: (node: WorkflowNodeType) => void;
124
+ /** Start the node-swap flow for a node. Omit to leave "Swap node" out of the context menu. */
125
+ onSwapNode?: (nodeId: string) => void;
126
+ /** A node was clicked (not dragged). Test mode opens its inspector sheet from here. */
127
+ onNodeClick?: (node: WorkflowNodeType) => void;
82
128
  /**
83
129
  * Editor interaction mode. `'edit'` allows node drag/connect/select and
84
130
  * proximity-connect; `'readonly'` and `'locked'` disable all canvas
@@ -95,11 +141,22 @@
95
141
  * arrivals down to the canvas without owning a separate status channel.
96
142
  */
97
143
  refreshTrigger?: number;
98
- // Console toggle
144
+ /**
145
+ * @deprecated No effect. The console is a bottom strip driven by the `ui.consoleOpen`
146
+ * setting; the toolbar toggle these three props fed is gone. Accepted so 2.11.0 hosts
147
+ * keep compiling. Removed in 3.0; use `updateSettings({ ui: { consoleOpen } })`.
148
+ */
99
149
  consoleOpen?: boolean;
150
+ /** @deprecated No effect (see `consoleOpen`). Removed in 3.0. */
100
151
  onToggleConsole?: () => void;
101
- /** Label of the console-group toggle; defaults to the Command Console wording. */
152
+ /** @deprecated No effect (see `consoleOpen`). Removed in 3.0. */
102
153
  consoleToggleLabel?: string;
154
+ /** Take a failed run on the run pill to the Assistant. */
155
+ onAskAssistant?: (runId: string) => void;
156
+ /** Offer the Runs list in Test mode (the canvas toolbar's "Runs"). @default false */
157
+ showRuns?: boolean;
158
+ /** Host URL templates for the Runs list's admin links (`features.adminLinks`). */
159
+ adminLinks?: { runs?: string; run?: string };
103
160
  /** Per-instance state container (created by mount functions). Defaults to the page-default instance. */
104
161
  instance?: FlowDropInstance;
105
162
  /**
@@ -125,8 +182,31 @@
125
182
  * The menu only opens in `'edit'` mode.
126
183
  */
127
184
  contextMenu?: ContextMenuOptions;
185
+ /**
186
+ * Show the run pill in the canvas toolbar while a run exists (a Console
187
+ * `session run`, an Assistant run). It appears only for an editable
188
+ * canvas and never at rest. In Test mode it shows only while the run is
189
+ * live. Hosts that show runs another way set `false`.
190
+ * @default true
191
+ */
192
+ showRunBar?: boolean;
193
+ /**
194
+ * Take the person to the run in Test mode: the run pill's Open button, shown
195
+ * while a run waits for them. Without it the button is not shown.
196
+ */
197
+ onOpenTest?: () => void;
198
+ /** Current editor mode, shown in the canvas toolbar's Edit | Test switch. @default 'edit' */
199
+ editorMode?: 'edit' | 'test';
200
+ /** Switch the editor mode. The toolbar's Edit | Test switch is shown only when this is set. */
201
+ onEditorModeChange?: (mode: 'edit' | 'test') => void;
202
+ /**
203
+ * How much of the canvas's right side an open sheet covers, in px, read when
204
+ * the view is fitted so the graph lands in the visible part. @default 0
205
+ */
206
+ fitInset?: () => number;
128
207
  }
129
208
 
209
+ // eslint-disable-next-line svelte/no-unused-props -- `consoleOpen`, `onToggleConsole` and `consoleToggleLabel` are deprecated no-ops kept for hosts
130
210
  let props: Props = $props();
131
211
 
132
212
  // Resolve (and provide to children) the per-instance state container.
@@ -198,17 +278,10 @@
198
278
  let flowNodes = $state.raw<WorkflowNodeType[]>([]);
199
279
  let flowEdges = $state.raw<WorkflowEdge[]>([]);
200
280
 
201
- // Execution info loading state
281
+ // Run status loading. The status itself lives in fd.playground.nodeStatuses
282
+ // (never on the nodes); the editor only decides when to ask fd.runs to load it.
202
283
  /** Cancels the scheduled (not yet started) execution-info load, if any. */
203
284
  let cancelScheduledExecutionInfo: (() => void) | null = null;
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;
212
285
 
213
286
  /**
214
287
  * Key for SvelteFlow component — changes when workflow ID changes.
@@ -239,8 +312,16 @@
239
312
  // ---------------------------------------------------------------------------
240
313
  /** Add the callbacks every node component can call: open config, commit an in-place edit. */
241
314
  function withNodeCallbacks(node: WorkflowNodeType) {
315
+ // Accessible name for xyflow's focusable node wrapper (the inner node
316
+ // components are role-less, so they cannot carry one).
317
+ const title =
318
+ (node.data.config?.instanceTitle as string) || node.data.label || node.data.metadata?.name;
319
+ const componentName = node.data.metadata
320
+ ? resolveComponentName(fd.nodes, node.data.metadata, node.data.config?.nodeType as string)
321
+ : 'workflowNode';
242
322
  return {
243
323
  ...node,
324
+ ariaLabel: nodeAriaLabel(getMsgs().nodes.graph, componentName, title ?? node.id),
244
325
  data: {
245
326
  ...node.data,
246
327
  onConfigOpen: props.openConfigSidebar,
@@ -255,17 +336,14 @@
255
336
  } {
256
337
  const nodesWithCallbacks = workflow.nodes.map(withNodeCallbacks);
257
338
  const styledEdges = EdgeStylingHelper.updateEdgeStyles(workflow.edges, nodesWithCallbacks);
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 };
339
+ return { nodes: nodesWithCallbacks, edges: styledEdges };
263
340
  }
264
341
 
265
342
  // ---------------------------------------------------------------------------
266
343
  // Helper: sync current flowNodes/flowEdges back to the global store
267
344
  // ---------------------------------------------------------------------------
268
345
  function syncFlowToStore(): void {
346
+ finishTidyAnimation();
269
347
  const storeValue = untrack(() => fd.workflow.current);
270
348
  if (!storeValue) return;
271
349
  const updatedWorkflow = WorkflowOperationsHelper.updateWorkflow(
@@ -302,7 +380,7 @@
302
380
  const isNewWorkflow = storeValue.id !== previousSyncedWorkflowId;
303
381
 
304
382
  // A different workflow never inherits the previous one's run status.
305
- if (isNewWorkflow) latestExecutionInfo = null;
383
+ if (isNewWorkflow) untrack(() => fd.runs.clearNodeStatuses());
306
384
 
307
385
  if (isNewWorkflow) {
308
386
  untrack(() =>
@@ -312,7 +390,19 @@
312
390
 
313
391
  // Derive flowNodes/flowEdges from store
314
392
  const derived = buildFlowNodesFromStore(storeValue);
315
- flowNodes = derived.nodes;
393
+ // The canvas owns selection. The store only holds the flags of its last
394
+ // structural sync, so rebuilding from it (any config edit) must not bring a
395
+ // stale selection back: two nodes would show the ring while the inspector
396
+ // names one. Nodes the canvas has not seen yet keep the store's flag.
397
+ const canvasSelection = isNewWorkflow
398
+ ? null
399
+ : untrack(() => new Map(flowNodes.map((n) => [n.id, !!n.selected])));
400
+ flowNodes = canvasSelection
401
+ ? derived.nodes.map((n) => {
402
+ const selected = canvasSelection.get(n.id);
403
+ return selected === undefined || selected === !!n.selected ? n : { ...n, selected };
404
+ })
405
+ : derived.nodes;
316
406
  flowEdges = derived.edges;
317
407
  previousSyncedWorkflowId = storeValue.id;
318
408
 
@@ -331,12 +421,9 @@
331
421
  // ---------------------------------------------------------------------------
332
422
  // Execution info effect (separate — async, depends on workflow + pipeline ID)
333
423
  // ---------------------------------------------------------------------------
334
- /** Forget the loaded run status and take it off the canvas nodes. */
424
+ /** Forget the loaded run status (and any load still in flight). */
335
425
  function resetExecutionInfo(): void {
336
- latestExecutionInfo = null;
337
- untrack(() => {
338
- flowNodes = NodeOperationsHelper.applyExecutionInfo(flowNodes, null);
339
- });
426
+ untrack(() => fd.runs.clearNodeStatuses());
340
427
  }
341
428
 
342
429
  let previousExecWorkflowId: string | null = null;
@@ -365,7 +452,6 @@
365
452
  // Cancel any pending schedule and any in-flight fetch (it belongs to the
366
453
  // previous pipeline), and drop the previous run's status.
367
454
  cancelScheduledExecutionInfo?.();
368
- executionInfoAbortController?.abort();
369
455
  resetExecutionInfo();
370
456
 
371
457
  // Schedule loading with requestIdleCallback (falls back to setTimeout)
@@ -379,19 +465,18 @@
379
465
  });
380
466
 
381
467
  // On unmount: drop a scheduled load and discard an in-flight one, so
382
- // nothing writes flowNodes after the editor is gone.
468
+ // nothing writes the store after the editor is gone.
383
469
  $effect(() => () => {
384
470
  cancelScheduledExecutionInfo?.();
385
- executionInfoAbortController?.abort();
386
- latestExecutionInfo = null;
471
+ fd.runs.clearNodeStatuses();
387
472
  });
388
473
 
389
474
  // Re-fetch node execution info when the parent bumps refreshTrigger
390
475
  // (poll ticks, chat-message arrivals, manual refresh). loadNodeExecutionInfo()
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.
476
+ // is the single loader of run status: fd.runs puts the result in
477
+ // fd.playground.nodeStatuses, which the node overlay reads. Nothing is
478
+ // written onto flowNodes, so a rebuild from the store (any edit, a settings
479
+ // change) never drops the badges. No parallel channel.
395
480
  // svelte-ignore state_referenced_locally
396
481
  let _prevExecRefreshTrigger = props.refreshTrigger ?? 0;
397
482
  $effect(() => {
@@ -429,42 +514,14 @@
429
514
  });
430
515
 
431
516
  /**
432
- * Load node execution information for all nodes in the workflow.
433
- * Cancels any in-flight fetch so concurrent callers (pipelineId change
434
- * and refreshTrigger bumps) can't race on flowNodes.
517
+ * Ask the run controller to load node status for the shown pipeline.
518
+ * A newer call (pipelineId change, refreshTrigger bump) supersedes an
519
+ * in-flight one, so they can't race.
435
520
  */
436
521
  async function loadNodeExecutionInfo(): Promise<void> {
437
522
  const workflow = untrack(() => fd.workflow.current);
438
523
  if (!workflow?.nodes || !props.pipelineId) return;
439
-
440
- if (executionInfoAbortController) {
441
- executionInfoAbortController.abort();
442
- }
443
- const controller = new AbortController();
444
- executionInfoAbortController = controller;
445
-
446
- try {
447
- const executionInfo = await NodeOperationsHelper.loadNodeExecutionInfo(
448
- fd.api,
449
- workflow,
450
- props.pipelineId
451
- );
452
-
453
- if (controller.signal.aborted) return;
454
-
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);
459
-
460
- if (executionInfoAbortController === controller) {
461
- executionInfoAbortController = null;
462
- }
463
- } catch (error) {
464
- if (error instanceof Error && error.name !== 'AbortError') {
465
- logger.error('Failed to load node execution info:', error);
466
- }
467
- }
524
+ await fd.runs.loadNodeStatuses(props.pipelineId, workflow);
468
525
  }
469
526
 
470
527
  // The global store should be initialized by the parent App component
@@ -493,23 +550,73 @@
493
550
  * position updates. SvelteFlow mutates flowNodes directly via bind:nodes.
494
551
  */
495
552
  function handleNodeDragStart(): void {
553
+ finishTidyAnimation();
496
554
  machine.send('START_DRAG');
555
+ lastMagnet = null;
556
+ straightGuides = [];
497
557
  // Clear any leftover proximity previews
498
558
  currentProximityCandidates = [];
499
559
  }
500
560
 
561
+ /** Guide lines along the wires a dragged node has snapped straight. */
562
+ let straightGuides = $state.raw<StraightGuide[]>([]);
563
+ /** The last magnetic shift of the running drag, re-applied at drag stop (xyflow rewrites the raw position then). */
564
+ let lastMagnet: { dy: number; ids: Set<string> } | null = null;
565
+
566
+ /** Move nodes vertically (flow units) in the canvas state. */
567
+ function shiftNodes(ids: ReadonlySet<string>, dy: number): void {
568
+ flowNodes = flowNodes.map((n) =>
569
+ ids.has(n.id) ? { ...n, position: { x: n.position.x, y: n.position.y + dy } } : n
570
+ );
571
+ }
572
+
573
+ /**
574
+ * Magnetic alignment: when a wire from a dragged node is within 10px of
575
+ * straight, shift the dragged node(s) so it is exactly straight and show a
576
+ * guide along it. Alt switches it off. xyflow recomputes the position from
577
+ * the pointer on every move, so the shift never accumulates.
578
+ */
579
+ function applyMagnet(
580
+ dragged: WorkflowNodeType[],
581
+ event: MouseEvent | TouchEvent | null | undefined
582
+ ): void {
583
+ const none = (): void => {
584
+ lastMagnet = null;
585
+ if (straightGuides.length > 0) straightGuides = [];
586
+ };
587
+ if (!canvasEditable || !canvasControllerRef || dragged.length === 0) return none();
588
+ const moving = new Set(dragged.map((n) => n.id));
589
+ const wires = canvasControllerRef.canvasWireEnds(
590
+ ProximityConnectHelper.removePreviewEdges(flowEdges)
591
+ );
592
+ const positions = new Map(flowNodes.map((n) => [n.id, n.position]));
593
+ for (const n of dragged) positions.set(n.id, n.position);
594
+ const settings = getEditorSettings();
595
+ const { dy, guides } = snapToStraight(wires, positions, moving, {
596
+ grid: settings.snapToGrid ? settings.gridSize : undefined,
597
+ disabled: !!event && 'altKey' in event && event.altKey
598
+ });
599
+ if (dy === 0 && guides.length === 0) return none();
600
+ lastMagnet = { dy, ids: moving };
601
+ if (dy !== 0) shiftNodes(moving, dy);
602
+ straightGuides = guides;
603
+ }
604
+
501
605
  /**
502
606
  * Handle node drag - compute proximity connect preview edges
503
607
  * Called continuously during drag if proximity connect is enabled.
504
608
  * Uses port-to-port distance via the port coordinate store.
505
609
  */
506
610
  function handleNodeDrag({
507
- targetNode
611
+ targetNode,
612
+ nodes: draggedNodes,
613
+ event
508
614
  }: {
509
615
  targetNode: WorkflowNodeType | null;
510
616
  nodes: WorkflowNodeType[];
511
617
  event: MouseEvent | TouchEvent;
512
618
  }): void {
619
+ applyMagnet(draggedNodes, event);
513
620
  if (!getEditorSettings().proximityConnect || !targetNode || !canvasEditable) {
514
621
  if (currentProximityCandidates.length > 0) {
515
622
  flowEdges = ProximityConnectHelper.removePreviewEdges(flowEdges);
@@ -561,6 +668,11 @@
561
668
  function handleNodeDragStop(): void {
562
669
  portCoordNodeToUpdate = null;
563
670
 
671
+ // xyflow wrote the raw pointer position back at drag end: put the snap back.
672
+ if (lastMagnet && lastMagnet.dy !== 0) shiftNodes(lastMagnet.ids, lastMagnet.dy);
673
+ lastMagnet = null;
674
+ straightGuides = [];
675
+
564
676
  // Finalize proximity connect if there are candidates
565
677
  if (getEditorSettings().proximityConnect && currentProximityCandidates.length > 0) {
566
678
  const baseEdges = ProximityConnectHelper.removePreviewEdges(flowEdges);
@@ -593,6 +705,27 @@
593
705
  machine.send('STOP_DRAG');
594
706
  }
595
707
 
708
+ /**
709
+ * A wire is dragged out of a port: record its type so every card can light
710
+ * the ports that take it. NodeCard puts the port's data type on the handle.
711
+ */
712
+ const handleConnectStart: OnConnectStart = (event, { nodeId, handleId, handleType }) => {
713
+ const handle =
714
+ event.target instanceof Element ? event.target.closest('.svelte-flow__handle') : null;
715
+ const dataType = handle instanceof HTMLElement ? handle.dataset.fdPortType : undefined;
716
+ const portId = extractPortId(handleId ?? undefined);
717
+ if (!nodeId || !portId || !handleType || !dataType) {
718
+ fd.connectDrag.set(null);
719
+ return;
720
+ }
721
+ fd.connectDrag.set({
722
+ nodeId,
723
+ direction: handleType === 'source' ? 'output' : 'input',
724
+ portId,
725
+ dataType
726
+ });
727
+ };
728
+
596
729
  /**
597
730
  * Handle new connections between nodes.
598
731
  * The connection details aren't needed — SvelteFlow auto-creates the edge
@@ -791,6 +924,50 @@
791
924
  let openMenu = $state.raw<OpenContextMenu | null>(null);
792
925
  let canvasEl: HTMLDivElement | undefined = $state();
793
926
 
927
+ // Canvas width, tracked on the canvas element (not the window): the editor can
928
+ // sit in a narrow column of a wider page. Drives the minimap's 800 px rule.
929
+ let canvasWidth: number | undefined = $state();
930
+ $effect(() => {
931
+ if (!canvasEl) return;
932
+ const el = canvasEl;
933
+ canvasWidth = el.clientWidth;
934
+ const observer = new ResizeObserver((entries) => {
935
+ const entry = entries[entries.length - 1];
936
+ if (entry) canvasWidth = entry.contentRect.width;
937
+ });
938
+ observer.observe(el);
939
+ return () => observer.disconnect();
940
+ });
941
+
942
+ // A message link's node lights up here, and the node under the pointer
943
+ // lights its messages (fd.highlight). A class on xyflow's own node wrapper,
944
+ // so every node type gets it without knowing about it.
945
+ const LINKED_CLASS = 'fd-node-linked';
946
+ $effect(() => {
947
+ const id = fd.highlight.canvasNodeId;
948
+ // Re-run when nodes are (re)rendered so a node that mounts later is lit too.
949
+ void flowNodes;
950
+ if (!id || !canvasEl) return;
951
+ const el = canvasEl.querySelector<HTMLElement>(
952
+ `.svelte-flow__node[data-id="${CSS.escape(id)}"]`
953
+ );
954
+ el?.classList.add(LINKED_CLASS);
955
+ return () => el?.classList.remove(LINKED_CLASS);
956
+ });
957
+
958
+ function nodeIdAt(target: EventTarget | null): string | null {
959
+ const el = (target as Element | null)?.closest?.('.svelte-flow__node');
960
+ return el?.getAttribute('data-id') ?? null;
961
+ }
962
+ function handleCanvasOver(event: MouseEvent): void {
963
+ const id = nodeIdAt(event.target);
964
+ if (id !== null) fd.highlight.hoverNode(id);
965
+ }
966
+ function handleCanvasOut(event: MouseEvent): void {
967
+ const leaving = nodeIdAt(event.target);
968
+ if (leaving !== null && nodeIdAt(event.relatedTarget) !== leaving) fd.highlight.hoverNode(null);
969
+ }
970
+
794
971
  /** Whether a node's registered component edits its text in place (the caption). */
795
972
  function nodeEditsInPlace(node: WorkflowNodeType): boolean {
796
973
  return (
@@ -879,9 +1056,236 @@
879
1056
  },
880
1057
  editInPlace(id) {
881
1058
  fd.inlineEdit.request(id);
1059
+ },
1060
+ duplicateNode(id) {
1061
+ const source = flowNodes.find((n) => n.id === id);
1062
+ if (!source?.data.metadata) return;
1063
+ const grid = getEditorSettings().gridSize;
1064
+ const offset = grid * 2;
1065
+ // The same path as a sidebar drop, so the id, history entry and sync all apply.
1066
+ placeNode(
1067
+ JSON.stringify({
1068
+ type: 'node',
1069
+ nodeData: {
1070
+ label: source.data.label,
1071
+ config: structuredClone($state.snapshot(source.data.config ?? {})),
1072
+ metadata: source.data.metadata
1073
+ }
1074
+ }),
1075
+ { x: source.position.x + offset, y: source.position.y + offset }
1076
+ );
1077
+ },
1078
+ tidyLayout() {
1079
+ tidyLayout();
1080
+ },
1081
+ tidyNodes(ids) {
1082
+ tidyNodes(ids);
1083
+ },
1084
+ hideUnconnectedPorts(ids) {
1085
+ changePortExposure(ids, 'hide');
1086
+ },
1087
+ countUnconnectedPorts(ids) {
1088
+ return countExposureChanges(ids, 'hide');
1089
+ },
1090
+ showHiddenPorts(ids) {
1091
+ changePortExposure(ids, 'show');
1092
+ },
1093
+ countHiddenPorts(ids) {
1094
+ return countExposureChanges(ids, 'show');
1095
+ },
1096
+ get swapNode() {
1097
+ const swap = props.onSwapNode;
1098
+ return swap ? (id: string) => swap(id) : undefined;
882
1099
  }
883
1100
  };
884
1101
 
1102
+ // ---------------------------------------------------------------------------
1103
+ // "Tidy up": the layout commands from the canvas button, the menus and the keys
1104
+ // ---------------------------------------------------------------------------
1105
+
1106
+ /** A command context on this instance, for the layout commands. Null without a workflow. */
1107
+ function layoutContext() {
1108
+ return createStoreCommandContext(fd.nodeTypes.current ?? [], undefined, fd);
1109
+ }
1110
+
1111
+ /** The layout counts of a layout command's result, if it has them. */
1112
+ function layoutData(result: CommandResult): LayoutResultData | undefined {
1113
+ return result.ok && result.data && 'changed' in result.data ? result.data : undefined;
1114
+ }
1115
+
1116
+ /** Tidy the whole graph (`layout beautify`): one undo step, or "already tidy" and nothing moves. */
1117
+ function tidyLayout(): void {
1118
+ if (!canvasEditable) return;
1119
+ const context = layoutContext();
1120
+ if (!context || flowNodes.length === 0) return;
1121
+ const from = positionsOf(flowNodes);
1122
+ const result = executeCommand({ type: 'beautify_layout' }, context);
1123
+ // A refusal (too many nodes) is not "already tidy": say what it is.
1124
+ if (!result.ok) {
1125
+ showError({
1126
+ title: result.code === 'TOO_LARGE' ? getMsgs().tidy.tooLarge : getMsgs().tidy.button,
1127
+ body: result.error
1128
+ });
1129
+ return;
1130
+ }
1131
+ announceTidy(layoutData(result), from, getMsgs().tidy.alreadyTidy);
1132
+ }
1133
+
1134
+ /**
1135
+ * Tidy these nodes one after another (`layout node beautify`). One node is one command; several
1136
+ * are one transaction, so one undo step, and none at all when nothing moved.
1137
+ */
1138
+ function tidyNodes(ids: readonly string[]): void {
1139
+ if (!canvasEditable || ids.length === 0) return;
1140
+ const msgs = getMsgs().tidy;
1141
+ const already = ids.length > 1 ? msgs.nodesAlreadyTidy : msgs.nodeAlreadyTidy;
1142
+ const context = layoutContext();
1143
+ if (!context) return;
1144
+ const from = positionsOf(flowNodes);
1145
+ const results: CommandResult[] = [];
1146
+ if (ids.length === 1) {
1147
+ // A beautify that changes nothing writes nothing, so it leaves no undo entry.
1148
+ results.push(executeCommand({ type: 'beautify_node', nodeId: ids[0] }, context));
1149
+ } else {
1150
+ context.dispatch.startTransaction(`Tidy ${ids.length} nodes`);
1151
+ for (const nodeId of ids) {
1152
+ const result = executeCommand({ type: 'beautify_node', nodeId }, context);
1153
+ results.push(result);
1154
+ if (!result.ok) break;
1155
+ }
1156
+ const moved = results.every((r) => r.ok) && results.some((r) => layoutData(r)?.changed);
1157
+ if (moved) context.dispatch.commitTransaction();
1158
+ else context.dispatch.cancelTransaction();
1159
+ }
1160
+ const steps = results.map(layoutData).filter((d): d is LayoutResultData => !!d);
1161
+ const data: LayoutResultData | undefined = steps.length
1162
+ ? {
1163
+ changed: steps.some((d) => d.changed),
1164
+ before: steps[0].before,
1165
+ after: steps[steps.length - 1].after
1166
+ }
1167
+ : undefined;
1168
+ announceTidy(data, from, already);
1169
+ }
1170
+
1171
+ function positionsOf(nodes: readonly WorkflowNodeType[]): Map<string, { x: number; y: number }> {
1172
+ return new Map(nodes.map((n) => [n.id, { x: n.position.x, y: n.position.y }]));
1173
+ }
1174
+
1175
+ /** The toast after a tidy, and the cards sliding from where they were. */
1176
+ function announceTidy(
1177
+ data: LayoutResultData | undefined,
1178
+ from: Map<string, { x: number; y: number }>,
1179
+ alreadyTidy: string
1180
+ ): void {
1181
+ const msgs = getMsgs().tidy;
1182
+ if (!data?.changed) {
1183
+ showInfo({ title: alreadyTidy, body: msgs.alreadyTidyBody });
1184
+ return;
1185
+ }
1186
+ const parts = describeTidy(data, msgs);
1187
+ showSuccess({
1188
+ title: msgs.done,
1189
+ ...(parts.length ? { body: parts.join(' · ') } : {}),
1190
+ action: { label: msgs.undo, onClick: () => fd.historyBindings.undo() }
1191
+ });
1192
+ void animateFrom(from);
1193
+ }
1194
+
1195
+ /**
1196
+ * Slide the cards from `from` to where the store now has them. Only the canvas moves: the
1197
+ * store and the history already hold the end state. Stops when the workflow changes again
1198
+ * (an undo, an edit) and skips the slide under reduced motion.
1199
+ */
1200
+ async function animateFrom(from: Map<string, { x: number; y: number }>): Promise<void> {
1201
+ if (typeof window === 'undefined' || typeof requestAnimationFrame === 'undefined') return;
1202
+ if (window.matchMedia?.('(prefers-reduced-motion: reduce)').matches) return;
1203
+ await tick();
1204
+ const target = fd.workflow.current;
1205
+ const to = positionsOf(flowNodes);
1206
+ if (tweenPositions(from, to, 0).size === 0) return;
1207
+ const tween = { target, to };
1208
+ tidyTween = tween;
1209
+ const start = performance.now();
1210
+ const frame = (now: number) => {
1211
+ if (tidyTween !== tween) return;
1212
+ if (fd.workflow.current !== target) {
1213
+ tidyTween = null;
1214
+ return;
1215
+ }
1216
+ const t = (now - start) / TIDY_ANIMATION_MS;
1217
+ const at = t >= 1 ? to : tweenPositions(from, to, t);
1218
+ flowNodes = flowNodes.map((n) => {
1219
+ const position = at.get(n.id);
1220
+ return position ? { ...n, position } : n;
1221
+ });
1222
+ if (t < 1) requestAnimationFrame(frame);
1223
+ else tidyTween = null;
1224
+ };
1225
+ requestAnimationFrame(frame);
1226
+ }
1227
+
1228
+ /** The running tidy slide, if any: the workflow it belongs to and where the cards end up. */
1229
+ let tidyTween: {
1230
+ target: unknown;
1231
+ to: Map<string, { x: number; y: number }>;
1232
+ } | null = null;
1233
+
1234
+ /**
1235
+ * Stop a running tidy slide and put the cards at its end positions, so a sync to the store
1236
+ * never commits a half-moved card.
1237
+ */
1238
+ function finishTidyAnimation(): void {
1239
+ const tween = tidyTween;
1240
+ if (!tween) return;
1241
+ tidyTween = null;
1242
+ if (fd.workflow.current !== tween.target) return;
1243
+ flowNodes = flowNodes.map((n) => {
1244
+ const position = tween.to.get(n.id);
1245
+ return position ? { ...n, position } : n;
1246
+ });
1247
+ }
1248
+
1249
+ /** How many ports a bulk exposure change would touch on these nodes. */
1250
+ function countExposureChanges(ids: readonly string[], mode: PortExposureMode): number {
1251
+ const workflow = fd.workflow.current;
1252
+ if (!workflow) return 0;
1253
+ return workflow.nodes
1254
+ .filter((n) => ids.includes(n.id))
1255
+ .reduce((sum, n) => sum + exposureCandidates(n, workflow, mode).length, 0);
1256
+ }
1257
+
1258
+ /**
1259
+ * "Hide unconnected ports" / "Show hidden ports": a real exposure edit of
1260
+ * each node's `config.ports` (the same one the Ports form's eye makes), as
1261
+ * one undo step. Hidden ports leave the canvas and stop being wireable.
1262
+ */
1263
+ function changePortExposure(ids: readonly string[], mode: PortExposureMode): void {
1264
+ const workflow = fd.workflow.current;
1265
+ if (!canvasEditable || !workflow) return;
1266
+ const changes = new Map<string, ReturnType<typeof applyPortExposure>>();
1267
+ for (const node of workflow.nodes) {
1268
+ if (!ids.includes(node.id)) continue;
1269
+ if (exposureCandidates(node, workflow, mode).length === 0) continue;
1270
+ changes.set(node.id, applyPortExposure(node, workflow, mode));
1271
+ }
1272
+ if (changes.size === 0) return;
1273
+ flowNodes = flowNodes.map((n) => {
1274
+ if (!changes.has(n.id)) return n;
1275
+ const { ports: _previous, ...rest } = n.data.config ?? {};
1276
+ const ports = changes.get(n.id);
1277
+ return { ...n, data: { ...n.data, config: ports ? { ...rest, ports } : rest } };
1278
+ });
1279
+ syncFlowToStore();
1280
+ const storeValue = fd.workflow.current;
1281
+ if (storeValue) {
1282
+ fd.workflow.pushHistory(
1283
+ mode === 'hide' ? 'Hide unconnected ports' : 'Show hidden ports',
1284
+ storeValue
1285
+ );
1286
+ }
1287
+ }
1288
+
885
1289
  /**
886
1290
  * Snap a flow position to the grid cell it falls in (floor, not round), so
887
1291
  * a node added from the menu has its top-left on the cell that was clicked.
@@ -964,10 +1368,162 @@
964
1368
  node: WorkflowNodeType;
965
1369
  }): void {
966
1370
  if (!canvasEditable) return;
1371
+ // A port has its own menu (publish it in the workflow interface).
1372
+ const handle =
1373
+ event.target instanceof Element ? event.target.closest('.svelte-flow__handle') : null;
1374
+ if (handle && showPortMenu(handle as HTMLElement, event.clientX, event.clientY)) {
1375
+ event.preventDefault();
1376
+ return;
1377
+ }
967
1378
  event.preventDefault();
968
1379
  openNodeMenu(node.id, event.clientX, event.clientY);
969
1380
  }
970
1381
 
1382
+ // ---------------------------------------------------------------------------
1383
+ // Workflow interface: the tags beside published ports
1384
+ // ---------------------------------------------------------------------------
1385
+
1386
+ /** The name being typed beside a port (a new entry, or a rename). */
1387
+ let tagEdit = $state.raw<InterfaceTagEdit | null>(null);
1388
+
1389
+ /** Write an interface edit through the store: one undo step, marks the workflow dirty. */
1390
+ function applyInterfaceEdit(
1391
+ result: ReturnType<typeof exposePortAsEntry> | ReturnType<typeof renameInterfaceEntry>
1392
+ ): void {
1393
+ if (!result) return;
1394
+ fd.workflow.editInterface(result.interface, result.edit);
1395
+ }
1396
+
1397
+ const interfaceMenuActions: InterfaceMenuActions = {
1398
+ expose(target: PortTarget) {
1399
+ // The port id is the starting name; the person edits it in the ghost tag.
1400
+ tagEdit = { mode: 'expose', ...target, value: target.portId };
1401
+ },
1402
+ rename(target: PortTarget) {
1403
+ const workflow = fd.workflow.current;
1404
+ const entry =
1405
+ workflow && entryAtPort(workflow, target.nodeId, target.direction, target.portId);
1406
+ if (entry) tagEdit = { mode: 'rename', ...target, entryId: entry.id, value: entry.id };
1407
+ },
1408
+ remove(target: PortTarget) {
1409
+ const workflow = fd.workflow.current;
1410
+ const entry =
1411
+ workflow && entryAtPort(workflow, target.nodeId, target.direction, target.portId);
1412
+ if (workflow && entry)
1413
+ applyInterfaceEdit(removeInterfaceEntry(workflow, target.direction, entry.id));
1414
+ }
1415
+ };
1416
+
1417
+ function commitTagEdit(): void {
1418
+ const edit = tagEdit;
1419
+ const workflow = fd.workflow.current;
1420
+ tagEdit = null;
1421
+ if (!edit || !workflow) return;
1422
+ applyInterfaceEdit(
1423
+ edit.mode === 'expose'
1424
+ ? exposePortAsEntry(workflow, edit, edit.value)
1425
+ : renameInterfaceEntry(workflow, edit.direction, edit.entryId ?? '', edit.value)
1426
+ );
1427
+ }
1428
+
1429
+ const portMenuActions: PortMenuActions = {
1430
+ ...interfaceMenuActions,
1431
+ connectTo(target: PortTarget) {
1432
+ openConnectPicker(target);
1433
+ }
1434
+ };
1435
+
1436
+ /** The "Connect to…" picker, while open. */
1437
+ interface OpenConnectPicker {
1438
+ target: PortTarget;
1439
+ portName: string;
1440
+ candidates: ReturnType<typeof listConnectCandidates>;
1441
+ /** Viewport (client) position; the picker is in the top layer. */
1442
+ x: number;
1443
+ y: number;
1444
+ }
1445
+
1446
+ let connectPicker = $state.raw<OpenConnectPicker | null>(null);
1447
+ /** Where the port menu was opened, which is where its picker opens. */
1448
+ let portMenuAt: { x: number; y: number } | null = null;
1449
+
1450
+ function openConnectPicker(target: PortTarget): void {
1451
+ const workflow = fd.workflow.current;
1452
+ const at = portMenuAt;
1453
+ if (!workflow || !at) return;
1454
+ const node = flowNodes.find((n) => n.id === target.nodeId);
1455
+ const port = node
1456
+ ? ProximityConnectHelper.getAllPorts(node, target.direction).find(
1457
+ (p) => p.id === target.portId
1458
+ )
1459
+ : undefined;
1460
+ connectPicker = {
1461
+ target,
1462
+ portName: port?.name ?? target.portId,
1463
+ candidates: listConnectCandidates(workflow, fd.portCompatibility, target),
1464
+ x: at.x,
1465
+ y: at.y
1466
+ };
1467
+ }
1468
+
1469
+ /** A port was picked in "Connect to…": the same edge a drag-connect makes. */
1470
+ function connectToCandidate(candidate: ConnectCandidate): void {
1471
+ const picker = connectPicker;
1472
+ connectPicker = null;
1473
+ if (!picker || !canvasEditable || candidate.connected) return;
1474
+ const edge = buildConnectEdge(picker.target, candidate);
1475
+ const sourceNode = flowNodes.find((n) => n.id === edge.source);
1476
+ const targetNode = flowNodes.find((n) => n.id === edge.target);
1477
+ if (!sourceNode || !targetNode) return;
1478
+ EdgeStylingHelper.applyConnectionStyling(edge, sourceNode, targetNode);
1479
+ flowEdges = [...flowEdges, edge];
1480
+ syncFlowToStore();
1481
+ const storeValue = fd.workflow.current;
1482
+ if (storeValue) fd.workflow.pushHistory('Add connection', storeValue);
1483
+ }
1484
+
1485
+ /** Open the menu of a port (a handle element). False when it has nothing to offer. */
1486
+ function showPortMenu(handle: HTMLElement, clientX: number, clientY: number): boolean {
1487
+ const workflow = fd.workflow.current;
1488
+ const handleId = handle.dataset.handleid;
1489
+ const nodeId = handle.dataset.nodeid;
1490
+ const direction = extractDirection(handleId);
1491
+ const portId = extractPortId(handleId);
1492
+ if (!workflow || !nodeId || !direction || !portId || !canvasControllerRef) return false;
1493
+ return openPortMenuAt({ nodeId, direction, portId }, clientX, clientY);
1494
+ }
1495
+
1496
+ function openPortMenuAt(target: PortTarget, clientX: number, clientY: number): boolean {
1497
+ const workflow = fd.workflow.current;
1498
+ const node = flowNodes.find((n) => n.id === target.nodeId);
1499
+ if (!workflow || !node || !canvasControllerRef) return false;
1500
+ const entries = buildPortMenuEntries(workflow, target, portMenuActions, getMsgs().contextMenu);
1501
+ if (entries.length === 0) return false;
1502
+ portMenuAt = { x: clientX, y: clientY };
1503
+ openMenu = {
1504
+ ctx: {
1505
+ target: 'node',
1506
+ nodes: [node],
1507
+ position: canvasControllerRef.canvasScreenToFlow({ x: clientX, y: clientY }),
1508
+ nodeTypes: fd.nodeTypes.current,
1509
+ actions: contextMenuActions
1510
+ },
1511
+ entries,
1512
+ x: clientX,
1513
+ y: clientY
1514
+ };
1515
+ return true;
1516
+ }
1517
+
1518
+ // A name being typed never outlives edit mode, its workflow, or its port (undo).
1519
+ $effect(() => {
1520
+ if (!canvasEditable) tagEdit = null;
1521
+ });
1522
+ $effect(() => {
1523
+ void svelteFlowKey;
1524
+ tagEdit = null;
1525
+ });
1526
+
971
1527
  function handleSelectionContextMenu({
972
1528
  event,
973
1529
  nodes
@@ -1021,11 +1577,15 @@
1021
1577
 
1022
1578
  // Menus never outlive edit mode or the workflow they were opened on.
1023
1579
  $effect(() => {
1024
- if (!canvasEditable) openMenu = null;
1580
+ if (!canvasEditable) {
1581
+ openMenu = null;
1582
+ connectPicker = null;
1583
+ }
1025
1584
  });
1026
1585
  $effect(() => {
1027
1586
  void svelteFlowKey;
1028
1587
  openMenu = null;
1588
+ connectPicker = null;
1029
1589
  pendingNewIds.clear();
1030
1590
  fd.inlineEdit.clear();
1031
1591
  });
@@ -1080,6 +1640,18 @@
1080
1640
  // remounted with the canvas and always talks to the live instance's store.
1081
1641
  let canvasControllerRef: CanvasController | undefined = $state();
1082
1642
 
1643
+ // Let node layout commands (console, assistant, WebMCP) read the canvas's
1644
+ // measurement while the canvas is mounted.
1645
+ $effect(() => {
1646
+ const controller = canvasControllerRef;
1647
+ if (!controller) return;
1648
+ const measure = (nodeId: string) => controller.canvasMeasureNode(nodeId);
1649
+ fd.measureNode = measure;
1650
+ return () => {
1651
+ if (fd.measureNode === measure) fd.measureNode = null;
1652
+ };
1653
+ });
1654
+
1083
1655
  /**
1084
1656
  * Update a node's data in the local editor state.
1085
1657
  * Called by App.svelte AFTER it has already updated the global store via
@@ -1131,6 +1703,10 @@
1131
1703
  canvasControllerRef?.canvasFitView();
1132
1704
  }
1133
1705
 
1706
+ export function canvasFocusNode(nodeId: string): void {
1707
+ canvasControllerRef?.canvasFocusNode(nodeId);
1708
+ }
1709
+
1134
1710
  export function canvasZoomIn(): void {
1135
1711
  canvasControllerRef?.canvasZoomIn();
1136
1712
  }
@@ -1194,6 +1770,40 @@
1194
1770
  return;
1195
1771
  }
1196
1772
 
1773
+ // Shift+S on the canvas: tidy the selected nodes.
1774
+ if (
1775
+ event.key.toLowerCase() === 's' &&
1776
+ event.shiftKey &&
1777
+ !event.ctrlKey &&
1778
+ !event.metaKey &&
1779
+ !event.altKey &&
1780
+ canvasEditable &&
1781
+ target.closest('.flowdrop-canvas')
1782
+ ) {
1783
+ const ids = flowNodes.filter((n) => n.selected).map((n) => n.id);
1784
+ if (ids.length > 0) {
1785
+ event.preventDefault();
1786
+ tidyNodes(ids);
1787
+ }
1788
+ return;
1789
+ }
1790
+
1791
+ // Shift+Alt+T on the canvas, or with nothing focused (a click on the empty canvas leaves the
1792
+ // focus on the body): tidy up the whole graph. By code: Alt changes the key on a Mac.
1793
+ if (
1794
+ event.code === 'KeyT' &&
1795
+ event.shiftKey &&
1796
+ event.altKey &&
1797
+ !event.ctrlKey &&
1798
+ !event.metaKey &&
1799
+ canvasEditable &&
1800
+ (target === document.body || target.closest('.flowdrop-canvas'))
1801
+ ) {
1802
+ event.preventDefault();
1803
+ tidyLayout();
1804
+ return;
1805
+ }
1806
+
1197
1807
  // Check for Ctrl (Windows/Linux) or Cmd (Mac)
1198
1808
  const isModifierPressed = event.ctrlKey || event.metaKey;
1199
1809
 
@@ -1225,10 +1835,13 @@
1225
1835
  <!-- Flow Canvas.
1226
1836
  Capture-phase mousedown so dragging from a port never turns into a
1227
1837
  WebKit text-selection drag — see suppressPortDragSelection. -->
1838
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
1228
1839
  <div
1229
1840
  class="flowdrop-canvas"
1230
1841
  bind:this={canvasEl}
1231
1842
  onmousedowncapture={suppressPortDragSelection}
1843
+ onpointerover={handleCanvasOver}
1844
+ onpointerout={handleCanvasOut}
1232
1845
  >
1233
1846
  <FlowDropZone
1234
1847
  ondrop={handleNodeDrop}
@@ -1244,8 +1857,20 @@
1244
1857
  {edgeTypes}
1245
1858
  {defaultEdgeOptions}
1246
1859
  onconnect={() => void handleConnect()}
1860
+ onconnectstart={handleConnectStart}
1861
+ onconnectend={() => fd.connectDrag.set(null)}
1862
+ isValidConnection={(connection) => !isEventInputConnection(connection, flowNodes)}
1247
1863
  onbeforedelete={handleBeforeDelete}
1248
1864
  ondelete={handleNodesDelete}
1865
+ onnodeclick={({ node }) => {
1866
+ if (!props.onNodeClick) return;
1867
+ const flowNode = {
1868
+ id: node.id,
1869
+ type: node.data.metadata?.type ?? 'default',
1870
+ data: node.data
1871
+ } as WorkflowNodeType;
1872
+ if (!nodeEditsInPlace(flowNode)) props.onNodeClick(flowNode);
1873
+ }}
1249
1874
  onnodedragstart={handleNodeDragStart}
1250
1875
  onnodedrag={handleNodeDrag}
1251
1876
  onnodedragstop={handleNodeDragStop}
@@ -1261,7 +1886,7 @@
1261
1886
  {snapGrid}
1262
1887
  {initialViewport}
1263
1888
  colorMode={getResolvedTheme() as ColorMode}
1264
- fitView={getEditorSettings().fitViewOnLoad}
1889
+ fitViewOptions={{ padding: CANVAS_FIT_PADDING }}
1265
1890
  nodesDraggable={canvasEditable}
1266
1891
  nodesConnectable={canvasEditable}
1267
1892
  elementsSelectable={canvasEditable}
@@ -1271,26 +1896,53 @@
1271
1896
  store with an empty one when a SvelteFlow is destroyed, so after
1272
1897
  the {#key} remount a helper outside would act on that empty
1273
1898
  store (context-menu Delete silently did nothing). -->
1274
- <CanvasController bind:this={canvasControllerRef} />
1899
+ <LoopbackLanes nodes={flowNodes} edges={flowEdges} />
1900
+ <CanvasController
1901
+ bind:this={canvasControllerRef}
1902
+ fitOnLoad={getEditorSettings().fitViewOnLoad}
1903
+ fitInset={props.fitInset}
1904
+ tagReserve={() =>
1905
+ fd.workflow.current
1906
+ ? interfaceTagReserve(fd.workflow.current)
1907
+ : new Map<string, { left: number; right: number }>()}
1908
+ />
1909
+ <ZoomTier />
1910
+ <StraightGuides guides={straightGuides} />
1275
1911
  <EdgeRefresher {nodeIdToRefresh} onRefreshComplete={handleEdgeRefreshComplete} />
1276
1912
  <PortCoordinateTracker
1277
1913
  nodeToUpdate={portCoordNodeToUpdate}
1278
1914
  rebuildTrigger={portCoordRebuildTrigger}
1279
1915
  nodes={flowNodes}
1280
1916
  />
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>
1917
+ {#if fd.workflow.current}
1918
+ <InterfaceTagLayer
1919
+ workflow={fd.workflow.current}
1920
+ editable={canvasEditable}
1921
+ edit={tagEdit}
1922
+ onedit={(value) => tagEdit && (tagEdit = { ...tagEdit, value })}
1923
+ onsubmit={commitTagEdit}
1924
+ oncancel={() => (tagEdit = null)}
1925
+ onrename={(tag) =>
1926
+ interfaceMenuActions.rename({
1927
+ nodeId: tag.nodeId,
1928
+ direction: tag.direction,
1929
+ portId: tag.portId
1930
+ })}
1931
+ onmenu={(tag, event) =>
1932
+ openPortMenuAt(
1933
+ { nodeId: tag.nodeId, direction: tag.direction, portId: tag.portId },
1934
+ event.clientX,
1935
+ event.clientY
1936
+ )}
1937
+ />
1293
1938
  {/if}
1939
+ <CanvasZoomControls
1940
+ nodeCount={flowNodes.length}
1941
+ edgeCount={flowEdges.length}
1942
+ {hasCycles}
1943
+ onfit={() => canvasControllerRef?.canvasFitView()}
1944
+ ontidy={canvasEditable ? tidyLayout : undefined}
1945
+ />
1294
1946
  <!-- Always render Background for consistent bg color in dark/light mode -->
1295
1947
  <Background
1296
1948
  gap={getEditorSettings().gridSize}
@@ -1301,8 +1953,11 @@
1301
1953
  ? 'var(--fd-grid-pattern-color)'
1302
1954
  : 'transparent'}
1303
1955
  />
1304
- {#if getEditorSettings().showMinimap}
1305
- <MiniMap />
1956
+ {#if shouldShowMinimap(getEditorSettings().showMinimap, canvasWidth)}
1957
+ <MiniMap
1958
+ width={MINIMAP_WIDTH - 2 * MINIMAP_BORDER}
1959
+ height={MINIMAP_HEIGHT - 2 * MINIMAP_BORDER}
1960
+ />
1306
1961
  {/if}
1307
1962
  </SvelteFlow>
1308
1963
  {/key}
@@ -1335,6 +1990,18 @@
1335
1990
  {/if}
1336
1991
  </FlowDropZone>
1337
1992
 
1993
+ {#if canvasEditable}
1994
+ <CanvasToolbar
1995
+ editorMode={props.editorMode}
1996
+ onEditorModeChange={props.onEditorModeChange}
1997
+ onOpenTest={props.onOpenTest}
1998
+ onAskAssistant={props.onAskAssistant}
1999
+ showRun={props.showRunBar ?? true}
2000
+ showRuns={props.showRuns}
2001
+ adminLinks={props.adminLinks}
2002
+ />
2003
+ {/if}
2004
+
1338
2005
  {#if openMenu}
1339
2006
  <CanvasContextMenu
1340
2007
  entries={openMenu.entries}
@@ -1344,24 +2011,19 @@
1344
2011
  onclose={closeContextMenu}
1345
2012
  />
1346
2013
  {/if}
1347
- </div>
1348
2014
 
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>
1356
-
1357
- {#if hasCycles}
1358
- <span class="flowdrop-text--xs flowdrop-text--gray">•</span>
1359
- <span class="flowdrop-text--xs flowdrop-font--medium flowdrop-text--error"
1360
- >⚠️ Cycles detected</span
1361
- >
1362
- {/if}
1363
- </div>
1364
- </div>
2015
+ {#if connectPicker}
2016
+ <ConnectPortPicker
2017
+ portName={connectPicker.portName}
2018
+ fromInput={connectPicker.target.direction === 'input'}
2019
+ groups={connectPickerGroups(connectPicker.candidates, getMsgs().connectTo)}
2020
+ checker={fd.portCompatibility}
2021
+ x={connectPicker.x}
2022
+ y={connectPicker.y}
2023
+ onselect={connectToCandidate}
2024
+ onclose={() => (connectPicker = null)}
2025
+ />
2026
+ {/if}
1365
2027
  </div>
1366
2028
  </div>
1367
2029
  </div>
@@ -1370,7 +2032,7 @@
1370
2032
  <!-- aria-live="polite" ensures screen readers announce toast messages without interrupting -->
1371
2033
  <div class="flowdrop-scope" aria-live="polite" aria-atomic="true">
1372
2034
  <Toaster
1373
- position="bottom-center"
2035
+ position="top-center"
1374
2036
  containerClassName={FLOWDROP_TOASTER_CLASS}
1375
2037
  toastOptions={flowdropToastOptions}
1376
2038
  />
@@ -1392,10 +2054,6 @@
1392
2054
  transition: margin-left 0.3s ease-in-out;
1393
2055
  }
1394
2056
 
1395
- .flowdrop-text--error {
1396
- color: var(--fd-error);
1397
- }
1398
-
1399
2057
  .flowdrop-canvas {
1400
2058
  flex: 1;
1401
2059
  min-height: 0;
@@ -1403,32 +2061,6 @@
1403
2061
  background: transparent;
1404
2062
  }
1405
2063
 
1406
- .flowdrop-status-bar {
1407
- background-color: var(--fd-backdrop);
1408
- backdrop-filter: var(--fd-backdrop-blur);
1409
- border-top: 1px solid var(--fd-border);
1410
- padding: 0.75rem;
1411
- height: 40px;
1412
- min-height: 40px;
1413
- max-height: 40px;
1414
- display: flex;
1415
- align-items: center;
1416
- flex-shrink: 0;
1417
- }
1418
-
1419
- .flowdrop-status-bar__content {
1420
- display: flex;
1421
- align-items: center;
1422
- justify-content: space-between;
1423
- }
1424
-
1425
- /* Console toggle — placement only; visuals live in CanvasIconButton */
1426
- :global(.flowdrop-console-toggle) {
1427
- bottom: 140px;
1428
- left: 12px;
1429
- z-index: 5;
1430
- }
1431
-
1432
2064
  :global(.flowdrop-workflow-editor .svelte-flow__node:hover) {
1433
2065
  transform: translateY(-2px);
1434
2066
  }
@@ -1452,6 +2084,13 @@
1452
2084
  stroke-width: 3 !important;
1453
2085
  }
1454
2086
 
2087
+ :global(.flowdrop-workflow-editor .svelte-flow__node.fd-node-linked) {
2088
+ border-radius: var(--fd-radius-lg);
2089
+ outline: 2px solid var(--fd-primary);
2090
+ outline-offset: 3px;
2091
+ box-shadow: 0 0 0 6px color-mix(in srgb, var(--fd-primary) 18%, transparent);
2092
+ }
2093
+
1455
2094
  :global(.flowdrop-workflow-editor .svelte-flow__edge.selected) {
1456
2095
  stroke: var(--fd-primary) !important;
1457
2096
  stroke-width: 3 !important;
@@ -1540,6 +2179,20 @@
1540
2179
  stroke-width: 2;
1541
2180
  }
1542
2181
 
2182
+ /* Zoom tiers: wires get thicker as the canvas zooms out, so the topology still
2183
+ reads. Fixed flow px; the canvas scales them. */
2184
+ :global([data-fd-zoom='glyph'] .svelte-flow__edge path.svelte-flow__edge-path) {
2185
+ stroke-width: var(--fd-node-zoom-edge-width-glyph) !important;
2186
+ }
2187
+
2188
+ :global([data-fd-zoom='map'] .svelte-flow__edge path.svelte-flow__edge-path) {
2189
+ stroke-width: var(--fd-node-zoom-edge-width-map) !important;
2190
+ }
2191
+
2192
+ :global([data-fd-zoom='map'] .svelte-flow__edge:not(.selected) path.svelte-flow__edge-path) {
2193
+ stroke: var(--fd-node-zoom-edge-map);
2194
+ }
2195
+
1543
2196
  /* Loopback Edge: Dashed gray line for loop iteration connections */
1544
2197
  :global(.flowdrop--edge--loopback path.svelte-flow__edge-path) {
1545
2198
  stroke: var(--fd-edge-loopback);