@flowdrop/flowdrop 1.15.0 → 2.0.0-beta.10

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 (323) hide show
  1. package/CHANGELOG.md +648 -0
  2. package/MIGRATION-2.0.md +642 -0
  3. package/README.md +28 -28
  4. package/dist/adapters/WorkflowAdapter.d.ts +1 -1
  5. package/dist/adapters/WorkflowAdapter.js +18 -13
  6. package/dist/adapters/agentspec/AgentSpecAdapter.js +10 -10
  7. package/dist/adapters/agentspec/defaultNodeTypes.js +9 -9
  8. package/dist/api/enhanced-client.js +6 -11
  9. package/dist/chat/batchFeedback.d.ts +39 -0
  10. package/dist/chat/batchFeedback.js +51 -0
  11. package/dist/commands/executor.js +66 -27
  12. package/dist/commands/storeIntegration.svelte.d.ts +4 -1
  13. package/dist/commands/storeIntegration.svelte.js +36 -21
  14. package/dist/commands/types.d.ts +2 -0
  15. package/dist/commands/types.js +5 -5
  16. package/dist/components/App.svelte +696 -565
  17. package/dist/components/App.svelte.d.ts +63 -16
  18. package/dist/components/Button.stories.svelte +65 -0
  19. package/dist/components/Button.stories.svelte.d.ts +19 -0
  20. package/dist/components/Button.svelte +62 -0
  21. package/dist/components/Button.svelte.d.ts +24 -0
  22. package/dist/components/CanvasIconButton.svelte +76 -0
  23. package/dist/components/CanvasIconButton.svelte.d.ts +18 -0
  24. package/dist/components/ConfigForm.svelte +181 -552
  25. package/dist/components/ConfigForm.svelte.d.ts +24 -7
  26. package/dist/components/ConfigModal.svelte +16 -3
  27. package/dist/components/ConfigPanel.svelte +234 -15
  28. package/dist/components/ConfigPanel.svelte.d.ts +6 -0
  29. package/dist/components/ConnectionLine.svelte +4 -2
  30. package/dist/components/EditorStatusBar.stories.svelte +44 -0
  31. package/dist/components/EditorStatusBar.stories.svelte.d.ts +27 -0
  32. package/dist/components/EditorStatusBar.svelte +99 -0
  33. package/dist/components/EditorStatusBar.svelte.d.ts +15 -0
  34. package/dist/components/IconButton.svelte +80 -0
  35. package/dist/components/IconButton.svelte.d.ts +30 -0
  36. package/dist/components/Input.svelte +74 -0
  37. package/dist/components/Input.svelte.d.ts +17 -0
  38. package/dist/components/LogoWordmark.svelte +113 -0
  39. package/dist/components/LogoWordmark.svelte.d.ts +26 -0
  40. package/dist/components/Navbar.svelte +78 -64
  41. package/dist/components/Navbar.svelte.d.ts +3 -0
  42. package/dist/components/NodeSidebar.svelte +48 -171
  43. package/dist/components/NodeStatusOverlay.svelte +94 -6
  44. package/dist/components/NodeSwapPicker.svelte +22 -38
  45. package/dist/components/PipelineStatus.svelte +22 -68
  46. package/dist/components/PipelineStatus.svelte.d.ts +3 -0
  47. package/dist/components/PortCoordinateTracker.svelte +5 -6
  48. package/dist/components/PortMappingRow.svelte +0 -2
  49. package/dist/components/SchemaForm.stories.svelte +1 -3
  50. package/dist/components/SchemaForm.svelte +22 -39
  51. package/dist/components/SchemaForm.svelte.d.ts +0 -8
  52. package/dist/components/Select.svelte +53 -0
  53. package/dist/components/Select.svelte.d.ts +15 -0
  54. package/dist/components/SettingsModal.svelte +8 -8
  55. package/dist/components/SettingsPanel.svelte +44 -10
  56. package/dist/components/SwapMappingEditor.svelte +67 -49
  57. package/dist/components/SwapMappingEditor.svelte.d.ts +0 -2
  58. package/dist/components/Textarea.svelte +39 -0
  59. package/dist/components/Textarea.svelte.d.ts +12 -0
  60. package/dist/components/ThemeToggle.svelte +15 -94
  61. package/dist/components/UniversalNode.svelte +45 -11
  62. package/dist/components/UniversalNode.svelte.d.ts +1 -1
  63. package/dist/components/WorkflowEditor.svelte +183 -162
  64. package/dist/components/WorkflowEditor.svelte.d.ts +39 -10
  65. package/dist/components/chat/AIChatPanel.svelte +99 -90
  66. package/dist/components/chat/AIChatPanel.svelte.d.ts +0 -4
  67. package/dist/components/chat/CommandPreview.svelte +2 -1
  68. package/dist/components/console/CommandConsole.svelte +7 -5
  69. package/dist/components/console/ConsoleAutocomplete.svelte +11 -12
  70. package/dist/components/console/ConsoleAutocomplete.svelte.d.ts +6 -0
  71. package/dist/components/console/ConsoleInput.svelte +18 -9
  72. package/dist/components/console/ConsoleOutput.svelte +4 -3
  73. package/dist/components/form/FormArray.svelte +42 -182
  74. package/dist/components/form/FormArray.svelte.d.ts +2 -1
  75. package/dist/components/form/FormAutocomplete.svelte +26 -21
  76. package/dist/components/form/FormCheckboxGroup.svelte +1 -5
  77. package/dist/components/form/FormCodeEditor.svelte +9 -7
  78. package/dist/components/form/FormField.svelte +22 -44
  79. package/dist/components/form/FormFieldLight.svelte +56 -50
  80. package/dist/components/form/FormFieldLight.svelte.d.ts +12 -0
  81. package/dist/components/form/FormFieldset.svelte +45 -11
  82. package/dist/components/form/FormMarkdownEditor.svelte +17 -9
  83. package/dist/components/form/FormNumberField.svelte +4 -36
  84. package/dist/components/form/FormPorts.svelte +262 -0
  85. package/dist/components/form/FormPorts.svelte.d.ts +13 -0
  86. package/dist/components/form/FormRangeField.svelte +62 -30
  87. package/dist/components/form/FormSelect.svelte +13 -75
  88. package/dist/components/form/FormTemplateEditor.svelte +17 -7
  89. package/dist/components/form/FormTextField.svelte +3 -35
  90. package/dist/components/form/FormTextarea.svelte +4 -39
  91. package/dist/components/form/FormToggle.svelte +5 -16
  92. package/dist/components/form/FormToggle.svelte.d.ts +4 -2
  93. package/dist/components/form/FormUISchemaRenderer.svelte +3 -1
  94. package/dist/components/form/resolveFieldType.d.ts +24 -0
  95. package/dist/components/form/resolveFieldType.js +55 -0
  96. package/dist/components/form/templateAutocomplete.js +1 -5
  97. package/dist/components/form/types.d.ts +1 -14
  98. package/dist/components/icons/CloseIcon.svelte +6 -0
  99. package/dist/components/icons/CloseIcon.svelte.d.ts +26 -0
  100. package/dist/components/icons/CommandLineIcon.svelte +15 -0
  101. package/dist/components/icons/CommandLineIcon.svelte.d.ts +26 -0
  102. package/dist/components/icons/MenuIcon.svelte +4 -0
  103. package/dist/components/icons/MenuIcon.svelte.d.ts +26 -0
  104. package/dist/components/icons/MenuOpenIcon.svelte +6 -0
  105. package/dist/components/icons/MenuOpenIcon.svelte.d.ts +26 -0
  106. package/dist/components/interrupt/ChoicePrompt.svelte +0 -10
  107. package/dist/components/interrupt/ConfirmationPrompt.svelte +0 -5
  108. package/dist/components/interrupt/FormPrompt.svelte +3 -2
  109. package/dist/components/interrupt/InterruptBubble.svelte +25 -27
  110. package/dist/components/interrupt/ReviewPrompt.svelte +10 -23
  111. package/dist/components/interrupt/TextInputPrompt.svelte +2 -7
  112. package/dist/components/layouts/MainLayout.svelte +24 -18
  113. package/dist/components/layouts/MainLayout.svelte.d.ts +4 -0
  114. package/dist/components/nodes/AtomNode.svelte +70 -72
  115. package/dist/components/nodes/AtomNode.svelte.d.ts +1 -1
  116. package/dist/components/nodes/GatewayNode.svelte +134 -172
  117. package/dist/components/nodes/GatewayNode.svelte.d.ts +1 -1
  118. package/dist/components/nodes/IdeaNode.svelte +79 -98
  119. package/dist/components/nodes/IdeaNode.svelte.d.ts +8 -4
  120. package/dist/components/nodes/NodeConfigButton.svelte +86 -0
  121. package/dist/components/nodes/NodeConfigButton.svelte.d.ts +15 -0
  122. package/dist/components/nodes/NotesNode.svelte +76 -85
  123. package/dist/components/nodes/NotesNode.svelte.d.ts +8 -4
  124. package/dist/components/nodes/SimpleNode.svelte +68 -137
  125. package/dist/components/nodes/SimpleNode.svelte.d.ts +4 -4
  126. package/dist/components/nodes/SquareNode.svelte +122 -169
  127. package/dist/components/nodes/SquareNode.svelte.d.ts +4 -4
  128. package/dist/components/nodes/TerminalNode.svelte +70 -127
  129. package/dist/components/nodes/TerminalNode.svelte.d.ts +4 -4
  130. package/dist/components/nodes/ToolNode.svelte +99 -104
  131. package/dist/components/nodes/ToolNode.svelte.d.ts +6 -6
  132. package/dist/components/nodes/WorkflowNode.svelte +145 -195
  133. package/dist/components/nodes/WorkflowNode.svelte.d.ts +1 -1
  134. package/dist/components/playground/ChatInput.svelte +11 -15
  135. package/dist/components/playground/ChatPanel.svelte +6 -49
  136. package/dist/components/playground/ChatPanel.svelte.d.ts +0 -14
  137. package/dist/components/playground/ControlPanel.svelte +134 -123
  138. package/dist/components/playground/ControlPanel.svelte.d.ts +3 -0
  139. package/dist/components/playground/ExecutionLogs.svelte +11 -9
  140. package/dist/components/playground/InputCollector.svelte +22 -57
  141. package/dist/components/playground/MessageStream.svelte +17 -23
  142. package/dist/components/playground/PipelineKanbanView.svelte +69 -8
  143. package/dist/components/playground/PipelineKanbanView.svelte.d.ts +2 -0
  144. package/dist/components/playground/PipelinePanel.svelte +31 -8
  145. package/dist/components/playground/PipelinePanel.svelte.d.ts +2 -0
  146. package/dist/components/playground/PipelineTableView.svelte +188 -44
  147. package/dist/components/playground/PipelineTableView.svelte.d.ts +2 -0
  148. package/dist/components/playground/Playground.svelte +154 -105
  149. package/dist/components/playground/Playground.svelte.d.ts +5 -0
  150. package/dist/components/playground/PlaygroundApp.svelte +12 -2
  151. package/dist/components/playground/PlaygroundApp.svelte.d.ts +6 -0
  152. package/dist/components/playground/PlaygroundModal.svelte +18 -3
  153. package/dist/components/playground/PlaygroundModal.svelte.d.ts +6 -0
  154. package/dist/components/playground/PlaygroundStudio.svelte +40 -37
  155. package/dist/components/playground/PlaygroundStudio.svelte.d.ts +6 -0
  156. package/dist/components/playground/SessionManager.svelte +9 -12
  157. package/dist/components/playground/pipelineViewUtils.svelte.d.ts +30 -1
  158. package/dist/components/playground/pipelineViewUtils.svelte.js +40 -3
  159. package/dist/components/surfaces/SurfaceOverlay.svelte +153 -0
  160. package/dist/components/surfaces/SurfaceOverlay.svelte.d.ts +14 -0
  161. package/dist/components/surfaces/TabbedSurface.svelte +133 -0
  162. package/dist/components/surfaces/TabbedSurface.svelte.d.ts +27 -0
  163. package/dist/config/endpoints.d.ts +23 -7
  164. package/dist/config/endpoints.js +30 -10
  165. package/dist/core/index.d.ts +6 -7
  166. package/dist/core/index.js +8 -12
  167. package/dist/display/index.d.ts +6 -3
  168. package/dist/display/index.js +7 -5
  169. package/dist/editor/index.d.ts +20 -21
  170. package/dist/editor/index.js +26 -36
  171. package/dist/form/code.d.ts +25 -15
  172. package/dist/form/code.js +44 -41
  173. package/dist/form/fieldRegistry.d.ts +17 -13
  174. package/dist/form/fieldRegistry.js +32 -12
  175. package/dist/form/full.d.ts +19 -14
  176. package/dist/form/full.js +26 -28
  177. package/dist/form/index.d.ts +3 -4
  178. package/dist/form/index.js +6 -5
  179. package/dist/form/markdown.d.ts +13 -8
  180. package/dist/form/markdown.js +22 -23
  181. package/dist/helpers/proximityConnect.d.ts +3 -2
  182. package/dist/helpers/proximityConnect.js +2 -5
  183. package/dist/helpers/workflowEditorHelper.d.ts +14 -5
  184. package/dist/helpers/workflowEditorHelper.js +32 -30
  185. package/dist/index.d.ts +28 -24
  186. package/dist/index.js +27 -50
  187. package/dist/messages/defaults.d.ts +2 -5
  188. package/dist/messages/defaults.js +3 -6
  189. package/dist/messages/index.d.ts +1 -2
  190. package/dist/messages/index.js +1 -2
  191. package/dist/mocks/app-forms.d.ts +6 -2
  192. package/dist/mocks/app-forms.js +11 -4
  193. package/dist/openapi/v1/openapi.yaml +38 -26
  194. package/dist/playground/index.d.ts +4 -5
  195. package/dist/playground/index.js +4 -32
  196. package/dist/playground/mount.d.ts +34 -5
  197. package/dist/playground/mount.js +58 -24
  198. package/dist/registry/{BaseRegistry.d.ts → BaseRegistry.svelte.d.ts} +22 -1
  199. package/dist/registry/{BaseRegistry.js → BaseRegistry.svelte.js} +37 -1
  200. package/dist/registry/builtinFormats.d.ts +9 -18
  201. package/dist/registry/builtinFormats.js +9 -39
  202. package/dist/registry/builtinNodeTypes.d.ts +53 -0
  203. package/dist/registry/builtinNodeTypes.js +67 -0
  204. package/dist/registry/builtinNodes.d.ts +2 -64
  205. package/dist/registry/builtinNodes.js +7 -103
  206. package/dist/registry/index.d.ts +3 -4
  207. package/dist/registry/index.js +4 -6
  208. package/dist/registry/nodeComponentRegistry.d.ts +184 -16
  209. package/dist/registry/nodeComponentRegistry.js +235 -17
  210. package/dist/registry/workflowFormatRegistry.d.ts +14 -9
  211. package/dist/registry/workflowFormatRegistry.js +24 -8
  212. package/dist/{schema → schemas}/index.d.ts +2 -2
  213. package/dist/{schema → schemas}/index.js +2 -2
  214. package/dist/schemas/v1/workflow.schema.json +19 -17
  215. package/dist/services/agentSpecExecutionService.d.ts +0 -2
  216. package/dist/services/agentSpecExecutionService.js +0 -3
  217. package/dist/services/apiVariableService.d.ts +2 -1
  218. package/dist/services/apiVariableService.js +16 -47
  219. package/dist/services/autoSaveService.d.ts +7 -0
  220. package/dist/services/autoSaveService.js +6 -4
  221. package/dist/services/categoriesApi.js +3 -6
  222. package/dist/services/chatService.d.ts +9 -4
  223. package/dist/services/chatService.js +23 -28
  224. package/dist/services/draftStorage.d.ts +129 -13
  225. package/dist/services/draftStorage.js +185 -37
  226. package/dist/services/dynamicSchemaService.d.ts +33 -5
  227. package/dist/services/dynamicSchemaService.js +67 -55
  228. package/dist/services/globalSave.d.ts +13 -12
  229. package/dist/services/globalSave.js +29 -51
  230. package/dist/services/historyService.d.ts +39 -11
  231. package/dist/services/historyService.js +60 -18
  232. package/dist/services/interruptService.d.ts +15 -9
  233. package/dist/services/interruptService.js +35 -37
  234. package/dist/services/nodeExecutionService.d.ts +18 -3
  235. package/dist/services/nodeExecutionService.js +71 -45
  236. package/dist/services/playgroundService.d.ts +16 -10
  237. package/dist/services/playgroundService.js +42 -43
  238. package/dist/services/portConfigApi.js +3 -6
  239. package/dist/services/settingsService.d.ts +9 -4
  240. package/dist/services/settingsService.js +23 -12
  241. package/dist/services/variableService.d.ts +2 -1
  242. package/dist/services/variableService.js +2 -2
  243. package/dist/services/workflowStorage.js +6 -6
  244. package/dist/skins/drafter.d.ts +30 -0
  245. package/dist/skins/drafter.js +198 -0
  246. package/dist/skins/index.d.ts +2 -1
  247. package/dist/skins/index.js +4 -2
  248. package/dist/stores/apiContext.d.ts +56 -0
  249. package/dist/stores/apiContext.js +80 -0
  250. package/dist/stores/categoriesStore.svelte.d.ts +28 -23
  251. package/dist/stores/categoriesStore.svelte.js +69 -64
  252. package/dist/stores/getInstance.svelte.d.ts +39 -0
  253. package/dist/stores/getInstance.svelte.js +65 -0
  254. package/dist/stores/historyStore.svelte.d.ts +89 -91
  255. package/dist/stores/historyStore.svelte.js +159 -158
  256. package/dist/stores/instanceContainer.svelte.d.ts +111 -0
  257. package/dist/stores/instanceContainer.svelte.js +119 -0
  258. package/dist/stores/interruptStore.svelte.d.ts +112 -82
  259. package/dist/stores/interruptStore.svelte.js +253 -226
  260. package/dist/stores/pipelinePanelStore.svelte.d.ts +27 -3
  261. package/dist/stores/pipelinePanelStore.svelte.js +61 -14
  262. package/dist/stores/playgroundStore.svelte.d.ts +169 -222
  263. package/dist/stores/playgroundStore.svelte.js +513 -580
  264. package/dist/stores/portCoordinateStore.svelte.d.ts +57 -51
  265. package/dist/stores/portCoordinateStore.svelte.js +109 -98
  266. package/dist/stores/settingsStore.svelte.d.ts +17 -1
  267. package/dist/stores/settingsStore.svelte.js +79 -12
  268. package/dist/stores/workflowStore.svelte.d.ts +212 -210
  269. package/dist/stores/workflowStore.svelte.js +527 -502
  270. package/dist/stories/EdgeDecorator.svelte +5 -2
  271. package/dist/stories/NodeDecorator.svelte +5 -3
  272. package/dist/styles/base.css +285 -14
  273. package/dist/styles/tokens.css +60 -2
  274. package/dist/svelte-app.d.ts +78 -11
  275. package/dist/svelte-app.js +210 -141
  276. package/dist/themes/drafter.d.ts +2 -0
  277. package/dist/themes/drafter.js +15 -0
  278. package/dist/themes/index.d.ts +2 -1
  279. package/dist/themes/index.js +8 -2
  280. package/dist/types/auth.d.ts +9 -51
  281. package/dist/types/auth.js +4 -54
  282. package/dist/types/events.d.ts +24 -3
  283. package/dist/types/events.js +2 -1
  284. package/dist/types/index.d.ts +117 -32
  285. package/dist/types/index.js +0 -1
  286. package/dist/types/navbar.d.ts +7 -0
  287. package/dist/types/playground.d.ts +18 -3
  288. package/dist/types/settings.d.ts +30 -1
  289. package/dist/types/settings.js +5 -2
  290. package/dist/types/skin.d.ts +1 -1
  291. package/dist/types/theme.d.ts +16 -2
  292. package/dist/types/uischema.d.ts +5 -0
  293. package/dist/utils/colors.d.ts +74 -21
  294. package/dist/utils/colors.js +92 -68
  295. package/dist/utils/connections.d.ts +9 -15
  296. package/dist/utils/connections.js +33 -88
  297. package/dist/utils/duration.d.ts +13 -0
  298. package/dist/utils/duration.js +45 -0
  299. package/dist/utils/edgeStyling.js +9 -5
  300. package/dist/utils/fetchWithAuth.d.ts +36 -15
  301. package/dist/utils/fetchWithAuth.js +53 -23
  302. package/dist/utils/icons.d.ts +5 -2
  303. package/dist/utils/icons.js +6 -5
  304. package/dist/utils/nodeIds.d.ts +1 -1
  305. package/dist/utils/nodeIds.js +1 -1
  306. package/dist/utils/nodeSwap.d.ts +6 -2
  307. package/dist/utils/nodeSwap.js +62 -129
  308. package/dist/utils/nodeTypes.d.ts +17 -8
  309. package/dist/utils/nodeTypes.js +27 -20
  310. package/dist/utils/performanceUtils.js +7 -0
  311. package/dist/utils/portUtils.d.ts +47 -11
  312. package/dist/utils/portUtils.js +67 -14
  313. package/dist/utils/portal.d.ts +18 -0
  314. package/dist/utils/portal.js +34 -0
  315. package/dist/utils/schemaMerge.d.ts +25 -0
  316. package/dist/utils/schemaMerge.js +61 -0
  317. package/package.json +7 -5
  318. package/dist/messages/deprecation.d.ts +0 -20
  319. package/dist/messages/deprecation.js +0 -33
  320. package/dist/registry/plugin.d.ts +0 -215
  321. package/dist/registry/plugin.js +0 -249
  322. package/dist/services/api.d.ts +0 -129
  323. package/dist/services/api.js +0 -217
@@ -5,28 +5,28 @@
5
5
  -->
6
6
 
7
7
  <script lang="ts">
8
- import { onMount, tick } from 'svelte';
8
+ import { onMount, tick, untrack } from 'svelte';
9
9
  import MainLayout from './layouts/MainLayout.svelte';
10
10
  import WorkflowEditor from './WorkflowEditor.svelte';
11
11
  import NodeSidebar from './NodeSidebar.svelte';
12
- import Icon from '@iconify/svelte';
12
+ import CanvasIconButton from './CanvasIconButton.svelte';
13
+ import EditorStatusBar from './EditorStatusBar.svelte';
14
+ import MenuIcon from './icons/MenuIcon.svelte';
15
+ import MenuOpenIcon from './icons/MenuOpenIcon.svelte';
13
16
  import ConfigForm from './ConfigForm.svelte';
14
17
  import ConfigPanel from './ConfigPanel.svelte';
18
+ import ReadOnlyDetails from './ReadOnlyDetails.svelte';
15
19
  import CommandConsole from './console/CommandConsole.svelte';
16
20
  import AIChatPanel from './chat/AIChatPanel.svelte';
21
+ import TabbedSurface from './surfaces/TabbedSurface.svelte';
22
+ import type { SurfaceTab } from './surfaces/TabbedSurface.svelte';
23
+ import SurfaceOverlay from './surfaces/SurfaceOverlay.svelte';
17
24
  import type { UIAction } from '../commands/index.js';
18
25
  import NodeSwapPicker from './NodeSwapPicker.svelte';
19
26
  import SwapMappingEditor from './SwapMappingEditor.svelte';
20
27
  import Navbar from './Navbar.svelte';
21
- import { api, setEndpointConfig } from '../services/api.js';
22
- import { EnhancedFlowDropApiClient } from '../api/enhanced-client.js';
23
- import type {
24
- NodeMetadata,
25
- Workflow,
26
- WorkflowNode,
27
- ConfigSchema,
28
- NodeUIExtensions
29
- } from '../types/index.js';
28
+ import type { NavbarAction } from '../types/navbar.js';
29
+ import type { NodeMetadata, Workflow, WorkflowNode, ConfigSchema } from '../types/index.js';
30
30
  import type { InteractiveSwapState, SwapEventContext } from '../utils/nodeSwap.js';
31
31
  import {
32
32
  computeInteractiveState,
@@ -44,27 +44,20 @@
44
44
  import type { FlowDropTheme, FlowDropThemeName } from '../types/theme.js';
45
45
  import type { FlowDropSkinTokens } from '../types/skin.js';
46
46
  import { resolveTheme } from '../themes/index.js';
47
- import {
48
- getWorkflowStore,
49
- workflowActions,
50
- getWorkflowName,
51
- getWorkflowFormat,
52
- markAsSaved
53
- } from '../stores/workflowStore.svelte.js';
47
+ import { provideInstance } from '../stores/getInstance.svelte.js';
48
+ import type { FlowDropInstance } from '../stores/instanceContainer.svelte.js';
54
49
  import { globalSaveWorkflow, globalExportWorkflow } from '../services/globalSave.js';
55
50
  import { apiToasts, dismissToast } from '../services/toastService.js';
56
51
  import { initAutoSave } from '../services/autoSaveService.js';
57
- import { getUiSettings, updateSettings } from '../stores/settingsStore.svelte.js';
58
52
  import {
59
- initializePortCompatibility,
60
- getPortCompatibilityChecker,
61
- isPortCompatibilityInitialized
62
- } from '../utils/connections.js';
63
- import { DEFAULT_PORT_CONFIG } from '../config/defaultPortConfig.js';
64
- import { workflowFormatRegistry } from '../registry/workflowFormatRegistry.js';
53
+ getUiSettings,
54
+ updateSettings,
55
+ seedUiDefaults,
56
+ initializeTheme
57
+ } from '../stores/settingsStore.svelte.js';
65
58
  import { logger } from '../utils/logger.js';
66
59
  import { validateWorkflowData } from '../utils/validation.js';
67
- import type { SettingsCategory } from '../types/settings.js';
60
+ import type { SettingsCategory, SurfacePlacement } from '../types/settings.js';
68
61
  import { defaultMessages, mergeMessages, setMessages } from '../messages/index.js';
69
62
  import type { MessagesOverride } from '../messages/index.js';
70
63
 
@@ -84,34 +77,77 @@
84
77
  showNavbar?: boolean;
85
78
  /** Disable the node sidebar */
86
79
  disableSidebar?: boolean;
87
- /** Lock the workflow (prevent changes) */
88
- lockWorkflow?: boolean;
89
- /** Read-only mode */
90
- readOnly?: boolean;
91
- /** Node execution statuses */
92
- nodeStatuses?: Record<string, 'pending' | 'running' | 'completed' | 'error'>;
80
+ /**
81
+ * Default host for the node/workflow configuration panel: `sidebar` (right
82
+ * rail), `modal` (centered overlay), or `below` (bottom panel). Seeds the
83
+ * user setting on first load — a value the user later changes wins.
84
+ * @default 'sidebar'
85
+ */
86
+ configPlacement?: SurfacePlacement;
87
+ /**
88
+ * Default host for the console / AI Assistant group. Seeds the user setting
89
+ * on first load — a value the user later changes wins.
90
+ * @default 'below'
91
+ */
92
+ consolePlacement?: SurfacePlacement;
93
+ /**
94
+ * Editor interaction mode. Replaces the former `readOnly` + `lockWorkflow`
95
+ * boolean pair (2.0 breaking change).
96
+ *
97
+ * | mode | node drag / connect / select | proximity-connect | node swap | bottom console panel + toggle |
98
+ * |--------------|------------------------------|-------------------|-----------|-------------------------------|
99
+ * | `'edit'` | enabled | enabled | enabled | available |
100
+ * | `'readonly'` | disabled | disabled | disabled | hidden |
101
+ * | `'locked'` | disabled | disabled | disabled | hidden |
102
+ *
103
+ * In 1.x `readOnly` and `lockWorkflow` gated the exact same set of
104
+ * interactions and were always combined as `!readOnly && !lockWorkflow`,
105
+ * so any combination of the two booleans collapsed to "edit" (both false)
106
+ * or "disabled" (either true). `'readonly'` and `'locked'` therefore behave
107
+ * identically today; the two names are kept as distinct intents so future
108
+ * versions can differentiate them without another breaking change.
109
+ *
110
+ * Migration: `readOnly` → `mode="readonly"`; `lockWorkflow` →
111
+ * `mode="locked"`; both `false` (or unset) → `mode="edit"` (the default).
112
+ *
113
+ * @default 'edit'
114
+ */
115
+ mode?: 'edit' | 'readonly' | 'locked';
93
116
  /** Pipeline ID for fetching node execution info */
94
117
  pipelineId?: string;
118
+ /** Increments to force a refresh of pipeline node status from the server */
119
+ refreshTrigger?: number;
95
120
  /** Custom navbar title */
96
121
  navbarTitle?: string;
97
122
  /** Custom navbar actions */
98
- navbarActions?: Array<{
99
- label: string;
100
- href: string;
101
- icon?: string;
102
- variant?: 'primary' | 'secondary' | 'outline';
103
- onclick?: (event: Event) => void;
104
- }>;
123
+ navbarActions?: NavbarAction[];
105
124
  /** Show settings gear icon in navbar */
106
125
  showSettings?: boolean;
126
+ /** Show the "Connected" status indicator in the navbar (default: true) */
127
+ showStatus?: boolean;
107
128
  /** API base URL */
108
129
  apiBaseUrl?: string;
109
130
  /** Endpoint configuration */
110
131
  endpointConfig?: EndpointConfig;
111
132
  /** Authentication provider */
112
133
  authProvider?: AuthProvider;
113
- /** Event handlers */
114
- eventHandlers?: FlowDropEventHandlers;
134
+ /**
135
+ * Called before save — return false to cancel. Forwarded to the save
136
+ * pipeline. (Flattened from the former `eventHandlers` object in 2.0.)
137
+ */
138
+ onBeforeSave?: FlowDropEventHandlers['onBeforeSave'];
139
+ /** Called after a successful save. */
140
+ onAfterSave?: FlowDropEventHandlers['onAfterSave'];
141
+ /** Called when a save fails. */
142
+ onSaveError?: FlowDropEventHandlers['onSaveError'];
143
+ /** Called on any API error — return true to suppress the default toast. */
144
+ onApiError?: FlowDropEventHandlers['onApiError'];
145
+ /** Called after a workflow is loaded/imported. */
146
+ onWorkflowLoad?: FlowDropEventHandlers['onWorkflowLoad'];
147
+ /** Called before a node swap — return false to cancel. */
148
+ onBeforeSwap?: FlowDropEventHandlers['onBeforeSwap'];
149
+ /** Called after a node swap is applied. */
150
+ onAfterSwap?: FlowDropEventHandlers['onAfterSwap'];
115
151
  /** Feature configuration */
116
152
  features?: FlowDropFeatures;
117
153
  /** Visual theme — named built-in ('default' | 'minimal') or custom theme object */
@@ -138,6 +174,8 @@
138
174
  * function call you'd rather not invoke unless the prop is actually read.
139
175
  */
140
176
  messages?: MessagesOverride | (() => MessagesOverride);
177
+ /** Per-instance state container (created by mount functions). Defaults to the page-default instance. */
178
+ instance?: FlowDropInstance;
141
179
  }
142
180
 
143
181
  let {
@@ -147,17 +185,25 @@
147
185
  width = '100%',
148
186
  showNavbar = false,
149
187
  disableSidebar = false,
150
- lockWorkflow = false,
151
- readOnly = false,
152
- nodeStatuses = {},
188
+ configPlacement: configPlacementProp,
189
+ consolePlacement: consolePlacementProp,
190
+ mode = 'edit',
153
191
  pipelineId,
192
+ refreshTrigger = 0,
154
193
  navbarTitle,
155
194
  navbarActions = [],
156
195
  showSettings = true,
196
+ showStatus = true,
157
197
  apiBaseUrl,
158
198
  endpointConfig: propEndpointConfig,
159
199
  authProvider,
160
- eventHandlers,
200
+ onBeforeSave,
201
+ onAfterSave,
202
+ onSaveError,
203
+ onApiError,
204
+ onWorkflowLoad,
205
+ onBeforeSwap,
206
+ onAfterSwap,
161
207
  features: propFeatures,
162
208
  theme: themeProp,
163
209
  settingsCategories,
@@ -165,12 +211,25 @@
165
211
  showSettingsResetButton,
166
212
  swapStrategies,
167
213
  workflowSettingsSchema,
168
- messages: messagesOverride
214
+ messages: messagesOverride,
215
+ instance
169
216
  }: Props = $props();
170
217
 
171
- // svelte-ignore state_referenced_locally — feature flags don't change at runtime
218
+ // Resolve (and provide to children) the per-instance state container.
219
+ // Must run during component init — provideInstance reads/sets Svelte context.
220
+ // The instance never changes for a mounted component, so capturing it once is correct.
221
+ // svelte-ignore state_referenced_locally
222
+ const fd = provideInstance(instance);
223
+
224
+ // feature flags don't change at runtime
225
+ // svelte-ignore state_referenced_locally
172
226
  const features = mergeFeatures(propFeatures);
173
227
 
228
+ // `mode` is the public API; internally the canvas only cares whether editing
229
+ // is disabled. 'readonly' and 'locked' both disable the same interactions
230
+ // (see the `mode` prop JSDoc for the full matrix).
231
+ const canvasEditable = $derived(mode === 'edit');
232
+
174
233
  // Messages: merge consumer overrides over defaults; expose via context as a
175
234
  // getter so consumer-side reactivity (e.g. paraglide-js locale switches)
176
235
  // propagates into every child without a subscription. Accepts either a
@@ -271,7 +330,7 @@
271
330
  return navbarTitle;
272
331
  }
273
332
  // Default workflow title logic
274
- const wfName = getWorkflowName();
333
+ const wfName = fd.workflow.name;
275
334
  if (!wfName || wfName === 'Untitled Workflow') {
276
335
  return 'Workflow / New Workflow';
277
336
  }
@@ -285,12 +344,6 @@
285
344
  let error = $state<string | null>(null);
286
345
  let endpointConfig = $state<EndpointConfig | null>(null);
287
346
 
288
- /**
289
- * Enhanced API client with authProvider support
290
- * Used when authProvider is provided; otherwise falls back to legacy api service
291
- */
292
- let apiClient = $state<EnhancedFlowDropApiClient | null>(null);
293
-
294
347
  // ConfigSidebar state
295
348
  let isConfigSidebarOpen = $state(false);
296
349
  let selectedNodeId = $state<string | null>(null);
@@ -298,9 +351,14 @@
298
351
  // Workflow settings sidebar state
299
352
  let isWorkflowSettingsOpen = $state(false);
300
353
 
354
+ // Which surface (`config` | `console` | `chat`) is focused in its host. A
355
+ // single selector across hosts: each TabbedSurface highlights this id when it
356
+ // hosts that surface, else falls back to its own first tab. Opening config
357
+ // focuses it wherever it lives (sidebar/modal/below).
358
+ let activeSurface = $state<string>(getUiSettings().bottomPanelTab);
359
+
301
360
  // Node swap state
302
361
  let swapMode = $state<'idle' | 'picking' | 'mapping'>('idle');
303
- let swapTargetMetadata = $state<NodeMetadata | null>(null);
304
362
  let swapInteractiveState = $state<InteractiveSwapState | null>(null);
305
363
 
306
364
  // Built-in workflow settings field names — consumer schemas must not reuse these.
@@ -342,7 +400,7 @@
342
400
  type: 'string',
343
401
  title: 'Workflow Format',
344
402
  description: 'The specification format for this workflow',
345
- oneOf: workflowFormatRegistry.getOneOfOptions(),
403
+ oneOf: fd.formats.getOneOfOptions(),
346
404
  default: 'flowdrop'
347
405
  },
348
406
  ...extraProps
@@ -353,15 +411,15 @@
353
411
 
354
412
  // Workflow configuration values
355
413
  let workflowConfigValues = $derived({
356
- name: getWorkflowName() || '',
357
- description: getWorkflowStore()?.description || '',
358
- format: getWorkflowStore()?.metadata?.format || 'flowdrop',
359
- ...(getWorkflowStore()?.config ?? {})
414
+ name: fd.workflow.name || '',
415
+ description: fd.workflow.current?.description || '',
416
+ format: fd.workflow.current?.metadata?.format || 'flowdrop',
417
+ ...(fd.workflow.current?.config ?? {})
360
418
  });
361
419
 
362
420
  // Get the current node from the workflow store
363
421
  let selectedNodeForConfig = $derived.by(() => {
364
- const wf = getWorkflowStore();
422
+ const wf = fd.workflow.current;
365
423
  if (!selectedNodeId || !wf) return null;
366
424
  return wf.nodes.find((node) => node.id === selectedNodeId) || null;
367
425
  });
@@ -379,9 +437,9 @@
379
437
  // If nodes were provided as props, use them directly (skip API fetch)
380
438
  if (propNodes && propNodes.length > 0) {
381
439
  // Merge format-provided nodes with prop nodes (deduplicate by ID, props take priority)
382
- const formatNodes = workflowFormatRegistry.getAllFormatNodes();
383
- const existingIds = new Set(propNodes.map((n) => n.id));
384
- const uniqueFormatNodes = formatNodes.filter((n) => !existingIds.has(n.id));
440
+ const formatNodes = fd.formats.getAllFormatNodes();
441
+ const existingIds = new Set(propNodes.map((n) => n.node_type_id));
442
+ const uniqueFormatNodes = formatNodes.filter((n) => !existingIds.has(n.node_type_id));
385
443
  nodes = [...propNodes, ...uniqueFormatNodes];
386
444
  nodeTypesLoading = false;
387
445
  return;
@@ -392,18 +450,13 @@
392
450
  try {
393
451
  error = null;
394
452
 
395
- // Use enhanced client with authProvider if available, otherwise fall back to legacy api
396
- let fetchedNodes: NodeMetadata[];
397
- if (apiClient) {
398
- fetchedNodes = await apiClient.getAvailableNodes();
399
- } else {
400
- fetchedNodes = await api.nodes.getNodes();
401
- }
453
+ // Fetch via this instance's API client (configured in initializeApiEndpoints).
454
+ const fetchedNodes: NodeMetadata[] = await fd.api.client.getAvailableNodes();
402
455
 
403
456
  // Merge format-provided nodes with API nodes (deduplicate by ID, API takes priority)
404
- const formatNodes = workflowFormatRegistry.getAllFormatNodes();
405
- const existingIds = new Set(fetchedNodes.map((n) => n.id));
406
- const uniqueFormatNodes = formatNodes.filter((n) => !existingIds.has(n.id));
457
+ const formatNodes = fd.formats.getAllFormatNodes();
458
+ const existingIds = new Set(fetchedNodes.map((n) => n.node_type_id));
459
+ const uniqueFormatNodes = formatNodes.filter((n) => !existingIds.has(n.node_type_id));
407
460
  nodes = [...fetchedNodes, ...uniqueFormatNodes];
408
461
  error = null;
409
462
  nodeTypesLoading = false;
@@ -421,8 +474,8 @@
421
474
  const errorMessage = err instanceof Error ? err.message : 'Unknown error';
422
475
 
423
476
  // Notify parent via event handler
424
- if (eventHandlers?.onApiError) {
425
- const suppressToast = eventHandlers.onApiError(
477
+ if (onApiError) {
478
+ const suppressToast = onApiError(
426
479
  err instanceof Error ? err : new Error(errorMessage),
427
480
  'fetchNodes'
428
481
  );
@@ -481,28 +534,15 @@
481
534
  async function initializeApiEndpoints(): Promise<void> {
482
535
  // First priority: Use endpointConfig prop if provided (from mountFlowDropApp)
483
536
  if (propEndpointConfig) {
484
- setEndpointConfig(propEndpointConfig);
485
- endpointConfig = propEndpointConfig;
486
-
487
- // Create enhanced API client with authProvider support if provided
488
- if (authProvider) {
489
- apiClient = new EnhancedFlowDropApiClient(propEndpointConfig, authProvider);
490
- }
537
+ configureApi(propEndpointConfig);
491
538
  return;
492
539
  }
493
540
 
494
- // Second priority: Check if endpoint config is already set (e.g., by parent layout)
495
- const { getEndpointConfig } = await import('../services/api.js');
496
- const existingConfig = getEndpointConfig();
497
-
498
- // If config already exists and no override provided, use existing
541
+ // Second priority: Reuse this instance's existing config (e.g. set by a
542
+ // parent layout that already configured fd.api) when no override is given.
543
+ const existingConfig = fd.api.config;
499
544
  if (existingConfig && !apiBaseUrl) {
500
- endpointConfig = existingConfig;
501
-
502
- // Create enhanced API client with authProvider support if provided
503
- if (authProvider) {
504
- apiClient = new EnhancedFlowDropApiClient(existingConfig, authProvider);
505
- }
545
+ configureApi(existingConfig);
506
546
  return;
507
547
  }
508
548
 
@@ -510,9 +550,6 @@
510
550
  const baseUrl = apiBaseUrl || '/api/flowdrop';
511
551
 
512
552
  const config = createEndpointConfig(baseUrl, {
513
- auth: {
514
- type: 'none' // No authentication for now
515
- },
516
553
  timeout: 10000, // 10 second timeout
517
554
  retry: {
518
555
  enabled: true,
@@ -522,14 +559,16 @@
522
559
  }
523
560
  });
524
561
 
525
- setEndpointConfig(config);
526
- // Store the configuration for passing to WorkflowEditor
527
- endpointConfig = config;
562
+ configureApi(config);
563
+ }
528
564
 
529
- // Create enhanced API client with authProvider support if provided
530
- if (authProvider) {
531
- apiClient = new EnhancedFlowDropApiClient(config, authProvider);
532
- }
565
+ /**
566
+ * Configure this instance's ApiContext and mirror its config/client into the
567
+ * local state used by child components and the save service.
568
+ */
569
+ function configureApi(config: EndpointConfig): void {
570
+ fd.api.configure(config, authProvider);
571
+ endpointConfig = config;
533
572
  }
534
573
 
535
574
  /**
@@ -543,9 +582,9 @@
543
582
  }
544
583
  selectedNodeId = node.id;
545
584
  isConfigSidebarOpen = true;
585
+ activeSurface = 'config';
546
586
  // Reset swap state when switching nodes
547
587
  swapMode = 'idle';
548
- swapTargetMetadata = null;
549
588
  swapInteractiveState = null;
550
589
  }
551
590
 
@@ -554,7 +593,6 @@
554
593
  selectedNodeId = null;
555
594
  // Reset swap state when closing
556
595
  swapMode = 'idle';
557
- swapTargetMetadata = null;
558
596
  swapInteractiveState = null;
559
597
  }
560
598
 
@@ -566,6 +604,7 @@
566
604
  // Close config sidebar if opening workflow settings
567
605
  if (isWorkflowSettingsOpen) {
568
606
  closeConfigSidebar();
607
+ activeSurface = 'config';
569
608
  }
570
609
  }
571
610
 
@@ -574,7 +613,6 @@
574
613
  */
575
614
  function startSwap(): void {
576
615
  swapMode = 'picking';
577
- swapTargetMetadata = null;
578
616
  swapInteractiveState = null;
579
617
  }
580
618
 
@@ -585,29 +623,21 @@
585
623
  const node = selectedNodeForConfig;
586
624
  if (!node) return;
587
625
 
588
- const wf = getWorkflowStore();
626
+ const wf = fd.workflow.current;
589
627
  if (!wf) return;
590
628
 
591
629
  // Format compatibility guard — defence-in-depth behind picker's own filter
592
- const currentFormat = getWorkflowFormat();
630
+ const currentFormat = fd.workflow.format;
593
631
  if (metadata.formats?.length && !metadata.formats.includes(currentFormat)) {
594
632
  return;
595
633
  }
596
634
 
597
- // Get port compatibility checker (may be null if not initialized)
598
- let checker: import('../utils/connections.js').PortCompatibilityChecker | null = null;
599
- try {
600
- checker = getPortCompatibilityChecker();
601
- } catch {
602
- // Checker not initialized — computeSwapPreview will use exact dataType matching
603
- }
604
-
635
+ // Port compatibility comes from this instance's checker.
605
636
  const interactive = computeInteractiveState(node, metadata, wf.edges, wf.nodes, {
606
- checker,
637
+ checker: fd.portCompatibility,
607
638
  strategies: swapStrategies
608
639
  });
609
640
 
610
- swapTargetMetadata = metadata;
611
641
  swapInteractiveState = interactive;
612
642
  swapMode = 'mapping';
613
643
  }
@@ -619,7 +649,7 @@
619
649
  const state = finalState ?? swapInteractiveState;
620
650
  if (!state) return;
621
651
 
622
- const wf = getWorkflowStore();
652
+ const wf = fd.workflow.current;
623
653
  if (!wf) return;
624
654
 
625
655
  const oldLabel = state.oldNode.data.label;
@@ -639,7 +669,7 @@
639
669
  }
640
670
 
641
671
  // onBeforeSwap hook — abort if returns false
642
- if (eventHandlers?.onBeforeSwap) {
672
+ if (onBeforeSwap) {
643
673
  const swapEventCtx: SwapEventContext = {
644
674
  oldNode: state.oldNode,
645
675
  newMetadata: state.newMetadata,
@@ -647,21 +677,21 @@
647
677
  portOverrides: [],
648
678
  configOverrides: []
649
679
  };
650
- const shouldProceed = await eventHandlers.onBeforeSwap(swapEventCtx);
680
+ const shouldProceed = await onBeforeSwap(swapEventCtx);
651
681
  if (shouldProceed === false) return;
652
682
  }
653
683
 
654
684
  // Apply as a single atomic swap with descriptive history entry
655
- workflowActions.swapNode({
685
+ fd.workflow.swapNode({
656
686
  nodes: result.updatedNodes,
657
687
  edges: result.updatedEdges,
658
688
  description: `Swap node: ${oldLabel} → ${newLabel}`
659
689
  });
660
690
 
661
691
  // onAfterSwap hook (fire-and-forget — swap is already applied)
662
- if (eventHandlers?.onAfterSwap) {
692
+ if (onAfterSwap) {
663
693
  try {
664
- eventHandlers.onAfterSwap(result, state.oldNode, state.newNodeId);
694
+ onAfterSwap(result, state.oldNode, state.newNodeId);
665
695
  } catch (err) {
666
696
  logger.error('onAfterSwap hook error:', err);
667
697
  }
@@ -673,7 +703,6 @@
673
703
 
674
704
  // Reset swap state
675
705
  swapMode = 'idle';
676
- swapTargetMetadata = null;
677
706
  swapInteractiveState = null;
678
707
 
679
708
  // Wait for SvelteFlow to process the new node before updating visual state
@@ -694,47 +723,57 @@
694
723
  */
695
724
  function cancelSwap(): void {
696
725
  swapMode = 'idle';
697
- swapTargetMetadata = null;
698
726
  swapInteractiveState = null;
699
727
  }
700
728
 
701
- /**
702
- * Handle workflow configuration save
703
- */
704
- async function handleWorkflowSave(config: Record<string, unknown>): Promise<void> {
705
- // Update the workflow store
706
- if (getWorkflowStore()) {
707
- workflowActions.batchUpdate({
708
- name: config.name as string | undefined,
709
- description: config.description as string | undefined
710
- });
711
- }
712
-
713
- // Close the sidebar
714
- isWorkflowSettingsOpen = false;
715
-
716
- // Also save the workflow to the backend
717
- try {
718
- await saveWorkflow();
719
- } catch (error) {
720
- logger.error('Failed to save workflow to backend:', error);
721
- // Note: We don't throw the error here to avoid breaking the UI flow
722
- // The user can still manually save via the main Save button if needed
723
- }
724
- }
725
-
726
729
  /**
727
730
  * Save workflow - thin wrapper that delegates to globalSaveWorkflow().
728
731
  *
729
732
  * All save logic (blur flush, metadata construction, API call, event hooks,
730
733
  * toast notifications) lives in globalSave.ts — the single source of truth.
731
734
  */
735
+ // --- Node config live-edit sessions --------------------------------------
736
+ // Config fields commit live (per change) into the store via
737
+ // fd.workflow.updateNodeConfig(), which coalesces a field-editing session
738
+ // into a single undo step and defers the external change event. We finalize
739
+ // that session — commit the undo step, fire the deferred event, and refresh
740
+ // edge geometry ONCE — on blur, panel close, node switch, and save. Edges are
741
+ // refreshed only here, never per keystroke (that per-change recompute, plus a
742
+ // full-workflow history clone per keystroke, was the original editor freeze).
743
+ let pendingConfigNodeId: string | null = null;
744
+
745
+ function flushNodeConfigEdit(): void {
746
+ const nodeId = pendingConfigNodeId;
747
+ pendingConfigNodeId = null;
748
+ fd.workflow.finalizeNodeConfig();
749
+ if (nodeId) {
750
+ // Handle geometry can only have changed via config (e.g. gateway
751
+ // branches); refresh once now that the session is done.
752
+ void workflowEditorRef?.refreshEdgePositions(nodeId);
753
+ }
754
+ }
755
+
756
+ // Finalize the previous field session when the open config node changes
757
+ // (switching nodes, or closing the panel). Tracks the node id reactively;
758
+ // the flush itself is untracked so it can't feed back into the effect.
759
+ let lastConfigNodeId: string | null = null;
760
+ $effect(() => {
761
+ const id = activeConfig?.kind === 'node' ? activeConfig.node.id : null;
762
+ if (id !== lastConfigNodeId) {
763
+ lastConfigNodeId = id;
764
+ untrack(() => flushNodeConfigEdit());
765
+ }
766
+ });
767
+
732
768
  async function saveWorkflow(): Promise<void> {
769
+ // Commit any in-flight config edit so the save and its history are
770
+ // consistent (the value itself is already live in the store).
771
+ flushNodeConfigEdit();
733
772
  await globalSaveWorkflow({
734
- apiClient: apiClient ?? undefined,
735
- eventHandlers,
773
+ eventHandlers: { onBeforeSave, onAfterSave, onSaveError, onApiError },
736
774
  features,
737
- onMarkAsSaved: markAsSaved
775
+ instance: fd,
776
+ onMarkAsSaved: () => fd.workflow.markAsSaved()
738
777
  });
739
778
  }
740
779
 
@@ -745,7 +784,7 @@
745
784
  * in globalSave.ts — the single source of truth.
746
785
  */
747
786
  async function exportWorkflow(): Promise<void> {
748
- await globalExportWorkflow({ features });
787
+ await globalExportWorkflow({ features, instance: fd });
749
788
  }
750
789
 
751
790
  /**
@@ -770,12 +809,12 @@
770
809
  logger.warn('Workflow import validation failed:', validation.error);
771
810
  return;
772
811
  }
773
- workflowActions.initialize(data as Workflow);
812
+ fd.workflow.initialize(data as Workflow);
774
813
  if (features.showToasts) {
775
814
  apiToasts.success('Import workflow', 'Workflow imported successfully');
776
815
  }
777
- if (eventHandlers?.onWorkflowLoad) {
778
- eventHandlers.onWorkflowLoad(data as Workflow);
816
+ if (onWorkflowLoad) {
817
+ onWorkflowLoad(data as Workflow);
779
818
  }
780
819
  } catch (error) {
781
820
  const errorObj = error instanceof Error ? error : new Error('Unknown error occurred');
@@ -822,26 +861,38 @@
822
861
 
823
862
  // Load node types on mount
824
863
  onMount(() => {
864
+ // Apply the persisted theme preference to the document and wire its
865
+ // reactivity. Idempotent — a no-op when mountFlowDropApp already
866
+ // initialized it; load-bearing for hosts rendering <App> directly,
867
+ // where nothing else applies data-theme (the persisted light/dark
868
+ // choice was otherwise never restored on reload).
869
+ initializeTheme();
870
+
871
+ // Seed placement defaults from mount props without clobbering a returning
872
+ // user's persisted choices (host default < user snapshot).
873
+ seedUiDefaults({
874
+ configPlacement: configPlacementProp,
875
+ consolePlacement: consolePlacementProp
876
+ });
877
+
825
878
  (async () => {
826
879
  try {
827
880
  await initializeApiEndpoints();
828
881
 
829
- // Ensure port compatibility checker is initialized (needed for proximity connect, etc.)
830
- // mountFlowDropApp initializes this before mounting, but SvelteKit routes need it here.
831
- // Only initialize with defaults if not already set — preserves custom port configs.
832
- if (!isPortCompatibilityInitialized()) {
833
- initializePortCompatibility(DEFAULT_PORT_CONFIG);
834
- }
882
+ // The instance's port compatibility checker is seeded with
883
+ // DEFAULT_PORT_CONFIG at construction; mountFlowDropApp re-initializes
884
+ // it from the backend's port config. SvelteKit routes that render
885
+ // <App> directly keep the defaults (no separate fetch here).
835
886
 
836
887
  await fetchNodeTypes();
837
888
 
838
889
  // Initialize the workflow store
839
890
  if (initialWorkflow) {
840
- workflowActions.initialize(initialWorkflow);
891
+ fd.workflow.initialize(initialWorkflow);
841
892
 
842
893
  // Emit onWorkflowLoad event
843
- if (eventHandlers?.onWorkflowLoad) {
844
- eventHandlers.onWorkflowLoad(initialWorkflow);
894
+ if (onWorkflowLoad) {
895
+ onWorkflowLoad(initialWorkflow);
845
896
  }
846
897
  } else {
847
898
  // Initialize with a default empty workflow so the editor is functional
@@ -852,13 +903,13 @@
852
903
  nodes: [],
853
904
  edges: [],
854
905
  metadata: {
855
- version: '1.0.0',
906
+ schemaVersion: '1.0.0',
856
907
  format: DEFAULT_WORKFLOW_FORMAT,
857
908
  createdAt: new Date().toISOString(),
858
909
  updatedAt: new Date().toISOString()
859
910
  }
860
911
  };
861
- workflowActions.initialize(defaultWorkflow);
912
+ fd.workflow.initialize(defaultWorkflow);
862
913
  }
863
914
  } catch (error) {
864
915
  logger.error('Failed to initialize editor:', error);
@@ -874,6 +925,7 @@
874
925
 
875
926
  // Initialize auto-save based on user settings
876
927
  const cleanupAutoSave = initAutoSave({
928
+ isDirty: () => fd.workflow.isDirty,
877
929
  onSave: async () => {
878
930
  await saveWorkflow();
879
931
  },
@@ -892,14 +944,83 @@
892
944
  };
893
945
  });
894
946
 
947
+ // =========================================================================
948
+ // Surface placement — where the config panel and console/chat are hosted.
949
+ // =========================================================================
950
+
951
+ const configPlacement = $derived(getUiSettings().configPlacement);
952
+ const consolePlacement = $derived(getUiSettings().consolePlacement);
953
+
954
+ /** Config surface has something to show (node config or workflow settings). */
955
+ const configActive = $derived(isWorkflowSettingsOpen || !!selectedNodeForConfig);
956
+ /** Console/chat group is available (editable canvas, console toggled open). */
957
+ const consoleActive = $derived(getUiSettings().consoleOpen && canvasEditable);
958
+ /** Node-swap sub-flow occupies the right sidebar regardless of placement. */
959
+ const swapActive = $derived(swapMode !== 'idle');
960
+
961
+ const configHere = (loc: SurfacePlacement) => configActive && configPlacement === loc;
962
+ const consoleHere = (loc: SurfacePlacement) => consoleActive && consolePlacement === loc;
963
+
964
+ /** Any surface routed to a given host location is present there. */
965
+ const anyHere = (loc: SurfacePlacement) => configHere(loc) || consoleHere(loc);
966
+
895
967
  /**
896
- * Derived value for showing the right config panel
897
- * Config panel always appears on the right side
968
+ * Metadata for the active config surface, independent of its host. The form
969
+ * itself is rendered by the host via the `configBody` snippet.
898
970
  */
899
- const hasConfigPanelOpen = $derived(
900
- isWorkflowSettingsOpen || !!selectedNodeForConfig || swapMode !== 'idle'
971
+ const activeConfig = $derived.by(() => {
972
+ if (isWorkflowSettingsOpen) {
973
+ return {
974
+ kind: 'workflow' as const,
975
+ title: mergedMessages.navigation.workflowSettingsPanelTitle,
976
+ id: fd.workflow.current?.id,
977
+ description: undefined as string | undefined,
978
+ details: [
979
+ { label: 'Nodes', value: String(fd.workflow.current?.nodes?.length ?? 0) },
980
+ { label: 'Connections', value: String(fd.workflow.current?.edges?.length ?? 0) }
981
+ ],
982
+ configTitle: mergedMessages.navigation.workflowSettingsPanelSubtitle
983
+ };
984
+ }
985
+ const node = selectedNodeForConfig;
986
+ if (node) {
987
+ return {
988
+ kind: 'node' as const,
989
+ node,
990
+ title: node.data.label,
991
+ id: node.id,
992
+ description:
993
+ node.data.metadata?.description || mergedMessages.navigation.nodeConfigDescription,
994
+ details: [
995
+ { label: 'Type', value: node.data.metadata?.type || node.type },
996
+ { label: 'Category', value: node.data.metadata?.category || 'general' }
997
+ ],
998
+ configTitle: undefined as string | undefined
999
+ };
1000
+ }
1001
+ return null;
1002
+ });
1003
+
1004
+ /** Close whichever config surface is currently open. */
1005
+ function closeActiveConfig(): void {
1006
+ if (isWorkflowSettingsOpen) {
1007
+ isWorkflowSettingsOpen = false;
1008
+ } else {
1009
+ closeConfigSidebar();
1010
+ }
1011
+ }
1012
+
1013
+ /** Select a surface tab; console/chat also persist as the last bottom tab. */
1014
+ function selectSurface(id: string): void {
1015
+ activeSurface = id;
1016
+ if (id === 'console' || id === 'chat') {
1017
+ updateSettings({ ui: { bottomPanelTab: id } });
1018
+ }
1019
+ }
1020
+
1021
+ const showRightPanel = $derived(
1022
+ !disableSidebar && (swapActive || configHere('sidebar') || consoleHere('sidebar'))
901
1023
  );
902
- const showRightPanel = $derived(!disableSidebar && hasConfigPanelOpen);
903
1024
 
904
1025
  /**
905
1026
  * Calculate left sidebar width based on collapsed state
@@ -945,7 +1066,7 @@
945
1066
 
946
1067
  function handleConsoleUIAction(action: UIAction): void {
947
1068
  if (action.type === 'open_config') {
948
- const wf = getWorkflowStore();
1069
+ const wf = fd.workflow.current;
949
1070
  if (!wf) return;
950
1071
  const node = wf.nodes.find((n) => n.id === action.nodeId);
951
1072
  if (node) openConfigSidebar(node);
@@ -984,6 +1105,11 @@
984
1105
  }
985
1106
  });
986
1107
  }
1108
+
1109
+ /** Close the console/chat group (used by the modal host's close button). */
1110
+ function closeConsole(): void {
1111
+ updateSettings({ ui: { consoleOpen: false } });
1112
+ }
987
1113
  </script>
988
1114
 
989
1115
  <svelte:window onkeydown={handleGlobalKeydown} />
@@ -1002,13 +1128,206 @@
1002
1128
  onchange={handleImportFileChange}
1003
1129
  />
1004
1130
 
1131
+ <!--
1132
+ Surface content snippets — each rendered by exactly one host (a surface has a
1133
+ single placement), so the once-per-render Snippet constraint always holds.
1134
+ -->
1135
+
1136
+ {#snippet nodeConfigFormEl(node: WorkflowNode)}
1137
+ <ConfigForm
1138
+ {authProvider}
1139
+ {node}
1140
+ commitMode="live"
1141
+ workflowId={fd.workflow.current?.id}
1142
+ workflowNodes={fd.workflow.current?.nodes}
1143
+ workflowEdges={fd.workflow.current?.edges}
1144
+ onChange={(updatedConfig, meta) => {
1145
+ if (!node.id) return;
1146
+ const updatedData = { ...node.data, config: updatedConfig };
1147
+
1148
+ // Blur / end-of-session: commit the coalesced undo step + fire the
1149
+ // change event once, and refresh edges once.
1150
+ if (meta?.commit) {
1151
+ pendingConfigNodeId = node.id;
1152
+ flushNodeConfigEdit();
1153
+ return;
1154
+ }
1155
+
1156
+ // Live edit (every change): update the store cheaply — no history clone,
1157
+ // no external event; both are deferred to the session flush above. Also
1158
+ // reflect the change on the canvas immediately (e.g. nodeType changes).
1159
+ pendingConfigNodeId = node.id;
1160
+ fd.workflow.updateNodeConfig(node.id, { data: updatedData }, { fieldKey: meta?.fieldKey });
1161
+ workflowEditorRef?.updateNodeData(node.id, updatedData);
1162
+ }}
1163
+ />
1164
+ {/snippet}
1165
+
1166
+ {#snippet workflowConfigFormEl()}
1167
+ <ConfigForm
1168
+ {authProvider}
1169
+ schema={workflowConfigSchema}
1170
+ values={workflowConfigValues}
1171
+ commitMode="blur"
1172
+ onChange={(config) => {
1173
+ // Sync workflow settings changes immediately on field blur
1174
+ const wf = fd.workflow.current;
1175
+ if (wf) {
1176
+ const newFormat = (config.format as string) || DEFAULT_WORKFLOW_FORMAT;
1177
+ const currentFormat = wf.metadata?.format || DEFAULT_WORKFLOW_FORMAT;
1178
+
1179
+ // Warn about incompatible nodes when format changes
1180
+ if (newFormat !== currentFormat) {
1181
+ const incompatibleNodes = wf.nodes?.filter((node) => {
1182
+ const formats = node.data?.metadata?.formats;
1183
+ return formats && formats.length > 0 && !formats.includes(newFormat);
1184
+ });
1185
+ if (incompatibleNodes && incompatibleNodes.length > 0) {
1186
+ logger.warn(
1187
+ `Format changed to '${newFormat}'. ${incompatibleNodes.length} node(s) are not compatible with this format and may not export correctly:`,
1188
+ incompatibleNodes.map((n) => n.data?.label || n.type)
1189
+ );
1190
+ }
1191
+ }
1192
+
1193
+ // Extract built-in fields; everything else belongs in workflow.config
1194
+ const { name, description, format: _format, ...customConfig } = config;
1195
+ fd.workflow.batchUpdate({
1196
+ name: name as string,
1197
+ description: description as string | undefined,
1198
+ metadata: {
1199
+ ...wf.metadata,
1200
+ format: newFormat
1201
+ },
1202
+ ...(workflowSettingsSchema && { config: customConfig as Record<string, unknown> })
1203
+ });
1204
+ }
1205
+ }}
1206
+ />
1207
+ {/snippet}
1208
+
1209
+ <!--
1210
+ Chromeless config body for tabbed/overlay hosts. `showHeader` draws a slim
1211
+ title + close bar when the host doesn't provide one (bottom / shared sidebar);
1212
+ the modal host supplies its own header, so it passes `false`.
1213
+ -->
1214
+ {#snippet configBody(showHeader: boolean)}
1215
+ {#if activeConfig}
1216
+ <div class="config-surface">
1217
+ {#if showHeader}
1218
+ <div class="config-surface__header">
1219
+ <h2 class="config-surface__title">{activeConfig.title}</h2>
1220
+ <button
1221
+ class="config-surface__close"
1222
+ onclick={closeActiveConfig}
1223
+ aria-label={mergedMessages.layout.closeConfigPanel}
1224
+ >
1225
+ ×
1226
+ </button>
1227
+ </div>
1228
+ {/if}
1229
+ {#if activeConfig.id}
1230
+ <div class="config-surface__details">
1231
+ <ReadOnlyDetails
1232
+ id={activeConfig.id}
1233
+ description={activeConfig.description}
1234
+ details={activeConfig.details}
1235
+ />
1236
+ </div>
1237
+ {/if}
1238
+ <div class="config-surface__content">
1239
+ <div class="config-surface__section">
1240
+ <h3 class="config-surface__section-title">
1241
+ {activeConfig.configTitle ?? 'Configuration'}
1242
+ </h3>
1243
+ {#if activeConfig.kind === 'node'}
1244
+ {@render nodeConfigFormEl(activeConfig.node)}
1245
+ {:else}
1246
+ {@render workflowConfigFormEl()}
1247
+ {/if}
1248
+ </div>
1249
+ </div>
1250
+ </div>
1251
+ {/if}
1252
+ {/snippet}
1253
+
1254
+ {#snippet configTabContent()}
1255
+ {@render configBody(true)}
1256
+ {/snippet}
1257
+
1258
+ {#snippet configBareContent()}
1259
+ {@render configBody(false)}
1260
+ {/snippet}
1261
+
1262
+ {#snippet consoleSurfaceBody()}
1263
+ <CommandConsole nodeTypes={nodes} onUIAction={handleConsoleUIAction} />
1264
+ {/snippet}
1265
+
1266
+ {#snippet chatSurfaceBody()}
1267
+ <AIChatPanel
1268
+ nodeTypes={nodes}
1269
+ workflowId={fd.workflow.current?.id}
1270
+ onUIAction={handleConsoleUIAction}
1271
+ {endpointConfig}
1272
+ />
1273
+ {/snippet}
1274
+
1275
+ <!--
1276
+ Console + chat tabs, shared by whichever host the console group is routed to.
1277
+ -->
1278
+ {#snippet consoleChatTabs()}
1279
+ {@const tabs = [
1280
+ {
1281
+ id: 'console',
1282
+ label: mergedMessages.navigation.bottomPanel.console,
1283
+ content: consoleSurfaceBody,
1284
+ display: 'contents' as const
1285
+ },
1286
+ {
1287
+ id: 'chat',
1288
+ label: mergedMessages.navigation.bottomPanel.chat,
1289
+ content: chatSurfaceBody
1290
+ }
1291
+ ]}
1292
+ <TabbedSurface {tabs} activeId={activeSurface} onSelect={selectSurface} />
1293
+ {/snippet}
1294
+
1295
+ <!--
1296
+ Rich config panel for the common case: config is the sole occupant of the
1297
+ right sidebar. Keeps ConfigPanel's full chrome (swap, ad-hoc pop-out, details)
1298
+ so the default experience is unchanged.
1299
+ -->
1300
+ {#snippet configPanelSidebar()}
1301
+ {#if activeConfig}
1302
+ <ConfigPanel
1303
+ title={activeConfig.title}
1304
+ id={activeConfig.id}
1305
+ description={activeConfig.description}
1306
+ details={activeConfig.details}
1307
+ configTitle={activeConfig.configTitle ?? 'Configuration'}
1308
+ onClose={closeActiveConfig}
1309
+ onSwap={activeConfig.kind === 'node' && canvasEditable && features.enableNodeSwap
1310
+ ? startSwap
1311
+ : undefined}
1312
+ >
1313
+ {#if activeConfig.kind === 'node'}
1314
+ {@render nodeConfigFormEl(activeConfig.node)}
1315
+ {:else}
1316
+ {@render workflowConfigFormEl()}
1317
+ {/if}
1318
+ </ConfigPanel>
1319
+ {/if}
1320
+ {/snippet}
1321
+
1005
1322
  <!-- MainLayout wrapper for workflow editor -->
1006
1323
  <div class="flowdrop-root">
1007
1324
  <MainLayout
1325
+ {height}
1326
+ {width}
1008
1327
  showHeader={showNavbar}
1009
1328
  showLeftSidebar={!disableSidebar}
1010
1329
  showRightSidebar={showRightPanel}
1011
- showBottomPanel={getUiSettings().consoleOpen && !readOnly && !lockWorkflow}
1330
+ showBottomPanel={anyHere('below')}
1012
1331
  bottomPanelHeight={getUiSettings().consoleHeight}
1013
1332
  showFooter={false}
1014
1333
  headerHeight={60}
@@ -1027,7 +1346,7 @@
1027
1346
  <Navbar
1028
1347
  title={breadcrumbTitle}
1029
1348
  primaryActions={navbarActions.length > 0 ? navbarActions : defaultPrimaryActions}
1030
- showStatus={true}
1349
+ {showStatus}
1031
1350
  {showSettings}
1032
1351
  {settingsCategories}
1033
1352
  {showSettingsSyncButton}
@@ -1040,24 +1359,20 @@
1040
1359
  <NodeSidebar
1041
1360
  {nodes}
1042
1361
  loading={nodeTypesLoading}
1043
- activeFormat={getWorkflowFormat()}
1362
+ activeFormat={fd.workflow.format}
1044
1363
  categoriesDefaultOpen={themeConfig?.sidebar?.categoriesDefaultOpen ?? false}
1045
1364
  />
1046
1365
  {/snippet}
1047
1366
 
1048
- <!-- Right Sidebar: Configuration, Swap, or Workflow Settings -->
1367
+ <!--
1368
+ Right Sidebar. Node-swap sub-flow takes over when active. Otherwise the
1369
+ rail hosts whichever surfaces are placed `sidebar`: a lone config surface
1370
+ keeps the rich ConfigPanel; anything shared coexists as tabs.
1371
+ -->
1049
1372
  {#snippet rightSidebar()}
1050
1373
  {#if swapMode === 'mapping' && swapInteractiveState && selectedNodeForConfig}
1051
- {@const swapChecker = (() => {
1052
- try {
1053
- return getPortCompatibilityChecker();
1054
- } catch {
1055
- return null;
1056
- }
1057
- })()}
1058
1374
  <SwapMappingEditor
1059
1375
  interactiveState={swapInteractiveState}
1060
- checker={swapChecker}
1061
1376
  onConfirm={executeNodeSwap}
1062
1377
  onCancel={cancelSwap}
1063
1378
  onBack={() => {
@@ -1069,227 +1384,98 @@
1069
1384
  <NodeSwapPicker
1070
1385
  currentNode={selectedNodeForConfig}
1071
1386
  availableNodes={nodes}
1072
- activeFormat={getWorkflowFormat()}
1387
+ activeFormat={fd.workflow.format}
1073
1388
  onSelect={handleSwapSelect}
1074
1389
  onCancel={cancelSwap}
1075
1390
  />
1076
- {:else if isWorkflowSettingsOpen}
1077
- <ConfigPanel
1078
- title={mergedMessages.navigation.workflowSettingsPanelTitle}
1079
- id={getWorkflowStore()?.id}
1080
- details={[
1081
- {
1082
- label: 'Nodes',
1083
- value: String(getWorkflowStore()?.nodes?.length ?? 0)
1084
- },
1085
- {
1086
- label: 'Connections',
1087
- value: String(getWorkflowStore()?.edges?.length ?? 0)
1088
- }
1089
- ]}
1090
- configTitle={mergedMessages.navigation.workflowSettingsPanelSubtitle}
1091
- onClose={() => (isWorkflowSettingsOpen = false)}
1092
- >
1093
- <ConfigForm
1094
- {authProvider}
1095
- schema={workflowConfigSchema}
1096
- values={workflowConfigValues}
1097
- showUIExtensions={false}
1098
- onChange={(config) => {
1099
- // Sync workflow settings changes immediately on field blur
1100
- const wf = getWorkflowStore();
1101
- if (wf) {
1102
- const newFormat = (config.format as string) || DEFAULT_WORKFLOW_FORMAT;
1103
- const currentFormat = wf.metadata?.format || DEFAULT_WORKFLOW_FORMAT;
1104
-
1105
- // Warn about incompatible nodes when format changes
1106
- if (newFormat !== currentFormat) {
1107
- const incompatibleNodes = wf.nodes?.filter((node) => {
1108
- const formats = node.data?.metadata?.formats;
1109
- return formats && formats.length > 0 && !formats.includes(newFormat);
1110
- });
1111
- if (incompatibleNodes && incompatibleNodes.length > 0) {
1112
- logger.warn(
1113
- `Format changed to '${newFormat}'. ${incompatibleNodes.length} node(s) are not compatible with this format and may not export correctly:`,
1114
- incompatibleNodes.map((n) => n.data?.label || n.type)
1115
- );
1116
- }
1391
+ {:else if configHere('sidebar') && !consoleHere('sidebar')}
1392
+ {@render configPanelSidebar()}
1393
+ {:else if configHere('sidebar') || consoleHere('sidebar')}
1394
+ {@const tabs = [
1395
+ ...(configHere('sidebar')
1396
+ ? [
1397
+ {
1398
+ id: 'config',
1399
+ label: activeConfig?.title ?? 'Configuration',
1400
+ content: configTabContent
1117
1401
  }
1118
-
1119
- // Extract built-in fields; everything else belongs in workflow.config
1120
- const { name, description, format: _format, ...customConfig } = config;
1121
- workflowActions.batchUpdate({
1122
- name: name as string,
1123
- description: description as string | undefined,
1124
- metadata: {
1125
- ...wf.metadata,
1126
- format: newFormat
1127
- },
1128
- ...(workflowSettingsSchema && { config: customConfig as Record<string, unknown> })
1129
- });
1130
- }
1131
- }}
1132
- />
1133
- </ConfigPanel>
1134
- {:else if selectedNodeForConfig}
1135
- {@const currentNode = selectedNodeForConfig}
1136
- <ConfigPanel
1137
- title={currentNode.data.label}
1138
- id={currentNode.id}
1139
- description={currentNode.data.metadata?.description ||
1140
- mergedMessages.navigation.nodeConfigDescription}
1141
- details={[
1142
- {
1143
- label: 'Type',
1144
- value: currentNode.data.metadata?.type || currentNode.type
1145
- },
1146
- {
1147
- label: 'Category',
1148
- value: currentNode.data.metadata?.category || 'general'
1149
- }
1150
- ]}
1151
- onClose={closeConfigSidebar}
1152
- onSwap={!readOnly && !lockWorkflow && features.enableNodeSwap ? startSwap : undefined}
1153
- >
1154
- <ConfigForm
1155
- {authProvider}
1156
- node={currentNode}
1157
- workflowId={getWorkflowStore()?.id}
1158
- workflowNodes={getWorkflowStore()?.nodes}
1159
- workflowEdges={getWorkflowStore()?.edges}
1160
- onChange={async (updatedConfig, uiExtensions) => {
1161
- // Sync config changes to workflow immediately on field blur
1162
- if (selectedNodeId && currentNode) {
1163
- // Build the updated node data
1164
- const updatedData = {
1165
- ...currentNode.data,
1166
- config: updatedConfig
1167
- };
1168
-
1169
- // Include UI extensions if provided
1170
- if (uiExtensions) {
1171
- updatedData.extensions = {
1172
- ...currentNode.data.extensions,
1173
- ui: uiExtensions
1174
- };
1402
+ ]
1403
+ : []),
1404
+ ...(consoleHere('sidebar')
1405
+ ? [
1406
+ {
1407
+ id: 'console',
1408
+ label: mergedMessages.navigation.bottomPanel.console,
1409
+ content: consoleSurfaceBody,
1410
+ display: 'contents' as const
1411
+ },
1412
+ {
1413
+ id: 'chat',
1414
+ label: mergedMessages.navigation.bottomPanel.chat,
1415
+ content: chatSurfaceBody
1175
1416
  }
1176
-
1177
- // Update the node in the workflow store
1178
- const nodeUpdates: Record<string, unknown> = {
1179
- data: updatedData
1180
- };
1181
-
1182
- workflowActions.updateNode(selectedNodeId, nodeUpdates);
1183
-
1184
- // Update the local editor state to reflect config changes immediately
1185
- // This is needed for nodeType changes to take effect visually
1186
- workflowEditorRef?.updateNodeData(selectedNodeId, updatedData);
1187
-
1188
- // Refresh edge positions in case config changes affect handles
1189
- await workflowEditorRef?.refreshEdgePositions(selectedNodeId);
1190
- }
1191
- }}
1192
- />
1193
- </ConfigPanel>
1417
+ ]
1418
+ : [])
1419
+ ] as SurfaceTab[]}
1420
+ <TabbedSurface {tabs} activeId={activeSurface} onSelect={selectSurface} />
1194
1421
  {/if}
1195
1422
  {/snippet}
1196
1423
 
1197
- <!-- Bottom Panel: Tabbed Console / AI Assistant -->
1424
+ <!--
1425
+ Bottom Panel. Hosts whichever surfaces are placed `below` — config,
1426
+ console, chat — as a single tab strip (hidden when only one is present).
1427
+ -->
1198
1428
  {#snippet bottomPanel()}
1199
- <div class="bottom-panel-tabs">
1200
- <div class="bottom-panel-tabs__bar">
1201
- <button
1202
- class="bottom-panel-tabs__tab {getUiSettings().bottomPanelTab === 'console'
1203
- ? 'bottom-panel-tabs__tab--active'
1204
- : ''}"
1205
- onclick={() => updateSettings({ ui: { bottomPanelTab: 'console' } })}
1206
- >
1207
- {mergedMessages.navigation.bottomPanel.console}
1208
- </button>
1209
- <button
1210
- class="bottom-panel-tabs__tab {getUiSettings().bottomPanelTab === 'chat'
1211
- ? 'bottom-panel-tabs__tab--active'
1212
- : ''}"
1213
- onclick={() => updateSettings({ ui: { bottomPanelTab: 'chat' } })}
1214
- >
1215
- {mergedMessages.navigation.bottomPanel.chat}
1216
- </button>
1217
- </div>
1218
- <div class="bottom-panel-tabs__content">
1219
- <div
1220
- class="bottom-panel-tabs__panel"
1221
- style:display={getUiSettings().bottomPanelTab === 'console' ? 'contents' : 'none'}
1222
- >
1223
- <CommandConsole nodeTypes={nodes} onUIAction={handleConsoleUIAction} />
1224
- </div>
1225
- <div
1226
- class="bottom-panel-tabs__panel"
1227
- style:display={getUiSettings().bottomPanelTab === 'chat' ? 'flex' : 'none'}
1228
- >
1229
- <AIChatPanel
1230
- nodeTypes={nodes}
1231
- workflowId={getWorkflowStore()?.id}
1232
- onUIAction={handleConsoleUIAction}
1233
- {endpointConfig}
1234
- />
1235
- </div>
1236
- </div>
1237
- </div>
1429
+ {@const tabs = [
1430
+ ...(configHere('below')
1431
+ ? [
1432
+ {
1433
+ id: 'config',
1434
+ label: activeConfig?.title ?? 'Configuration',
1435
+ content: configTabContent
1436
+ }
1437
+ ]
1438
+ : []),
1439
+ ...(consoleHere('below')
1440
+ ? [
1441
+ {
1442
+ id: 'console',
1443
+ label: mergedMessages.navigation.bottomPanel.console,
1444
+ content: consoleSurfaceBody,
1445
+ display: 'contents' as const
1446
+ },
1447
+ {
1448
+ id: 'chat',
1449
+ label: mergedMessages.navigation.bottomPanel.chat,
1450
+ content: chatSurfaceBody
1451
+ }
1452
+ ]
1453
+ : [])
1454
+ ] as SurfaceTab[]}
1455
+ <TabbedSurface {tabs} activeId={activeSurface} onSelect={selectSurface} />
1238
1456
  {/snippet}
1239
1457
 
1240
1458
  <!-- Main Content: Workflow Editor with Error Status -->
1241
- <!-- Status Display: aria-live announces API errors dynamically without requiring focus -->
1242
1459
  {#if error}
1243
- <div class="flowdrop-status flowdrop-status--error" aria-live="polite" aria-atomic="true">
1244
- <div class="flowdrop-status__content">
1245
- <div class="flowdrop-flex flowdrop-gap--3">
1246
- <div class="flowdrop-status__indicator flowdrop-status__indicator--error"></div>
1247
- <span class="flowdrop-text--sm flowdrop-font--medium">Error: {error}</span>
1248
- </div>
1249
- <div class="flowdrop-flex flowdrop-gap--2">
1250
- <button
1251
- class="flowdrop-btn flowdrop-btn--sm flowdrop-btn--primary"
1252
- onclick={retryLoad}
1253
- type="button"
1254
- >
1255
- Retry
1256
- </button>
1257
- <button
1258
- class="flowdrop-btn flowdrop-btn--sm flowdrop-btn--outline"
1259
- onclick={() => {
1260
- const defaultUrl = '/api/flowdrop';
1261
- const newUrl = prompt('Enter Backend API URL:', defaultUrl);
1262
- if (newUrl) {
1263
- const endpointConfig = createEndpointConfig(newUrl);
1264
- setEndpointConfig(endpointConfig);
1265
- fetchNodeTypes();
1266
- }
1267
- }}
1268
- type="button"
1269
- >
1270
- Set API URL
1271
- </button>
1272
- <button
1273
- class="flowdrop-btn flowdrop-btn--sm flowdrop-btn--outline"
1274
- onclick={testApiConnection}
1275
- type="button"
1276
- >
1277
- Test API
1278
- </button>
1279
- <button
1280
- class="flowdrop-btn flowdrop-btn--ghost flowdrop-btn--sm"
1281
- onclick={() => (error = null)}
1282
- type="button"
1283
- >
1284
- ✕
1285
- </button>
1286
- </div>
1287
- </div>
1288
- </div>
1460
+ <EditorStatusBar
1461
+ {error}
1462
+ onRetry={retryLoad}
1463
+ onSetApiUrl={() => {
1464
+ const defaultUrl = '/api/flowdrop';
1465
+ const newUrl = prompt('Enter Backend API URL:', defaultUrl);
1466
+ if (newUrl) {
1467
+ configureApi(createEndpointConfig(newUrl));
1468
+ fetchNodeTypes();
1469
+ }
1470
+ }}
1471
+ onTestApi={testApiConnection}
1472
+ onDismiss={() => (error = null)}
1473
+ />
1289
1474
  {/if}
1290
1475
 
1291
1476
  <!-- Main Editor Area -->
1292
- <!-- svelte-ignore a11y_no_noninteractive_element_interactions — interactive workflow canvas region with keyboard support -->
1477
+ <!-- interactive workflow canvas region with keyboard support -->
1478
+ <!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
1293
1479
  <div
1294
1480
  class="flowdrop-editor-main"
1295
1481
  class:pipeline-view={!!pipelineId}
@@ -1301,34 +1487,34 @@
1301
1487
  >
1302
1488
  <!-- Floating sidebar toggle — always visible on the canvas top-left -->
1303
1489
  {#if !disableSidebar}
1304
- <button
1490
+ <CanvasIconButton
1305
1491
  class="flowdrop-sidebar-fab"
1306
- onclick={toggleSidebar}
1307
- aria-label={isSidebarCollapsed
1308
- ? mergedMessages.layout.expandSidebar
1309
- : mergedMessages.layout.collapseSidebar}
1310
- title={isSidebarCollapsed
1492
+ label={isSidebarCollapsed
1311
1493
  ? mergedMessages.layout.expandSidebar
1312
1494
  : mergedMessages.layout.collapseSidebar}
1495
+ active={!isSidebarCollapsed}
1496
+ onclick={toggleSidebar}
1313
1497
  >
1314
- <Icon icon={isSidebarCollapsed ? 'mdi:menu' : 'mdi:menu-open'} />
1315
- </button>
1498
+ {#snippet icon()}
1499
+ {#if isSidebarCollapsed}
1500
+ <MenuIcon />
1501
+ {:else}
1502
+ <MenuOpenIcon />
1503
+ {/if}
1504
+ {/snippet}
1505
+ </CanvasIconButton>
1316
1506
  {/if}
1317
1507
 
1318
1508
  <WorkflowEditor
1319
1509
  bind:this={workflowEditorRef}
1320
- {nodes}
1321
- {height}
1322
- {width}
1323
1510
  endpointConfig={endpointConfig ?? undefined}
1324
- {isConfigSidebarOpen}
1325
- {selectedNodeForConfig}
1511
+ {authProvider}
1326
1512
  {openConfigSidebar}
1327
- {closeConfigSidebar}
1328
- {lockWorkflow}
1329
- {readOnly}
1330
- {nodeStatuses}
1513
+ {mode}
1331
1514
  {pipelineId}
1515
+ {refreshTrigger}
1516
+ builtinEditors={features.builtinEditors}
1517
+ gridVariant={themeConfig?.canvas?.grid ?? 'dots'}
1332
1518
  consoleOpen={getUiSettings().consoleOpen}
1333
1519
  onToggleConsole={toggleConsole}
1334
1520
  />
@@ -1336,143 +1522,62 @@
1336
1522
  </MainLayout>
1337
1523
  </div>
1338
1524
 
1525
+ <!--
1526
+ Modal host — floats surfaces routed to `modal` above the canvas. Portalled to
1527
+ <body> by SurfaceOverlay. When both config and console are modal they coexist
1528
+ as tabs inside one overlay.
1529
+ -->
1530
+ {#if configHere('modal') && consoleHere('modal')}
1531
+ <SurfaceOverlay
1532
+ title={activeConfig?.title ?? mergedMessages.navigation.workflowSettingsPanelTitle}
1533
+ closeLabel={mergedMessages.layout.closeConfigPanel}
1534
+ onClose={() => {
1535
+ closeActiveConfig();
1536
+ closeConsole();
1537
+ }}
1538
+ >
1539
+ {@const tabs = [
1540
+ { id: 'config', label: activeConfig?.title ?? 'Configuration', content: configBareContent },
1541
+ {
1542
+ id: 'console',
1543
+ label: mergedMessages.navigation.bottomPanel.console,
1544
+ content: consoleSurfaceBody,
1545
+ display: 'contents' as const
1546
+ },
1547
+ { id: 'chat', label: mergedMessages.navigation.bottomPanel.chat, content: chatSurfaceBody }
1548
+ ] as SurfaceTab[]}
1549
+ <TabbedSurface {tabs} activeId={activeSurface} onSelect={selectSurface} />
1550
+ </SurfaceOverlay>
1551
+ {:else if configHere('modal')}
1552
+ <SurfaceOverlay
1553
+ title={activeConfig?.title ?? 'Configuration'}
1554
+ closeLabel={mergedMessages.layout.closeConfigPanel}
1555
+ onClose={closeActiveConfig}
1556
+ >
1557
+ {@render configBareContent()}
1558
+ </SurfaceOverlay>
1559
+ {:else if consoleHere('modal')}
1560
+ <SurfaceOverlay
1561
+ title={activeSurface === 'chat'
1562
+ ? mergedMessages.navigation.bottomPanel.chat
1563
+ : mergedMessages.navigation.bottomPanel.console}
1564
+ closeLabel={mergedMessages.layout.closeConfigPanel}
1565
+ onClose={closeConsole}
1566
+ >
1567
+ {@render consoleChatTabs()}
1568
+ </SurfaceOverlay>
1569
+ {/if}
1570
+
1339
1571
  <style>
1340
1572
  .flowdrop-root {
1341
1573
  display: contents;
1342
1574
  }
1343
- /* Status bar styles */
1344
- .flowdrop-status {
1345
- background-color: var(--fd-info-muted);
1346
- border-bottom: 1px solid var(--fd-info);
1347
- padding: 1rem;
1348
- }
1349
-
1350
- .flowdrop-status--error {
1351
- background-color: var(--fd-error-muted);
1352
- border-bottom: 1px solid var(--fd-error);
1353
- }
1354
-
1355
- .flowdrop-status__content {
1356
- max-width: 80rem;
1357
- margin: 0 auto;
1358
- display: flex;
1359
- align-items: center;
1360
- justify-content: space-between;
1361
- }
1362
-
1363
- .flowdrop-status__indicator {
1364
- width: 0.5rem;
1365
- height: 0.5rem;
1366
- border-radius: 50%;
1367
- }
1368
-
1369
- .flowdrop-status__indicator--error {
1370
- background-color: var(--fd-error);
1371
- }
1372
-
1373
- /* Button styles */
1374
- .flowdrop-btn {
1375
- padding: 0.375rem 0.75rem;
1376
- border-radius: var(--fd-radius-md);
1377
- font-size: 0.75rem;
1378
- font-weight: 500;
1379
- cursor: pointer;
1380
- border: 1px solid transparent;
1381
- transition: all var(--fd-transition-fast);
1382
- }
1383
-
1384
- .flowdrop-btn--sm {
1385
- padding: 0.25rem 0.5rem;
1386
- font-size: 0.625rem;
1387
- }
1388
-
1389
- .flowdrop-btn--outline {
1390
- background-color: transparent;
1391
- border-color: var(--fd-border);
1392
- color: var(--fd-foreground);
1393
- }
1394
-
1395
- .flowdrop-btn--outline:hover {
1396
- background-color: var(--fd-muted);
1397
- border-color: var(--fd-border-strong);
1398
- }
1399
-
1400
- .flowdrop-btn--primary {
1401
- background-color: var(--fd-primary);
1402
- border-color: var(--fd-primary);
1403
- color: var(--fd-primary-foreground);
1404
- }
1405
-
1406
- .flowdrop-btn--primary:hover {
1407
- background-color: var(--fd-primary-hover);
1408
- border-color: var(--fd-primary-hover);
1409
- }
1410
-
1411
- .flowdrop-btn--ghost {
1412
- background-color: transparent;
1413
- border-color: transparent;
1414
- color: var(--fd-muted-foreground);
1415
- }
1416
-
1417
- .flowdrop-btn--ghost:hover {
1418
- background-color: var(--fd-muted);
1419
- color: var(--fd-foreground);
1420
- }
1421
-
1422
- /* Utility classes */
1423
- .flowdrop-flex {
1424
- display: flex;
1425
- }
1426
-
1427
- .flowdrop-gap--2 {
1428
- gap: 0.5rem;
1429
- }
1430
-
1431
- .flowdrop-gap--3 {
1432
- gap: 0.75rem;
1433
- }
1434
-
1435
- .flowdrop-text--sm {
1436
- font-size: 0.875rem;
1437
- line-height: 1.25rem;
1438
- }
1439
1575
 
1440
- .flowdrop-font--medium {
1441
- font-weight: 500;
1442
- }
1443
-
1444
- /* Floating sidebar toggle button */
1445
- .flowdrop-sidebar-fab {
1446
- position: absolute;
1576
+ /* Floating sidebar toggle button — placement only; visuals live in CanvasIconButton */
1577
+ :global(.flowdrop-sidebar-fab) {
1447
1578
  top: 12px;
1448
1579
  left: 12px;
1449
1580
  z-index: 50;
1450
- display: flex;
1451
- align-items: center;
1452
- justify-content: center;
1453
- width: 2.25rem;
1454
- height: 2.25rem;
1455
- border: 1px solid var(--fd-border);
1456
- border-radius: var(--fd-radius-md);
1457
- background-color: var(--fd-background);
1458
- color: var(--fd-muted-foreground);
1459
- cursor: pointer;
1460
- box-shadow: var(--fd-shadow-md);
1461
- transition:
1462
- color var(--fd-transition-fast),
1463
- background-color var(--fd-transition-fast),
1464
- box-shadow var(--fd-transition-fast);
1465
- }
1466
-
1467
- .flowdrop-sidebar-fab:hover {
1468
- color: var(--fd-foreground);
1469
- background-color: var(--fd-subtle);
1470
- box-shadow: var(--fd-shadow-lg);
1471
- }
1472
-
1473
- .flowdrop-sidebar-fab:focus {
1474
- outline: none;
1475
- box-shadow: 0 0 0 2px var(--fd-ring);
1476
1581
  }
1477
1582
 
1478
1583
  /* Main editor area */
@@ -1485,55 +1590,81 @@
1485
1590
  background: var(--fd-layout-background);
1486
1591
  }
1487
1592
 
1488
- /* Bottom panel tab system */
1489
- .bottom-panel-tabs {
1593
+ /*
1594
+ Chromeless config surface (bottom / modal / shared-sidebar hosts). Mirrors
1595
+ ConfigPanel's inner layout; the host owns any outer chrome.
1596
+ */
1597
+ .config-surface {
1490
1598
  display: flex;
1491
1599
  flex-direction: column;
1492
1600
  height: 100%;
1493
- overflow: hidden;
1601
+ min-height: 0;
1602
+ background-color: var(--fd-panel-bg);
1603
+ backdrop-filter: var(--fd-panel-backdrop-filter);
1494
1604
  }
1495
1605
 
1496
- .bottom-panel-tabs__bar {
1606
+ .config-surface__header {
1497
1607
  display: flex;
1498
- gap: 0;
1499
- background: var(--fd-muted);
1608
+ justify-content: space-between;
1609
+ align-items: center;
1610
+ padding: 0.875rem 1rem;
1500
1611
  border-bottom: 1px solid var(--fd-border);
1612
+ background-color: var(--fd-card);
1501
1613
  flex-shrink: 0;
1502
1614
  }
1503
1615
 
1504
- .bottom-panel-tabs__tab {
1505
- padding: 0.375rem 0.75rem;
1506
- font-size: 0.75rem;
1507
- font-weight: 500;
1508
- cursor: pointer;
1616
+ .config-surface__title {
1617
+ margin: 0;
1618
+ font-size: 1rem;
1619
+ font-weight: 600;
1620
+ color: var(--fd-foreground);
1621
+ }
1622
+
1623
+ .config-surface__close {
1624
+ background: none;
1509
1625
  border: none;
1510
- border-bottom: 2px solid transparent;
1511
- background: transparent;
1626
+ font-size: 1.25rem;
1627
+ line-height: 1;
1628
+ cursor: pointer;
1512
1629
  color: var(--fd-muted-foreground);
1513
- transition: all var(--fd-transition-fast);
1630
+ padding: 0.25rem;
1631
+ border-radius: var(--fd-radius-sm);
1632
+ transition:
1633
+ color var(--fd-transition-fast),
1634
+ background-color var(--fd-transition-fast);
1514
1635
  }
1515
1636
 
1516
- .bottom-panel-tabs__tab:hover {
1637
+ .config-surface__close:hover {
1517
1638
  color: var(--fd-foreground);
1518
- background: var(--fd-background);
1639
+ background-color: var(--fd-subtle);
1519
1640
  }
1520
1641
 
1521
- .bottom-panel-tabs__tab--active {
1522
- color: var(--fd-foreground);
1523
- border-bottom-color: var(--fd-primary);
1524
- background: var(--fd-background);
1642
+ .config-surface__details {
1643
+ padding: 0.75rem 1rem;
1644
+ border-bottom: 1px solid var(--fd-border-muted);
1645
+ background-color: var(--fd-card);
1646
+ flex-shrink: 0;
1525
1647
  }
1526
1648
 
1527
- .bottom-panel-tabs__content {
1649
+ .config-surface__content {
1528
1650
  flex: 1;
1529
- overflow: hidden;
1651
+ min-height: 0;
1652
+ overflow-y: auto;
1653
+ padding: 1rem;
1654
+ }
1655
+
1656
+ .config-surface__section {
1530
1657
  display: flex;
1531
1658
  flex-direction: column;
1659
+ gap: 0.75rem;
1532
1660
  }
1533
1661
 
1534
- .bottom-panel-tabs__panel {
1535
- flex: 1;
1536
- overflow: hidden;
1537
- flex-direction: column;
1662
+ .config-surface__section-title {
1663
+ margin: 0;
1664
+ font-size: var(--fd-text-xs);
1665
+ font-weight: 600;
1666
+ color: var(--fd-muted-foreground);
1667
+ text-transform: uppercase;
1668
+ letter-spacing: 0.05em;
1538
1669
  }
1539
1670
  </style>