@flowdrop/flowdrop 2.16.0 → 2.17.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 (84) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/README.md +6 -1
  3. package/dist/components/App.svelte +212 -6
  4. package/dist/components/App.svelte.d.ts +2 -0
  5. package/dist/components/CanvasToolbar.svelte +40 -3
  6. package/dist/components/CanvasToolbar.svelte.d.ts +5 -1
  7. package/dist/components/ConnectPortPicker.svelte +8 -4
  8. package/dist/components/DoctorMenu.svelte +208 -126
  9. package/dist/components/ImpactConfirm.svelte +341 -0
  10. package/dist/components/ImpactConfirm.svelte.d.ts +12 -0
  11. package/dist/components/Navbar.svelte +42 -3
  12. package/dist/components/Navbar.svelte.d.ts +4 -0
  13. package/dist/components/NodeSidebar.svelte +36 -15
  14. package/dist/components/NodeSidebar.svelte.d.ts +2 -0
  15. package/dist/components/NodeSwapPicker.svelte +4 -14
  16. package/dist/components/RunBar.svelte +36 -1
  17. package/dist/components/RunBar.svelte.d.ts +5 -0
  18. package/dist/components/RunInputsDialog.svelte +198 -0
  19. package/dist/components/RunInputsDialog.svelte.d.ts +34 -0
  20. package/dist/components/WorkflowCompareDialog.svelte +177 -0
  21. package/dist/components/WorkflowCompareDialog.svelte.d.ts +10 -0
  22. package/dist/components/WorkflowEditor.svelte +88 -6
  23. package/dist/components/WorkflowEditor.svelte.d.ts +6 -0
  24. package/dist/components/WorkflowInterfaceEditor.svelte +14 -4
  25. package/dist/components/WorkflowInterfaceEntryCard.svelte +19 -3
  26. package/dist/components/WorkflowInterfaceEntryCard.svelte.d.ts +2 -0
  27. package/dist/components/nodes/NodeCard.svelte +2 -2
  28. package/dist/components/toast/DismissibleToast.svelte +25 -6
  29. package/dist/components/toast/DismissibleToast.svelte.d.ts +3 -0
  30. package/dist/config/endpoints.d.ts +7 -0
  31. package/dist/config/endpoints.js +2 -1
  32. package/dist/editor/connectCandidates.d.ts +3 -0
  33. package/dist/editor/connectCandidates.js +14 -5
  34. package/dist/editor/index.d.ts +1 -1
  35. package/dist/editor/index.js +1 -1
  36. package/dist/helpers/workflowEditorHelper.d.ts +15 -0
  37. package/dist/helpers/workflowEditorHelper.js +9 -0
  38. package/dist/index.d.ts +1 -0
  39. package/dist/messages/defaults.d.ts +100 -0
  40. package/dist/messages/defaults.js +91 -1
  41. package/dist/services/draftStorage.d.ts +24 -10
  42. package/dist/services/draftStorage.js +60 -35
  43. package/dist/services/globalSave.d.ts +28 -10
  44. package/dist/services/globalSave.js +135 -31
  45. package/dist/services/impactGate.d.ts +34 -0
  46. package/dist/services/impactGate.js +70 -0
  47. package/dist/services/impactService.d.ts +28 -0
  48. package/dist/services/impactService.js +71 -0
  49. package/dist/services/toastQueue.d.ts +9 -0
  50. package/dist/services/toastService.d.ts +4 -0
  51. package/dist/services/toastService.js +9 -3
  52. package/dist/services/workflowLaunchService.js +3 -1
  53. package/dist/settings/index.d.ts +2 -2
  54. package/dist/settings/index.js +1 -1
  55. package/dist/stores/doctorStore.svelte.d.ts +24 -1
  56. package/dist/stores/doctorStore.svelte.js +105 -2
  57. package/dist/stores/instanceContainer.svelte.d.ts +16 -0
  58. package/dist/stores/instanceContainer.svelte.js +22 -2
  59. package/dist/stores/saveConflictStore.svelte.d.ts +62 -0
  60. package/dist/stores/saveConflictStore.svelte.js +169 -0
  61. package/dist/stores/workflowStore.svelte.d.ts +7 -3
  62. package/dist/stores/workflowStore.svelte.js +14 -5
  63. package/dist/styles/toast.css +10 -1
  64. package/dist/svelte-app.d.ts +2 -0
  65. package/dist/svelte-app.js +74 -2
  66. package/dist/types/doctor.d.ts +3 -1
  67. package/dist/types/events.d.ts +20 -0
  68. package/dist/types/events.js +2 -0
  69. package/dist/types/impact.d.ts +25 -0
  70. package/dist/types/impact.js +7 -0
  71. package/dist/types/settings.d.ts +31 -0
  72. package/dist/types/settings.js +132 -0
  73. package/dist/utils/draftRestore.d.ts +27 -0
  74. package/dist/utils/draftRestore.js +36 -0
  75. package/dist/utils/interfaceTags.js +4 -1
  76. package/dist/utils/nodeSearch.d.ts +10 -0
  77. package/dist/utils/nodeSearch.js +37 -0
  78. package/dist/utils/runOffer.d.ts +21 -0
  79. package/dist/utils/runOffer.js +13 -0
  80. package/dist/utils/workflowCompare.d.ts +35 -0
  81. package/dist/utils/workflowCompare.js +84 -0
  82. package/dist/utils/workflowInterface.d.ts +26 -1
  83. package/dist/utils/workflowInterface.js +91 -11
  84. package/package.json +3 -2
@@ -11,11 +11,18 @@
11
11
  * workflow update, which is one undo step; an operation the editor cannot map
12
12
  * aborts the whole remedy before anything changes.
13
13
  *
14
+ * A remedy the server marks `params.automatic` is applied by the editor itself
15
+ * when its problem first appears after the workflow loaded (never for a problem
16
+ * present at load, a destructive remedy or one that needs a choice), once per
17
+ * code per workflow, with an Undo toast. See {@link DoctorStore.setAutoApply}.
18
+ *
14
19
  * @module stores/doctorStore
15
20
  */
16
21
  import { diagnoseDraft, doctorSupported, requestRemedy } from '../services/doctorService.js';
17
22
  import { applyDoctorOperations } from '../utils/doctorOperations.js';
18
23
  import { buildSaveBody } from '../utils/workflowDraft.js';
24
+ import { dismissToast, showInfo } from '../services/toastService.js';
25
+ import { defaultMessages } from '../messages/index.js';
19
26
  /** How long the draft must sit still before it is diagnosed. */
20
27
  export const DOCTOR_IDLE_MS = 800;
21
28
  const RANK = { error: 0, warning: 1, info: 2 };
@@ -38,10 +45,27 @@ export class DoctorStore {
38
45
  #workflow;
39
46
  #api;
40
47
  #idleMs;
41
- constructor(workflow, api, idleMs = DOCTOR_IDLE_MS) {
48
+ #history;
49
+ #messages;
50
+ #undoToast = 0;
51
+ /** The id of the Undo toast now showing, if any. */
52
+ #undoToastId = null;
53
+ #stopWatching = null;
54
+ #autoApply = false;
55
+ /** The problem ids of the first answer after a workflow loaded: those are never applied by themselves. */
56
+ #atLoad = null;
57
+ /** `<workflow id>:<code>` of every remedy applied by itself in this mount, so an undone one stays undone. */
58
+ #autoApplied = new Set();
59
+ constructor(workflow, api, options = {}) {
42
60
  this.#workflow = workflow;
43
61
  this.#api = api;
44
- this.#idleMs = idleMs;
62
+ this.#idleMs = options.idleMs ?? DOCTOR_IDLE_MS;
63
+ this.#history = options.history ?? { undo: () => false, position: () => 0 };
64
+ this.#messages = options.messages ?? (() => defaultMessages);
65
+ }
66
+ /** Whether the editor may apply automatic remedies (the canvas is editable). */
67
+ setAutoApply(enabled) {
68
+ this.#autoApply = enabled;
45
69
  }
46
70
  /** Whether the backend offers a Doctor (the endpoints are configured). */
47
71
  get supported() {
@@ -153,6 +177,7 @@ export class DoctorStore {
153
177
  if (result.status === 'ok') {
154
178
  this.#problems = result.problems;
155
179
  this.#status = 'ready';
180
+ await this.#applyAutomatic(id, result.problems);
156
181
  }
157
182
  else if (result.status === 'unavailable') {
158
183
  // Quiet: no indicator, no more requests for this version.
@@ -167,6 +192,83 @@ export class DoctorStore {
167
192
  this.#requested = null;
168
193
  }
169
194
  }
195
+ /**
196
+ * Apply the first automatic remedy of a problem that appeared after load.
197
+ * One per answer: the check that follows finds the next.
198
+ */
199
+ async #applyAutomatic(workflowId, problems) {
200
+ // A reload of the same id is a new load: its problems are not new.
201
+ const loadKey = `${workflowId}:${this.#workflow.loadGeneration}`;
202
+ if (this.#atLoad?.key !== loadKey) {
203
+ this.#atLoad = { key: loadKey, ids: new Set(problems.map((p) => p.id)) };
204
+ return;
205
+ }
206
+ if (!this.#autoApply)
207
+ return;
208
+ for (const problem of problems) {
209
+ if (this.#atLoad.ids.has(problem.id))
210
+ continue;
211
+ const key = `${workflowId}:${problem.code}`;
212
+ if (this.#autoApplied.has(key))
213
+ continue;
214
+ const remedy = problem.remedies.find((r) => r.params?.automatic === true && !r.destructive && !r.params.choices);
215
+ if (!remedy)
216
+ continue;
217
+ this.#autoApplied.add(key);
218
+ if (await this.applyRemedy(problem, remedy))
219
+ this.#offerUndo(remedy.label);
220
+ return;
221
+ }
222
+ }
223
+ /**
224
+ * Tell the person what was applied by itself. Undo works only while the
225
+ * remedy is the latest history step; once the history moves on the toast goes.
226
+ */
227
+ #offerUndo(label) {
228
+ this.#clearUndo();
229
+ const messages = this.#messages().doctor;
230
+ const id = `flowdrop:doctor-auto-${++this.#undoToast}`;
231
+ const at = this.#history.position();
232
+ let stop = null;
233
+ let done = false;
234
+ const finish = () => {
235
+ if (done)
236
+ return;
237
+ done = true;
238
+ dismissToast(id);
239
+ // The effect may run before `stop` is assigned.
240
+ queueMicrotask(() => stop?.());
241
+ };
242
+ showInfo({
243
+ title: messages.autoDone({ label }),
244
+ action: {
245
+ label: messages.undo,
246
+ onClick: () => {
247
+ if (this.#history.position() === at)
248
+ this.#history.undo();
249
+ finish();
250
+ }
251
+ }
252
+ }, { id });
253
+ stop = $effect.root(() => {
254
+ $effect(() => {
255
+ if (this.#history.position() !== at)
256
+ finish();
257
+ });
258
+ });
259
+ if (done)
260
+ queueMicrotask(() => stop?.());
261
+ this.#stopWatching = stop;
262
+ this.#undoToastId = done ? null : id;
263
+ }
264
+ /** Stop watching the history and take down the Undo toast, if one is up. */
265
+ #clearUndo() {
266
+ this.#stopWatching?.();
267
+ this.#stopWatching = null;
268
+ if (this.#undoToastId)
269
+ dismissToast(this.#undoToastId);
270
+ this.#undoToastId = null;
271
+ }
170
272
  /**
171
273
  * Apply `remedy` for `problem` as one undoable edit. Returns whether the
172
274
  * workflow changed; otherwise {@link notice} says why.
@@ -240,5 +342,6 @@ export class DoctorStore {
240
342
  this.#timer = null;
241
343
  this.#token++;
242
344
  this.#focus = null;
345
+ this.#clearUndo();
243
346
  }
244
347
  }
@@ -13,6 +13,7 @@
13
13
  *
14
14
  * @module stores/instanceContainer
15
15
  */
16
+ import { type Messages } from '../messages/index.js';
16
17
  import type { NodeMetadata } from '../types/index.js';
17
18
  import type { HostHooks } from '../webmcp/types.js';
18
19
  import type { ApprovalGate } from '../webmcp/gate.js';
@@ -33,6 +34,7 @@ import { ConnectDragStore } from './connectDragStore.svelte.js';
33
34
  import { LoopbackLanesStore } from './loopbackLanesStore.svelte.js';
34
35
  import { EditedNodesStore } from './editedNodesStore.svelte.js';
35
36
  import { DoctorStore } from './doctorStore.svelte.js';
37
+ import { SaveConflictStore } from './saveConflictStore.svelte.js';
36
38
  import { PlaygroundService } from '../services/playgroundService.js';
37
39
  import { ApiContext } from './apiContext.js';
38
40
  import { PortCompatibilityChecker } from '../utils/connections.js';
@@ -155,6 +157,11 @@ export interface FlowDropInstance {
155
157
  * clicking Save does.
156
158
  */
157
159
  readonly host: HostHooksStore;
160
+ /**
161
+ * A save the server refused because someone else saved first: the toast's
162
+ * Keep mine / Load theirs / Compare choices and the compare dialog's state.
163
+ */
164
+ readonly saveConflict: SaveConflictStore;
158
165
  /**
159
166
  * The approval gate every agent surface on this editor asks — the WebMCP
160
167
  * registration and the chat panel's tool loop. Whichever surface comes
@@ -177,6 +184,15 @@ export interface FlowDropInstance {
177
184
  * a canvas they fall back to computed geometry.
178
185
  */
179
186
  measureNode: ((nodeId: string) => MeasuredCard | undefined) | null;
187
+ /**
188
+ * The messages this editor shows, merged with the host's overrides. `App`
189
+ * registers its live tree; until then (and on a page with no editor mounted)
190
+ * these are the defaults. Code that runs outside the component tree reads
191
+ * strings from here instead of `defaultMessages`.
192
+ */
193
+ readonly messages: () => Messages;
194
+ /** Register the getter `messages()` reads. `App` does this while it is mounted. */
195
+ setMessages(get: () => Messages): void;
180
196
  /**
181
197
  * Run `fn` when this instance is destroyed. Returns an unsubscribe; calling
182
198
  * it before `destroy()` means `fn` never runs. Adapters that bind to an
@@ -13,6 +13,7 @@
13
13
  *
14
14
  * @module stores/instanceContainer
15
15
  */
16
+ import { defaultMessages } from '../messages/index.js';
16
17
  import { HistoryService, historyService } from '../services/historyService.js';
17
18
  import { WorkflowStore } from './workflowStore.svelte.js';
18
19
  import { HistoryStore } from './historyStore.svelte.js';
@@ -30,6 +31,7 @@ import { ConnectDragStore } from './connectDragStore.svelte.js';
30
31
  import { LoopbackLanesStore } from './loopbackLanesStore.svelte.js';
31
32
  import { EditedNodesStore } from './editedNodesStore.svelte.js';
32
33
  import { DoctorStore } from './doctorStore.svelte.js';
34
+ import { SaveConflictStore } from './saveConflictStore.svelte.js';
33
35
  import { PlaygroundService, playgroundService } from '../services/playgroundService.js';
34
36
  import { ApiContext } from './apiContext.js';
35
37
  import { PortCompatibilityChecker } from '../utils/connections.js';
@@ -115,7 +117,13 @@ export function createFlowDropInstance(options = {}) {
115
117
  const playground = new PlaygroundStore();
116
118
  const instancePlaygroundService = isDefault ? playgroundService : new PlaygroundService();
117
119
  const api = new ApiContext();
118
- const doctor = new DoctorStore(workflow, api);
120
+ const doctor = new DoctorStore(workflow, api, {
121
+ history: {
122
+ undo: () => historyBindings.undo(),
123
+ position: () => historyBindings.state.currentIndex
124
+ },
125
+ messages: () => readMessages()
126
+ });
119
127
  const runs = new RunController({
120
128
  playground,
121
129
  service: instancePlaygroundService,
@@ -143,7 +151,8 @@ export function createFlowDropInstance(options = {}) {
143
151
  instancePlaygroundService.stopPolling();
144
152
  }
145
153
  ];
146
- return {
154
+ let readMessages = () => defaultMessages;
155
+ const instance = {
147
156
  id,
148
157
  storagePrefix,
149
158
  isDefault,
@@ -176,6 +185,12 @@ export function createFlowDropInstance(options = {}) {
176
185
  doctor,
177
186
  nodeTypes: new NodeTypesStore(),
178
187
  host: new HostHooksStore(),
188
+ saveConflict: new SaveConflictStore({
189
+ workflow,
190
+ loadWorkflow: (id) => api.client.loadWorkflow(id),
191
+ schedule: () => doctor.schedule(),
192
+ messages: () => readMessages()
193
+ }),
179
194
  approvalGate: null,
180
195
  skinScope: null,
181
196
  get measureNode() {
@@ -184,6 +199,10 @@ export function createFlowDropInstance(options = {}) {
184
199
  set measureNode(fn) {
185
200
  measureNodeFn = fn;
186
201
  },
202
+ messages: () => readMessages(),
203
+ setMessages(get) {
204
+ readMessages = get;
205
+ },
187
206
  onDestroy(fn) {
188
207
  cleanups.push(fn);
189
208
  return () => {
@@ -198,6 +217,7 @@ export function createFlowDropInstance(options = {}) {
198
217
  }
199
218
  }
200
219
  };
220
+ return instance;
201
221
  }
202
222
  // =========================================================================
203
223
  // Default instance (backward compatibility)
@@ -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
+ }
@@ -169,6 +169,8 @@ export declare class WorkflowStore {
169
169
  * 5. If not: the save didn't persist the version you submitted — reset from backend response
170
170
  */
171
171
  get editVersion(): number;
172
+ /** Counts the `initialize()` calls: a reload of the same id is a new load. */
173
+ get loadGeneration(): number;
172
174
  /** Whether history recording is enabled. */
173
175
  get historyEnabled(): boolean;
174
176
  /** Enable or disable history recording (e.g. for bulk operations). */
@@ -180,10 +182,12 @@ export declare class WorkflowStore {
180
182
  /**
181
183
  * Mark the current workflow state as saved.
182
184
  *
183
- * Captures the current edit version so isDirty becomes false.
184
- * Call this after a successful backend save.
185
+ * Captures the edit version so isDirty becomes false. Call this after a
186
+ * successful backend save. Pass the `editVersion` read when the saved
187
+ * snapshot was taken: an edit made while the save was in flight is then not
188
+ * marked saved. Without it, the current version is taken.
185
189
  */
186
- markAsSaved(): void;
190
+ markAsSaved(version?: number): void;
187
191
  /**
188
192
  * Take the server's word on the workflow's revision and permissions after a
189
193
  * save (the load path sets them with the payload). Bookkeeping only: no history entry, no dirty flag, no
@@ -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.
@@ -296,6 +297,10 @@ export class WorkflowStore {
296
297
  get editVersion() {
297
298
  return this.#editVersion;
298
299
  }
300
+ /** Counts the `initialize()` calls: a reload of the same id is a new load. */
301
+ get loadGeneration() {
302
+ return this.#loadGeneration;
303
+ }
299
304
  /** Whether history recording is enabled. */
300
305
  get historyEnabled() {
301
306
  return this.#historyEnabled;
@@ -318,13 +323,16 @@ export class WorkflowStore {
318
323
  /**
319
324
  * Mark the current workflow state as saved.
320
325
  *
321
- * Captures the current edit version so isDirty becomes false.
322
- * Call this after a successful backend save.
326
+ * Captures the edit version so isDirty becomes false. Call this after a
327
+ * successful backend save. Pass the `editVersion` read when the saved
328
+ * snapshot was taken: an edit made while the save was in flight is then not
329
+ * marked saved. Without it, the current version is taken.
323
330
  */
324
- markAsSaved() {
331
+ markAsSaved(version) {
325
332
  const wasDirty = this.#editVersion !== this.#savedVersion;
326
- this.#savedVersion = this.#editVersion;
327
- if (wasDirty)
333
+ this.#savedVersion = Math.min(version ?? this.#editVersion, this.#editVersion);
334
+ const isDirty = this.#editVersion !== this.#savedVersion;
335
+ if (wasDirty && !isDirty)
328
336
  this.#emitDirty(false);
329
337
  }
330
338
  /**
@@ -451,6 +459,7 @@ export class WorkflowStore {
451
459
  * This sets the initial saved snapshot, clears dirty state, and initializes history.
452
460
  */
453
461
  initialize(workflow) {
462
+ this.#loadGeneration++;
454
463
  this.#configEditKey = null;
455
464
  workflow = normalizeWorkflowMetadata(workflow);
456
465
  this.#workflow = workflow;
@@ -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
+ }
@@ -95,6 +95,8 @@ export interface FlowDropMountOptions {
95
95
  pipelineId?: string;
96
96
  /** Custom navbar title */
97
97
  navbarTitle?: string;
98
+ /** Heading level of the navbar title: 1 renders it as the page's H1 (default 2) */
99
+ navbarTitleLevel?: 1 | 2;
98
100
  /** Custom navbar actions */
99
101
  navbarActions?: NavbarAction[];
100
102
  /**