@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.
Files changed (77) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/api/enhanced-client.d.ts +3 -1
  3. package/dist/api/enhanced-client.js +4 -2
  4. package/dist/commands/executor.js +9 -0
  5. package/dist/commands/storeIntegration.svelte.js +6 -0
  6. package/dist/commands/types.d.ts +8 -0
  7. package/dist/components/App.svelte +209 -106
  8. package/dist/components/App.svelte.d.ts +29 -0
  9. package/dist/components/FlowDropZone.svelte +7 -1
  10. package/dist/components/FlowDropZone.svelte.d.ts +5 -0
  11. package/dist/components/ImpactConfirm.svelte +246 -33
  12. package/dist/components/ImpactConfirm.svelte.d.ts +13 -3
  13. package/dist/components/Input.svelte +8 -2
  14. package/dist/components/LockBanner.svelte +76 -0
  15. package/dist/components/LockBanner.svelte.d.ts +14 -0
  16. package/dist/components/LockFence.svelte +33 -0
  17. package/dist/components/LockFence.svelte.d.ts +19 -0
  18. package/dist/components/Navbar.svelte +35 -6
  19. package/dist/components/Navbar.svelte.d.ts +6 -0
  20. package/dist/components/RunBar.svelte +16 -4
  21. package/dist/components/Textarea.svelte +7 -1
  22. package/dist/components/WorkflowEditor.svelte +32 -9
  23. package/dist/components/WorkflowInterfaceEditor.svelte +3 -0
  24. package/dist/components/WorkflowInterfaceEntryCard.svelte +21 -4
  25. package/dist/components/WorkflowPlaygroundSettings.svelte +9 -1
  26. package/dist/components/form/FieldFactory.svelte +13 -6
  27. package/dist/components/form/FormArray.svelte +0 -1
  28. package/dist/components/form/FormArrayRows.svelte +4 -4
  29. package/dist/components/form/FormCodeEditor.svelte +18 -2
  30. package/dist/components/form/FormMarkdownEditor.svelte +22 -8
  31. package/dist/components/form/FormTemplateEditor.svelte +17 -1
  32. package/dist/components/form/readOnly.d.ts +13 -0
  33. package/dist/components/form/readOnly.js +18 -0
  34. package/dist/components/nodes/CaptionNode.svelte +1 -0
  35. package/dist/components/primitives/Checkbox.svelte +5 -1
  36. package/dist/components/primitives/Select.svelte +6 -1
  37. package/dist/components/primitives/Switch.svelte +5 -1
  38. package/dist/editor/index.d.ts +1 -0
  39. package/dist/index.d.ts +2 -1
  40. package/dist/messages/defaults.d.ts +45 -0
  41. package/dist/messages/defaults.js +51 -3
  42. package/dist/openapi/v1/openapi.yaml +492 -0
  43. package/dist/registry/nodeComponentRegistry.d.ts +5 -0
  44. package/dist/schemas/v1/workflow.schema.json +2 -0
  45. package/dist/services/globalSave.d.ts +17 -0
  46. package/dist/services/globalSave.js +166 -6
  47. package/dist/services/impactGate.d.ts +7 -3
  48. package/dist/services/impactGate.js +9 -7
  49. package/dist/services/impactService.d.ts +18 -1
  50. package/dist/services/impactService.js +93 -7
  51. package/dist/services/runsService.d.ts +9 -0
  52. package/dist/services/runsService.js +13 -0
  53. package/dist/services/workflowLaunchService.d.ts +6 -0
  54. package/dist/services/workflowLaunchService.js +2 -0
  55. package/dist/stores/historyStore.svelte.d.ts +12 -2
  56. package/dist/stores/historyStore.svelte.js +25 -2
  57. package/dist/stores/instanceContainer.svelte.d.ts +7 -0
  58. package/dist/stores/instanceContainer.svelte.js +10 -0
  59. package/dist/stores/lockStore.svelte.d.ts +39 -0
  60. package/dist/stores/lockStore.svelte.js +109 -0
  61. package/dist/stores/runController.svelte.d.ts +2 -0
  62. package/dist/stores/runController.svelte.js +27 -11
  63. package/dist/stores/workflowStore.svelte.d.ts +7 -1
  64. package/dist/stores/workflowStore.svelte.js +41 -13
  65. package/dist/styles/base.css +6 -0
  66. package/dist/svelte-app.d.ts +31 -0
  67. package/dist/svelte-app.js +110 -26
  68. package/dist/types/events.d.ts +17 -0
  69. package/dist/types/impact.d.ts +52 -0
  70. package/dist/types/lock.d.ts +35 -0
  71. package/dist/types/lock.js +13 -0
  72. package/dist/types/navbar.d.ts +6 -0
  73. package/dist/utils/links.d.ts +29 -0
  74. package/dist/utils/links.js +63 -0
  75. package/dist/webmcp/runtime.js +16 -3
  76. package/dist/webmcp/types.d.ts +11 -1
  77. package/package.json +1 -1
@@ -73,6 +73,12 @@
73
73
  * it in the menu. Off by default: a host page may have its own Save shortcut.
74
74
  */
75
75
  saveShortcut?: boolean;
76
+ /**
77
+ * Called when Ctrl/Cmd+S is pressed (with `saveShortcut`) while the first
78
+ * action (Save) is `disabled`. The key is still taken, so the browser's own
79
+ * Save Page does not open; use this to say why nothing was saved.
80
+ */
81
+ onDisabledSave?: () => void;
76
82
  /**
77
83
  * Drawn in the action row before the Save button: the Problems indicator.
78
84
  * Renders nothing of its own, so an empty snippet leaves no gap.
@@ -97,6 +103,7 @@
97
103
  onWorkflowSettings,
98
104
  workflowSettingsOpen = false,
99
105
  saveShortcut = false,
106
+ onDisabledSave,
100
107
  status,
101
108
  dirty = false
102
109
  }: Props = $props();
@@ -183,6 +190,13 @@
183
190
  }
184
191
  const save = taskActions[0];
185
192
  if (!save?.onclick) return;
193
+ // Disabled (for example locked): the key still belongs to the editor, so
194
+ // the browser's Save Page does not open in its place.
195
+ if (save.disabled) {
196
+ event.preventDefault();
197
+ onDisabledSave?.();
198
+ return;
199
+ }
186
200
  event.preventDefault();
187
201
  save.onclick(event);
188
202
  }
@@ -190,6 +204,16 @@
190
204
  return () => window.removeEventListener('keydown', onKeydown);
191
205
  });
192
206
 
207
+ /** Run an action's handler, unless it is disabled (then the link goes nowhere). */
208
+ function run(action: NavbarAction, event: Event, after?: () => void): void {
209
+ if (action.disabled) {
210
+ event.preventDefault();
211
+ return;
212
+ }
213
+ action.onclick?.(event);
214
+ after?.();
215
+ }
216
+
193
217
  // Cmd/Ctrl+, opens the full settings dialog, as in most desktop apps.
194
218
  $effect(() => {
195
219
  if (!showSettings) return;
@@ -216,10 +240,8 @@
216
240
  href={action.href}
217
241
  role="menuitem"
218
242
  class="flowdrop-navbar__dropdown-item"
219
- onclick={(e) => {
220
- action.onclick?.(e);
221
- close();
222
- }}
243
+ aria-disabled={action.disabled ? 'true' : undefined}
244
+ onclick={(e) => run(action, e, close)}
223
245
  target={action.external ? '_blank' : undefined}
224
246
  rel={action.external ? 'noopener noreferrer' : undefined}
225
247
  >
@@ -364,7 +386,8 @@
364
386
  class="flowdrop-navbar__action flowdrop-navbar__action--{action.variant || 'primary'}"
365
387
  data-dirty={unsaved ? 'true' : undefined}
366
388
  title={unsaved ? `${action.label}, ${nav.unsavedChanges}` : undefined}
367
- onclick={action.onclick}
389
+ aria-disabled={action.disabled ? 'true' : undefined}
390
+ onclick={(e) => run(action, e)}
368
391
  target={action.external ? '_blank' : undefined}
369
392
  rel={action.external ? 'noopener noreferrer' : undefined}
370
393
  >
@@ -392,7 +415,8 @@
392
415
  'primary'}"
393
416
  data-dirty={dirty ? 'true' : undefined}
394
417
  title={dirty ? `${primaryAction.label}, ${nav.unsavedChanges}` : undefined}
395
- onclick={primaryAction.onclick}
418
+ aria-disabled={primaryAction.disabled ? 'true' : undefined}
419
+ onclick={(e) => run(primaryAction, e)}
396
420
  target={primaryAction.external ? '_blank' : undefined}
397
421
  rel={primaryAction.external ? 'noopener noreferrer' : undefined}
398
422
  >
@@ -1026,6 +1050,11 @@
1026
1050
  background-color: var(--fd-muted);
1027
1051
  }
1028
1052
 
1053
+ a[aria-disabled='true'] {
1054
+ opacity: 0.5;
1055
+ cursor: not-allowed;
1056
+ }
1057
+
1029
1058
  .flowdrop-navbar__action {
1030
1059
  display: flex;
1031
1060
  align-items: center;
@@ -41,6 +41,12 @@ interface Props {
41
41
  * it in the menu. Off by default: a host page may have its own Save shortcut.
42
42
  */
43
43
  saveShortcut?: boolean;
44
+ /**
45
+ * Called when Ctrl/Cmd+S is pressed (with `saveShortcut`) while the first
46
+ * action (Save) is `disabled`. The key is still taken, so the browser's own
47
+ * Save Page does not open; use this to say why nothing was saved.
48
+ */
49
+ onDisabledSave?: () => void;
44
50
  /**
45
51
  * Drawn in the action row before the Save button: the Problems indicator.
46
52
  * Renders nothing of its own, so an empty snippet leaves no gap.
@@ -72,8 +72,20 @@
72
72
  /** Test mode shows the pill only while the run is live. */
73
73
  const visible = $derived(mode === 'test' ? live : status !== null);
74
74
 
75
- const statusLabel = $derived(status ? msgs[status] : '');
76
- const announcement = $derived(status ? msgs.announce[status] : '');
75
+ const statusLabel = $derived(
76
+ status === 'running' && run?.waitingForWorker
77
+ ? msgs.waitingForWorker
78
+ : status
79
+ ? msgs[status]
80
+ : ''
81
+ );
82
+ const announcement = $derived(
83
+ status === 'running' && run?.waitingForWorker
84
+ ? msgs.announce.waitingForWorker
85
+ : status
86
+ ? msgs.announce[status]
87
+ : ''
88
+ );
77
89
 
78
90
  // The bar stays put while it is hovered or holds focus: a person reading it
79
91
  // or about to press Open is not made to chase it.
@@ -145,10 +157,10 @@
145
157
  <a
146
158
  class="flowdrop-run-bar__link"
147
159
  href={runLink}
148
- title={msgs.openRunTitle}
160
+ title={status === 'done' ? msgs.viewResultTitle : msgs.openRunTitle}
149
161
  data-testid="run-bar-open-run"
150
162
  >
151
- {msgs.openRun}
163
+ {status === 'done' ? msgs.viewResult : msgs.openRun}
152
164
  </a>
153
165
  {/if}
154
166
  {#if live}
@@ -11,6 +11,7 @@
11
11
 
12
12
  <script lang="ts">
13
13
  import type { HTMLTextareaAttributes } from 'svelte/elements';
14
+ import { useFormReadOnly } from './form/readOnly.js';
14
15
 
15
16
  interface Props extends HTMLTextareaAttributes {
16
17
  /** Size — `md` is the base; `sm`/`lg` add a modifier */
@@ -23,6 +24,11 @@
23
24
 
24
25
  let { size = 'md', invalid = false, class: className = '', ...rest }: Props = $props();
25
26
 
27
+ const formReadOnly = useFormReadOnly();
28
+ // A read-only form (a locked editor) keeps the value readable: it can be
29
+ // focused, selected and copied, just not changed. Hence readonly, not disabled.
30
+ const isReadOnly = $derived(Boolean(rest.readonly) || formReadOnly());
31
+
26
32
  const textareaClass = $derived(
27
33
  [
28
34
  'flowdrop-input',
@@ -36,4 +42,4 @@
36
42
  );
37
43
  </script>
38
44
 
39
- <textarea class={textareaClass} {...rest}></textarea>
45
+ <textarea class={textareaClass} {...rest} readonly={isReadOnly}></textarea>
@@ -22,6 +22,7 @@
22
22
  } from '../stores/settingsStore.svelte.js';
23
23
  import type { WorkflowNode as WorkflowNodeType, Workflow, WorkflowEdge } from '../types/index.js';
24
24
  import CanvasBanner from './CanvasBanner.svelte';
25
+ import LockBanner from './LockBanner.svelte';
25
26
  import CanvasToolbar from './CanvasToolbar.svelte';
26
27
  import CanvasController from './CanvasController.svelte';
27
28
  import StraightGuides from './StraightGuides.svelte';
@@ -247,8 +248,11 @@
247
248
  });
248
249
 
249
250
  // `mode` is the public API; the canvas only needs to know whether editing is
250
- // enabled. 'readonly' and 'locked' both disable interaction identically.
251
- const canvasEditable = $derived((props.mode ?? 'edit') === 'edit');
251
+ // enabled. 'readonly' and 'locked' both disable interaction identically, and
252
+ // so does a lock on the instance (`fd.lock`), even when this editor is mounted
253
+ // on its own without App.
254
+ const hostEditable = $derived((props.mode ?? 'edit') === 'edit');
255
+ const canvasEditable = $derived(hostEditable && !fd.lock.isLocked);
252
256
 
253
257
  // Canvas grid pattern, supplied by the active theme's config.canvas.grid
254
258
  // (App passes it down). BackgroundVariant's enum values are the same strings
@@ -867,6 +871,8 @@
867
871
  options: { history?: boolean; emptyLabel?: boolean } = {}
868
872
  ): { id: string | null; done: Promise<void> } {
869
873
  const { history = true, emptyLabel = false } = options;
874
+ // The store refuses the node when locked; the canvas must not show it either.
875
+ if (!canvasEditable) return { id: null, done: Promise.resolve() };
870
876
  // The machine's `dropping` state is what holds the store -> canvas sync
871
877
  // off while a node is added (see its permissions), so every placement
872
878
  // goes through it, not only a sidebar drop.
@@ -1006,11 +1012,12 @@
1006
1012
  function handleInlineCommit(id: string, text: string | null): void {
1007
1013
  const node = flowNodes.find((n) => n.id === id);
1008
1014
  const isNew = pendingNewIds.delete(id);
1009
- if (!node || !canvasEditable) {
1010
- // Gone (undo, workflow switch) or no longer editable: a pending node must not linger.
1011
- if (node && isNew) removeNode(id);
1012
- return;
1013
- }
1015
+ // Gone (undo, workflow switch).
1016
+ if (!node) return;
1017
+ // A locked store refuses every change, so the canvas must not make one
1018
+ // either: the node stays as it is. A read-only editor is not locked: the
1019
+ // edit that was in progress ends like any other.
1020
+ if (fd.workflow.locked) return;
1014
1021
 
1015
1022
  const { outcome, label } = decideInlineCommit(text, node.data.label ?? '', isNew);
1016
1023
  if (outcome === 'none') return;
@@ -1521,6 +1528,11 @@
1521
1528
  return true;
1522
1529
  }
1523
1530
 
1531
+ // A name being typed beside a port is saved when the lock arrives, while the
1532
+ // store still accepts it. (A node's own label is saved by the caption's blur,
1533
+ // which the lock store triggers right after.)
1534
+ $effect(() => fd.lock.onBeforeLock(() => tagEdit && commitTagEdit()));
1535
+
1524
1536
  // A name being typed never outlives edit mode, its workflow, or its port (undo).
1525
1537
  $effect(() => {
1526
1538
  if (!canvasEditable) tagEdit = null;
@@ -1617,8 +1629,12 @@
1617
1629
  * loads it into the workflow store. Shows a toast on validation failure or read error.
1618
1630
  */
1619
1631
  function handleWorkflowFileDrop(file: File): void {
1632
+ // `initialize` ignores the lock on purpose, so a drop must check it itself:
1633
+ // now, and again when the file has been read (a lock may arrive meanwhile).
1634
+ if (!canvasEditable) return;
1620
1635
  const reader = new FileReader();
1621
1636
  reader.onload = (event) => {
1637
+ if (!canvasEditable) return;
1622
1638
  try {
1623
1639
  const text = event.target?.result;
1624
1640
  if (typeof text !== 'string') {
@@ -1891,6 +1907,9 @@
1891
1907
  return;
1892
1908
  }
1893
1909
 
1910
+ // A locked or read-only canvas has nothing to undo or redo.
1911
+ if (!canvasEditable) return;
1912
+
1894
1913
  // Undo: Ctrl+Z (without Shift)
1895
1914
  if (event.key === 'z' && !event.shiftKey) {
1896
1915
  event.preventDefault();
@@ -1912,6 +1931,7 @@
1912
1931
  <div class="flowdrop-scope flowdrop-workflow-editor">
1913
1932
  <!-- Main Editor Area -->
1914
1933
  <div class="flowdrop-workflow-editor__main">
1934
+ <LockBanner />
1915
1935
  <!-- Flow Canvas.
1916
1936
  Capture-phase mousedown so dragging from a port never turns into a
1917
1937
  WebKit text-selection drag — see suppressPortDragSelection. -->
@@ -1926,6 +1946,7 @@
1926
1946
  <FlowDropZone
1927
1947
  ondrop={handleNodeDrop}
1928
1948
  onfiledrop={handleWorkflowFileDrop}
1949
+ editable={canvasEditable}
1929
1950
  toFlowPosition={(point) => canvasControllerRef?.canvasScreenToFlow(point) ?? null}
1930
1951
  >
1931
1952
  {#key svelteFlowKey}
@@ -1969,7 +1990,8 @@
1969
1990
  fitViewOptions={{ padding: CANVAS_FIT_PADDING }}
1970
1991
  nodesDraggable={canvasEditable}
1971
1992
  nodesConnectable={canvasEditable}
1972
- elementsSelectable={canvasEditable}
1993
+ elementsSelectable={canvasEditable || fd.lock.isLocked}
1994
+ deleteKey={canvasEditable ? undefined : null}
1973
1995
  >
1974
1996
  <!-- Renderless helpers. They live inside <SvelteFlow>, not beside it
1975
1997
  under a provider: @xyflow/svelte >= 1.6.6 replaces the provider's
@@ -2070,7 +2092,8 @@
2070
2092
  {/if}
2071
2093
  </FlowDropZone>
2072
2094
 
2073
- {#if canvasEditable}
2095
+ <!-- Edit | Test, Run and the run bar change nothing in the workflow: a lock keeps them. -->
2096
+ {#if hostEditable}
2074
2097
  <CanvasToolbar
2075
2098
  editorMode={props.editorMode}
2076
2099
  onEditorModeChange={props.onEditorModeChange}
@@ -33,6 +33,7 @@
33
33
  import Icon from '@iconify/svelte';
34
34
  import { SvelteSet } from 'svelte/reactivity';
35
35
  import Button from './primitives/Button.svelte';
36
+ import { useFormReadOnly } from './form/readOnly.js';
36
37
  import { m } from '../messages/index.js';
37
38
  import WorkflowInterfaceEntryCard from './WorkflowInterfaceEntryCard.svelte';
38
39
  import WorkflowInterfaceEntryComposer from './WorkflowInterfaceEntryComposer.svelte';
@@ -94,6 +95,7 @@
94
95
  dataTypes = DEFAULT_PORT_CONFIG.dataTypes.filter((dt) => dt.enabled !== false),
95
96
  checker = new PortCompatibilityChecker(DEFAULT_PORT_CONFIG)
96
97
  }: Props = $props();
98
+ const readOnly = useFormReadOnly();
97
99
 
98
100
  type Direction = 'inputs' | 'outputs';
99
101
 
@@ -451,6 +453,7 @@
451
453
  variant="ghost"
452
454
  size="sm"
453
455
  class="wf-interface__add"
456
+ disabled={readOnly()}
454
457
  onclick={() => toggleComposer(section.key)}
455
458
  >
456
459
  {#snippet leadingIcon()}<Icon icon="heroicons:plus" />{/snippet}
@@ -22,6 +22,7 @@
22
22
  import Icon from '@iconify/svelte';
23
23
  import Button from './Button.svelte';
24
24
  import IconButton from './primitives/IconButton.svelte';
25
+ import { useFormReadOnly } from './form/readOnly.js';
25
26
  import Input from './Input.svelte';
26
27
  import Select from './primitives/Select.svelte';
27
28
  import Checkbox from './primitives/Checkbox.svelte';
@@ -191,18 +192,22 @@
191
192
  * remove are never on screen at rest; the menu is the one way in, and it is a
192
193
  * real menu (arrow keys, type-ahead, Escape), so the keyboard reaches all of it.
193
194
  */
195
+ /** Read-only (for example while the editor is locked): look, but do not change. */
196
+ const formReadOnly = useFormReadOnly();
197
+ const readOnly = $derived(formReadOnly());
198
+
194
199
  const rowMenu = $derived<MenuEntry[]>([
195
200
  {
196
201
  label: m().workflowInterface.menuMoveUp,
197
202
  icon: 'heroicons:chevron-up',
198
- disabled: isFirst,
203
+ disabled: readOnly || isFirst,
199
204
  testId: 'wf-entry-move-up',
200
205
  onselect: () => onMove(-1)
201
206
  },
202
207
  {
203
208
  label: m().workflowInterface.menuMoveDown,
204
209
  icon: 'heroicons:chevron-down',
205
- disabled: isLast,
210
+ disabled: readOnly || isLast,
206
211
  testId: 'wf-entry-move-down',
207
212
  onselect: () => onMove(1)
208
213
  },
@@ -217,6 +222,7 @@
217
222
  {
218
223
  label: m().workflowInterface.menuRemove,
219
224
  icon: 'heroicons:trash',
225
+ disabled: readOnly,
220
226
  testId: 'wf-entry-remove',
221
227
  onselect: onRemove
222
228
  }
@@ -320,6 +326,7 @@
320
326
  aria-label={m().workflowInterface.idLabel}
321
327
  title={m().workflowInterface.idLabel}
322
328
  spellcheck="false"
329
+ disabled={readOnly}
323
330
  value={entry.id}
324
331
  onchange={(e) => {
325
332
  // An input needs an id: an emptied field goes back to the old one
@@ -340,6 +347,7 @@
340
347
  aria-haspopup="listbox"
341
348
  aria-expanded={pickerOpen}
342
349
  title={m().workflowInterface.bindingChange}
350
+ disabled={readOnly}
343
351
  onclick={() => (pickerOpen = !pickerOpen)}
344
352
  >
345
353
  <span class="wf-interface__sr">{m().workflowInterface.bindingLabel}:</span>
@@ -415,7 +423,7 @@
415
423
  />
416
424
  <div class="wf-interface__picker-actions">
417
425
  {#if entry.bindings[0]}
418
- <Button variant="ghost" size="sm" onclick={unbind}>
426
+ <Button variant="ghost" size="sm" disabled={readOnly} onclick={unbind}>
419
427
  <Icon icon="heroicons:link-slash" />
420
428
  {m().workflowInterface.bindingUnbind}
421
429
  </Button>
@@ -497,6 +505,7 @@
497
505
  size="sm"
498
506
  class="wf-interface__pull"
499
507
  title={m().workflowInterface.pullFromPortTitle}
508
+ disabled={readOnly}
500
509
  onclick={() => onPatch(pullEntryFieldsFromPort(boundTarget.port))}
501
510
  >
502
511
  <Icon icon="heroicons:arrow-down-tray" />
@@ -543,6 +552,7 @@
543
552
  <button
544
553
  type="button"
545
554
  class="wf-interface__quickfix"
555
+ disabled={readOnly}
546
556
  onclick={() => onPatch({ dataType: boundPortType ?? entry.dataType })}
547
557
  >
548
558
  {m().workflowInterface.useMatchPortType}
@@ -600,6 +610,7 @@
600
610
  <IconButton
601
611
  size="sm"
602
612
  class="wf-interface__example-remove"
613
+ disabled={readOnly}
603
614
  onclick={() => removeExample(exampleIndex)}
604
615
  ariaLabel={m().workflowInterface.removeExample}
605
616
  >
@@ -607,7 +618,13 @@
607
618
  </IconButton>
608
619
  </div>
609
620
  {/each}
610
- <Button variant="ghost" size="sm" class="wf-interface__example-add" onclick={addExample}>
621
+ <Button
622
+ variant="ghost"
623
+ size="sm"
624
+ class="wf-interface__example-add"
625
+ disabled={readOnly}
626
+ onclick={addExample}
627
+ >
611
628
  <Icon icon="heroicons:plus" />
612
629
  {m().workflowInterface.addExample}
613
630
  </Button>
@@ -24,6 +24,7 @@
24
24
  <script lang="ts">
25
25
  import Icon from '@iconify/svelte';
26
26
  import Button from './Button.svelte';
27
+ import { useFormReadOnly } from './form/readOnly.js';
27
28
  import Input from './Input.svelte';
28
29
  import Select from './primitives/Select.svelte';
29
30
  import Checkbox from './primitives/Checkbox.svelte';
@@ -70,6 +71,7 @@
70
71
  }
71
72
 
72
73
  let { workflow, onChange, onMoveTurns }: Props = $props();
74
+ const readOnly = useFormReadOnly();
73
75
 
74
76
  /** The stored binding, every key present; `null` = not set up. */
75
77
  const stored = $derived(
@@ -257,6 +259,7 @@
257
259
  <Button
258
260
  variant="secondary"
259
261
  size="sm"
262
+ disabled={readOnly()}
260
263
  onclick={() => turnChat && onMoveTurns?.(turnChat)}
261
264
  >
262
265
  {m().playgroundSettings.moveTurns}
@@ -276,7 +279,12 @@
276
279
  {m().playgroundSettings.leftoverTurns}
277
280
  {#snippet actions()}
278
281
  {#if onMoveTurns}
279
- <Button variant="secondary" size="sm" onclick={() => stored && onMoveTurns?.(stored)}>
282
+ <Button
283
+ variant="secondary"
284
+ size="sm"
285
+ disabled={readOnly()}
286
+ onclick={() => stored && onMoveTurns?.(stored)}
287
+ >
280
288
  {m().playgroundSettings.removeTurns}
281
289
  </Button>
282
290
  {/if}
@@ -59,6 +59,7 @@
59
59
  import FormPorts from './FormPorts.svelte';
60
60
  import FormAutocomplete from './FormAutocomplete.svelte';
61
61
  import { humanizeKey } from './humanizeKey.js';
62
+ import { useFormReadOnly } from './readOnly.js';
62
63
  import { getInstance } from '../../stores/getInstance.svelte.js';
63
64
  import { getResolvedTheme } from '../../stores/settingsStore.svelte.js';
64
65
  import type { FormFieldFactoryProps } from './types.js';
@@ -98,9 +99,14 @@
98
99
  }: Props = $props();
99
100
 
100
101
  /**
101
- * When schema.readOnly is true, disable all inputs (no editing).
102
+ * Disable all inputs (no editing) when schema.readOnly is true or the form
103
+ * around the field is read-only (for example while the editor is locked).
102
104
  */
103
- const isReadOnly = $derived(schema.readOnly === true);
105
+ const formReadOnly = useFormReadOnly();
106
+ const isReadOnly = $derived(schema.readOnly === true || formReadOnly());
107
+ // Text, textarea and number fields take a read-only form from the form context
108
+ // themselves (as readonly, so the value stays selectable); they are disabled
109
+ // only by a read-only schema.
104
110
 
105
111
  /**
106
112
  * Computed description ID for ARIA association
@@ -331,7 +337,7 @@
331
337
  placeholder={schema.placeholder ?? ''}
332
338
  {required}
333
339
  ariaDescribedBy={descriptionId}
334
- disabled={isReadOnly}
340
+ disabled={schema.readOnly === true}
335
341
  onChange={(val) => onChange(val)}
336
342
  />
337
343
  {:else if fieldType === 'text'}
@@ -341,7 +347,7 @@
341
347
  placeholder={schema.placeholder ?? ''}
342
348
  {required}
343
349
  ariaDescribedBy={descriptionId}
344
- disabled={isReadOnly}
350
+ disabled={schema.readOnly === true}
345
351
  onChange={(val) => onChange(val)}
346
352
  />
347
353
  {:else if fieldType === 'number'}
@@ -354,7 +360,7 @@
354
360
  step={schema.step}
355
361
  {required}
356
362
  ariaDescribedBy={descriptionId}
357
- disabled={isReadOnly}
363
+ disabled={schema.readOnly === true}
358
364
  onChange={(val) => onChange(val)}
359
365
  />
360
366
  {:else if fieldType === 'range'}
@@ -395,7 +401,8 @@
395
401
  minItems={schema.minItems}
396
402
  maxItems={schema.maxItems}
397
403
  addLabel={`Add ${schema.items.title ?? 'Item'}`}
398
- readOnly={isReadOnly}
404
+ readOnly={schema.readOnly === true}
405
+ disabled={isReadOnly}
399
406
  {itemRef}
400
407
  help={arrayText.help}
401
408
  onChange={(val) => onChange(val)}
@@ -647,7 +647,6 @@
647
647
 
648
648
  .form-array--disabled {
649
649
  opacity: 0.6;
650
- pointer-events: none;
651
650
  }
652
651
 
653
652
  .form-array__items {
@@ -65,7 +65,7 @@
65
65
  label: t.makeDefault,
66
66
  icon: 'mdi:star-outline',
67
67
  testId: 'array-row-make-default',
68
- disabled: itemRef.wired || markedIndex === index,
68
+ disabled: disabled || itemRef.wired || markedIndex === index,
69
69
  onselect: () => {
70
70
  const name = (items[index] as Record<string, unknown> | undefined)?.[columns[0][0]];
71
71
  itemRef.onChange(typeof name === 'string' ? name : '');
@@ -77,13 +77,13 @@
77
77
  {
78
78
  label: t.moveUp,
79
79
  icon: 'mdi:arrow-up',
80
- disabled: index === 0,
80
+ disabled: disabled || index === 0,
81
81
  onselect: () => onMove(index, index - 1)
82
82
  },
83
83
  {
84
84
  label: t.moveDown,
85
85
  icon: 'mdi:arrow-down',
86
- disabled: index === items.length - 1,
86
+ disabled: disabled || index === items.length - 1,
87
87
  onselect: () => onMove(index, index + 1)
88
88
  },
89
89
  { type: 'separator' },
@@ -91,7 +91,7 @@
91
91
  label: t.delete,
92
92
  icon: 'mdi:trash-can-outline',
93
93
  testId: 'array-row-delete',
94
- disabled: !canRemove,
94
+ disabled: disabled || !canRemove,
95
95
  onselect: () => onRemove(index)
96
96
  }
97
97
  );
@@ -17,7 +17,7 @@
17
17
  highlightActiveLineGutter,
18
18
  drawSelection
19
19
  } from '@codemirror/view';
20
- import { EditorState } from '@codemirror/state';
20
+ import { EditorState, Compartment } from '@codemirror/state';
21
21
  import { history, historyKeymap } from '@codemirror/commands';
22
22
  import { highlightSpecialChars, highlightActiveLine } from '@codemirror/view';
23
23
  import { syntaxHighlighting, defaultHighlightStyle } from '@codemirror/language';
@@ -172,6 +172,13 @@
172
172
  }
173
173
  }
174
174
 
175
+ /** Compartment so the editor can turn read-only on and off after it is mounted. */
176
+ const readOnlyCompartment = new Compartment();
177
+
178
+ function readOnlyExtensions(readOnly: boolean) {
179
+ return readOnly ? [EditorState.readOnly.of(true), EditorView.editable.of(false)] : [];
180
+ }
181
+
175
182
  /**
176
183
  * Create editor extensions array
177
184
  * Uses minimal setup for better performance (no auto-closing brackets, no autocompletion)
@@ -192,7 +199,7 @@
192
199
  : [history(), keymap.of([...defaultKeymap, ...historyKeymap, indentWithTab])]),
193
200
 
194
201
  // Read-only: prevent document changes and mark content as non-editable
195
- ...(disabled ? [EditorState.readOnly.of(true), EditorView.editable.of(false)] : []),
202
+ readOnlyCompartment.of(readOnlyExtensions(disabled)),
196
203
 
197
204
  // Syntax highlighting - use default for light mode, oneDark handles dark mode
198
205
  ...(darkTheme ? [oneDark] : [syntaxHighlighting(defaultHighlightStyle, { fallback: true })]),
@@ -263,6 +270,15 @@
263
270
  }
264
271
  });
265
272
 
273
+ /** Follow `disabled` after mount (for example when the editor gets locked). */
274
+ $effect(() => {
275
+ const readOnly = disabled;
276
+ if (!editorView) return;
277
+ editorView.dispatch({
278
+ effects: [readOnlyCompartment.reconfigure(readOnlyExtensions(readOnly))]
279
+ });
280
+ });
281
+
266
282
  /**
267
283
  * Update editor content when value prop changes externally
268
284
  */
@@ -95,6 +95,13 @@
95
95
  /** Autosave timer */
96
96
  let autosaveTimer: ReturnType<typeof setTimeout> | undefined;
97
97
 
98
+ /** Compartment so the editor can turn read-only on and off after it is mounted. */
99
+ const readOnlyCompartment = new Compartment();
100
+
101
+ function readOnlyExtensions(readOnly: boolean) {
102
+ return readOnly ? [EditorState.readOnly.of(true), EditorView.editable.of(false)] : [];
103
+ }
104
+
98
105
  /** Theme compartment for dynamic theme switching */
99
106
  const themeCompartment = new Compartment();
100
107
 
@@ -349,14 +356,12 @@
349
356
  drawSelection(),
350
357
  placeholderCompartment.of(placeholder(placeholderText)),
351
358
 
352
- // Editing features (skip when read-only)
353
- ...(disabled
354
- ? [EditorState.readOnly.of(true), EditorView.editable.of(false)]
355
- : [
356
- history(),
357
- keymap.of([...defaultKeymap, ...historyKeymap, indentWithTab]),
358
- createToolbarKeymap()
359
- ]),
359
+ // Editing features
360
+ history(),
361
+ keymap.of([...defaultKeymap, ...historyKeymap, indentWithTab]),
362
+ createToolbarKeymap(),
363
+ // Read-only: prevents document changes and marks content as non-editable
364
+ readOnlyCompartment.of(readOnlyExtensions(disabled)),
360
365
 
361
366
  // Theme
362
367
  themeCompartment.of(
@@ -455,6 +460,15 @@
455
460
  if (editorView) editorView.destroy();
456
461
  });
457
462
 
463
+ /** Follow `disabled` after mount (for example when the editor gets locked). */
464
+ $effect(() => {
465
+ const readOnly = disabled;
466
+ if (!editorView) return;
467
+ editorView.dispatch({
468
+ effects: [readOnlyCompartment.reconfigure(readOnlyExtensions(readOnly))]
469
+ });
470
+ });
471
+
458
472
  /**
459
473
  * Update editor content when value prop changes externally
460
474
  */