@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
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,101 @@ 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
|
+
|
|
23
|
+
## [2.17.0] - 2026-11-04
|
|
24
|
+
|
|
25
|
+
### Added
|
|
26
|
+
|
|
27
|
+
- Save asks before a change that breaks or switches off what uses the workflow, listing what is affected and asking to save anyway (needs the new optional `workflows.impact` endpoint). The dialog opens on Cancel and is a native modal dialog.
|
|
28
|
+
|
|
29
|
+
- **Field schema for every editor setting.** `SETTINGS_FIELD_SCHEMA` (and the `SettingsFieldSchema` type),
|
|
30
|
+
exported from `@flowdrop/flowdrop/settings`, describes each setting: its type, a short label and the
|
|
31
|
+
values it allows.
|
|
32
|
+
|
|
33
|
+
- Publishing a generic port (data, value, ...) suggests the id, title and type from the node instead of data, data_2 and Mixed.
|
|
34
|
+
|
|
35
|
+
- New interface rows open their Title, Description, Required and Example fields; Mixed and untitled inputs are flagged.
|
|
36
|
+
|
|
37
|
+
- Toasts accept `actions` (several follow-up buttons); a toast with actions stays until it is closed.
|
|
38
|
+
|
|
39
|
+
- The navbar's main action (Save) shows a dot and says 'Unsaved changes' while the workflow has changes that are not saved.
|
|
40
|
+
|
|
41
|
+
- mountFlowDropApp asks the browser to confirm leaving the page while there are unsaved changes (`features.confirmUnsavedLeave`, on by default).
|
|
42
|
+
|
|
43
|
+
- When a stored draft differs from the loaded workflow, the editor offers Restore or Discard (and says when the workflow was saved after the draft).
|
|
44
|
+
|
|
45
|
+
- A compare dialog lists the steps, wires, interface and chat settings that differ between two versions of a workflow.
|
|
46
|
+
|
|
47
|
+
- A save refused with 409 CONFLICT shows Keep mine / Load theirs / Compare instead of a plain error.
|
|
48
|
+
|
|
49
|
+
- Edit mode has a Run button (`features.runButton`, on with the default endpoint config; `false` turns it off): it saves unsaved changes first, then starts the workflow through `host.onRun` or the `workflows.run` endpoint and shows the run on the canvas.
|
|
50
|
+
|
|
51
|
+
- Run opens a form built from the workflow interface's inputs and remembers the last values for the page.
|
|
52
|
+
|
|
53
|
+
- The run pill links 'Open run' when `features.adminLinks.run` is set; a queued run says it waits for the site's queue.
|
|
54
|
+
|
|
55
|
+
- Doctor remedies with `params.automatic: true` are applied by the editor when their problem first appears after load, as one undoable edit with an Undo toast.
|
|
56
|
+
|
|
57
|
+
- The Problems indicator shows 'Checking...' for a slow check and 'Check unavailable' with Retry when the check fails, instead of staying blank.
|
|
58
|
+
|
|
59
|
+
- The editor offers a 'Skip to the canvas' link, and mountFlowDropApp accepts navbarTitleLevel to render the title as the page's H1.
|
|
60
|
+
|
|
61
|
+
- Node search in the palette and the swap picker ranks exact name and keyword matches first.
|
|
62
|
+
|
|
63
|
+
- A palette item can be added by click or Enter: next to the selected node, else in the middle of the view.
|
|
64
|
+
|
|
65
|
+
- Port pins can be reached with Tab; Enter opens the port menu with 'Connect to…'.
|
|
66
|
+
|
|
67
|
+
### Fixed
|
|
68
|
+
|
|
69
|
+
- Drafts carry `metadata.baseRevision`, include interface and Playground edits, and are removed when the workflow is saved; `draftFingerprint` is exported.
|
|
70
|
+
|
|
71
|
+
- Run asks for a workflow's inputs also when it has no Playground settings.
|
|
72
|
+
|
|
73
|
+
- Autosave never opens the impact question: a save that needs an answer is skipped, the workflow stays unsaved, and an info toast says once that autosave waits for Save (no further impact request until the workflow changes). A 401 or 403 from the impact route counts as no impact check, like 404 and 405.
|
|
74
|
+
|
|
75
|
+
- Doctor's Undo only undoes the automatic fix, and its toast goes once the history moves on. A reload never applies an automatic fix again.
|
|
76
|
+
|
|
77
|
+
- The save conflict toast follows `showToasts` and `onApiError`.
|
|
78
|
+
|
|
79
|
+
- Host `messages` reach the impact dialog, the draft offer, the conflict toast and the Doctor toast.
|
|
80
|
+
|
|
81
|
+
- A stored draft stays while its Restore or Discard offer is open, however long the offer waits.
|
|
82
|
+
|
|
83
|
+
- Port pins are Tab stops only on the selected node, not on every node; the palette adds one node per key press (Enter on key down, Space on key up).
|
|
84
|
+
|
|
85
|
+
- A generated interface id keeps accented letters as plain letters (`Übersetzung` gives `ubersetzung`).
|
|
86
|
+
|
|
87
|
+
- "Connect to…" lists trigger pins under "Other types" when connecting a data port, and data ports when connecting a trigger pin.
|
|
88
|
+
|
|
89
|
+
- Port and interface pickers show each node's own title, and add the node id when two nodes share a name.
|
|
90
|
+
|
|
91
|
+
- An edit made while a save is in flight stays unsaved instead of being marked saved. `WorkflowStore.markAsSaved(version?)` takes the edit version the save was taken at, and `globalSaveWorkflow`'s `onMarkAsSaved` receives it.
|
|
92
|
+
|
|
93
|
+
- A second save while one is in flight joins it instead of sending the old revision again (which the server refused as a conflict). A Save pressed during an autosave that is waiting for the impact answer asks the question itself.
|
|
94
|
+
|
|
95
|
+
- The impact question comes before `onBeforeSave`, so a cancelled question never leaves a host with `onBeforeSave` and no outcome hook; Cmd+S or autosave while the question is open no longer moves the focus out of it.
|
|
96
|
+
|
|
97
|
+
- The save conflict choices stay on screen after Compare is cancelled or loading the saved version fails (toast actions accept `keepOpen`); the compare dialog heads its shared list 'Different in the two versions' and names steps by their title.
|
|
98
|
+
|
|
99
|
+
- The Run form and the compare dialog take the editor's skin; the Run form no longer closes when a text selection ends over the backdrop.
|
|
100
|
+
|
|
101
|
+
- The Problems indicator announces 'Checking...' and 'Check unavailable' to screen readers; a new automatic fix replaces the previous Undo toast; an impact question closes when its editor is destroyed.
|
|
102
|
+
|
|
8
103
|
## [2.16.0] - 2026-10-24
|
|
9
104
|
|
|
10
105
|
### Added
|
package/README.md
CHANGED
|
@@ -283,12 +283,17 @@ FLOWDROP_API_BASE_URL=http://your-backend/api node build
|
|
|
283
283
|
|
|
284
284
|
Runtime configuration means you build once and deploy to staging, production, or anywhere else with just environment variables.
|
|
285
285
|
|
|
286
|
+
## Specification
|
|
287
|
+
|
|
288
|
+
The editor implements the [FlowDrop Workflow Specification](https://flowdrop.io/spec/), version 1.0: the rules a FlowDrop workflow obeys, stated independently of any one implementation. The specification has 386 numbered rules (217 core, 167 extended, 2 optional) covering how a workflow is written, stored, validated and executed, with rulings for the hard cases and conformance fixtures you can run against your own backend. Rules are also published as [machine-readable JSON](https://flowdrop.io/spec/rules.json), and the source is on [GitHub](https://github.com/flowdrop-io/flowdrop-spec).
|
|
289
|
+
|
|
286
290
|
## Documentation
|
|
287
291
|
|
|
288
292
|
| Resource | Description |
|
|
289
293
|
| -------------------------------------------------------------------------------------------- | ------------------------ |
|
|
290
294
|
| [QUICK_START.md](https://flowdrop.mintlify.app/docs/quickstart) | Get running in 5 minutes |
|
|
291
|
-
| [API Documentation](https://flowdrop.
|
|
295
|
+
| [API Documentation](https://flowdrop.io/docs/api/) | REST API specification |
|
|
296
|
+
| [Workflow Specification](https://flowdrop.io/spec/) | Rules for workflows |
|
|
292
297
|
| [CHANGELOG.md](https://github.com/flowdrop-io/flowdrop/blob/main/libs/flowdrop/CHANGELOG.md) | Version history |
|
|
293
298
|
|
|
294
299
|
## Development
|
|
@@ -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.
|