@flowdrop/flowdrop 2.17.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 +15 -0
- 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 +209 -106
- package/dist/components/App.svelte.d.ts +29 -0
- package/dist/components/FlowDropZone.svelte +7 -1
- package/dist/components/FlowDropZone.svelte.d.ts +5 -0
- package/dist/components/ImpactConfirm.svelte +246 -33
- package/dist/components/ImpactConfirm.svelte.d.ts +13 -3
- 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 +35 -6
- package/dist/components/Navbar.svelte.d.ts +6 -0
- package/dist/components/RunBar.svelte +16 -4
- package/dist/components/Textarea.svelte +7 -1
- package/dist/components/WorkflowEditor.svelte +32 -9
- package/dist/components/WorkflowInterfaceEditor.svelte +3 -0
- package/dist/components/WorkflowInterfaceEntryCard.svelte +21 -4
- 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/primitives/Checkbox.svelte +5 -1
- package/dist/components/primitives/Select.svelte +6 -1
- package/dist/components/primitives/Switch.svelte +5 -1
- package/dist/editor/index.d.ts +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/messages/defaults.d.ts +45 -0
- package/dist/messages/defaults.js +51 -3
- 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/globalSave.d.ts +17 -0
- package/dist/services/globalSave.js +166 -6
- package/dist/services/impactGate.d.ts +7 -3
- package/dist/services/impactGate.js +9 -7
- package/dist/services/impactService.d.ts +18 -1
- package/dist/services/impactService.js +93 -7
- package/dist/services/runsService.d.ts +9 -0
- package/dist/services/runsService.js +13 -0
- package/dist/services/workflowLaunchService.d.ts +6 -0
- package/dist/services/workflowLaunchService.js +2 -0
- package/dist/stores/historyStore.svelte.d.ts +12 -2
- package/dist/stores/historyStore.svelte.js +25 -2
- package/dist/stores/instanceContainer.svelte.d.ts +7 -0
- package/dist/stores/instanceContainer.svelte.js +10 -0
- 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/workflowStore.svelte.d.ts +7 -1
- package/dist/stores/workflowStore.svelte.js +41 -13
- package/dist/styles/base.css +6 -0
- package/dist/svelte-app.d.ts +31 -0
- package/dist/svelte-app.js +110 -26
- package/dist/types/events.d.ts +17 -0
- package/dist/types/impact.d.ts +52 -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/utils/links.d.ts +29 -0
- package/dist/utils/links.js +63 -0
- package/dist/webmcp/runtime.js +16 -3
- package/dist/webmcp/types.d.ts +11 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [2.18.0] - 2026-11-10
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Editor lock: a host can lock the editor with the new `lock` option (`App` prop and mount option) or at run time with `app.setLock(lock | null)` / `instance.lock.set(...)`. The shape is `{ reasons: [{ kind, message, url? }], actions: [{ id, label, primary? }] }`. While locked, nothing can change the workflow (canvas, config panels, console, shortcuts, undo, a dropped workflow file, a node dropped from the palette), Save and Import are disabled (Import is also disabled with `mode="readonly"`; a Save the host adds through `navbarActions` stays enabled; a person's save while locked, Ctrl/Cmd+S included, saves nothing (the browser's Save Page does not open) and shows "The editor is locked, so nothing was saved.", new message `lock.saveRefused`), and a banner above the canvas lists the reasons (plain text, an optional "Learn more" link for `http(s)` and site-relative URLs) and the action buttons. Selecting, panning, zooming, inspecting (array rows open and close, text and code fields are read-only, so their values can still be selected and copied) and testing in Test mode still work. A field being typed in when the lock arrives keeps that last edit, including a caption's text or a port's name being typed on the canvas. Edits made before the lock arrived are still unsaved, and Save keeps showing it. A lock set for one mount does not carry into the next mount of the same page. Restore on the stored-draft offer while the editor is locked restores nothing and keeps the draft, so it is offered again when the workflow next opens. The canvas toolbar stays on a locked editor (Edit | Test, Run, the run bar): Run on a locked workflow runs the saved version, and with unsaved changes it says so. An editor opened locked keeps the stored draft (autosave does not delete it) and offers it once the lock is removed. `mountWorkflowEditor` takes `lock` and `onLockAction` too. A pressed button calls the new `onLockAction(id)`; the host answers it, and "Edit anyway" is just an action the host answers by removing the lock (`null`). New exported types `EditorLock`, `EditorLockReason`, `EditorLockAction`; `NavbarAction` gains an optional `disabled`; `Navbar` gains an optional `onDisabledSave` (called when Ctrl/Cmd+S is pressed while the first action, Save, is disabled), and Ctrl/Cmd+S with a disabled Save no longer opens the browser's Save Page; the new messages are `lock.title` and `lock.learnMore`. With no `lock`, nothing changes.
|
|
13
|
+
- While the editor is locked, `runCommand`, the Console and the WebMCP tools answer a command that would change the workflow with the new error code `LOCKED` (type `CommandErrorCode`) instead of failing silently; WebMCP answers `LOCKED` before it asks the person for approval, and `save` does the same; reads and view commands (select, zoom, pan) still run. With no lock, nothing changes.
|
|
14
|
+
- A read-only or locked canvas no longer reacts to Ctrl/Cmd+Z and Ctrl/Cmd+Shift+Z. While the editor is locked, undo and redo do nothing at all and leave the history where it is.
|
|
15
|
+
- The save dialog handles a refused save: when the backend's impact check says `refused`, it says the change can't be saved while N places use it, lists them, and offers Save as a copy (POSTs the draft to the check's `copyUrl`: a path from the site root, resolved against the page and not the API base, or a URL on the site's or the API's origin) and Discard my changes (throws away every unsaved edit, history included, and its stored draft, loads the saved version and calls `onWorkflowLoad`; offered when the workflow has an id). The number counts only the places that break; with none it says "while other things use this workflow". A backend that sends none of the new report fields behaves as before.
|
|
16
|
+
- Renamed inputs and outputs are listed with the places that use them (a place needs only a `label`; `url`, `message` and `enabled` are optional) and a box, "Also update these N places", unticked by default. A rename nothing uses does not interrupt saving (no dialog, autosave goes on), and the box shows only when some place uses a rename. The save request then carries a top-level `followRenames: true|false`. A save the backend refuses with `WORKFLOW_IN_USE_BREAKING` opens the same refused dialog instead of an error toast; autosave does not open it, shows "Autosave is waiting" once for that version and tries again after the next edit. `globalSaveWorkflow` takes a new `onRefused(outcome)` option, called after the person answers a refused save: `'copied'`, `'discarded'` or `'kept'` (new exported type `SaveRefusalOutcome` from `/editor`). The mount's default WebMCP `onSave` (and the assistant's `save`) then answers `WORKFLOW_IN_USE_BREAKING` with what the person chose, instead of `UNAVAILABLE`.
|
|
17
|
+
- New event handler `onSavedAsCopy(copy, workflow)`, on the mount API (also for `app.save()`) and the `App` component. Without it the editor marks the workflow as saved (no "Leave site?" prompt, the original's stored draft is dropped) and follows the copy's `editorUrl` (a site path or an `http(s)` address; anything else is ignored); with no URL it shows a "Saved a copy" toast and stays as it is. An error thrown by the handler is logged and never reported as a failed save.
|
|
18
|
+
- New exported types `ImpactRename`, `ImpactRenamePlace` and `SavedCopy`. On `ImpactReport`, the new fields `refused`, `refusedMessage`, `copyUrl` and `renames` are optional, so code that builds a report keeps compiling.
|
|
19
|
+
- The run bar (and its screen-reader announcement, "Run is waiting for a worker.") says "Waiting for a worker" while a run is queued and the backend reports `activity.kind: 'waiting_for_worker'` on the pipeline status endpoint (or in the data a host passes to `onRunStatus`). Once the run is done, the run bar link reads "View result" and opens the run page. New messages `waitingForWorker`, `viewResult` and `viewResultTitle`; the run status payload type gains an optional `activity` (`{ kind }`). A run opened from the Runs list, or started by the host, has its status read once right away, so the wait shows at once instead of after the first poll interval. A backend that sends no activity behaves as before.
|
|
20
|
+
- When the editor starts a run through the built-in `workflows.run` endpoint (no host `onRun`), the launch request carries `origin: 'editor'`, so the backend can show where a run was started. A host's `onRun` starts the run itself, so no `origin` is sent for it. The launch options gain an optional `origin`; a backend that does not know the field ignores it.
|
|
21
|
+
- The OpenAPI spec (`@flowdrop/flowdrop/openapi`) documents the impact check, the copy endpoint, `followRenames` on update, the `WORKFLOW_IN_USE_BREAKING` and `WORKFLOW_MANAGED` refusals, the run endpoint with `origin`, and `activity` on the pipeline status.
|
|
22
|
+
|
|
8
23
|
## [2.17.0] - 2026-11-04
|
|
9
24
|
|
|
10
25
|
### Added
|
|
@@ -147,7 +147,9 @@ export declare class EnhancedFlowDropApiClient {
|
|
|
147
147
|
/**
|
|
148
148
|
* Update an existing workflow
|
|
149
149
|
*/
|
|
150
|
-
updateWorkflow(workflowId: string, workflow: Partial<Workflow
|
|
150
|
+
updateWorkflow(workflowId: string, workflow: Partial<Workflow>,
|
|
151
|
+
/** Extra top-level fields of the request body, such as `followRenames`. */
|
|
152
|
+
extra?: Record<string, unknown>): Promise<Workflow>;
|
|
151
153
|
/**
|
|
152
154
|
* Load a workflow by ID
|
|
153
155
|
*/
|
|
@@ -298,10 +298,12 @@ export class EnhancedFlowDropApiClient {
|
|
|
298
298
|
/**
|
|
299
299
|
* Update an existing workflow
|
|
300
300
|
*/
|
|
301
|
-
async updateWorkflow(workflowId, workflow
|
|
301
|
+
async updateWorkflow(workflowId, workflow,
|
|
302
|
+
/** Extra top-level fields of the request body, such as `followRenames`. */
|
|
303
|
+
extra) {
|
|
302
304
|
const response = await this.request('workflows.update', this.config.endpoints.workflows.update, { id: workflowId }, {
|
|
303
305
|
method: 'PUT',
|
|
304
|
-
body: JSON.stringify(workflow)
|
|
306
|
+
body: JSON.stringify(extra ? { ...workflow, ...extra } : workflow)
|
|
305
307
|
}, 'update workflow');
|
|
306
308
|
if (!response.success || !response.data) {
|
|
307
309
|
throw new Error(response.error ?? 'Failed to update workflow');
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* @module commands/executor
|
|
8
8
|
*/
|
|
9
9
|
import { fromWorkflow, inspect as inspectLayout, beautify as beautifyLayout, formatBeautify, sweep as sweepLayout, formatSweep, applyProposalToNodes, applySweepToNodes, DEFAULT_LAYOUT_OPTIONS, LAYOUT_GRID, MAX_SWEEP_CARDS } from '../layout/index.js';
|
|
10
|
+
import { isMutatingCommand, isViewCommand } from '../chat/commandClassifier.js';
|
|
10
11
|
import { generateNodeId } from '../utils/nodeIds.js';
|
|
11
12
|
import { extractConfigDefaults } from '../utils/nodeIds.js';
|
|
12
13
|
import { computeAutoPosition } from './positioner.js';
|
|
@@ -1584,6 +1585,14 @@ function executeCanvasResetView(context) {
|
|
|
1584
1585
|
* Execute a parsed command against a workflow context.
|
|
1585
1586
|
*/
|
|
1586
1587
|
export function executeCommand(command, context) {
|
|
1588
|
+
// A locked editor refuses every change; say so instead of failing silently.
|
|
1589
|
+
if (context.isLocked?.() && isMutatingCommand(command.type) && !isViewCommand(command.type)) {
|
|
1590
|
+
return {
|
|
1591
|
+
ok: false,
|
|
1592
|
+
code: 'LOCKED',
|
|
1593
|
+
error: 'The editor is locked (read-only), so this change was not made.'
|
|
1594
|
+
};
|
|
1595
|
+
}
|
|
1587
1596
|
switch (command.type) {
|
|
1588
1597
|
case 'add_node':
|
|
1589
1598
|
return executeAddNode(command, context);
|
|
@@ -34,6 +34,9 @@ export function createStoreCommandContext(nodeTypes, onUIAction, instance) {
|
|
|
34
34
|
removeEdge: (edgeId) => actions.removeEdge(edgeId),
|
|
35
35
|
batchUpdate: (updates) => actions.batchUpdate(updates),
|
|
36
36
|
undo: () => {
|
|
37
|
+
// A locked workflow refuses the restore; leave the history where it is.
|
|
38
|
+
if (fd.workflow.locked)
|
|
39
|
+
return false;
|
|
37
40
|
// Flush a pending edit session into a committed step before undoing it.
|
|
38
41
|
actions.finalizeNodeConfig();
|
|
39
42
|
const previousState = history.undo();
|
|
@@ -44,6 +47,8 @@ export function createStoreCommandContext(nodeTypes, onUIAction, instance) {
|
|
|
44
47
|
return false;
|
|
45
48
|
},
|
|
46
49
|
redo: () => {
|
|
50
|
+
if (fd.workflow.locked)
|
|
51
|
+
return false;
|
|
47
52
|
actions.finalizeNodeConfig();
|
|
48
53
|
const nextState = history.redo();
|
|
49
54
|
if (nextState) {
|
|
@@ -80,6 +85,7 @@ export function createStoreCommandContext(nodeTypes, onUIAction, instance) {
|
|
|
80
85
|
nodeTypes,
|
|
81
86
|
typeMap: buildTypeMap(nodeTypes),
|
|
82
87
|
dispatch,
|
|
88
|
+
isLocked: () => fd.workflow.locked,
|
|
83
89
|
// Node layout reads the canvas's measurement; without a canvas it falls back to computed geometry.
|
|
84
90
|
measureNode: (nodeId) => fd.measureNode?.(nodeId),
|
|
85
91
|
visualType: (node) => {
|
package/dist/commands/types.d.ts
CHANGED
|
@@ -188,6 +188,8 @@ export type ParseResult = {
|
|
|
188
188
|
input: string;
|
|
189
189
|
};
|
|
190
190
|
export type CommandErrorCode = 'NODE_NOT_FOUND' | 'NODE_TYPE_NOT_FOUND' | 'PORT_NOT_FOUND' | 'EDGE_NOT_FOUND' | 'INVALID_CONNECTION' | 'CYCLE_DETECTED' | 'NO_WORKFLOW'
|
|
191
|
+
/** The editor is locked (read-only): a command that would change the workflow was refused. */
|
|
192
|
+
| 'LOCKED'
|
|
191
193
|
/** `runCommand({ baseline: true })` on a workflow with unsaved changes: nothing was run. */
|
|
192
194
|
| 'DIRTY' | 'PARSE_ERROR'
|
|
193
195
|
/** An argument is out of range, e.g. a layout gap that is not a multiple of the grid. */
|
|
@@ -464,6 +466,12 @@ export interface CommandContext {
|
|
|
464
466
|
typeMap: Map<string, NodeMetadata>;
|
|
465
467
|
/** Dispatch interface for mutating workflow state */
|
|
466
468
|
dispatch: CommandDispatch;
|
|
469
|
+
/**
|
|
470
|
+
* Whether the editor is locked (read-only). Optional: without it nothing is
|
|
471
|
+
* treated as locked. While true, commands that change the workflow are
|
|
472
|
+
* refused with `LOCKED`; reads and view commands still run.
|
|
473
|
+
*/
|
|
474
|
+
isLocked?(): boolean;
|
|
467
475
|
/**
|
|
468
476
|
* How the canvas measured a node (size, handle centres). Optional: without it
|
|
469
477
|
* node layout commands use computed geometry.
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
withoutInterfaceTurns
|
|
33
33
|
} from '../utils/playgroundChat.js';
|
|
34
34
|
import ReadOnlyDetails from './ReadOnlyDetails.svelte';
|
|
35
|
+
import LockFence from './LockFence.svelte';
|
|
35
36
|
import CommandConsole from './console/CommandConsole.svelte';
|
|
36
37
|
import ConsoleStrip from './console/ConsoleStrip.svelte';
|
|
37
38
|
import {
|
|
@@ -111,6 +112,7 @@
|
|
|
111
112
|
import type { SettingsCategory, SurfacePlacement } from '../types/settings.js';
|
|
112
113
|
import type { EditorPlaygroundConfig } from '../types/playground.js';
|
|
113
114
|
import type { EditorMode } from '../stores/editorModeStore.svelte.js';
|
|
115
|
+
import type { EditorLock } from '../types/lock.js';
|
|
114
116
|
import { defaultMessages, mergeMessages, setMessages, m } from '../messages/index.js';
|
|
115
117
|
import type { MessagesOverride } from '../messages/index.js';
|
|
116
118
|
|
|
@@ -181,6 +183,25 @@
|
|
|
181
183
|
* @default 'edit'
|
|
182
184
|
*/
|
|
183
185
|
editorMode?: EditorMode;
|
|
186
|
+
/**
|
|
187
|
+
* Lock the editor: the workflow becomes read-only and a banner above the
|
|
188
|
+
* canvas lists the `reasons` and offers the `actions` (buttons the host
|
|
189
|
+
* answers through `onLockAction`). While locked, nothing can change the
|
|
190
|
+
* workflow (canvas, config panels, console, shortcuts, undo) and Save is
|
|
191
|
+
* disabled (a host's own Save action stays enabled; pressing it saves nothing
|
|
192
|
+
* and says the editor is locked); selecting, panning, zooming and inspecting
|
|
193
|
+
* still work. `null`
|
|
194
|
+
* removes the lock. Seeds `instance.lock`, which holds it afterwards
|
|
195
|
+
* (`instance.lock.set(...)`); passing a different value later sets it
|
|
196
|
+
* again, passing the same one does not. Unset, nothing changes.
|
|
197
|
+
*/
|
|
198
|
+
lock?: EditorLock | null;
|
|
199
|
+
/**
|
|
200
|
+
* Called with the action's `id` when a person presses a button on the lock
|
|
201
|
+
* banner. The host decides what it does; an "Edit" action is answered by
|
|
202
|
+
* removing the lock.
|
|
203
|
+
*/
|
|
204
|
+
onLockAction?: (id: string) => void;
|
|
184
205
|
/**
|
|
185
206
|
* Called when the Edit | Test mode changes after mount (the canvas toolbar switch,
|
|
186
207
|
* the T shortcut, the run pill's "Open", `instance.editorMode.set`). Not called for the
|
|
@@ -228,6 +249,15 @@
|
|
|
228
249
|
onBeforeSave?: FlowDropEventHandlers['onBeforeSave'];
|
|
229
250
|
/** Called after a successful save. */
|
|
230
251
|
onAfterSave?: FlowDropEventHandlers['onAfterSave'];
|
|
252
|
+
/** Called after a refused save was saved as a copy; replaces following the copy's editor URL. */
|
|
253
|
+
onSavedAsCopy?: FlowDropEventHandlers['onSavedAsCopy'];
|
|
254
|
+
/**
|
|
255
|
+
* Called when the unsaved edits are gone for good: just before the editor
|
|
256
|
+
* follows a saved copy's editor URL (after the workflow is marked saved), or
|
|
257
|
+
* after "Discard my changes" loaded the saved version. The mount API uses it
|
|
258
|
+
* to drop the stored draft.
|
|
259
|
+
*/
|
|
260
|
+
onDiscardDraft?: () => void;
|
|
231
261
|
/** Called when a save fails. */
|
|
232
262
|
onSaveError?: FlowDropEventHandlers['onSaveError'];
|
|
233
263
|
/** Called on any API error — return true to suppress the default toast. */
|
|
@@ -292,6 +322,8 @@
|
|
|
292
322
|
configPlacement: configPlacementProp,
|
|
293
323
|
consolePlacement: consolePlacementProp,
|
|
294
324
|
mode = 'edit',
|
|
325
|
+
lock: lockProp,
|
|
326
|
+
onLockAction,
|
|
295
327
|
editorMode: editorModeProp,
|
|
296
328
|
onEditorModeChange,
|
|
297
329
|
pipelineId,
|
|
@@ -308,6 +340,8 @@
|
|
|
308
340
|
authProvider,
|
|
309
341
|
onBeforeSave,
|
|
310
342
|
onAfterSave,
|
|
343
|
+
onSavedAsCopy,
|
|
344
|
+
onDiscardDraft,
|
|
311
345
|
onSaveError,
|
|
312
346
|
onApiError,
|
|
313
347
|
onWorkflowLoad,
|
|
@@ -353,18 +387,40 @@
|
|
|
353
387
|
// read when it fires, so a changed callback prop is the one used.
|
|
354
388
|
onMount(() => fd.editorMode.onChange((mode) => onEditorModeChange?.(mode)));
|
|
355
389
|
|
|
390
|
+
// The lock: `instance.lock` holds it. The `lock` prop seeds it and sets it
|
|
391
|
+
// again only when the host passes a different value, so the prop and
|
|
392
|
+
// `instance.lock.set(...)` take turns rather than fight: the last one wins.
|
|
393
|
+
// `undefined` means "no opinion".
|
|
394
|
+
// svelte-ignore state_referenced_locally
|
|
395
|
+
let appliedLockProp = lockProp;
|
|
396
|
+
// svelte-ignore state_referenced_locally
|
|
397
|
+
if (lockProp !== undefined) fd.lock.set(lockProp);
|
|
398
|
+
$effect.pre(() => {
|
|
399
|
+
const requested = lockProp;
|
|
400
|
+
if (requested === undefined || requested === appliedLockProp) return;
|
|
401
|
+
appliedLockProp = requested;
|
|
402
|
+
untrack(() => fd.lock.set(requested));
|
|
403
|
+
});
|
|
404
|
+
onMount(() => fd.lock.onAction((id) => onLockAction?.(id)));
|
|
405
|
+
|
|
356
406
|
// `mode` is the public API; internally the canvas only cares whether editing
|
|
357
407
|
// is disabled. 'readonly' and 'locked' both disable the same interactions
|
|
358
|
-
// (see the `mode` prop JSDoc for the full matrix).
|
|
359
|
-
|
|
408
|
+
// (see the `mode` prop JSDoc for the full matrix). A lock on the editor does
|
|
409
|
+
// the same as `mode="locked"` while it lasts.
|
|
410
|
+
const effectiveMode = $derived(fd.lock.isLocked ? 'locked' : mode);
|
|
411
|
+
const canvasEditable = $derived(effectiveMode === 'edit');
|
|
412
|
+
// Save's unsaved marker follows the host's mode, not the lock: edits made
|
|
413
|
+
// before a lock arrived are still unsaved (the leave prompt and Run say so).
|
|
414
|
+
const showUnsaved = $derived(mode === 'edit' && fd.workflow.isDirty);
|
|
360
415
|
|
|
361
416
|
/**
|
|
362
|
-
* Test mode can be entered: it is offered, the
|
|
417
|
+
* Test mode can be entered: it is offered, the host's mode is `edit`, this is
|
|
363
418
|
* not a pipeline view, and the workflow is saved (the Playground runs the
|
|
364
|
-
* saved workflow's id).
|
|
419
|
+
* saved workflow's id). A lock does not remove it: a locked workflow can still
|
|
420
|
+
* be tested, the canvas just stays read-only.
|
|
365
421
|
*/
|
|
366
422
|
const testModeAvailable = $derived(
|
|
367
|
-
features.testMode &&
|
|
423
|
+
features.testMode && mode === 'edit' && !pipelineId && !!fd.workflow.current?.id
|
|
368
424
|
);
|
|
369
425
|
/** Test mode is in effect: requested, and available. */
|
|
370
426
|
const testMode = $derived(testModeAvailable && fd.editorMode.isTest);
|
|
@@ -487,6 +543,7 @@
|
|
|
487
543
|
href: '#save',
|
|
488
544
|
icon: 'mdi:file-download-outline',
|
|
489
545
|
variant: 'primary' as const,
|
|
546
|
+
disabled: fd.lock.isLocked,
|
|
490
547
|
onclick: (e: Event) => {
|
|
491
548
|
e.preventDefault();
|
|
492
549
|
saveWorkflow();
|
|
@@ -507,6 +564,7 @@
|
|
|
507
564
|
href: '#import',
|
|
508
565
|
icon: 'mdi:upload',
|
|
509
566
|
variant: 'outline' as const,
|
|
567
|
+
disabled: !canvasEditable,
|
|
510
568
|
onclick: (e: Event) => {
|
|
511
569
|
e.preventDefault();
|
|
512
570
|
fileInputRef?.click();
|
|
@@ -583,13 +641,15 @@
|
|
|
583
641
|
let endpointConfig = $state<EndpointConfig | null>(null);
|
|
584
642
|
|
|
585
643
|
/**
|
|
586
|
-
* The Edit canvas offers a Run button:
|
|
587
|
-
* supplies `onRun` or the backend has the `workflows.run`
|
|
644
|
+
* The Edit canvas offers a Run button: the host's mode is `edit`, saved, and
|
|
645
|
+
* either the host supplies `onRun` or the backend has the `workflows.run`
|
|
646
|
+
* endpoint. A lock does not remove it: a locked workflow can still be run (the
|
|
647
|
+
* saved version; `startRun` says so when there are unsaved changes).
|
|
588
648
|
*/
|
|
589
649
|
const runOffered = $derived(
|
|
590
650
|
canOfferRun({
|
|
591
651
|
runButton: features.runButton,
|
|
592
|
-
canvasEditable,
|
|
652
|
+
canvasEditable: mode === 'edit',
|
|
593
653
|
pipelineId,
|
|
594
654
|
workflowId: fd.workflow.current?.id,
|
|
595
655
|
hostCanRun: !!fd.host.current.onRun,
|
|
@@ -632,7 +692,7 @@
|
|
|
632
692
|
const result = await workflowLaunchService.launch(
|
|
633
693
|
endpointConfig,
|
|
634
694
|
workflow.id,
|
|
635
|
-
{ inputs, workflow },
|
|
695
|
+
{ inputs, workflow, origin: 'editor' },
|
|
636
696
|
authProvider
|
|
637
697
|
);
|
|
638
698
|
if (result.status === 'launched') {
|
|
@@ -656,8 +716,13 @@
|
|
|
656
716
|
runStarting = true;
|
|
657
717
|
try {
|
|
658
718
|
if (fd.workflow.isDirty) {
|
|
659
|
-
|
|
660
|
-
|
|
719
|
+
if (fd.lock.isLocked) {
|
|
720
|
+
// A locked editor cannot save: run the saved workflow and say so.
|
|
721
|
+
showInfo(mergedMessages.runButton.lockedUnsaved);
|
|
722
|
+
} else if (!(await saveWorkflow())) {
|
|
723
|
+
// The save toast already explains a failed save.
|
|
724
|
+
return;
|
|
725
|
+
}
|
|
661
726
|
}
|
|
662
727
|
const workflow = fd.workflow.current;
|
|
663
728
|
if (!workflow?.id) return;
|
|
@@ -1306,14 +1371,24 @@
|
|
|
1306
1371
|
);
|
|
1307
1372
|
|
|
1308
1373
|
async function saveWorkflow(options: { interactive?: boolean } = {}): Promise<boolean> {
|
|
1374
|
+
// A locked editor is refused inside globalSaveWorkflow, the one place that
|
|
1375
|
+
// decides it: quietly for autosave, with "nothing was saved" for a person.
|
|
1309
1376
|
// Commit any in-flight config edit so the save and its history are
|
|
1310
1377
|
// consistent (the value itself is already live in the store).
|
|
1311
1378
|
flushNodeConfigEdit();
|
|
1312
1379
|
return globalSaveWorkflow({
|
|
1313
|
-
eventHandlers: {
|
|
1380
|
+
eventHandlers: {
|
|
1381
|
+
onBeforeSave,
|
|
1382
|
+
onAfterSave,
|
|
1383
|
+
onSavedAsCopy,
|
|
1384
|
+
onSaveError,
|
|
1385
|
+
onApiError,
|
|
1386
|
+
onWorkflowLoad
|
|
1387
|
+
},
|
|
1314
1388
|
features,
|
|
1315
1389
|
instance: fd,
|
|
1316
1390
|
interactive: options.interactive,
|
|
1391
|
+
onDiscardDraft,
|
|
1317
1392
|
onMarkAsSaved: (version) => fd.workflow.markAsSaved(version)
|
|
1318
1393
|
});
|
|
1319
1394
|
}
|
|
@@ -1334,8 +1409,12 @@
|
|
|
1334
1409
|
* Reads the selected file, validates its structure, and loads it into the workflow store.
|
|
1335
1410
|
*/
|
|
1336
1411
|
function importWorkflow(file: File): void {
|
|
1412
|
+
// Import replaces the workflow: not while it is locked or read-only.
|
|
1413
|
+
if (!canvasEditable) return;
|
|
1337
1414
|
const reader = new FileReader();
|
|
1338
1415
|
reader.onload = (event) => {
|
|
1416
|
+
// A lock or read-only mode may have arrived while the file was being read.
|
|
1417
|
+
if (!canvasEditable) return;
|
|
1339
1418
|
try {
|
|
1340
1419
|
const text = event.target?.result;
|
|
1341
1420
|
if (typeof text !== 'string') {
|
|
@@ -1914,34 +1993,41 @@
|
|
|
1914
1993
|
-->
|
|
1915
1994
|
|
|
1916
1995
|
{#snippet nodeConfigFormEl(node: WorkflowNode)}
|
|
1917
|
-
<
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1996
|
+
<LockFence>
|
|
1997
|
+
<ConfigForm
|
|
1998
|
+
{authProvider}
|
|
1999
|
+
{node}
|
|
2000
|
+
commitMode="live"
|
|
2001
|
+
workflowId={fd.workflow.current?.id}
|
|
2002
|
+
workflowNodes={fd.workflow.current?.nodes}
|
|
2003
|
+
workflowEdges={fd.workflow.current?.edges}
|
|
2004
|
+
onExternalEdit={externalEditForConfig}
|
|
2005
|
+
onChange={(updatedConfig, meta) => {
|
|
2006
|
+
// A locked workflow takes no edits: the store would refuse them and the canvas must not move.
|
|
2007
|
+
if (!node.id || fd.lock.isLocked) return;
|
|
2008
|
+
const updatedData = { ...node.data, config: updatedConfig };
|
|
2009
|
+
|
|
2010
|
+
// Blur / end-of-session: commit the coalesced undo step + fire the
|
|
2011
|
+
// change event once, and refresh edges once.
|
|
2012
|
+
if (meta?.commit) {
|
|
2013
|
+
pendingConfigNodeId = node.id;
|
|
2014
|
+
flushNodeConfigEdit();
|
|
2015
|
+
return;
|
|
2016
|
+
}
|
|
1936
2017
|
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
2018
|
+
// Live edit (every change): update the store cheaply — no history clone,
|
|
2019
|
+
// no external event; both are deferred to the session flush above. Also
|
|
2020
|
+
// reflect the change on the canvas immediately (e.g. nodeType changes).
|
|
2021
|
+
// The canvas mirrors the store, so it follows only an edit the store took.
|
|
2022
|
+
pendingConfigNodeId = node.id;
|
|
2023
|
+
if (
|
|
2024
|
+
fd.workflow.updateNodeConfig(node.id, { data: updatedData }, { fieldKey: meta?.fieldKey })
|
|
2025
|
+
) {
|
|
2026
|
+
workflowEditorRef?.updateNodeData(node.id, updatedData);
|
|
2027
|
+
}
|
|
2028
|
+
}}
|
|
2029
|
+
/>
|
|
2030
|
+
</LockFence>
|
|
1945
2031
|
{/snippet}
|
|
1946
2032
|
|
|
1947
2033
|
<!-- Last run of a failed node: take the run to the Assistant -->
|
|
@@ -1979,49 +2065,52 @@
|
|
|
1979
2065
|
{/snippet}
|
|
1980
2066
|
|
|
1981
2067
|
{#snippet workflowConfigFormEl()}
|
|
1982
|
-
<
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
const
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2068
|
+
<LockFence>
|
|
2069
|
+
<ConfigForm
|
|
2070
|
+
{authProvider}
|
|
2071
|
+
schema={workflowConfigSchema}
|
|
2072
|
+
values={workflowConfigValues}
|
|
2073
|
+
commitMode="blur"
|
|
2074
|
+
onChange={(config) => {
|
|
2075
|
+
if (fd.lock.isLocked) return;
|
|
2076
|
+
// Sync workflow settings changes immediately on field blur
|
|
2077
|
+
const wf = fd.workflow.current;
|
|
2078
|
+
if (wf) {
|
|
2079
|
+
const currentFormat = wf.metadata?.format || DEFAULT_WORKFLOW_FORMAT;
|
|
2080
|
+
// Fall back to the CURRENT format, not the default: when the field is
|
|
2081
|
+
// hidden (host supports one format) config.format is absent, and
|
|
2082
|
+
// applying name/description must not silently rewrite the format.
|
|
2083
|
+
const newFormat = (config.format as string) || currentFormat;
|
|
2084
|
+
|
|
2085
|
+
// Warn about incompatible nodes when format changes
|
|
2086
|
+
if (newFormat !== currentFormat) {
|
|
2087
|
+
const incompatibleNodes = wf.nodes?.filter((node) => {
|
|
2088
|
+
const formats = node.data?.metadata?.formats;
|
|
2089
|
+
return formats && formats.length > 0 && !formats.includes(newFormat);
|
|
2090
|
+
});
|
|
2091
|
+
if (incompatibleNodes && incompatibleNodes.length > 0) {
|
|
2092
|
+
logger.warn(
|
|
2093
|
+
`Format changed to '${newFormat}'. ${incompatibleNodes.length} node(s) are not compatible with this format and may not export correctly:`,
|
|
2094
|
+
incompatibleNodes.map((n) => n.data?.label || n.type)
|
|
2095
|
+
);
|
|
2096
|
+
}
|
|
2008
2097
|
}
|
|
2009
|
-
}
|
|
2010
2098
|
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2099
|
+
// Extract built-in fields; everything else belongs in workflow.config
|
|
2100
|
+
const { name, description, format: _format, ...customConfig } = config;
|
|
2101
|
+
fd.workflow.batchUpdate({
|
|
2102
|
+
name: name as string,
|
|
2103
|
+
description: description as string | undefined,
|
|
2104
|
+
metadata: {
|
|
2105
|
+
...wf.metadata,
|
|
2106
|
+
format: newFormat
|
|
2107
|
+
},
|
|
2108
|
+
...(workflowSettingsSchema && { config: customConfig as Record<string, unknown> })
|
|
2109
|
+
});
|
|
2110
|
+
}
|
|
2111
|
+
}}
|
|
2112
|
+
/>
|
|
2113
|
+
</LockFence>
|
|
2025
2114
|
{/snippet}
|
|
2026
2115
|
|
|
2027
2116
|
<!--
|
|
@@ -2031,17 +2120,22 @@
|
|
|
2031
2120
|
mutation.
|
|
2032
2121
|
-->
|
|
2033
2122
|
{#snippet workflowInterfaceEl()}
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2123
|
+
<LockFence>
|
|
2124
|
+
{#if fd.workflow.current}
|
|
2125
|
+
<WorkflowInterfaceEditor
|
|
2126
|
+
workflow={fd.workflow.current}
|
|
2127
|
+
dataTypes={fd.portCompatibility.getEnabledDataTypes()}
|
|
2128
|
+
checker={fd.portCompatibility}
|
|
2129
|
+
onChange={(next, edit) => {
|
|
2130
|
+
if (fd.lock.isLocked) return;
|
|
2131
|
+
fd.workflow.editInterface(next, edit);
|
|
2132
|
+
}}
|
|
2133
|
+
onOpenPlaygroundSettings={fd.workflow.current.playground !== undefined
|
|
2134
|
+
? () => (workflowSettingsTab = 'playground')
|
|
2135
|
+
: undefined}
|
|
2136
|
+
/>
|
|
2137
|
+
{/if}
|
|
2138
|
+
</LockFence>
|
|
2045
2139
|
{/snippet}
|
|
2046
2140
|
|
|
2047
2141
|
<!--
|
|
@@ -2051,20 +2145,25 @@
|
|
|
2051
2145
|
mark the workflow dirty and are saved with it.
|
|
2052
2146
|
-->
|
|
2053
2147
|
{#snippet workflowPlaygroundEl()}
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2148
|
+
<LockFence>
|
|
2149
|
+
{#if fd.workflow.current}
|
|
2150
|
+
<WorkflowPlaygroundSettings
|
|
2151
|
+
workflow={fd.workflow.current}
|
|
2152
|
+
onChange={(next) => {
|
|
2153
|
+
if (fd.lock.isLocked) return;
|
|
2154
|
+
fd.workflow.batchUpdate({ playground: next });
|
|
2155
|
+
}}
|
|
2156
|
+
onMoveTurns={(chat) => {
|
|
2157
|
+
const current = fd.workflow.current;
|
|
2158
|
+
if (!current || fd.lock.isLocked) return;
|
|
2159
|
+
fd.workflow.batchUpdate({
|
|
2160
|
+
playground: withPlaygroundChat(current.playground, chat),
|
|
2161
|
+
interface: withoutInterfaceTurns(current.interface)
|
|
2162
|
+
});
|
|
2163
|
+
}}
|
|
2164
|
+
/>
|
|
2165
|
+
{/if}
|
|
2166
|
+
</LockFence>
|
|
2068
2167
|
{/snippet}
|
|
2069
2168
|
|
|
2070
2169
|
<!--
|
|
@@ -2278,7 +2377,11 @@
|
|
|
2278
2377
|
{branding}
|
|
2279
2378
|
end={navbarEnd}
|
|
2280
2379
|
saveShortcut
|
|
2281
|
-
|
|
2380
|
+
onDisabledSave={() => {
|
|
2381
|
+
// Save is disabled by the lock: saving says so ("nothing was saved").
|
|
2382
|
+
if (fd.lock.isLocked) void saveWorkflow();
|
|
2383
|
+
}}
|
|
2384
|
+
dirty={showUnsaved}
|
|
2282
2385
|
onWorkflowSettings={toggleWorkflowSettings}
|
|
2283
2386
|
status={doctorStatus}
|
|
2284
2387
|
workflowSettingsOpen={isWorkflowSettingsOpen}
|
|
@@ -11,6 +11,7 @@ import type { FlowDropInstance } from '../stores/instanceContainer.svelte.js';
|
|
|
11
11
|
import type { SettingsCategory, SurfacePlacement } from '../types/settings.js';
|
|
12
12
|
import type { EditorPlaygroundConfig } from '../types/playground.js';
|
|
13
13
|
import type { EditorMode } from '../stores/editorModeStore.svelte.js';
|
|
14
|
+
import type { EditorLock } from '../types/lock.js';
|
|
14
15
|
import type { MessagesOverride } from '../messages/index.js';
|
|
15
16
|
/**
|
|
16
17
|
* Configuration props for runtime customization
|
|
@@ -79,6 +80,25 @@ interface Props {
|
|
|
79
80
|
* @default 'edit'
|
|
80
81
|
*/
|
|
81
82
|
editorMode?: EditorMode;
|
|
83
|
+
/**
|
|
84
|
+
* Lock the editor: the workflow becomes read-only and a banner above the
|
|
85
|
+
* canvas lists the `reasons` and offers the `actions` (buttons the host
|
|
86
|
+
* answers through `onLockAction`). While locked, nothing can change the
|
|
87
|
+
* workflow (canvas, config panels, console, shortcuts, undo) and Save is
|
|
88
|
+
* disabled (a host's own Save action stays enabled; pressing it saves nothing
|
|
89
|
+
* and says the editor is locked); selecting, panning, zooming and inspecting
|
|
90
|
+
* still work. `null`
|
|
91
|
+
* removes the lock. Seeds `instance.lock`, which holds it afterwards
|
|
92
|
+
* (`instance.lock.set(...)`); passing a different value later sets it
|
|
93
|
+
* again, passing the same one does not. Unset, nothing changes.
|
|
94
|
+
*/
|
|
95
|
+
lock?: EditorLock | null;
|
|
96
|
+
/**
|
|
97
|
+
* Called with the action's `id` when a person presses a button on the lock
|
|
98
|
+
* banner. The host decides what it does; an "Edit" action is answered by
|
|
99
|
+
* removing the lock.
|
|
100
|
+
*/
|
|
101
|
+
onLockAction?: (id: string) => void;
|
|
82
102
|
/**
|
|
83
103
|
* Called when the Edit | Test mode changes after mount (the canvas toolbar switch,
|
|
84
104
|
* the T shortcut, the run pill's "Open", `instance.editorMode.set`). Not called for the
|
|
@@ -126,6 +146,15 @@ interface Props {
|
|
|
126
146
|
onBeforeSave?: FlowDropEventHandlers['onBeforeSave'];
|
|
127
147
|
/** Called after a successful save. */
|
|
128
148
|
onAfterSave?: FlowDropEventHandlers['onAfterSave'];
|
|
149
|
+
/** Called after a refused save was saved as a copy; replaces following the copy's editor URL. */
|
|
150
|
+
onSavedAsCopy?: FlowDropEventHandlers['onSavedAsCopy'];
|
|
151
|
+
/**
|
|
152
|
+
* Called when the unsaved edits are gone for good: just before the editor
|
|
153
|
+
* follows a saved copy's editor URL (after the workflow is marked saved), or
|
|
154
|
+
* after "Discard my changes" loaded the saved version. The mount API uses it
|
|
155
|
+
* to drop the stored draft.
|
|
156
|
+
*/
|
|
157
|
+
onDiscardDraft?: () => void;
|
|
129
158
|
/** Called when a save fails. */
|
|
130
159
|
onSaveError?: FlowDropEventHandlers['onSaveError'];
|
|
131
160
|
/** Called on any API error — return true to suppress the default toast. */
|