@flowdrop/flowdrop 2.16.0 → 2.18.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 (130) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/README.md +6 -1
  3. package/dist/api/enhanced-client.d.ts +3 -1
  4. package/dist/api/enhanced-client.js +4 -2
  5. package/dist/commands/executor.js +9 -0
  6. package/dist/commands/storeIntegration.svelte.js +6 -0
  7. package/dist/commands/types.d.ts +8 -0
  8. package/dist/components/App.svelte +414 -105
  9. package/dist/components/App.svelte.d.ts +31 -0
  10. package/dist/components/CanvasToolbar.svelte +40 -3
  11. package/dist/components/CanvasToolbar.svelte.d.ts +5 -1
  12. package/dist/components/ConnectPortPicker.svelte +8 -4
  13. package/dist/components/DoctorMenu.svelte +208 -126
  14. package/dist/components/FlowDropZone.svelte +7 -1
  15. package/dist/components/FlowDropZone.svelte.d.ts +5 -0
  16. package/dist/components/ImpactConfirm.svelte +554 -0
  17. package/dist/components/ImpactConfirm.svelte.d.ts +22 -0
  18. package/dist/components/Input.svelte +8 -2
  19. package/dist/components/LockBanner.svelte +76 -0
  20. package/dist/components/LockBanner.svelte.d.ts +14 -0
  21. package/dist/components/LockFence.svelte +33 -0
  22. package/dist/components/LockFence.svelte.d.ts +19 -0
  23. package/dist/components/Navbar.svelte +77 -9
  24. package/dist/components/Navbar.svelte.d.ts +10 -0
  25. package/dist/components/NodeSidebar.svelte +36 -15
  26. package/dist/components/NodeSidebar.svelte.d.ts +2 -0
  27. package/dist/components/NodeSwapPicker.svelte +4 -14
  28. package/dist/components/RunBar.svelte +50 -3
  29. package/dist/components/RunBar.svelte.d.ts +5 -0
  30. package/dist/components/RunInputsDialog.svelte +198 -0
  31. package/dist/components/RunInputsDialog.svelte.d.ts +34 -0
  32. package/dist/components/Textarea.svelte +7 -1
  33. package/dist/components/WorkflowCompareDialog.svelte +177 -0
  34. package/dist/components/WorkflowCompareDialog.svelte.d.ts +10 -0
  35. package/dist/components/WorkflowEditor.svelte +120 -15
  36. package/dist/components/WorkflowEditor.svelte.d.ts +6 -0
  37. package/dist/components/WorkflowInterfaceEditor.svelte +17 -4
  38. package/dist/components/WorkflowInterfaceEntryCard.svelte +40 -7
  39. package/dist/components/WorkflowInterfaceEntryCard.svelte.d.ts +2 -0
  40. package/dist/components/WorkflowPlaygroundSettings.svelte +9 -1
  41. package/dist/components/form/FieldFactory.svelte +13 -6
  42. package/dist/components/form/FormArray.svelte +0 -1
  43. package/dist/components/form/FormArrayRows.svelte +4 -4
  44. package/dist/components/form/FormCodeEditor.svelte +18 -2
  45. package/dist/components/form/FormMarkdownEditor.svelte +22 -8
  46. package/dist/components/form/FormTemplateEditor.svelte +17 -1
  47. package/dist/components/form/readOnly.d.ts +13 -0
  48. package/dist/components/form/readOnly.js +18 -0
  49. package/dist/components/nodes/CaptionNode.svelte +1 -0
  50. package/dist/components/nodes/NodeCard.svelte +2 -2
  51. package/dist/components/primitives/Checkbox.svelte +5 -1
  52. package/dist/components/primitives/Select.svelte +6 -1
  53. package/dist/components/primitives/Switch.svelte +5 -1
  54. package/dist/components/toast/DismissibleToast.svelte +25 -6
  55. package/dist/components/toast/DismissibleToast.svelte.d.ts +3 -0
  56. package/dist/config/endpoints.d.ts +7 -0
  57. package/dist/config/endpoints.js +2 -1
  58. package/dist/editor/connectCandidates.d.ts +3 -0
  59. package/dist/editor/connectCandidates.js +14 -5
  60. package/dist/editor/index.d.ts +2 -1
  61. package/dist/editor/index.js +1 -1
  62. package/dist/helpers/workflowEditorHelper.d.ts +15 -0
  63. package/dist/helpers/workflowEditorHelper.js +9 -0
  64. package/dist/index.d.ts +2 -0
  65. package/dist/messages/defaults.d.ts +145 -0
  66. package/dist/messages/defaults.js +139 -1
  67. package/dist/openapi/v1/openapi.yaml +492 -0
  68. package/dist/registry/nodeComponentRegistry.d.ts +5 -0
  69. package/dist/schemas/v1/workflow.schema.json +2 -0
  70. package/dist/services/draftStorage.d.ts +24 -10
  71. package/dist/services/draftStorage.js +60 -35
  72. package/dist/services/globalSave.d.ts +45 -10
  73. package/dist/services/globalSave.js +296 -32
  74. package/dist/services/impactGate.d.ts +38 -0
  75. package/dist/services/impactGate.js +72 -0
  76. package/dist/services/impactService.d.ts +45 -0
  77. package/dist/services/impactService.js +157 -0
  78. package/dist/services/runsService.d.ts +9 -0
  79. package/dist/services/runsService.js +13 -0
  80. package/dist/services/toastQueue.d.ts +9 -0
  81. package/dist/services/toastService.d.ts +4 -0
  82. package/dist/services/toastService.js +9 -3
  83. package/dist/services/workflowLaunchService.d.ts +6 -0
  84. package/dist/services/workflowLaunchService.js +5 -1
  85. package/dist/settings/index.d.ts +2 -2
  86. package/dist/settings/index.js +1 -1
  87. package/dist/stores/doctorStore.svelte.d.ts +24 -1
  88. package/dist/stores/doctorStore.svelte.js +105 -2
  89. package/dist/stores/historyStore.svelte.d.ts +12 -2
  90. package/dist/stores/historyStore.svelte.js +25 -2
  91. package/dist/stores/instanceContainer.svelte.d.ts +23 -0
  92. package/dist/stores/instanceContainer.svelte.js +32 -2
  93. package/dist/stores/lockStore.svelte.d.ts +39 -0
  94. package/dist/stores/lockStore.svelte.js +109 -0
  95. package/dist/stores/runController.svelte.d.ts +2 -0
  96. package/dist/stores/runController.svelte.js +27 -11
  97. package/dist/stores/saveConflictStore.svelte.d.ts +62 -0
  98. package/dist/stores/saveConflictStore.svelte.js +169 -0
  99. package/dist/stores/workflowStore.svelte.d.ts +14 -4
  100. package/dist/stores/workflowStore.svelte.js +55 -18
  101. package/dist/styles/base.css +6 -0
  102. package/dist/styles/toast.css +10 -1
  103. package/dist/svelte-app.d.ts +33 -0
  104. package/dist/svelte-app.js +178 -22
  105. package/dist/types/doctor.d.ts +3 -1
  106. package/dist/types/events.d.ts +37 -0
  107. package/dist/types/events.js +2 -0
  108. package/dist/types/impact.d.ts +77 -0
  109. package/dist/types/impact.js +7 -0
  110. package/dist/types/lock.d.ts +35 -0
  111. package/dist/types/lock.js +13 -0
  112. package/dist/types/navbar.d.ts +6 -0
  113. package/dist/types/settings.d.ts +31 -0
  114. package/dist/types/settings.js +132 -0
  115. package/dist/utils/draftRestore.d.ts +27 -0
  116. package/dist/utils/draftRestore.js +36 -0
  117. package/dist/utils/interfaceTags.js +4 -1
  118. package/dist/utils/links.d.ts +29 -0
  119. package/dist/utils/links.js +63 -0
  120. package/dist/utils/nodeSearch.d.ts +10 -0
  121. package/dist/utils/nodeSearch.js +37 -0
  122. package/dist/utils/runOffer.d.ts +21 -0
  123. package/dist/utils/runOffer.js +13 -0
  124. package/dist/utils/workflowCompare.d.ts +35 -0
  125. package/dist/utils/workflowCompare.js +84 -0
  126. package/dist/utils/workflowInterface.d.ts +26 -1
  127. package/dist/utils/workflowInterface.js +91 -11
  128. package/dist/webmcp/runtime.js +16 -3
  129. package/dist/webmcp/types.d.ts +11 -1
  130. package/package.json +3 -2
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Save Conflict Store
3
+ *
4
+ * One editor's answer to a save the server refused because someone else saved
5
+ * the workflow first (409 CONFLICT). It offers three ways out in a toast:
6
+ * keep mine (send again on top of the newer version), load the saved version (take the
7
+ * saved version) and compare (see what differs before choosing).
8
+ *
9
+ * @module stores/saveConflictStore
10
+ */
11
+ import type { Workflow } from '../types/index.js';
12
+ import type { Messages } from '../messages/index.js';
13
+ import { type WorkflowComparison } from '../utils/workflowCompare.js';
14
+ import type { WorkflowStore } from './workflowStore.svelte.js';
15
+ /** What a refused save hands over. */
16
+ export interface SaveConflictReport {
17
+ /** The revision the server holds now, or `null` when the refusal did not say. */
18
+ currentRevision: string | null;
19
+ /** Sends the same save again; resolves true when it wrote. */
20
+ retry: () => Promise<boolean>;
21
+ }
22
+ /** What the store needs from the editor. */
23
+ export interface SaveConflictDeps {
24
+ workflow: Pick<WorkflowStore, 'current' | 'initialize' | 'acknowledgeServer'>;
25
+ /** Loads the saved version of a workflow. */
26
+ loadWorkflow: (id: string) => Promise<Workflow>;
27
+ /** Asks the Doctor to check the editor's workflow again. */
28
+ schedule: () => void;
29
+ messages: () => Messages;
30
+ }
31
+ export declare class SaveConflictStore {
32
+ #private;
33
+ /** The saved version, once loaded for Compare or Load saved version. */
34
+ theirs: Workflow | null;
35
+ /** The differences shown by the compare dialog. */
36
+ comparison: WorkflowComparison | null;
37
+ constructor(deps: SaveConflictDeps);
38
+ /** True while the compare dialog is wanted. */
39
+ get comparing(): boolean;
40
+ /**
41
+ * Remember the refused save and offer the three choices in a toast that
42
+ * stays until closed. The actions set `keepOpen`: a failed or cancelled choice
43
+ * leaves the toast up, and the store dismisses it itself once a choice has
44
+ * been carried out. With `showToast` false the choices stay available to
45
+ * code (keepMine, loadTheirs, compare) but nothing is shown.
46
+ */
47
+ report(args: SaveConflictReport, showToast?: boolean): void;
48
+ /**
49
+ * Take the server's revision and send the save again. When the refusal did
50
+ * not name the revision it is read from the saved version; if that cannot be
51
+ * done nothing is sent and the choice stays open.
52
+ */
53
+ keepMine(): Promise<void>;
54
+ /** Replace the editor's workflow with the saved version. */
55
+ loadTheirs(): Promise<void>;
56
+ /** Load the saved version and open the comparison. */
57
+ compare(): Promise<void>;
58
+ /** Use the already loaded saved version (the dialog's "Load saved version"). */
59
+ acceptTheirs(): void;
60
+ /** Close the dialog without choosing; the toast stays (its actions are `keepOpen`). */
61
+ closeComparison(): void;
62
+ }
@@ -0,0 +1,169 @@
1
+ /**
2
+ * Save Conflict Store
3
+ *
4
+ * One editor's answer to a save the server refused because someone else saved
5
+ * the workflow first (409 CONFLICT). It offers three ways out in a toast:
6
+ * keep mine (send again on top of the newer version), load the saved version (take the
7
+ * saved version) and compare (see what differs before choosing).
8
+ *
9
+ * @module stores/saveConflictStore
10
+ */
11
+ import { compareWorkflows } from '../utils/workflowCompare.js';
12
+ import { apiToasts, dismissToast, showError } from '../services/toastService.js';
13
+ const TOAST_ID = 'flowdrop:save-conflict';
14
+ export class SaveConflictStore {
15
+ #deps;
16
+ #pending = null;
17
+ /** Whether the editor shows toasts; set by `report`. */
18
+ #showToasts = true;
19
+ /** True while keepMine, loadTheirs or compare runs; a second call is ignored. */
20
+ #busy = false;
21
+ /** The saved version, once loaded for Compare or Load saved version. */
22
+ theirs = $state(null);
23
+ /** The differences shown by the compare dialog. */
24
+ comparison = $state(null);
25
+ constructor(deps) {
26
+ this.#deps = deps;
27
+ }
28
+ /** True while the compare dialog is wanted. */
29
+ get comparing() {
30
+ return this.comparison !== null;
31
+ }
32
+ /**
33
+ * Remember the refused save and offer the three choices in a toast that
34
+ * stays until closed. The actions set `keepOpen`: a failed or cancelled choice
35
+ * leaves the toast up, and the store dismisses it itself once a choice has
36
+ * been carried out. With `showToast` false the choices stay available to
37
+ * code (keepMine, loadTheirs, compare) but nothing is shown.
38
+ */
39
+ report(args, showToast = true) {
40
+ this.#pending = args;
41
+ this.#showToasts = showToast;
42
+ if (!showToast)
43
+ return;
44
+ const messages = this.#deps.messages();
45
+ showError({
46
+ title: messages.saveConflict.title,
47
+ body: messages.saveConflict.body,
48
+ actions: [
49
+ {
50
+ label: messages.compare.keepMine,
51
+ primary: true,
52
+ keepOpen: true,
53
+ onClick: () => void this.keepMine()
54
+ },
55
+ {
56
+ label: messages.compare.loadTheirs,
57
+ keepOpen: true,
58
+ onClick: () => void this.loadTheirs()
59
+ },
60
+ {
61
+ label: messages.saveConflict.compare,
62
+ keepOpen: true,
63
+ onClick: () => void this.compare()
64
+ }
65
+ ]
66
+ }, { id: TOAST_ID });
67
+ }
68
+ /**
69
+ * Take the server's revision and send the save again. When the refusal did
70
+ * not name the revision it is read from the saved version; if that cannot be
71
+ * done nothing is sent and the choice stays open.
72
+ */
73
+ async keepMine() {
74
+ const pending = this.#pending;
75
+ if (!pending || this.#busy)
76
+ return;
77
+ this.#busy = true;
78
+ try {
79
+ let revision = pending.currentRevision;
80
+ if (revision === null) {
81
+ const loaded = this.theirs ?? (await this.#load());
82
+ revision = loaded?.revision ? String(loaded.revision) : null;
83
+ if (revision === null) {
84
+ // The toast stays, so the other choices are still there.
85
+ if (this.#showToasts)
86
+ showError(this.#deps.messages().saveConflict.noRevision);
87
+ return;
88
+ }
89
+ }
90
+ this.#clear();
91
+ this.#deps.workflow.acknowledgeServer({ revision });
92
+ try {
93
+ await pending.retry();
94
+ }
95
+ catch {
96
+ // The retried save has already shown its own error.
97
+ }
98
+ }
99
+ finally {
100
+ this.#busy = false;
101
+ }
102
+ }
103
+ /** Replace the editor's workflow with the saved version. */
104
+ async loadTheirs() {
105
+ if (this.#busy)
106
+ return;
107
+ this.#busy = true;
108
+ try {
109
+ const loaded = this.theirs ?? (await this.#load());
110
+ if (!loaded)
111
+ return;
112
+ this.#accept(loaded);
113
+ }
114
+ finally {
115
+ this.#busy = false;
116
+ }
117
+ }
118
+ /** Load the saved version and open the comparison. */
119
+ async compare() {
120
+ if (this.#busy)
121
+ return;
122
+ this.#busy = true;
123
+ try {
124
+ const mine = this.#deps.workflow.current;
125
+ const loaded = await this.#load();
126
+ if (!loaded || !mine)
127
+ return;
128
+ this.theirs = loaded;
129
+ this.comparison = compareWorkflows(mine, loaded);
130
+ }
131
+ finally {
132
+ this.#busy = false;
133
+ }
134
+ }
135
+ /** Use the already loaded saved version (the dialog's "Load saved version"). */
136
+ acceptTheirs() {
137
+ if (this.theirs)
138
+ this.#accept(this.theirs);
139
+ }
140
+ /** Close the dialog without choosing; the toast stays (its actions are `keepOpen`). */
141
+ closeComparison() {
142
+ this.comparison = null;
143
+ this.theirs = null;
144
+ }
145
+ #accept(loaded) {
146
+ this.#clear();
147
+ this.#deps.workflow.initialize(loaded);
148
+ this.#deps.schedule();
149
+ }
150
+ #clear() {
151
+ this.#pending = null;
152
+ this.comparison = null;
153
+ this.theirs = null;
154
+ dismissToast(TOAST_ID);
155
+ }
156
+ async #load() {
157
+ const id = this.#deps.workflow.current?.id;
158
+ if (!id)
159
+ return null;
160
+ try {
161
+ return await this.#deps.loadWorkflow(id);
162
+ }
163
+ catch (error) {
164
+ if (this.#showToasts)
165
+ apiToasts.error('Load workflow', error instanceof Error ? error : String(error));
166
+ return null;
167
+ }
168
+ }
169
+ }
@@ -102,6 +102,10 @@ export declare class WorkflowStore {
102
102
  /** Bound mutation facade — see {@link WorkflowStoreActions}. */
103
103
  readonly actions: WorkflowStoreActions;
104
104
  constructor(history: HistoryService);
105
+ /** Whether edits are refused (the editor is locked). */
106
+ get locked(): boolean;
107
+ /** Refuse (or allow again) every edit. Ends an open config-edit session first. */
108
+ setLocked(locked: boolean): void;
105
109
  /** The current workflow, or null when none is loaded. */
106
110
  get current(): Workflow | null;
107
111
  /**
@@ -169,6 +173,8 @@ export declare class WorkflowStore {
169
173
  * 5. If not: the save didn't persist the version you submitted — reset from backend response
170
174
  */
171
175
  get editVersion(): number;
176
+ /** Counts the `initialize()` calls: a reload of the same id is a new load. */
177
+ get loadGeneration(): number;
172
178
  /** Whether history recording is enabled. */
173
179
  get historyEnabled(): boolean;
174
180
  /** Enable or disable history recording (e.g. for bulk operations). */
@@ -180,10 +186,12 @@ export declare class WorkflowStore {
180
186
  /**
181
187
  * Mark the current workflow state as saved.
182
188
  *
183
- * Captures the current edit version so isDirty becomes false.
184
- * Call this after a successful backend save.
189
+ * Captures the edit version so isDirty becomes false. Call this after a
190
+ * successful backend save. Pass the `editVersion` read when the saved
191
+ * snapshot was taken: an edit made while the save was in flight is then not
192
+ * marked saved. Without it, the current version is taken.
185
193
  */
186
- markAsSaved(): void;
194
+ markAsSaved(version?: number): void;
187
195
  /**
188
196
  * Take the server's word on the workflow's revision and permissions after a
189
197
  * save (the load path sets them with the payload). Bookkeeping only: no history entry, no dirty flag, no
@@ -272,10 +280,12 @@ export declare class WorkflowStore {
272
280
  * @param updates - Partial node updates (typically `{ data }`)
273
281
  * @param opts.fieldKey - The config field being edited; drives per-field
274
282
  * session boundaries. Omit to treat the whole node as one session.
283
+ * @returns `false` when the edit was refused (no workflow, or the editor is
284
+ * locked): whatever mirrors the store must not show it either.
275
285
  */
276
286
  updateNodeConfig(nodeId: string, updates: Partial<WorkflowNode>, opts?: {
277
287
  fieldKey?: string;
278
- }): void;
288
+ }): boolean;
279
289
  /**
280
290
  * Finalize the in-progress config-edit session, if any.
281
291
  *
@@ -119,6 +119,7 @@ export class WorkflowStore {
119
119
  * didn't persist the version the client submitted.
120
120
  */
121
121
  #editVersion = $state(0);
122
+ #loadGeneration = 0;
122
123
  /**
123
124
  * Edit version captured at the last successful save.
124
125
  * When #editVersion === #savedVersion, the workflow is clean.
@@ -135,6 +136,12 @@ export class WorkflowStore {
135
136
  * When true, prevents pushing to history to avoid recursive loops.
136
137
  */
137
138
  #restoringFromHistory = false;
139
+ /**
140
+ * Whether the editor is locked: every edit is refused, so a locked canvas
141
+ * cannot change by any route (canvas, config panel, console, shortcuts,
142
+ * undo). Loading a workflow (`initialize`) still works.
143
+ */
144
+ #locked = $state(false);
138
145
  /** Whether history recording is enabled (disable for bulk operations). */
139
146
  #historyEnabled = true;
140
147
  /**
@@ -181,6 +188,18 @@ export class WorkflowStore {
181
188
  // -----------------------------------------------------------------------
182
189
  // Reactive getters
183
190
  // -----------------------------------------------------------------------
191
+ /** Whether edits are refused (the editor is locked). */
192
+ get locked() {
193
+ return this.#locked;
194
+ }
195
+ /** Refuse (or allow again) every edit. Ends an open config-edit session first. */
196
+ setLocked(locked) {
197
+ if (locked === this.#locked)
198
+ return;
199
+ if (locked)
200
+ this.finalizeNodeConfig();
201
+ this.#locked = locked;
202
+ }
184
203
  /** The current workflow, or null when none is loaded. */
185
204
  get current() {
186
205
  return this.#workflow;
@@ -296,6 +315,10 @@ export class WorkflowStore {
296
315
  get editVersion() {
297
316
  return this.#editVersion;
298
317
  }
318
+ /** Counts the `initialize()` calls: a reload of the same id is a new load. */
319
+ get loadGeneration() {
320
+ return this.#loadGeneration;
321
+ }
299
322
  /** Whether history recording is enabled. */
300
323
  get historyEnabled() {
301
324
  return this.#historyEnabled;
@@ -318,13 +341,16 @@ export class WorkflowStore {
318
341
  /**
319
342
  * Mark the current workflow state as saved.
320
343
  *
321
- * Captures the current edit version so isDirty becomes false.
322
- * Call this after a successful backend save.
344
+ * Captures the edit version so isDirty becomes false. Call this after a
345
+ * successful backend save. Pass the `editVersion` read when the saved
346
+ * snapshot was taken: an edit made while the save was in flight is then not
347
+ * marked saved. Without it, the current version is taken.
323
348
  */
324
- markAsSaved() {
349
+ markAsSaved(version) {
325
350
  const wasDirty = this.#editVersion !== this.#savedVersion;
326
- this.#savedVersion = this.#editVersion;
327
- if (wasDirty)
351
+ this.#savedVersion = Math.min(version ?? this.#editVersion, this.#editVersion);
352
+ const isDirty = this.#editVersion !== this.#savedVersion;
353
+ if (wasDirty && !isDirty)
328
354
  this.#emitDirty(false);
329
355
  }
330
356
  /**
@@ -451,6 +477,7 @@ export class WorkflowStore {
451
477
  * This sets the initial saved snapshot, clears dirty state, and initializes history.
452
478
  */
453
479
  initialize(workflow) {
480
+ this.#loadGeneration++;
454
481
  this.#configEditKey = null;
455
482
  workflow = normalizeWorkflowMetadata(workflow);
456
483
  this.#workflow = workflow;
@@ -468,6 +495,8 @@ export class WorkflowStore {
468
495
  * for every small change. History is pushed by specific actions or drag handlers.
469
496
  */
470
497
  updateWorkflow(workflow) {
498
+ if (this.#locked)
499
+ return;
471
500
  this.#workflow = this.#withoutRepliesOnRemovedNodes(workflow);
472
501
  this.#bumpVersion();
473
502
  this.#notifyWorkflowChange('metadata');
@@ -478,6 +507,8 @@ export class WorkflowStore {
478
507
  * This bypasses history recording to prevent recursive loops.
479
508
  */
480
509
  restoreFromHistory(workflow) {
510
+ if (this.#locked)
511
+ return;
481
512
  // Undo/redo supersedes any in-progress config edit; drop the session marker
482
513
  // (the history service already closed the transaction).
483
514
  this.#configEditKey = null;
@@ -490,7 +521,7 @@ export class WorkflowStore {
490
521
  }
491
522
  /** Update nodes. */
492
523
  updateNodes(nodes) {
493
- if (!this.#workflow)
524
+ if (!this.#workflow || this.#locked)
494
525
  return;
495
526
  // Check if nodes have actually changed to prevent infinite loops
496
527
  if (!hasWorkflowDataChanged(this.#workflow, nodes, this.#workflow.edges)) {
@@ -511,7 +542,7 @@ export class WorkflowStore {
511
542
  }
512
543
  /** Update edges. */
513
544
  updateEdges(edges) {
514
- if (!this.#workflow)
545
+ if (!this.#workflow || this.#locked)
515
546
  return;
516
547
  // Check if edges have actually changed to prevent infinite loops
517
548
  if (!hasWorkflowDataChanged(this.#workflow, this.#workflow.nodes, edges)) {
@@ -532,7 +563,7 @@ export class WorkflowStore {
532
563
  }
533
564
  /** Update workflow name. */
534
565
  updateName(name) {
535
- if (!this.#workflow)
566
+ if (!this.#workflow || this.#locked)
536
567
  return;
537
568
  this.#workflow = {
538
569
  ...this.#workflow,
@@ -544,7 +575,7 @@ export class WorkflowStore {
544
575
  }
545
576
  /** Add a node. */
546
577
  addNode(node) {
547
- if (!this.#workflow)
578
+ if (!this.#workflow || this.#locked)
548
579
  return;
549
580
  this.#workflow = {
550
581
  ...this.#workflow,
@@ -562,7 +593,7 @@ export class WorkflowStore {
562
593
  * A single undo will restore both the node and its edges.
563
594
  */
564
595
  removeNode(nodeId) {
565
- if (!this.#workflow)
596
+ if (!this.#workflow || this.#locked)
566
597
  return;
567
598
  this.#workflow = this.#withoutRepliesOnRemovedNodes({
568
599
  ...this.#workflow,
@@ -576,7 +607,7 @@ export class WorkflowStore {
576
607
  }
577
608
  /** Add an edge. */
578
609
  addEdge(edge) {
579
- if (!this.#workflow)
610
+ if (!this.#workflow || this.#locked)
580
611
  return;
581
612
  // Never append an edge whose id already exists — SvelteFlow keys edges by id
582
613
  // and a duplicate throws `each_key_duplicate`, taking down the canvas. Guard
@@ -594,7 +625,7 @@ export class WorkflowStore {
594
625
  }
595
626
  /** Remove an edge. */
596
627
  removeEdge(edgeId) {
597
- if (!this.#workflow)
628
+ if (!this.#workflow || this.#locked)
598
629
  return;
599
630
  this.#workflow = {
600
631
  ...this.#workflow,
@@ -611,7 +642,7 @@ export class WorkflowStore {
611
642
  * Used for config changes. Pushes to history for undo support.
612
643
  */
613
644
  updateNode(nodeId, updates) {
614
- if (!this.#workflow)
645
+ if (!this.#workflow || this.#locked)
615
646
  return;
616
647
  this.#workflow = {
617
648
  ...this.#workflow,
@@ -640,10 +671,12 @@ export class WorkflowStore {
640
671
  * @param updates - Partial node updates (typically `{ data }`)
641
672
  * @param opts.fieldKey - The config field being edited; drives per-field
642
673
  * session boundaries. Omit to treat the whole node as one session.
674
+ * @returns `false` when the edit was refused (no workflow, or the editor is
675
+ * locked): whatever mirrors the store must not show it either.
643
676
  */
644
677
  updateNodeConfig(nodeId, updates, opts) {
645
- if (!this.#workflow)
646
- return;
678
+ if (!this.#workflow || this.#locked)
679
+ return false;
647
680
  const sessionKey = `${nodeId}::${opts?.fieldKey ?? ''}`;
648
681
  // Moving to a different field/node closes the previous field's session.
649
682
  if (this.#configEditKey !== null && this.#configEditKey !== sessionKey) {
@@ -665,6 +698,7 @@ export class WorkflowStore {
665
698
  this.#bumpVersion();
666
699
  // Deliberately no #pushToHistory (coalesced into the transaction) and no
667
700
  // #notifyWorkflowChange (deferred to finalize) — that is the whole point.
701
+ return true;
668
702
  }
669
703
  /**
670
704
  * Finalize the in-progress config-edit session, if any.
@@ -701,7 +735,7 @@ export class WorkflowStore {
701
735
  }
702
736
  /** Update workflow metadata. */
703
737
  updateMetadata(metadata) {
704
- if (!this.#workflow)
738
+ if (!this.#workflow || this.#locked)
705
739
  return;
706
740
  this.#workflow = {
707
741
  ...this.#workflow,
@@ -717,7 +751,7 @@ export class WorkflowStore {
717
751
  * Creates a single history entry for the entire batch.
718
752
  */
719
753
  batchUpdate(updates) {
720
- if (!this.#workflow)
754
+ if (!this.#workflow || this.#locked)
721
755
  return;
722
756
  const next = {
723
757
  ...this.#workflow,
@@ -768,7 +802,7 @@ export class WorkflowStore {
768
802
  * records a meaningful description for the undo history.
769
803
  */
770
804
  swapNode(updates) {
771
- if (!this.#workflow)
805
+ if (!this.#workflow || this.#locked)
772
806
  return;
773
807
  // Node swap is the one mutation that actively moves interface bindings —
774
808
  // every other mutation (including delete) leaves them untouched. The chat
@@ -802,6 +836,9 @@ export class WorkflowStore {
802
836
  * @param workflow - Optional workflow to push (uses store state if not provided)
803
837
  */
804
838
  pushHistory(description, workflow) {
839
+ // A locked store refuses every edit, so there is nothing to undo.
840
+ if (this.#locked)
841
+ return;
805
842
  this.#pushToHistory(description, workflow);
806
843
  }
807
844
  }
@@ -467,6 +467,12 @@
467
467
  cursor: not-allowed;
468
468
  }
469
469
 
470
+ /* Read-only (a locked editor): the value can be focused, selected and copied, not changed. */
471
+ .flowdrop-input[readonly] {
472
+ background-color: var(--fd-muted);
473
+ border-color: var(--fd-border-muted);
474
+ }
475
+
470
476
  /* Invalid keeps its error border even on hover. */
471
477
  .flowdrop-input--invalid,
472
478
  .flowdrop-input--invalid:hover:not(:disabled) {
@@ -171,7 +171,16 @@
171
171
  calc(-1 * var(--fd-space-sm, 8px));
172
172
  }
173
173
 
174
- .flowdrop-toaster.flowdrop-toaster .flowdrop-toast-actions button {
174
+ .flowdrop-toaster.flowdrop-toaster
175
+ .flowdrop-toast-actions:not(.flowdrop-toast-actions--multi)
176
+ button {
175
177
  color: var(--fd-accent, var(--fd-primary));
176
178
  font-weight: 500;
177
179
  }
180
+
181
+ /* Several actions: real buttons, so they keep their own colours and sit on the toast's left edge. */
182
+ .flowdrop-toaster.flowdrop-toaster .flowdrop-toast-actions--multi {
183
+ margin-left: 0;
184
+ margin-bottom: 0;
185
+ flex-wrap: wrap;
186
+ }
@@ -10,6 +10,7 @@ import type { Workflow, NodeMetadata, PortConfig, CategoryDefinition, ConfigSche
10
10
  import type { EndpointConfig } from './config/endpoints.js';
11
11
  import type { AuthProvider } from './types/auth.js';
12
12
  import type { EditorPlaygroundConfig } from './types/playground.js';
13
+ import type { EditorLock } from './types/lock.js';
13
14
  import type { FlowDropEventHandlers, FlowDropFeatures } from './types/events.js';
14
15
  import type { FlowDropTheme, FlowDropThemeName } from './types/theme.js';
15
16
  import type { WorkflowFormatAdapter } from './registry/workflowFormatRegistry.js';
@@ -67,6 +68,20 @@ export interface FlowDropMountOptions {
67
68
  * @default 'edit'
68
69
  */
69
70
  mode?: 'edit' | 'readonly' | 'locked';
71
+ /**
72
+ * Open the editor locked: the workflow is read-only, nothing can change it
73
+ * (canvas, config panels, console, shortcuts, undo), Save is disabled (a
74
+ * Save in `navbarActions` stays enabled; it saves nothing and says the editor
75
+ * is locked), and a
76
+ * banner above the canvas lists `reasons` (plain text, optional link) and
77
+ * offers `actions` (buttons). A button press calls `onLockAction(id)`; the
78
+ * host answers it, for example by removing the lock with `app.setLock(null)`.
79
+ * Selecting, panning, zooming and inspecting stay available. Unset, the
80
+ * editor is not locked and nothing changes.
81
+ */
82
+ lock?: EditorLock | null;
83
+ /** Called with the action's `id` when a person presses a button on the lock banner. */
84
+ onLockAction?: (id: string) => void;
70
85
  /**
71
86
  * Start in Test mode (`'test'`): the Playground docked beside the canvas,
72
87
  * the inspector always open. Edit | Test is a second axis beside `mode`: it
@@ -95,6 +110,8 @@ export interface FlowDropMountOptions {
95
110
  pipelineId?: string;
96
111
  /** Custom navbar title */
97
112
  navbarTitle?: string;
113
+ /** Heading level of the navbar title: 1 renders it as the page's H1 (default 2) */
114
+ navbarTitleLevel?: 1 | 2;
98
115
  /** Custom navbar actions */
99
116
  navbarActions?: NavbarAction[];
100
117
  /**
@@ -258,6 +275,11 @@ export interface MountedFlowDropApp {
258
275
  * `app.instance.history.undo()` on the mount that owns the editor.
259
276
  */
260
277
  instance: FlowDropInstance;
278
+ /**
279
+ * Lock the editor (see the `lock` mount option) or, with `null`, unlock it.
280
+ * The same as `app.instance.lock.set(...)`.
281
+ */
282
+ setLock: (lock: EditorLock | null) => void;
261
283
  /**
262
284
  * Destroy the app and clean up resources
263
285
  */
@@ -399,6 +421,17 @@ export declare function mountWorkflowEditor(container: HTMLElement, options?: {
399
421
  builtinEditors?: boolean;
400
422
  /** Customise the canvas context menu — see {@link FlowDropMountOptions.contextMenu}. */
401
423
  contextMenu?: ContextMenuOptions;
424
+ /**
425
+ * Open the editor locked: the workflow is read-only, nothing can change it
426
+ * (canvas, undo), and a banner above the canvas lists `reasons` (plain text,
427
+ * optional link) and offers `actions` (buttons). A button press calls
428
+ * `onLockAction(id)`; the host answers it, for example by removing the lock
429
+ * with `app.setLock(null)`. Selecting, panning, zooming and inspecting stay
430
+ * available. Unset, the editor is not locked and nothing changes.
431
+ */
432
+ lock?: EditorLock | null;
433
+ /** Called with the action's `id` when a person presses a button on the lock banner. */
434
+ onLockAction?: (id: string) => void;
402
435
  }): Promise<MountedFlowDropApp>;
403
436
  /**
404
437
  * Unmount a FlowDrop app