@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.
- package/CHANGELOG.md +80 -0
- package/README.md +6 -1
- package/dist/components/App.svelte +212 -6
- package/dist/components/App.svelte.d.ts +2 -0
- package/dist/components/CanvasToolbar.svelte +40 -3
- package/dist/components/CanvasToolbar.svelte.d.ts +5 -1
- package/dist/components/ConnectPortPicker.svelte +8 -4
- package/dist/components/DoctorMenu.svelte +208 -126
- package/dist/components/ImpactConfirm.svelte +341 -0
- package/dist/components/ImpactConfirm.svelte.d.ts +12 -0
- package/dist/components/Navbar.svelte +42 -3
- package/dist/components/Navbar.svelte.d.ts +4 -0
- package/dist/components/NodeSidebar.svelte +36 -15
- package/dist/components/NodeSidebar.svelte.d.ts +2 -0
- package/dist/components/NodeSwapPicker.svelte +4 -14
- package/dist/components/RunBar.svelte +36 -1
- package/dist/components/RunBar.svelte.d.ts +5 -0
- package/dist/components/RunInputsDialog.svelte +198 -0
- package/dist/components/RunInputsDialog.svelte.d.ts +34 -0
- package/dist/components/WorkflowCompareDialog.svelte +177 -0
- package/dist/components/WorkflowCompareDialog.svelte.d.ts +10 -0
- package/dist/components/WorkflowEditor.svelte +88 -6
- package/dist/components/WorkflowEditor.svelte.d.ts +6 -0
- package/dist/components/WorkflowInterfaceEditor.svelte +14 -4
- package/dist/components/WorkflowInterfaceEntryCard.svelte +19 -3
- package/dist/components/WorkflowInterfaceEntryCard.svelte.d.ts +2 -0
- package/dist/components/nodes/NodeCard.svelte +2 -2
- package/dist/components/toast/DismissibleToast.svelte +25 -6
- package/dist/components/toast/DismissibleToast.svelte.d.ts +3 -0
- package/dist/config/endpoints.d.ts +7 -0
- package/dist/config/endpoints.js +2 -1
- package/dist/editor/connectCandidates.d.ts +3 -0
- package/dist/editor/connectCandidates.js +14 -5
- package/dist/editor/index.d.ts +1 -1
- package/dist/editor/index.js +1 -1
- package/dist/helpers/workflowEditorHelper.d.ts +15 -0
- package/dist/helpers/workflowEditorHelper.js +9 -0
- package/dist/index.d.ts +1 -0
- package/dist/messages/defaults.d.ts +100 -0
- package/dist/messages/defaults.js +91 -1
- package/dist/services/draftStorage.d.ts +24 -10
- package/dist/services/draftStorage.js +60 -35
- package/dist/services/globalSave.d.ts +28 -10
- package/dist/services/globalSave.js +135 -31
- package/dist/services/impactGate.d.ts +34 -0
- package/dist/services/impactGate.js +70 -0
- package/dist/services/impactService.d.ts +28 -0
- package/dist/services/impactService.js +71 -0
- package/dist/services/toastQueue.d.ts +9 -0
- package/dist/services/toastService.d.ts +4 -0
- package/dist/services/toastService.js +9 -3
- package/dist/services/workflowLaunchService.js +3 -1
- package/dist/settings/index.d.ts +2 -2
- package/dist/settings/index.js +1 -1
- package/dist/stores/doctorStore.svelte.d.ts +24 -1
- package/dist/stores/doctorStore.svelte.js +105 -2
- package/dist/stores/instanceContainer.svelte.d.ts +16 -0
- package/dist/stores/instanceContainer.svelte.js +22 -2
- package/dist/stores/saveConflictStore.svelte.d.ts +62 -0
- package/dist/stores/saveConflictStore.svelte.js +169 -0
- package/dist/stores/workflowStore.svelte.d.ts +7 -3
- package/dist/stores/workflowStore.svelte.js +14 -5
- package/dist/styles/toast.css +10 -1
- package/dist/svelte-app.d.ts +2 -0
- package/dist/svelte-app.js +74 -2
- package/dist/types/doctor.d.ts +3 -1
- package/dist/types/events.d.ts +20 -0
- package/dist/types/events.js +2 -0
- package/dist/types/impact.d.ts +25 -0
- package/dist/types/impact.js +7 -0
- package/dist/types/settings.d.ts +31 -0
- package/dist/types/settings.js +132 -0
- package/dist/utils/draftRestore.d.ts +27 -0
- package/dist/utils/draftRestore.js +36 -0
- package/dist/utils/interfaceTags.js +4 -1
- package/dist/utils/nodeSearch.d.ts +10 -0
- package/dist/utils/nodeSearch.js +37 -0
- package/dist/utils/runOffer.d.ts +21 -0
- package/dist/utils/runOffer.js +13 -0
- package/dist/utils/workflowCompare.d.ts +35 -0
- package/dist/utils/workflowCompare.js +84 -0
- package/dist/utils/workflowInterface.d.ts +26 -1
- package/dist/utils/workflowInterface.js +91 -11
- package/package.json +3 -2
|
@@ -226,6 +226,7 @@ export const defaultMessages = {
|
|
|
226
226
|
tagline: 'Visual Workflow Manager',
|
|
227
227
|
breadcrumbAriaLabel: 'Breadcrumb',
|
|
228
228
|
connected: 'Connected',
|
|
229
|
+
unsavedChanges: 'Unsaved changes',
|
|
229
230
|
settingsTitle: 'Settings',
|
|
230
231
|
settingsAriaLabel: 'Open settings',
|
|
231
232
|
// The gear menu: an Appearance switch, then the full settings dialog.
|
|
@@ -375,6 +376,24 @@ export const defaultMessages = {
|
|
|
375
376
|
optionCurrent: 'current',
|
|
376
377
|
optionTaken: 'already taken'
|
|
377
378
|
},
|
|
379
|
+
// The Run button in the canvas toolbar (Edit mode).
|
|
380
|
+
runButton: {
|
|
381
|
+
label: 'Run',
|
|
382
|
+
title: 'Run this workflow',
|
|
383
|
+
// Toast when the run could not start and the server gave no message.
|
|
384
|
+
failed: 'The run could not be started.',
|
|
385
|
+
// Info toast when the run was accepted but waits for the site's queue.
|
|
386
|
+
queued: "The run is queued. It starts when the site's queue runs (cron)."
|
|
387
|
+
},
|
|
388
|
+
// The form Run opens for a workflow that has inputs.
|
|
389
|
+
runInputsDialog: {
|
|
390
|
+
title: ({ name }) => `Run ${name}`,
|
|
391
|
+
close: 'Close the run form',
|
|
392
|
+
// Shown under the Run button when required inputs are empty; names the inputs.
|
|
393
|
+
missing: ({ names }) => `Fill in the required inputs first: ${names}.`,
|
|
394
|
+
// Shown when an input holds text that is not the JSON its type needs.
|
|
395
|
+
invalid: ({ names }) => `These inputs are not valid: ${names}.`
|
|
396
|
+
},
|
|
378
397
|
// The run bar on the Edit canvas: shown only while a run exists.
|
|
379
398
|
runBar: {
|
|
380
399
|
label: 'Run',
|
|
@@ -387,6 +406,8 @@ export const defaultMessages = {
|
|
|
387
406
|
stopLabel: 'Stop the run',
|
|
388
407
|
open: 'Open',
|
|
389
408
|
openLabel: 'Open the run in Test mode',
|
|
409
|
+
openRun: 'Open run',
|
|
410
|
+
openRunTitle: 'Open the run page',
|
|
390
411
|
askAssistant: 'Ask the Assistant',
|
|
391
412
|
askAssistantLabel: 'Ask the Assistant about this run',
|
|
392
413
|
// Read out politely when the status changes.
|
|
@@ -402,6 +423,10 @@ export const defaultMessages = {
|
|
|
402
423
|
doctor: {
|
|
403
424
|
trigger: ({ count }) => (count === 1 ? '1 problem' : `${count} problems`),
|
|
404
425
|
triggerTitle: 'Problems found in this workflow',
|
|
426
|
+
checking: 'Checking...',
|
|
427
|
+
unavailable: 'Check unavailable',
|
|
428
|
+
unavailableTitle: 'The problem check could not run. It tries again after your next change.',
|
|
429
|
+
retry: 'Retry',
|
|
405
430
|
title: 'Problems',
|
|
406
431
|
listLabel: 'Problems in this workflow',
|
|
407
432
|
severity: { error: 'Error', warning: 'Warning', info: 'Note' },
|
|
@@ -425,7 +450,10 @@ export const defaultMessages = {
|
|
|
425
450
|
empty: 'That fix would change nothing.',
|
|
426
451
|
failed: ({ message }) => `The fix could not be applied. ${message}`
|
|
427
452
|
},
|
|
428
|
-
dismissNotice: 'Dismiss'
|
|
453
|
+
dismissNotice: 'Dismiss',
|
|
454
|
+
// A remedy the editor applied by itself: the toast names what it did.
|
|
455
|
+
autoDone: ({ label }) => `Done: ${label}`,
|
|
456
|
+
undo: 'Undo'
|
|
429
457
|
},
|
|
430
458
|
// The Runs list in Test mode: a popover from the canvas toolbar.
|
|
431
459
|
runsList: {
|
|
@@ -504,9 +532,13 @@ export const defaultMessages = {
|
|
|
504
532
|
layout: {
|
|
505
533
|
// Sidebar/main-region landmarks.
|
|
506
534
|
componentsSidebar: 'Components sidebar',
|
|
535
|
+
// Palette item: click or Enter adds the node.
|
|
536
|
+
addNode: ({ name }) => `Add ${name}`,
|
|
507
537
|
// Edit mode's left slot: Nodes | Assistant.
|
|
508
538
|
nodesTab: 'Nodes',
|
|
509
539
|
workflowCanvas: 'Workflow canvas',
|
|
540
|
+
// The skip link at the start of the editor.
|
|
541
|
+
skipToCanvas: 'Skip to the canvas',
|
|
510
542
|
executionLogs: 'Execution logs sidebar',
|
|
511
543
|
settingsCategories: 'Settings categories',
|
|
512
544
|
zoomLevelsTitle: 'Zoom levels',
|
|
@@ -1024,6 +1056,8 @@ export const defaultMessages = {
|
|
|
1024
1056
|
descriptionLabel: 'Description',
|
|
1025
1057
|
dataTypeLabel: 'Data type',
|
|
1026
1058
|
dataTypePlaceholder: 'Select a data type…',
|
|
1059
|
+
mixedInputHint: 'Callers can send anything. Pick a type so forms can ask for it properly.',
|
|
1060
|
+
noTitle: 'No title',
|
|
1027
1061
|
namePlaceholder: 'Defaults to ID',
|
|
1028
1062
|
typeMismatchInline: ({ portType }) => `Doesn't match the bound port's type (${portType}).`,
|
|
1029
1063
|
useMatchPortType: 'Use port type',
|
|
@@ -1136,6 +1170,22 @@ export const defaultMessages = {
|
|
|
1136
1170
|
replyPortMissing: ({ reply }) => `The reply "${reply}" is on an output the node no longer has.`
|
|
1137
1171
|
}
|
|
1138
1172
|
},
|
|
1173
|
+
// The confirm dialog the editor shows before a save that breaks or changes what uses the workflow.
|
|
1174
|
+
impact: {
|
|
1175
|
+
title: 'Before you save',
|
|
1176
|
+
breaks: 'This change breaks',
|
|
1177
|
+
changes: 'This change also does',
|
|
1178
|
+
info: 'Also good to know',
|
|
1179
|
+
// The severity as a word on each row, so it never rests on colour alone.
|
|
1180
|
+
severity: {
|
|
1181
|
+
breaks: 'Breaks',
|
|
1182
|
+
changes: 'Changes',
|
|
1183
|
+
info: 'Info'
|
|
1184
|
+
},
|
|
1185
|
+
failed: ({ message }) => `The check of what uses this workflow failed: ${message}`,
|
|
1186
|
+
cancel: 'Cancel',
|
|
1187
|
+
save: 'Save anyway'
|
|
1188
|
+
},
|
|
1139
1189
|
// The confirm dialog the WebMCP adapter shows before a browser agent's change runs.
|
|
1140
1190
|
webmcp: {
|
|
1141
1191
|
// The desktop bridge: a button beside the canvas zoom controls and its popover, for a
|
|
@@ -1187,6 +1237,14 @@ export const defaultMessages = {
|
|
|
1187
1237
|
failed: 'Failed',
|
|
1188
1238
|
skipped: 'Skipped'
|
|
1189
1239
|
},
|
|
1240
|
+
// The offer to bring back unsaved changes found in browser storage.
|
|
1241
|
+
drafts: {
|
|
1242
|
+
// "Unsaved changes from 14:02 were found."
|
|
1243
|
+
found: ({ time }) => `Unsaved changes from ${time} were found.`,
|
|
1244
|
+
savedSince: 'The workflow was saved after this draft. Restoring puts your draft over that version.',
|
|
1245
|
+
restore: 'Restore',
|
|
1246
|
+
discard: 'Discard'
|
|
1247
|
+
},
|
|
1190
1248
|
composer: {
|
|
1191
1249
|
placeholder: 'Type a message',
|
|
1192
1250
|
send: 'Send',
|
|
@@ -1212,5 +1270,37 @@ export const defaultMessages = {
|
|
|
1212
1270
|
hintMove: 'move',
|
|
1213
1271
|
hintChoose: 'choose',
|
|
1214
1272
|
hintClose: 'close'
|
|
1273
|
+
},
|
|
1274
|
+
// Autosave could not save on its own.
|
|
1275
|
+
autoSave: {
|
|
1276
|
+
waiting: 'Autosave is waiting: this change affects what uses the workflow. Press Save to review it.'
|
|
1277
|
+
},
|
|
1278
|
+
// The dialog that compares your workflow with the saved version.
|
|
1279
|
+
compare: {
|
|
1280
|
+
title: 'Your version and the saved version',
|
|
1281
|
+
onlyMine: 'Only in yours',
|
|
1282
|
+
onlyTheirs: 'Only in the saved version',
|
|
1283
|
+
changedInBoth: 'Different in the two versions',
|
|
1284
|
+
none: 'No differences in the workflow itself',
|
|
1285
|
+
keepMine: 'Keep mine',
|
|
1286
|
+
loadTheirs: 'Load saved version',
|
|
1287
|
+
cancel: 'Cancel',
|
|
1288
|
+
stepOnly: ({ label }) => `Step "${label}"`,
|
|
1289
|
+
stepSettings: ({ label }) => `Step "${label}": settings changed`,
|
|
1290
|
+
stepLabel: ({ label }) => `Step "${label}": name changed`,
|
|
1291
|
+
stepPosition: ({ label }) => `Step "${label}": moved`,
|
|
1292
|
+
wiresOnly: ({ n }) => (n === 1 ? '1 wire' : `${n} wires`),
|
|
1293
|
+
name: ({ mine, theirs }) => `Workflow name: "${mine}" and "${theirs}"`,
|
|
1294
|
+
description: 'Workflow description changed',
|
|
1295
|
+
interface: 'Workflow interface changed',
|
|
1296
|
+
chat: 'Chat settings changed'
|
|
1297
|
+
},
|
|
1298
|
+
// The toast shown when a save is refused because someone saved first. Its
|
|
1299
|
+
// Keep mine / Load saved version labels are the compare dialog's.
|
|
1300
|
+
saveConflict: {
|
|
1301
|
+
title: 'Someone saved this workflow after you opened it.',
|
|
1302
|
+
body: 'Your changes are not saved yet.',
|
|
1303
|
+
compare: 'Compare',
|
|
1304
|
+
noRevision: 'Could not read the saved version, so your changes were not sent.'
|
|
1215
1305
|
}
|
|
1216
1306
|
};
|
|
@@ -87,6 +87,8 @@ interface DraftMetadata {
|
|
|
87
87
|
workflowId?: string;
|
|
88
88
|
/** Workflow name */
|
|
89
89
|
workflowName?: string;
|
|
90
|
+
/** Revision of the workflow the draft started from (absent in older drafts) */
|
|
91
|
+
baseRevision?: string;
|
|
90
92
|
}
|
|
91
93
|
/**
|
|
92
94
|
* Complete draft data stored in draft storage
|
|
@@ -189,6 +191,16 @@ export declare function getDraftMetadata(storageKey: string, storage?: DraftStor
|
|
|
189
191
|
* @returns The number of entries removed.
|
|
190
192
|
*/
|
|
191
193
|
export declare function clearAllDrafts(extraKeys?: readonly string[], storage?: DraftStorageAdapter): number;
|
|
194
|
+
/**
|
|
195
|
+
* Fingerprint of everything a draft preserves, for change detection.
|
|
196
|
+
*
|
|
197
|
+
* Covers name, description, nodes, edges, the workflow interface and the
|
|
198
|
+
* Playground settings. Not cryptographic, just a stable string to compare.
|
|
199
|
+
*
|
|
200
|
+
* @param workflow - The workflow to fingerprint
|
|
201
|
+
* @returns A string that changes whenever a draft-relevant part changes
|
|
202
|
+
*/
|
|
203
|
+
export declare function draftFingerprint(workflow: Workflow): string;
|
|
192
204
|
/**
|
|
193
205
|
* Draft auto-save manager
|
|
194
206
|
*
|
|
@@ -221,6 +233,8 @@ export declare class DraftAutoSaveManager {
|
|
|
221
233
|
private storage;
|
|
222
234
|
/** Last saved workflow hash (for change detection) */
|
|
223
235
|
private lastSavedHash;
|
|
236
|
+
/** Open draft offers: while any is open, a clean tick keeps the stored draft. */
|
|
237
|
+
private holds;
|
|
224
238
|
/**
|
|
225
239
|
* Create a new DraftAutoSaveManager
|
|
226
240
|
*
|
|
@@ -247,6 +261,14 @@ export declare class DraftAutoSaveManager {
|
|
|
247
261
|
* Stop auto-save interval
|
|
248
262
|
*/
|
|
249
263
|
stop(): void;
|
|
264
|
+
/**
|
|
265
|
+
* Keep the stored draft while an offer to restore it is open. A tick that
|
|
266
|
+
* finds the workflow clean would otherwise delete it behind the offer.
|
|
267
|
+
*
|
|
268
|
+
* @returns a function that ends the hold; Restore and Discard call it, and
|
|
269
|
+
* `stop()` ends every hold
|
|
270
|
+
*/
|
|
271
|
+
holdDraft(): () => void;
|
|
250
272
|
/**
|
|
251
273
|
* Save draft if there are unsaved changes
|
|
252
274
|
*
|
|
@@ -268,7 +290,8 @@ export declare class DraftAutoSaveManager {
|
|
|
268
290
|
/**
|
|
269
291
|
* Mark the current state as saved
|
|
270
292
|
*
|
|
271
|
-
* Updates the hash so the next saveIfDirty won't save unless there are new
|
|
293
|
+
* Updates the hash so the next saveIfDirty won't save unless there are new
|
|
294
|
+
* changes, and removes the stored draft (a saved workflow has none).
|
|
272
295
|
*/
|
|
273
296
|
markAsSaved(): void;
|
|
274
297
|
/**
|
|
@@ -279,15 +302,6 @@ export declare class DraftAutoSaveManager {
|
|
|
279
302
|
* @param newKey - The new storage key
|
|
280
303
|
*/
|
|
281
304
|
updateStorageKey(newKey: string): void;
|
|
282
|
-
/**
|
|
283
|
-
* Simple hash function for change detection
|
|
284
|
-
*
|
|
285
|
-
* Not cryptographically secure, just for detecting changes.
|
|
286
|
-
*
|
|
287
|
-
* @param workflow - The workflow to hash
|
|
288
|
-
* @returns A simple hash string
|
|
289
|
-
*/
|
|
290
|
-
private hashWorkflow;
|
|
291
305
|
/**
|
|
292
306
|
* Check if auto-save is currently running
|
|
293
307
|
*/
|
|
@@ -168,7 +168,10 @@ export function saveDraft(workflow, storageKey, storage = activeAdapter) {
|
|
|
168
168
|
metadata: {
|
|
169
169
|
savedAt: new Date().toISOString(),
|
|
170
170
|
workflowId: workflow.id,
|
|
171
|
-
workflowName: workflow.name
|
|
171
|
+
workflowName: workflow.name,
|
|
172
|
+
...(workflow.revision !== undefined && workflow.revision !== null
|
|
173
|
+
? { baseRevision: String(workflow.revision) }
|
|
174
|
+
: {})
|
|
172
175
|
}
|
|
173
176
|
};
|
|
174
177
|
storage.setItem(storageKey, JSON.stringify(draft));
|
|
@@ -284,6 +287,35 @@ export function clearAllDrafts(extraKeys = [], storage = activeAdapter) {
|
|
|
284
287
|
return 0;
|
|
285
288
|
}
|
|
286
289
|
}
|
|
290
|
+
/**
|
|
291
|
+
* Fingerprint of everything a draft preserves, for change detection.
|
|
292
|
+
*
|
|
293
|
+
* Covers name, description, nodes, edges, the workflow interface and the
|
|
294
|
+
* Playground settings. Not cryptographic, just a stable string to compare.
|
|
295
|
+
*
|
|
296
|
+
* @param workflow - The workflow to fingerprint
|
|
297
|
+
* @returns A string that changes whenever a draft-relevant part changes
|
|
298
|
+
*/
|
|
299
|
+
export function draftFingerprint(workflow) {
|
|
300
|
+
return JSON.stringify({
|
|
301
|
+
name: workflow.name,
|
|
302
|
+
description: workflow.description,
|
|
303
|
+
nodes: workflow.nodes.map((n) => ({
|
|
304
|
+
id: n.id,
|
|
305
|
+
position: n.position,
|
|
306
|
+
data: n.data
|
|
307
|
+
})),
|
|
308
|
+
edges: workflow.edges.map((e) => ({
|
|
309
|
+
id: e.id,
|
|
310
|
+
source: e.source,
|
|
311
|
+
target: e.target,
|
|
312
|
+
sourceHandle: e.sourceHandle,
|
|
313
|
+
targetHandle: e.targetHandle
|
|
314
|
+
})),
|
|
315
|
+
interface: workflow.interface,
|
|
316
|
+
playground: workflow.playground
|
|
317
|
+
});
|
|
318
|
+
}
|
|
287
319
|
/**
|
|
288
320
|
* Draft auto-save manager
|
|
289
321
|
*
|
|
@@ -316,6 +348,8 @@ export class DraftAutoSaveManager {
|
|
|
316
348
|
storage;
|
|
317
349
|
/** Last saved workflow hash (for change detection) */
|
|
318
350
|
lastSavedHash = null;
|
|
351
|
+
/** Open draft offers: while any is open, a clean tick keeps the stored draft. */
|
|
352
|
+
holds = new Set();
|
|
319
353
|
/**
|
|
320
354
|
* Create a new DraftAutoSaveManager
|
|
321
355
|
*
|
|
@@ -351,6 +385,21 @@ export class DraftAutoSaveManager {
|
|
|
351
385
|
clearInterval(this.intervalId);
|
|
352
386
|
this.intervalId = null;
|
|
353
387
|
}
|
|
388
|
+
this.holds.clear();
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Keep the stored draft while an offer to restore it is open. A tick that
|
|
392
|
+
* finds the workflow clean would otherwise delete it behind the offer.
|
|
393
|
+
*
|
|
394
|
+
* @returns a function that ends the hold; Restore and Discard call it, and
|
|
395
|
+
* `stop()` ends every hold
|
|
396
|
+
*/
|
|
397
|
+
holdDraft() {
|
|
398
|
+
const hold = Symbol('draft-offer');
|
|
399
|
+
this.holds.add(hold);
|
|
400
|
+
return () => {
|
|
401
|
+
this.holds.delete(hold);
|
|
402
|
+
};
|
|
354
403
|
}
|
|
355
404
|
/**
|
|
356
405
|
* Save draft if there are unsaved changes
|
|
@@ -365,12 +414,15 @@ export class DraftAutoSaveManager {
|
|
|
365
414
|
if (!workflow) {
|
|
366
415
|
return false;
|
|
367
416
|
}
|
|
368
|
-
//
|
|
417
|
+
// A saved workflow has no draft
|
|
369
418
|
if (!this.isDirty()) {
|
|
419
|
+
if (this.holds.size === 0 && hasDraft(this.storageKey, this.storage)) {
|
|
420
|
+
deleteDraft(this.storageKey, this.storage);
|
|
421
|
+
}
|
|
370
422
|
return false;
|
|
371
423
|
}
|
|
372
424
|
// Check if workflow has actually changed since last save
|
|
373
|
-
const currentHash =
|
|
425
|
+
const currentHash = draftFingerprint(workflow);
|
|
374
426
|
if (currentHash === this.lastSavedHash) {
|
|
375
427
|
return false;
|
|
376
428
|
}
|
|
@@ -397,7 +449,7 @@ export class DraftAutoSaveManager {
|
|
|
397
449
|
}
|
|
398
450
|
const saved = saveDraft(workflow, this.storageKey, this.storage);
|
|
399
451
|
if (saved) {
|
|
400
|
-
this.lastSavedHash =
|
|
452
|
+
this.lastSavedHash = draftFingerprint(workflow);
|
|
401
453
|
}
|
|
402
454
|
return saved;
|
|
403
455
|
}
|
|
@@ -411,12 +463,14 @@ export class DraftAutoSaveManager {
|
|
|
411
463
|
/**
|
|
412
464
|
* Mark the current state as saved
|
|
413
465
|
*
|
|
414
|
-
* Updates the hash so the next saveIfDirty won't save unless there are new
|
|
466
|
+
* Updates the hash so the next saveIfDirty won't save unless there are new
|
|
467
|
+
* changes, and removes the stored draft (a saved workflow has none).
|
|
415
468
|
*/
|
|
416
469
|
markAsSaved() {
|
|
470
|
+
deleteDraft(this.storageKey, this.storage);
|
|
417
471
|
const workflow = this.getWorkflow();
|
|
418
472
|
if (workflow) {
|
|
419
|
-
this.lastSavedHash =
|
|
473
|
+
this.lastSavedHash = draftFingerprint(workflow);
|
|
420
474
|
}
|
|
421
475
|
}
|
|
422
476
|
/**
|
|
@@ -439,35 +493,6 @@ export class DraftAutoSaveManager {
|
|
|
439
493
|
}
|
|
440
494
|
this.storageKey = newKey;
|
|
441
495
|
}
|
|
442
|
-
/**
|
|
443
|
-
* Simple hash function for change detection
|
|
444
|
-
*
|
|
445
|
-
* Not cryptographically secure, just for detecting changes.
|
|
446
|
-
*
|
|
447
|
-
* @param workflow - The workflow to hash
|
|
448
|
-
* @returns A simple hash string
|
|
449
|
-
*/
|
|
450
|
-
hashWorkflow(workflow) {
|
|
451
|
-
// Use a simple stringification for change detection
|
|
452
|
-
// We only need nodes, edges, name, and description for change detection
|
|
453
|
-
const toHash = {
|
|
454
|
-
name: workflow.name,
|
|
455
|
-
description: workflow.description,
|
|
456
|
-
nodes: workflow.nodes.map((n) => ({
|
|
457
|
-
id: n.id,
|
|
458
|
-
position: n.position,
|
|
459
|
-
data: n.data
|
|
460
|
-
})),
|
|
461
|
-
edges: workflow.edges.map((e) => ({
|
|
462
|
-
id: e.id,
|
|
463
|
-
source: e.source,
|
|
464
|
-
target: e.target,
|
|
465
|
-
sourceHandle: e.sourceHandle,
|
|
466
|
-
targetHandle: e.targetHandle
|
|
467
|
-
}))
|
|
468
|
-
};
|
|
469
|
-
return JSON.stringify(toHash);
|
|
470
|
-
}
|
|
471
496
|
/**
|
|
472
497
|
* Check if auto-save is currently running
|
|
473
498
|
*/
|
|
@@ -23,8 +23,10 @@ export interface GlobalSaveOptions {
|
|
|
23
23
|
/**
|
|
24
24
|
* Callback invoked after a successful save to clear the dirty state.
|
|
25
25
|
* Pass workflowStore's markAsSaved here when calling from App.svelte.
|
|
26
|
+
* Receives the `editVersion` read when the saved snapshot was taken: pass it
|
|
27
|
+
* on, so an edit made while the save was in flight stays dirty.
|
|
26
28
|
*/
|
|
27
|
-
onMarkAsSaved?: () => void;
|
|
29
|
+
onMarkAsSaved?: (version: number) => void;
|
|
28
30
|
/**
|
|
29
31
|
* Callback invoked after a successful save with the persisted workflow.
|
|
30
32
|
* Receives the server-returned workflow (which may have a different ID than
|
|
@@ -37,6 +39,12 @@ export interface GlobalSaveOptions {
|
|
|
37
39
|
* Defaults to the page-default instance when omitted.
|
|
38
40
|
*/
|
|
39
41
|
instance?: FlowDropInstance;
|
|
42
|
+
/**
|
|
43
|
+
* Whether the save may ask the person a question (the impact dialog).
|
|
44
|
+
* Default `true`. Autosave passes `false`: a save that needs an answer is not
|
|
45
|
+
* made, returns `false` and the workflow stays dirty.
|
|
46
|
+
*/
|
|
47
|
+
interactive?: boolean;
|
|
40
48
|
}
|
|
41
49
|
/**
|
|
42
50
|
* Options accepted by globalExportWorkflow().
|
|
@@ -56,18 +64,28 @@ export interface GlobalExportOptions {
|
|
|
56
64
|
* This is the single source of truth for save logic. App.svelte delegates
|
|
57
65
|
* to this function rather than reimplementing the steps.
|
|
58
66
|
*
|
|
67
|
+
* Joining: a call made while a save of the same instance is in flight (double
|
|
68
|
+
* Cmd+S, autosave plus a manual save) returns that save's promise instead of
|
|
69
|
+
* starting another, which would send the superseded revision and be refused as
|
|
70
|
+
* a conflict. Edits made meanwhile stay dirty and go with the next save.
|
|
71
|
+
*
|
|
59
72
|
* Steps performed:
|
|
73
|
+
* 0. Join a save already in flight, or drop the call while the impact question is open
|
|
60
74
|
* 1. Flush pending form changes (blur active element + tick)
|
|
61
|
-
* 2.
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
|
|
68
|
-
|
|
75
|
+
* 2. Build the canonical Workflow object (preserving metadata, format, etc.)
|
|
76
|
+
* and note the edit version it was taken at
|
|
77
|
+
* 3. Ask the backend what the save changes for the workflow's users; ask the
|
|
78
|
+
* person when something breaks or changes (autosave does not ask: it waits
|
|
79
|
+
* for a person, and says so once)
|
|
80
|
+
* 4. Optionally call onBeforeSave — return false cancels the save
|
|
81
|
+
* 5. Persist via the instance's API client (fd.api.client)
|
|
82
|
+
* 6. Update the store if the server assigned a new ID
|
|
83
|
+
* 7. Call onMarkAsSaved (up to the version noted in step 2) / onAfterSave hooks
|
|
84
|
+
* 8. Show toast notifications (respecting features.showToasts)
|
|
85
|
+
*
|
|
69
86
|
* Resolves `true` when the workflow was written, `false` when nothing was
|
|
70
|
-
* saved because there was no workflow
|
|
87
|
+
* saved because there was no workflow, `onBeforeSave` cancelled or the person
|
|
88
|
+
* cancelled the impact question. A failed
|
|
71
89
|
* request throws. Callers that relay the outcome (the WebMCP `save` tool)
|
|
72
90
|
* must not read a quiet return as a save.
|
|
73
91
|
*/
|