@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.
- package/CHANGELOG.md +95 -0
- package/README.md +6 -1
- package/dist/api/enhanced-client.d.ts +3 -1
- package/dist/api/enhanced-client.js +4 -2
- package/dist/commands/executor.js +9 -0
- package/dist/commands/storeIntegration.svelte.js +6 -0
- package/dist/commands/types.d.ts +8 -0
- package/dist/components/App.svelte +414 -105
- package/dist/components/App.svelte.d.ts +31 -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/FlowDropZone.svelte +7 -1
- package/dist/components/FlowDropZone.svelte.d.ts +5 -0
- package/dist/components/ImpactConfirm.svelte +554 -0
- package/dist/components/ImpactConfirm.svelte.d.ts +22 -0
- package/dist/components/Input.svelte +8 -2
- package/dist/components/LockBanner.svelte +76 -0
- package/dist/components/LockBanner.svelte.d.ts +14 -0
- package/dist/components/LockFence.svelte +33 -0
- package/dist/components/LockFence.svelte.d.ts +19 -0
- package/dist/components/Navbar.svelte +77 -9
- package/dist/components/Navbar.svelte.d.ts +10 -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 +50 -3
- 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/Textarea.svelte +7 -1
- package/dist/components/WorkflowCompareDialog.svelte +177 -0
- package/dist/components/WorkflowCompareDialog.svelte.d.ts +10 -0
- package/dist/components/WorkflowEditor.svelte +120 -15
- package/dist/components/WorkflowEditor.svelte.d.ts +6 -0
- package/dist/components/WorkflowInterfaceEditor.svelte +17 -4
- package/dist/components/WorkflowInterfaceEntryCard.svelte +40 -7
- package/dist/components/WorkflowInterfaceEntryCard.svelte.d.ts +2 -0
- package/dist/components/WorkflowPlaygroundSettings.svelte +9 -1
- package/dist/components/form/FieldFactory.svelte +13 -6
- package/dist/components/form/FormArray.svelte +0 -1
- package/dist/components/form/FormArrayRows.svelte +4 -4
- package/dist/components/form/FormCodeEditor.svelte +18 -2
- package/dist/components/form/FormMarkdownEditor.svelte +22 -8
- package/dist/components/form/FormTemplateEditor.svelte +17 -1
- package/dist/components/form/readOnly.d.ts +13 -0
- package/dist/components/form/readOnly.js +18 -0
- package/dist/components/nodes/CaptionNode.svelte +1 -0
- package/dist/components/nodes/NodeCard.svelte +2 -2
- package/dist/components/primitives/Checkbox.svelte +5 -1
- package/dist/components/primitives/Select.svelte +6 -1
- package/dist/components/primitives/Switch.svelte +5 -1
- 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 +2 -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 +2 -0
- package/dist/messages/defaults.d.ts +145 -0
- package/dist/messages/defaults.js +139 -1
- package/dist/openapi/v1/openapi.yaml +492 -0
- package/dist/registry/nodeComponentRegistry.d.ts +5 -0
- package/dist/schemas/v1/workflow.schema.json +2 -0
- package/dist/services/draftStorage.d.ts +24 -10
- package/dist/services/draftStorage.js +60 -35
- package/dist/services/globalSave.d.ts +45 -10
- package/dist/services/globalSave.js +296 -32
- package/dist/services/impactGate.d.ts +38 -0
- package/dist/services/impactGate.js +72 -0
- package/dist/services/impactService.d.ts +45 -0
- package/dist/services/impactService.js +157 -0
- package/dist/services/runsService.d.ts +9 -0
- package/dist/services/runsService.js +13 -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.d.ts +6 -0
- package/dist/services/workflowLaunchService.js +5 -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/historyStore.svelte.d.ts +12 -2
- package/dist/stores/historyStore.svelte.js +25 -2
- package/dist/stores/instanceContainer.svelte.d.ts +23 -0
- package/dist/stores/instanceContainer.svelte.js +32 -2
- package/dist/stores/lockStore.svelte.d.ts +39 -0
- package/dist/stores/lockStore.svelte.js +109 -0
- package/dist/stores/runController.svelte.d.ts +2 -0
- package/dist/stores/runController.svelte.js +27 -11
- package/dist/stores/saveConflictStore.svelte.d.ts +62 -0
- package/dist/stores/saveConflictStore.svelte.js +169 -0
- package/dist/stores/workflowStore.svelte.d.ts +14 -4
- package/dist/stores/workflowStore.svelte.js +55 -18
- package/dist/styles/base.css +6 -0
- package/dist/styles/toast.css +10 -1
- package/dist/svelte-app.d.ts +33 -0
- package/dist/svelte-app.js +178 -22
- package/dist/types/doctor.d.ts +3 -1
- package/dist/types/events.d.ts +37 -0
- package/dist/types/events.js +2 -0
- package/dist/types/impact.d.ts +77 -0
- package/dist/types/impact.js +7 -0
- package/dist/types/lock.d.ts +35 -0
- package/dist/types/lock.js +13 -0
- package/dist/types/navbar.d.ts +6 -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/links.d.ts +29 -0
- package/dist/utils/links.js +63 -0
- 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/dist/webmcp/runtime.js +16 -3
- package/dist/webmcp/types.d.ts +11 -1
- 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
|
-
|
|
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
|
}
|
|
@@ -81,6 +81,14 @@ export declare class HistoryStore {
|
|
|
81
81
|
* how the owner of that state flushes it first.
|
|
82
82
|
*/
|
|
83
83
|
setBeforeNavigateCallback(callback: (() => void) | null): void;
|
|
84
|
+
/**
|
|
85
|
+
* Set the check that freezes history. While it returns true, `undo()` and
|
|
86
|
+
* `redo()` change nothing (the history position stays, the restore callback
|
|
87
|
+
* is not called) and return false. Pass `null` to remove the check.
|
|
88
|
+
*/
|
|
89
|
+
setIsBlockedCheck(check: (() => boolean) | null): void;
|
|
90
|
+
/** Whether history is frozen right now. */
|
|
91
|
+
get isBlocked(): boolean;
|
|
84
92
|
/**
|
|
85
93
|
* Release the history service subscription.
|
|
86
94
|
* Called by the owning instance's destroy(); safe to call repeatedly.
|
|
@@ -99,7 +107,8 @@ export declare class HistoryStore {
|
|
|
99
107
|
*
|
|
100
108
|
* Restores the previous workflow state and invokes the restore callback.
|
|
101
109
|
*
|
|
102
|
-
* @returns true if undo was successful, false if at beginning of history
|
|
110
|
+
* @returns true if undo was successful, false if at beginning of history or
|
|
111
|
+
* while history is frozen (see {@link setIsBlockedCheck})
|
|
103
112
|
*/
|
|
104
113
|
undo(): boolean;
|
|
105
114
|
/**
|
|
@@ -107,7 +116,8 @@ export declare class HistoryStore {
|
|
|
107
116
|
*
|
|
108
117
|
* Restores the next workflow state and invokes the restore callback.
|
|
109
118
|
*
|
|
110
|
-
* @returns true if redo was successful, false if at end of history
|
|
119
|
+
* @returns true if redo was successful, false if at end of history or
|
|
120
|
+
* while history is frozen (see {@link setIsBlockedCheck})
|
|
111
121
|
*/
|
|
112
122
|
redo(): boolean;
|
|
113
123
|
/**
|
|
@@ -39,6 +39,11 @@ export class HistoryStore {
|
|
|
39
39
|
* session into a committed history step (see {@link setBeforeNavigateCallback}).
|
|
40
40
|
*/
|
|
41
41
|
#onBeforeNavigate = null;
|
|
42
|
+
/**
|
|
43
|
+
* Answers whether history is frozen (for example while the editor is locked).
|
|
44
|
+
* While it says yes, undo and redo do nothing.
|
|
45
|
+
*/
|
|
46
|
+
#isBlocked = null;
|
|
42
47
|
/** Unsubscribe handle for the service subscription. */
|
|
43
48
|
#unsubscribe;
|
|
44
49
|
/** The underlying (non-reactive) history service. */
|
|
@@ -119,6 +124,18 @@ export class HistoryStore {
|
|
|
119
124
|
setBeforeNavigateCallback(callback) {
|
|
120
125
|
this.#onBeforeNavigate = callback;
|
|
121
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* Set the check that freezes history. While it returns true, `undo()` and
|
|
129
|
+
* `redo()` change nothing (the history position stays, the restore callback
|
|
130
|
+
* is not called) and return false. Pass `null` to remove the check.
|
|
131
|
+
*/
|
|
132
|
+
setIsBlockedCheck(check) {
|
|
133
|
+
this.#isBlocked = check;
|
|
134
|
+
}
|
|
135
|
+
/** Whether history is frozen right now. */
|
|
136
|
+
get isBlocked() {
|
|
137
|
+
return this.#isBlocked?.() ?? false;
|
|
138
|
+
}
|
|
122
139
|
/**
|
|
123
140
|
* Release the history service subscription.
|
|
124
141
|
* Called by the owning instance's destroy(); safe to call repeatedly.
|
|
@@ -146,9 +163,12 @@ export class HistoryStore {
|
|
|
146
163
|
*
|
|
147
164
|
* Restores the previous workflow state and invokes the restore callback.
|
|
148
165
|
*
|
|
149
|
-
* @returns true if undo was successful, false if at beginning of history
|
|
166
|
+
* @returns true if undo was successful, false if at beginning of history or
|
|
167
|
+
* while history is frozen (see {@link setIsBlockedCheck})
|
|
150
168
|
*/
|
|
151
169
|
undo() {
|
|
170
|
+
if (this.isBlocked)
|
|
171
|
+
return false;
|
|
152
172
|
// Flush any pending edit session into a committed step first, so undo reverts
|
|
153
173
|
// exactly that step rather than skipping over an uncommitted edit.
|
|
154
174
|
this.#onBeforeNavigate?.();
|
|
@@ -164,9 +184,12 @@ export class HistoryStore {
|
|
|
164
184
|
*
|
|
165
185
|
* Restores the next workflow state and invokes the restore callback.
|
|
166
186
|
*
|
|
167
|
-
* @returns true if redo was successful, false if at end of history
|
|
187
|
+
* @returns true if redo was successful, false if at end of history or
|
|
188
|
+
* while history is frozen (see {@link setIsBlockedCheck})
|
|
168
189
|
*/
|
|
169
190
|
redo() {
|
|
191
|
+
if (this.isBlocked)
|
|
192
|
+
return false;
|
|
170
193
|
// A pending edit session invalidates the redo stack (it is a new change), so
|
|
171
194
|
// finalize it first; redo then correctly reports nothing to redo.
|
|
172
195
|
this.#onBeforeNavigate?.();
|
|
@@ -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';
|
|
@@ -27,12 +28,14 @@ import { PortCoordinateStore } from './portCoordinateStore.svelte.js';
|
|
|
27
28
|
import { PipelinePanelStore } from './pipelinePanelStore.svelte.js';
|
|
28
29
|
import { InlineEditStore } from './inlineEditStore.svelte.js';
|
|
29
30
|
import { EditorModeStore } from './editorModeStore.svelte.js';
|
|
31
|
+
import { EditorLockStore } from './lockStore.svelte.js';
|
|
30
32
|
import { AttachedRunStore } from './attachedRunStore.svelte.js';
|
|
31
33
|
import { NodeHighlightStore } from './nodeHighlightStore.svelte.js';
|
|
32
34
|
import { ConnectDragStore } from './connectDragStore.svelte.js';
|
|
33
35
|
import { LoopbackLanesStore } from './loopbackLanesStore.svelte.js';
|
|
34
36
|
import { EditedNodesStore } from './editedNodesStore.svelte.js';
|
|
35
37
|
import { DoctorStore } from './doctorStore.svelte.js';
|
|
38
|
+
import { SaveConflictStore } from './saveConflictStore.svelte.js';
|
|
36
39
|
import { PlaygroundService } from '../services/playgroundService.js';
|
|
37
40
|
import { ApiContext } from './apiContext.js';
|
|
38
41
|
import { PortCompatibilityChecker } from '../utils/connections.js';
|
|
@@ -115,6 +118,12 @@ export interface FlowDropInstance {
|
|
|
115
118
|
* writes the same store.
|
|
116
119
|
*/
|
|
117
120
|
readonly editorMode: EditorModeStore;
|
|
121
|
+
/**
|
|
122
|
+
* The lock on this editor: why the workflow is read-only and which actions
|
|
123
|
+
* the banner offers. `fd.lock.set({ reasons, actions })` locks it, `set(null)`
|
|
124
|
+
* unlocks it. While it is set, every edit is refused.
|
|
125
|
+
*/
|
|
126
|
+
readonly lock: EditorLockStore;
|
|
118
127
|
/**
|
|
119
128
|
* The run attached to the Assistant (`fd.attachedRun.attach(id)`): the chat
|
|
120
129
|
* request carries it as `attachedRunId`, and the Assistant's run tools read it.
|
|
@@ -155,6 +164,11 @@ export interface FlowDropInstance {
|
|
|
155
164
|
* clicking Save does.
|
|
156
165
|
*/
|
|
157
166
|
readonly host: HostHooksStore;
|
|
167
|
+
/**
|
|
168
|
+
* A save the server refused because someone else saved first: the toast's
|
|
169
|
+
* Keep mine / Load theirs / Compare choices and the compare dialog's state.
|
|
170
|
+
*/
|
|
171
|
+
readonly saveConflict: SaveConflictStore;
|
|
158
172
|
/**
|
|
159
173
|
* The approval gate every agent surface on this editor asks — the WebMCP
|
|
160
174
|
* registration and the chat panel's tool loop. Whichever surface comes
|
|
@@ -177,6 +191,15 @@ export interface FlowDropInstance {
|
|
|
177
191
|
* a canvas they fall back to computed geometry.
|
|
178
192
|
*/
|
|
179
193
|
measureNode: ((nodeId: string) => MeasuredCard | undefined) | null;
|
|
194
|
+
/**
|
|
195
|
+
* The messages this editor shows, merged with the host's overrides. `App`
|
|
196
|
+
* registers its live tree; until then (and on a page with no editor mounted)
|
|
197
|
+
* these are the defaults. Code that runs outside the component tree reads
|
|
198
|
+
* strings from here instead of `defaultMessages`.
|
|
199
|
+
*/
|
|
200
|
+
readonly messages: () => Messages;
|
|
201
|
+
/** Register the getter `messages()` reads. `App` does this while it is mounted. */
|
|
202
|
+
setMessages(get: () => Messages): void;
|
|
180
203
|
/**
|
|
181
204
|
* Run `fn` when this instance is destroyed. Returns an unsubscribe; calling
|
|
182
205
|
* 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';
|
|
@@ -24,12 +25,14 @@ import { PortCoordinateStore } from './portCoordinateStore.svelte.js';
|
|
|
24
25
|
import { PipelinePanelStore } from './pipelinePanelStore.svelte.js';
|
|
25
26
|
import { InlineEditStore } from './inlineEditStore.svelte.js';
|
|
26
27
|
import { EditorModeStore } from './editorModeStore.svelte.js';
|
|
28
|
+
import { EditorLockStore } from './lockStore.svelte.js';
|
|
27
29
|
import { AttachedRunStore } from './attachedRunStore.svelte.js';
|
|
28
30
|
import { NodeHighlightStore } from './nodeHighlightStore.svelte.js';
|
|
29
31
|
import { ConnectDragStore } from './connectDragStore.svelte.js';
|
|
30
32
|
import { LoopbackLanesStore } from './loopbackLanesStore.svelte.js';
|
|
31
33
|
import { EditedNodesStore } from './editedNodesStore.svelte.js';
|
|
32
34
|
import { DoctorStore } from './doctorStore.svelte.js';
|
|
35
|
+
import { SaveConflictStore } from './saveConflictStore.svelte.js';
|
|
33
36
|
import { PlaygroundService, playgroundService } from '../services/playgroundService.js';
|
|
34
37
|
import { ApiContext } from './apiContext.js';
|
|
35
38
|
import { PortCompatibilityChecker } from '../utils/connections.js';
|
|
@@ -104,7 +107,14 @@ export function createFlowDropInstance(options = {}) {
|
|
|
104
107
|
// keep operating on the default editor's history stack.
|
|
105
108
|
const history = isDefault ? historyService : new HistoryService();
|
|
106
109
|
const workflow = new WorkflowStore(history);
|
|
110
|
+
// A lock makes the workflow store refuse every edit, whoever asks.
|
|
111
|
+
const lock = new EditorLockStore();
|
|
112
|
+
// The lock store blurs a field being typed in before it locks, so that edit lands first.
|
|
113
|
+
lock.onChange((locked) => workflow.setLocked(locked));
|
|
107
114
|
const historyBindings = new HistoryStore(history);
|
|
115
|
+
// A locked workflow keeps its history where it is: undo and redo would only
|
|
116
|
+
// move the position, because the store refuses the restore.
|
|
117
|
+
historyBindings.setIsBlockedCheck(() => workflow.locked);
|
|
108
118
|
// Default wiring: undo/redo restores into this instance's workflow store.
|
|
109
119
|
// WorkflowEditor overrides this with a richer callback while mounted.
|
|
110
120
|
historyBindings.setOnRestoreCallback((restored) => workflow.restoreFromHistory(restored));
|
|
@@ -115,7 +125,13 @@ export function createFlowDropInstance(options = {}) {
|
|
|
115
125
|
const playground = new PlaygroundStore();
|
|
116
126
|
const instancePlaygroundService = isDefault ? playgroundService : new PlaygroundService();
|
|
117
127
|
const api = new ApiContext();
|
|
118
|
-
const doctor = new DoctorStore(workflow, api
|
|
128
|
+
const doctor = new DoctorStore(workflow, api, {
|
|
129
|
+
history: {
|
|
130
|
+
undo: () => historyBindings.undo(),
|
|
131
|
+
position: () => historyBindings.state.currentIndex
|
|
132
|
+
},
|
|
133
|
+
messages: () => readMessages()
|
|
134
|
+
});
|
|
119
135
|
const runs = new RunController({
|
|
120
136
|
playground,
|
|
121
137
|
service: instancePlaygroundService,
|
|
@@ -128,6 +144,7 @@ export function createFlowDropInstance(options = {}) {
|
|
|
128
144
|
() => historyBindings.cleanup(),
|
|
129
145
|
() => historyBindings.setOnRestoreCallback(null),
|
|
130
146
|
() => historyBindings.setBeforeNavigateCallback(null),
|
|
147
|
+
() => historyBindings.setIsBlockedCheck(null),
|
|
131
148
|
() => doctor.dispose(),
|
|
132
149
|
() => workflow.setOnDirtyStateChange(null),
|
|
133
150
|
() => workflow.setOnWorkflowChange(null),
|
|
@@ -143,7 +160,8 @@ export function createFlowDropInstance(options = {}) {
|
|
|
143
160
|
instancePlaygroundService.stopPolling();
|
|
144
161
|
}
|
|
145
162
|
];
|
|
146
|
-
|
|
163
|
+
let readMessages = () => defaultMessages;
|
|
164
|
+
const instance = {
|
|
147
165
|
id,
|
|
148
166
|
storagePrefix,
|
|
149
167
|
isDefault,
|
|
@@ -168,6 +186,7 @@ export function createFlowDropInstance(options = {}) {
|
|
|
168
186
|
pipelinePanel: new PipelinePanelStore(id),
|
|
169
187
|
inlineEdit: new InlineEditStore(),
|
|
170
188
|
editorMode: new EditorModeStore(),
|
|
189
|
+
lock,
|
|
171
190
|
attachedRun: new AttachedRunStore(),
|
|
172
191
|
highlight: new NodeHighlightStore(),
|
|
173
192
|
connectDrag: new ConnectDragStore(),
|
|
@@ -176,6 +195,12 @@ export function createFlowDropInstance(options = {}) {
|
|
|
176
195
|
doctor,
|
|
177
196
|
nodeTypes: new NodeTypesStore(),
|
|
178
197
|
host: new HostHooksStore(),
|
|
198
|
+
saveConflict: new SaveConflictStore({
|
|
199
|
+
workflow,
|
|
200
|
+
loadWorkflow: (id) => api.client.loadWorkflow(id),
|
|
201
|
+
schedule: () => doctor.schedule(),
|
|
202
|
+
messages: () => readMessages()
|
|
203
|
+
}),
|
|
179
204
|
approvalGate: null,
|
|
180
205
|
skinScope: null,
|
|
181
206
|
get measureNode() {
|
|
@@ -184,6 +209,10 @@ export function createFlowDropInstance(options = {}) {
|
|
|
184
209
|
set measureNode(fn) {
|
|
185
210
|
measureNodeFn = fn;
|
|
186
211
|
},
|
|
212
|
+
messages: () => readMessages(),
|
|
213
|
+
setMessages(get) {
|
|
214
|
+
readMessages = get;
|
|
215
|
+
},
|
|
187
216
|
onDestroy(fn) {
|
|
188
217
|
cleanups.push(fn);
|
|
189
218
|
return () => {
|
|
@@ -198,6 +227,7 @@ export function createFlowDropInstance(options = {}) {
|
|
|
198
227
|
}
|
|
199
228
|
}
|
|
200
229
|
};
|
|
230
|
+
return instance;
|
|
201
231
|
}
|
|
202
232
|
// =========================================================================
|
|
203
233
|
// Default instance (backward compatibility)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Editor lock: the reasons a workflow cannot be edited right now, and the
|
|
3
|
+
* actions a person is offered.
|
|
4
|
+
*
|
|
5
|
+
* One store per instance. While a lock is set the workflow store refuses every
|
|
6
|
+
* edit (see `WorkflowStore.setLocked`) and the canvas shows the banner. A host
|
|
7
|
+
* sets it through the `lock` option or `app.setLock(...)`, and removes it with
|
|
8
|
+
* `null`. Pressing an action reports its id to the host (`onLockAction`).
|
|
9
|
+
*
|
|
10
|
+
* @module stores/lockStore
|
|
11
|
+
*/
|
|
12
|
+
import type { EditorLock } from '../types/lock.js';
|
|
13
|
+
export declare class EditorLockStore {
|
|
14
|
+
#private;
|
|
15
|
+
/** The lock in force, or null when the editor is not locked. */
|
|
16
|
+
get current(): EditorLock | null;
|
|
17
|
+
/** Whether the editor is locked. */
|
|
18
|
+
get isLocked(): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Lock the editor, replace the lock, or (with `null`) unlock it. A value that
|
|
21
|
+
* is not a lock unlocks.
|
|
22
|
+
*/
|
|
23
|
+
set(lock: EditorLock | null | undefined): void;
|
|
24
|
+
/** Remove the lock. */
|
|
25
|
+
clear(): void;
|
|
26
|
+
/** Be told when the editor becomes locked or unlocked. Returns a function that stops listening. */
|
|
27
|
+
onChange(listener: (locked: boolean) => void): () => void;
|
|
28
|
+
/**
|
|
29
|
+
* Be told just before the editor becomes locked, while it still reads as
|
|
30
|
+
* unlocked, so an edit in progress can be saved. Returns a function that stops listening.
|
|
31
|
+
*
|
|
32
|
+
* @internal Used by the editor to save a half-typed name; not a supported host API.
|
|
33
|
+
*/
|
|
34
|
+
onBeforeLock(listener: () => void): () => void;
|
|
35
|
+
/** Be told when a person presses a lock action. Returns a function that stops listening. */
|
|
36
|
+
onAction(listener: (id: string) => void): () => void;
|
|
37
|
+
/** A person pressed the action `id`. Reported to the host, which decides what it does. */
|
|
38
|
+
fire(id: string): void;
|
|
39
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Editor lock: the reasons a workflow cannot be edited right now, and the
|
|
3
|
+
* actions a person is offered.
|
|
4
|
+
*
|
|
5
|
+
* One store per instance. While a lock is set the workflow store refuses every
|
|
6
|
+
* edit (see `WorkflowStore.setLocked`) and the canvas shows the banner. A host
|
|
7
|
+
* sets it through the `lock` option or `app.setLock(...)`, and removes it with
|
|
8
|
+
* `null`. Pressing an action reports its id to the host (`onLockAction`).
|
|
9
|
+
*
|
|
10
|
+
* @module stores/lockStore
|
|
11
|
+
*/
|
|
12
|
+
/** Keep what the banner needs, and drop anything that is not text. */
|
|
13
|
+
function normalise(lock) {
|
|
14
|
+
if (!lock || typeof lock !== 'object')
|
|
15
|
+
return null;
|
|
16
|
+
const reasons = (Array.isArray(lock.reasons) ? lock.reasons : []).filter((r) => r && typeof r.message === 'string' && r.message !== '');
|
|
17
|
+
const actions = (Array.isArray(lock.actions) ? lock.actions : []).filter((a) => a && typeof a.id === 'string' && a.id !== '' && typeof a.label === 'string');
|
|
18
|
+
return {
|
|
19
|
+
reasons: reasons.map((r) => ({
|
|
20
|
+
kind: String(r.kind ?? ''),
|
|
21
|
+
message: r.message,
|
|
22
|
+
url: r.url ?? null
|
|
23
|
+
})),
|
|
24
|
+
actions: actions.map((a) => ({ id: a.id, label: a.label, primary: a.primary === true }))
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Blur the focused element when it sits inside a lock fence (a config form or
|
|
29
|
+
* panel body) or is an in-place editor that commits on blur (`data-lock-commit`).
|
|
30
|
+
*/
|
|
31
|
+
function blurFieldInsideLockFence() {
|
|
32
|
+
if (typeof document === 'undefined')
|
|
33
|
+
return;
|
|
34
|
+
const active = document.activeElement;
|
|
35
|
+
if (active instanceof HTMLElement && active.closest('.flowdrop-lock-fence, [data-lock-commit]'))
|
|
36
|
+
active.blur();
|
|
37
|
+
}
|
|
38
|
+
export class EditorLockStore {
|
|
39
|
+
#current = $state(null);
|
|
40
|
+
#changeListeners = new Set();
|
|
41
|
+
#beforeLockListeners = new Set();
|
|
42
|
+
#actionListeners = new Set();
|
|
43
|
+
/** The lock in force, or null when the editor is not locked. */
|
|
44
|
+
get current() {
|
|
45
|
+
return this.#current;
|
|
46
|
+
}
|
|
47
|
+
/** Whether the editor is locked. */
|
|
48
|
+
get isLocked() {
|
|
49
|
+
return this.#current !== null;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Lock the editor, replace the lock, or (with `null`) unlock it. A value that
|
|
53
|
+
* is not a lock unlocks.
|
|
54
|
+
*/
|
|
55
|
+
set(lock) {
|
|
56
|
+
const next = normalise(lock);
|
|
57
|
+
const was = this.#current !== null;
|
|
58
|
+
// A field being typed in commits on blur. Blur it while the editor still
|
|
59
|
+
// reads as unlocked, so the edit lands before anything refuses it.
|
|
60
|
+
if (!was && next !== null) {
|
|
61
|
+
// Let an editor save what is half typed (a name beside a port) first.
|
|
62
|
+
for (const listener of [...this.#beforeLockListeners])
|
|
63
|
+
listener();
|
|
64
|
+
blurFieldInsideLockFence();
|
|
65
|
+
}
|
|
66
|
+
this.#current = next;
|
|
67
|
+
const is = next !== null;
|
|
68
|
+
if (was !== is)
|
|
69
|
+
for (const listener of [...this.#changeListeners])
|
|
70
|
+
listener(is);
|
|
71
|
+
}
|
|
72
|
+
/** Remove the lock. */
|
|
73
|
+
clear() {
|
|
74
|
+
this.set(null);
|
|
75
|
+
}
|
|
76
|
+
/** Be told when the editor becomes locked or unlocked. Returns a function that stops listening. */
|
|
77
|
+
onChange(listener) {
|
|
78
|
+
this.#changeListeners.add(listener);
|
|
79
|
+
return () => {
|
|
80
|
+
this.#changeListeners.delete(listener);
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Be told just before the editor becomes locked, while it still reads as
|
|
85
|
+
* unlocked, so an edit in progress can be saved. Returns a function that stops listening.
|
|
86
|
+
*
|
|
87
|
+
* @internal Used by the editor to save a half-typed name; not a supported host API.
|
|
88
|
+
*/
|
|
89
|
+
onBeforeLock(listener) {
|
|
90
|
+
this.#beforeLockListeners.add(listener);
|
|
91
|
+
return () => {
|
|
92
|
+
this.#beforeLockListeners.delete(listener);
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/** Be told when a person presses a lock action. Returns a function that stops listening. */
|
|
96
|
+
onAction(listener) {
|
|
97
|
+
this.#actionListeners.add(listener);
|
|
98
|
+
return () => {
|
|
99
|
+
this.#actionListeners.delete(listener);
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/** A person pressed the action `id`. Reported to the host, which decides what it does. */
|
|
103
|
+
fire(id) {
|
|
104
|
+
if (!this.#current?.actions.some((a) => a.id === id))
|
|
105
|
+
return;
|
|
106
|
+
for (const listener of [...this.#actionListeners])
|
|
107
|
+
listener(id);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -48,6 +48,8 @@ export interface ActiveRun {
|
|
|
48
48
|
startedAt: number;
|
|
49
49
|
/** When the run reached a terminal status (ms epoch), `null` while it is live. */
|
|
50
50
|
endedAt: number | null;
|
|
51
|
+
/** The run is queued and no worker has picked it up yet (the site says `waiting_for_worker`). */
|
|
52
|
+
waitingForWorker: boolean;
|
|
51
53
|
}
|
|
52
54
|
/** What a {@link RunController} is built from: the instance's own pieces. */
|
|
53
55
|
export interface RunControllerDeps {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import { SvelteSet } from 'svelte/reactivity';
|
|
19
19
|
import { nodeExecutionService } from '../services/nodeExecutionService.js';
|
|
20
|
-
import {
|
|
20
|
+
import { readRunState } from '../services/runsService.js';
|
|
21
21
|
import { pipelineSignalService } from '../services/pipelineSignalService.js';
|
|
22
22
|
import { workflowLaunchService } from '../services/workflowLaunchService.js';
|
|
23
23
|
import { describeLaunchResult } from '../playground/commands/index.js';
|
|
@@ -989,7 +989,10 @@ export class RunController {
|
|
|
989
989
|
runId,
|
|
990
990
|
status,
|
|
991
991
|
startedAt: tracked.startedAt,
|
|
992
|
-
endedAt: TERMINAL_RUN_STATUSES.includes(status) ? (this.#endedAt ?? tracked.startedAt) : null
|
|
992
|
+
endedAt: TERMINAL_RUN_STATUSES.includes(status) ? (this.#endedAt ?? tracked.startedAt) : null,
|
|
993
|
+
waitingForWorker: tracked.origin === 'host' &&
|
|
994
|
+
status === 'running' &&
|
|
995
|
+
tracked.activityKind === 'waiting_for_worker'
|
|
993
996
|
};
|
|
994
997
|
});
|
|
995
998
|
/**
|
|
@@ -1036,7 +1039,7 @@ export class RunController {
|
|
|
1036
1039
|
this.#hostStatusHook = onRunStatus;
|
|
1037
1040
|
out.onRunStatus = async (runId) => {
|
|
1038
1041
|
const envelope = await onRunStatus(runId);
|
|
1039
|
-
this.#applyHostStatus(runId, envelope.ok ? envelope.data?.status : undefined);
|
|
1042
|
+
this.#applyHostStatus(runId, envelope.ok ? envelope.data?.status : undefined, envelope.ok ? (envelope.data?.activity?.kind ?? null) : null);
|
|
1040
1043
|
return envelope;
|
|
1041
1044
|
};
|
|
1042
1045
|
}
|
|
@@ -1071,8 +1074,9 @@ export class RunController {
|
|
|
1071
1074
|
};
|
|
1072
1075
|
const terminal = TERMINAL_RUN_STATUSES.includes(hostStatus);
|
|
1073
1076
|
this.#endedAt = terminal ? Date.now() : null;
|
|
1077
|
+
// Read the status now, so "waiting for a worker" shows at once; then keep the interval.
|
|
1074
1078
|
if (!terminal)
|
|
1075
|
-
this.#scheduleHostPoll(runId,
|
|
1079
|
+
this.#scheduleHostPoll(runId, 0);
|
|
1076
1080
|
}
|
|
1077
1081
|
/**
|
|
1078
1082
|
* The run opened from the Runs list and still shown, or `null` (nothing
|
|
@@ -1137,17 +1141,21 @@ export class RunController {
|
|
|
1137
1141
|
};
|
|
1138
1142
|
this.#endedAt = TERMINAL_RUN_STATUSES.includes(hostStatus) ? Date.now() : null;
|
|
1139
1143
|
if (!TERMINAL_RUN_STATUSES.includes(hostStatus)) {
|
|
1140
|
-
this.#scheduleHostPoll(runId,
|
|
1144
|
+
this.#scheduleHostPoll(runId, 0);
|
|
1141
1145
|
}
|
|
1142
1146
|
}
|
|
1143
|
-
#applyHostStatus(runId, status) {
|
|
1147
|
+
#applyHostStatus(runId, status, activityKind = null) {
|
|
1144
1148
|
const tracked = this.#tracked;
|
|
1145
1149
|
if (tracked?.origin !== 'host' || tracked.runId !== runId || status === undefined)
|
|
1146
1150
|
return;
|
|
1147
1151
|
const next = hostRunStatus(status);
|
|
1148
|
-
if (next === tracked.hostStatus)
|
|
1152
|
+
if (next === tracked.hostStatus) {
|
|
1153
|
+
if ((tracked.activityKind ?? null) !== activityKind) {
|
|
1154
|
+
this.#tracked = { ...tracked, activityKind };
|
|
1155
|
+
}
|
|
1149
1156
|
return;
|
|
1150
|
-
|
|
1157
|
+
}
|
|
1158
|
+
this.#tracked = { ...tracked, hostStatus: next, activityKind };
|
|
1151
1159
|
if (TERMINAL_RUN_STATUSES.includes(next)) {
|
|
1152
1160
|
this.#endedAt = Date.now();
|
|
1153
1161
|
this.#clearHostPoll();
|
|
@@ -1173,7 +1181,7 @@ export class RunController {
|
|
|
1173
1181
|
const envelope = await hook(runId);
|
|
1174
1182
|
if (epoch !== this.#hostPollEpoch)
|
|
1175
1183
|
return;
|
|
1176
|
-
this.#applyHostStatus(runId, envelope.ok ? envelope.data?.status : undefined);
|
|
1184
|
+
this.#applyHostStatus(runId, envelope.ok ? envelope.data?.status : undefined, envelope.ok ? (envelope.data?.activity?.kind ?? null) : null);
|
|
1177
1185
|
}
|
|
1178
1186
|
catch (err) {
|
|
1179
1187
|
logger.error('Failed to read host run status:', err);
|
|
@@ -1192,8 +1200,16 @@ export class RunController {
|
|
|
1192
1200
|
const config = this.#api.config;
|
|
1193
1201
|
if (!config)
|
|
1194
1202
|
return { ok: false };
|
|
1195
|
-
const
|
|
1196
|
-
|
|
1203
|
+
const state = await readRunState(config, runId, this.#api.authProvider);
|
|
1204
|
+
if (state === undefined || state.status === undefined)
|
|
1205
|
+
return { ok: false };
|
|
1206
|
+
return {
|
|
1207
|
+
ok: true,
|
|
1208
|
+
data: {
|
|
1209
|
+
status: state.status,
|
|
1210
|
+
activity: state.activityKind === null ? null : { kind: state.activityKind }
|
|
1211
|
+
}
|
|
1212
|
+
};
|
|
1197
1213
|
};
|
|
1198
1214
|
#clearHostPoll() {
|
|
1199
1215
|
if (this.#hostPoll !== null)
|