@flowdrop/flowdrop 2.8.0 → 2.10.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 (99) hide show
  1. package/CHANGELOG.md +227 -0
  2. package/dist/commands/executor.js +52 -8
  3. package/dist/commands/types.d.ts +3 -0
  4. package/dist/components/App.svelte +8 -0
  5. package/dist/components/App.svelte.d.ts +6 -0
  6. package/dist/components/CanvasContextMenu.stories.svelte +63 -0
  7. package/dist/components/CanvasContextMenu.stories.svelte.d.ts +19 -0
  8. package/dist/components/CanvasContextMenu.svelte +259 -0
  9. package/dist/components/CanvasContextMenu.svelte.d.ts +16 -0
  10. package/dist/components/CanvasController.svelte +23 -1
  11. package/dist/components/CanvasController.svelte.d.ts +16 -0
  12. package/dist/components/UniversalNode.svelte +12 -13
  13. package/dist/components/WorkflowEditor.svelte +364 -27
  14. package/dist/components/WorkflowEditor.svelte.d.ts +7 -0
  15. package/dist/components/WorkflowInterfaceEditor.svelte +28 -3
  16. package/dist/components/WorkflowInterfaceEntryCard.svelte +112 -2
  17. package/dist/components/WorkflowInterfaceEntryCard.svelte.d.ts +3 -1
  18. package/dist/components/form/FieldFactory.svelte +478 -0
  19. package/dist/components/form/FieldFactory.svelte.d.ts +14 -0
  20. package/dist/components/form/FormField.svelte +19 -404
  21. package/dist/components/form/FormField.svelte.d.ts +2 -27
  22. package/dist/components/form/FormFieldLight.svelte +11 -424
  23. package/dist/components/form/FormFieldLight.svelte.d.ts +2 -28
  24. package/dist/components/form/FormMarkdownEditor.svelte +11 -4
  25. package/dist/components/form/FormTemplateEditor.svelte +12 -5
  26. package/dist/components/form/resolveFieldType.d.ts +18 -15
  27. package/dist/components/form/resolveFieldType.js +33 -12
  28. package/dist/components/form/types.d.ts +14 -2
  29. package/dist/components/nodes/CaptionNode.stories.svelte +65 -0
  30. package/dist/components/nodes/CaptionNode.stories.svelte.d.ts +18 -0
  31. package/dist/components/nodes/CaptionNode.svelte +313 -0
  32. package/dist/components/nodes/CaptionNode.svelte.d.ts +16 -0
  33. package/dist/components/nodes/NotesNode.svelte +6 -0
  34. package/dist/components/playground/ChatBubble.svelte +2 -0
  35. package/dist/components/playground/ChatInput.svelte +18 -34
  36. package/dist/components/playground/ChatInput.svelte.d.ts +7 -0
  37. package/dist/components/playground/ControlPanel.svelte +27 -0
  38. package/dist/components/playground/ControlPanel.svelte.d.ts +12 -0
  39. package/dist/components/playground/ExecutionLogs.svelte +11 -8
  40. package/dist/components/playground/InterfaceInputForm.svelte +74 -0
  41. package/dist/components/playground/InterfaceInputForm.svelte.d.ts +14 -0
  42. package/dist/components/playground/LogRow.svelte +2 -0
  43. package/dist/components/playground/MessageCard.svelte +15 -3
  44. package/dist/components/playground/MessageNotice.svelte +2 -0
  45. package/dist/components/playground/MessageStream.svelte +87 -23
  46. package/dist/components/playground/OriginBadge.svelte +48 -0
  47. package/dist/components/playground/OriginBadge.svelte.d.ts +7 -0
  48. package/dist/components/playground/Playground.svelte +155 -38
  49. package/dist/components/playground/messageDisplay.d.ts +23 -1
  50. package/dist/components/playground/messageDisplay.js +49 -0
  51. package/dist/config/endpoints.d.ts +65 -0
  52. package/dist/config/endpoints.js +39 -0
  53. package/dist/core/index.d.ts +6 -3
  54. package/dist/core/index.js +2 -1
  55. package/dist/editor/contextMenu.d.ts +107 -0
  56. package/dist/editor/contextMenu.js +134 -0
  57. package/dist/editor/index.d.ts +2 -0
  58. package/dist/editor/index.js +1 -0
  59. package/dist/index.d.ts +1 -1
  60. package/dist/index.js +1 -1
  61. package/dist/messages/defaults.d.ts +63 -0
  62. package/dist/messages/defaults.js +59 -0
  63. package/dist/openapi/v1/openapi.yaml +356 -7
  64. package/dist/playground/commands/registry.js +4 -2
  65. package/dist/playground/index.d.ts +3 -2
  66. package/dist/playground/index.js +2 -1
  67. package/dist/registry/builtinNodeTypes.d.ts +1 -1
  68. package/dist/registry/builtinNodeTypes.js +1 -0
  69. package/dist/registry/builtinNodes.js +13 -0
  70. package/dist/registry/nodeComponentRegistry.d.ts +18 -0
  71. package/dist/registry/nodeComponentRegistry.js +14 -2
  72. package/dist/schemas/v1/workflow.schema.json +22 -1
  73. package/dist/services/historyService.d.ts +1 -1
  74. package/dist/services/historyService.js +2 -2
  75. package/dist/services/playgroundService.d.ts +35 -1
  76. package/dist/services/playgroundService.js +82 -36
  77. package/dist/stores/inlineEditStore.svelte.d.ts +35 -0
  78. package/dist/stores/inlineEditStore.svelte.js +63 -0
  79. package/dist/stores/instanceContainer.svelte.d.ts +6 -0
  80. package/dist/stores/instanceContainer.svelte.js +2 -0
  81. package/dist/stores/playgroundStore.svelte.d.ts +59 -2
  82. package/dist/stores/playgroundStore.svelte.js +128 -2
  83. package/dist/styles/base.css +8 -0
  84. package/dist/styles/tokens.css +8 -0
  85. package/dist/svelte-app.d.ts +15 -0
  86. package/dist/svelte-app.js +6 -4
  87. package/dist/types/index.d.ts +34 -1
  88. package/dist/types/index.js +11 -0
  89. package/dist/types/playground.d.ts +90 -9
  90. package/dist/types/playground.js +12 -4
  91. package/dist/utils/captionText.d.ts +43 -0
  92. package/dist/utils/captionText.js +49 -0
  93. package/dist/utils/focus.d.ts +16 -0
  94. package/dist/utils/focus.js +40 -0
  95. package/dist/utils/nodeTypes.js +1 -0
  96. package/dist/utils/nodeWrapper.js +2 -0
  97. package/dist/utils/workflowInterface.d.ts +83 -1
  98. package/dist/utils/workflowInterface.js +192 -1
  99. package/package.json +1 -1
@@ -5,7 +5,8 @@
5
5
  * These types provide a foundation for dynamic form rendering based on JSON Schema
6
6
  * and support extensibility for complex field types like arrays and objects.
7
7
  */
8
- import type { AutocompleteConfig, TemplateVariablesConfig } from '../../types/index.js';
8
+ import type { AutocompleteConfig, TemplateVariablesConfig, WorkflowNode, WorkflowEdge } from '../../types/index.js';
9
+ import type { AuthProvider } from '../../types/auth.js';
9
10
  /**
10
11
  * Supported field types for form rendering
11
12
  * Aligned with JSON Schema specification (draft-07)
@@ -308,7 +309,8 @@ export interface FieldSchema {
308
309
  [key: string]: unknown;
309
310
  }
310
311
  /**
311
- * Props for the FormField factory component
312
+ * Props for the field factory components (`FormField` from `form`,
313
+ * `FormFieldFull` from `form/full`)
312
314
  * Renders the appropriate field component based on schema
313
315
  */
314
316
  export interface FormFieldFactoryProps {
@@ -322,6 +324,16 @@ export interface FormFieldFactoryProps {
322
324
  required?: boolean;
323
325
  /** Animation delay index for staggered animations */
324
326
  animationIndex?: number;
327
+ /** Current workflow node (optional, forwarded to registered editors for template variable API mode) */
328
+ node?: WorkflowNode;
329
+ /** All workflow nodes (optional, forwarded to registered editors for port-derived variables) */
330
+ nodes?: WorkflowNode[];
331
+ /** All workflow edges (optional, forwarded to registered editors for port-derived variables) */
332
+ edges?: WorkflowEdge[];
333
+ /** Workflow ID (optional, forwarded to registered editors for template variable API mode) */
334
+ workflowId?: string;
335
+ /** Auth provider (optional, forwarded to registered editors for API requests) */
336
+ authProvider?: AuthProvider;
325
337
  /** Callback when the field value changes */
326
338
  onChange: (value: unknown) => void;
327
339
  }
@@ -0,0 +1,65 @@
1
+ <script module lang="ts">
2
+ import { defineMeta } from '@storybook/addon-svelte-csf';
3
+ import NodeDecorator from '../../stories/NodeDecorator.svelte';
4
+
5
+ const { Story } = defineMeta({
6
+ title: 'Nodes/CaptionNode',
7
+ tags: ['autodocs'],
8
+ parameters: {
9
+ layout: 'centered'
10
+ }
11
+ });
12
+
13
+ /** Node data for a caption with the given text. */
14
+ function caption(label: string) {
15
+ return {
16
+ label,
17
+ config: {},
18
+ metadata: {
19
+ node_type_id: 'caption',
20
+ name: 'Caption',
21
+ description: 'Short high-contrast text that names or marks nearby nodes',
22
+ category: 'tools',
23
+ version: '1.0.0',
24
+ type: 'caption',
25
+ supportedTypes: ['caption'],
26
+ inputs: [],
27
+ outputs: []
28
+ }
29
+ };
30
+ }
31
+ </script>
32
+
33
+ <Story name="Tiny">
34
+ <NodeDecorator data={caption('A')} />
35
+ </Story>
36
+
37
+ <Story name="Section">
38
+ <NodeDecorator data={caption('Inputs')} />
39
+ </Story>
40
+
41
+ <Story name="Reminder">
42
+ <NodeDecorator data={caption('TODO: retry on 429')} />
43
+ </Story>
44
+
45
+ <Story name="Two lines">
46
+ <NodeDecorator
47
+ data={caption(
48
+ 'Everything to the right of this caption runs once per customer record, in the order they arrive'
49
+ )}
50
+ />
51
+ </Story>
52
+
53
+ <Story name="Too long (clamped)">
54
+ <NodeDecorator
55
+ data={caption(
56
+ 'This caption is far too long for two lines of a five hundred pixel wide label so the clamp has to cut it off with an ellipsis and keep the full text in the tooltip instead of growing taller'
57
+ )}
58
+ />
59
+ </Story>
60
+
61
+ <Story name="Dark theme">
62
+ <div data-theme="dark" style="background: #1a1a1e; padding: 8px;">
63
+ <NodeDecorator data={caption('Inputs')} />
64
+ </div>
65
+ </Story>
@@ -0,0 +1,18 @@
1
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
2
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
+ $$bindings?: Bindings;
4
+ } & Exports;
5
+ (internal: unknown, props: {
6
+ $$events?: Events;
7
+ $$slots?: Slots;
8
+ }): Exports & {
9
+ $set?: any;
10
+ $on?: any;
11
+ };
12
+ z_$$bindings?: Bindings;
13
+ }
14
+ declare const CaptionNode: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
15
+ [evt: string]: CustomEvent<any>;
16
+ }, {}, {}, string>;
17
+ type CaptionNode = InstanceType<typeof CaptionNode>;
18
+ export default CaptionNode;
@@ -0,0 +1,313 @@
1
+ <!--
2
+ Caption Node Component
3
+
4
+ A short, high-contrast line of text (one or two lines) that names or marks
5
+ nearby nodes. Text lives in `data.label`. It has no ports, no config panel
6
+ and no status overlay; it is edited in place (double-click, Enter on the
7
+ focused node, or the context menu) and the editor owns the write through
8
+ `data.onInlineCommit`.
9
+ -->
10
+
11
+ <script lang="ts">
12
+ import { tick, untrack } from 'svelte';
13
+ import type { Attachment } from 'svelte/attachments';
14
+ import { on } from 'svelte/events';
15
+ import { m } from '../../messages/index.js';
16
+ import { getInstance } from '../../stores/getInstance.svelte.js';
17
+ import { getEditorSettings } from '../../stores/settingsStore.svelte.js';
18
+ import { snapCaptionWidth } from '../../utils/captionText.js';
19
+ import { focusWhenVisible } from '../../utils/focus.js';
20
+
21
+ interface Props {
22
+ id: string;
23
+ data: {
24
+ label: string;
25
+ /**
26
+ * Called when an edit ends: the text as typed (the editor cleans it), or
27
+ * `null` when the edit was cancelled. The editor decides whether
28
+ * anything is written.
29
+ */
30
+ onInlineCommit?: (id: string, text: string | null) => void;
31
+ };
32
+ selected?: boolean;
33
+ }
34
+
35
+ let props: Props = $props();
36
+
37
+ const fd = getInstance();
38
+ const caption = $derived(m().nodes.caption);
39
+
40
+ /** Horizontal padding on each side, mirrors the CSS. */
41
+ const PADDING_X = 10;
42
+
43
+ let rootEl: HTMLDivElement | undefined = $state();
44
+ let editorEl: HTMLDivElement | undefined = $state();
45
+
46
+ /**
47
+ * One-line widths of the two measure spans, in px. `bind:offsetWidth` is
48
+ * unscaled by the viewport zoom (a bounding rect is not) and updates when a
49
+ * web font arrives, so the width below needs no font-loading hook.
50
+ */
51
+ let textW = $state(0);
52
+ let placeholderW = $state(0);
53
+
54
+ let editing = $state(false);
55
+ /** Text as typed while editing; drives live width measurement. */
56
+ let draft = $state('');
57
+ /** The text is cut off by the two-line clamp; checked on hover, when the tooltip matters. */
58
+ let clipped = $state(false);
59
+
60
+ const label = $derived(props.data.label ?? '');
61
+ const shownText = $derived(editing ? draft : label);
62
+ const showPlaceholder = $derived(editing && draft === '');
63
+
64
+ /**
65
+ * Width in px, snapped to the grid; undefined until the text has been
66
+ * measured, so the CSS minimum applies. While editing, the node is never
67
+ * narrower than the placeholder, so a new caption opens wide enough to show
68
+ * it on one line. The max width is the CSS `max-width`; it clamps this.
69
+ */
70
+ const width = $derived(
71
+ textW === 0 && !editing
72
+ ? undefined
73
+ : snapCaptionWidth(
74
+ Math.max(textW, editing ? placeholderW : 0) + 2 * PADDING_X,
75
+ getEditorSettings().gridSize
76
+ )
77
+ );
78
+
79
+ /** The tooltip shows the full text only when the clamp cuts it. */
80
+ function checkClipped(event: PointerEvent): void {
81
+ const el = event.currentTarget as HTMLElement;
82
+ clipped = el.scrollHeight > el.clientHeight + 1;
83
+ }
84
+
85
+ // ---------------------------------------------------------------------------
86
+ // In-place editing
87
+ // ---------------------------------------------------------------------------
88
+
89
+ function startEditing(): void {
90
+ if (editing) return;
91
+ draft = label;
92
+ editing = true;
93
+ }
94
+
95
+ function requestEdit(): void {
96
+ fd.inlineEdit.request(props.id);
97
+ }
98
+
99
+ // Take edit requests addressed to this node; a request made before this
100
+ // mounted runs as soon as it registers.
101
+ $effect(() => {
102
+ const id = props.id;
103
+ return untrack(() => fd.inlineEdit.register(id, startEditing));
104
+ });
105
+
106
+ /** Select everything in the box, once it has focus. */
107
+ function selectContents(box: HTMLElement): void {
108
+ const selection = window.getSelection();
109
+ if (!selection) return;
110
+ const range = document.createRange();
111
+ range.selectNodeContents(box);
112
+ selection.removeAllRanges();
113
+ selection.addRange(range);
114
+ }
115
+
116
+ /**
117
+ * Drop a caret or selection that sits in the edit box before the box goes
118
+ * away. Left in place, the browser moves it to the box's parent when the
119
+ * box is removed, and WebKit, after the caret was moved with an arrow key,
120
+ * scrolls the nearest scrollable ancestor to reveal it: the canvas area
121
+ * jumps and every node appears to move.
122
+ */
123
+ function dropCaret(): void {
124
+ const selection = window.getSelection();
125
+ if (selection && editorEl && editorEl.contains(selection.anchorNode)) {
126
+ selection.removeAllRanges();
127
+ }
128
+ }
129
+
130
+ function finish(save: boolean, refocusNode: boolean): void {
131
+ // The blur that follows an Enter or Escape finds the edit already over.
132
+ if (!editing) return;
133
+ const text = save ? (editorEl?.textContent ?? '') : null;
134
+ const wrapper = rootEl?.closest<HTMLElement>('.svelte-flow__node') ?? null;
135
+ dropCaret();
136
+ editing = false;
137
+ props.data.onInlineCommit?.(props.id, text);
138
+ if (refocusNode) {
139
+ // Keep keyboard users on the node.
140
+ void tick().then(() => wrapper?.isConnected && wrapper.focus({ preventScroll: true }));
141
+ }
142
+ }
143
+
144
+ function insertPlainText(text: string): void {
145
+ const clean = text.replace(/\s+/g, ' ');
146
+ if (!document.execCommand('insertText', false, clean)) {
147
+ const selection = window.getSelection();
148
+ if (!selection || selection.rangeCount === 0) return;
149
+ const range = selection.getRangeAt(0);
150
+ range.deleteContents();
151
+ range.insertNode(document.createTextNode(clean));
152
+ range.collapse(false);
153
+ }
154
+ }
155
+
156
+ /**
157
+ * Sets up the edit box: fills it with the current text and wires native
158
+ * listeners. Keys must not reach xyflow's Delete/Backspace and arrow
159
+ * handling, and `on()` (unlike an `onkeydown` attribute) is not delegated, so
160
+ * a real stopPropagation keeps them away. The box exists only while editing,
161
+ * so this runs once per edit.
162
+ */
163
+ const editable: Attachment<HTMLDivElement> = (node) => {
164
+ // `plaintext-only` where supported; otherwise plain `true` plus paste
165
+ // handling below, which never lets markup in.
166
+ node.contentEditable = 'plaintext-only';
167
+ if (node.contentEditable !== 'plaintext-only') node.contentEditable = 'true';
168
+ node.textContent = untrack(() => label);
169
+
170
+ // Keep pointer interaction inside the box from selecting or dragging the node.
171
+ const stop = (event: Event): void => event.stopPropagation();
172
+
173
+ const removers = [
174
+ on(node, 'keydown', (event) => {
175
+ event.stopPropagation();
176
+ if (event.isComposing) return;
177
+ if (event.key === 'Enter') {
178
+ event.preventDefault();
179
+ finish(true, true);
180
+ } else if (event.key === 'Escape') {
181
+ event.preventDefault();
182
+ finish(false, true);
183
+ }
184
+ }),
185
+ on(node, 'keyup', stop),
186
+ on(node, 'beforeinput', (event) => {
187
+ // Newlines are never stored.
188
+ if (event.inputType === 'insertParagraph' || event.inputType === 'insertLineBreak') {
189
+ event.preventDefault();
190
+ }
191
+ }),
192
+ on(node, 'input', () => {
193
+ draft = node.textContent ?? '';
194
+ }),
195
+ on(node, 'paste', (event) => {
196
+ event.preventDefault();
197
+ insertPlainText(event.clipboardData?.getData('text/plain') ?? '');
198
+ }),
199
+ on(node, 'drop', (event) => event.preventDefault()),
200
+ on(node, 'blur', () => finish(true, false)),
201
+ on(node, 'dblclick', stop)
202
+ ];
203
+ return () => removers.forEach((remove) => remove());
204
+ };
205
+ </script>
206
+
207
+ <!-- Presentational: focus, selection and keyboard activation live on xyflow's
208
+ node wrapper (see UniversalNode). Double-click is a mouse convenience. -->
209
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
210
+ <div
211
+ class="flowdrop-caption-node"
212
+ class:flowdrop-caption-node--selected={props.selected}
213
+ class:flowdrop-caption-node--editing={editing}
214
+ bind:this={rootEl}
215
+ style:width={width === undefined ? undefined : `${width}px`}
216
+ ondblclick={requestEdit}
217
+ >
218
+ <!-- Invisible one-line copy of the text; its natural width sets the node width. -->
219
+ <span class="flowdrop-caption-node__measure" aria-hidden="true" bind:offsetWidth={textW}
220
+ >{shownText}</span
221
+ >
222
+ {#if editing}
223
+ <span class="flowdrop-caption-node__measure" aria-hidden="true" bind:offsetWidth={placeholderW}
224
+ >{caption.placeholder}</span
225
+ >
226
+ {/if}
227
+
228
+ {#if editing}
229
+ <div
230
+ class="flowdrop-caption-node__text flowdrop-caption-node__text--editing nodrag nopan nowheel"
231
+ class:flowdrop-caption-node__text--empty={showPlaceholder}
232
+ role="textbox"
233
+ tabindex="0"
234
+ aria-label={caption.editLabel}
235
+ data-placeholder={caption.placeholder}
236
+ bind:this={editorEl}
237
+ {@attach editable}
238
+ {@attach focusWhenVisible(selectContents)}
239
+ ></div>
240
+ {:else}
241
+ <div
242
+ class="flowdrop-caption-node__text"
243
+ title={clipped ? label : undefined}
244
+ onpointerenter={checkClipped}
245
+ >
246
+ {label}
247
+ </div>
248
+ {/if}
249
+ </div>
250
+
251
+ <style>
252
+ .flowdrop-caption-node {
253
+ position: relative;
254
+ box-sizing: border-box;
255
+ min-width: 40px;
256
+ max-width: var(--fd-caption-node-max-width, 500px);
257
+ min-height: 40px;
258
+ padding: 10px;
259
+ border-radius: 6px;
260
+ background: var(--fd-caption-node-bg);
261
+ color: var(--fd-caption-node-fg);
262
+ font-family: var(--fd-font-mono);
263
+ font-size: 13px;
264
+ font-weight: 600;
265
+ line-height: 20px;
266
+ }
267
+
268
+ .flowdrop-caption-node--selected {
269
+ outline: 2px solid var(--fd-ring, currentColor);
270
+ outline-offset: 2px;
271
+ }
272
+
273
+ .flowdrop-caption-node__measure {
274
+ position: absolute;
275
+ top: 0;
276
+ left: 0;
277
+ width: max-content;
278
+ max-width: none;
279
+ white-space: nowrap;
280
+ visibility: hidden;
281
+ pointer-events: none;
282
+ font: inherit;
283
+ }
284
+
285
+ .flowdrop-caption-node__text {
286
+ display: -webkit-box;
287
+ -webkit-box-orient: vertical;
288
+ line-clamp: 2;
289
+ -webkit-line-clamp: 2;
290
+ overflow: hidden;
291
+ overflow-wrap: anywhere;
292
+ text-overflow: ellipsis;
293
+ min-height: 20px;
294
+ }
295
+
296
+ /* The clamp is lifted while typing so the whole text is visible. */
297
+ .flowdrop-caption-node__text--editing {
298
+ display: block;
299
+ line-clamp: none;
300
+ -webkit-line-clamp: unset;
301
+ overflow: visible;
302
+ outline: none;
303
+ cursor: text;
304
+ white-space: pre-wrap;
305
+ user-select: text;
306
+ }
307
+
308
+ .flowdrop-caption-node__text--empty::before {
309
+ content: attr(data-placeholder);
310
+ opacity: 0.55;
311
+ pointer-events: none;
312
+ }
313
+ </style>
@@ -0,0 +1,16 @@
1
+ interface Props {
2
+ id: string;
3
+ data: {
4
+ label: string;
5
+ /**
6
+ * Called when an edit ends: the text as typed (the editor cleans it), or
7
+ * `null` when the edit was cancelled. The editor decides whether
8
+ * anything is written.
9
+ */
10
+ onInlineCommit?: (id: string, text: string | null) => void;
11
+ };
12
+ selected?: boolean;
13
+ }
14
+ declare const CaptionNode: import("svelte").Component<Props, {}, "">;
15
+ type CaptionNode = ReturnType<typeof CaptionNode>;
16
+ export default CaptionNode;
@@ -315,6 +315,12 @@
315
315
  margin-bottom: 0;
316
316
  }
317
317
 
318
+ /* h1/h2 keep their browser-default sizes (~2em/1.5em), which overflow a 20px row
319
+ and overlap when they wrap; give each of their lines two grid rows instead. */
320
+ .flowdrop-notes-node__body :global(:is(h1, h2)) {
321
+ line-height: 40px;
322
+ }
323
+
318
324
  .flowdrop-notes-node__body :global(li) {
319
325
  margin: 0;
320
326
  line-height: 20px;
@@ -9,6 +9,7 @@
9
9
  import type { PlaygroundMessage } from '../../types/playground.js';
10
10
  import HierarchyTrail from './HierarchyTrail.svelte';
11
11
  import MessageTagStrip from './MessageTagStrip.svelte';
12
+ import OriginBadge from './OriginBadge.svelte';
12
13
  import MessageMarkdown from './MessageMarkdown.svelte';
13
14
  import { formatDuration, formatTimestamp, getRoleIcon, getRoleLabel } from './messageDisplay.js';
14
15
  import { m } from '../../messages/index.js';
@@ -45,6 +46,7 @@
45
46
  <div class="message-bubble__content">
46
47
  <div class="message-bubble__header">
47
48
  <span class="message-bubble__role">{roleLabel}</span>
49
+ <OriginBadge {message} />
48
50
  {#if showTimestamp}
49
51
  <time
50
52
  class="message-bubble__timestamp"
@@ -11,7 +11,6 @@
11
11
  <script lang="ts">
12
12
  import Icon from '@iconify/svelte';
13
13
  import { tick } from 'svelte';
14
- import { hasEnableRunFlag } from '../../types/playground.js';
15
14
  import { getInstance } from '../../stores/getInstance.svelte.js';
16
15
  import { m } from '../../messages/index.js';
17
16
  import {
@@ -52,6 +51,13 @@
52
51
  * button that launches instead.
53
52
  */
54
53
  onRunWorkflow?: () => void;
54
+ /**
55
+ * When true (the default, the original protocol for hosts using ChatInput
56
+ * directly), a Run click locks Run until the backend posts a message with
57
+ * `enableRun` metadata. The Playground turns it off for turn-port
58
+ * workflows, whose server never sends that message.
59
+ */
60
+ awaitEnableRun?: boolean;
55
61
  /**
56
62
  * Enable the slash-command lane (default: false).
57
63
  *
@@ -74,6 +80,7 @@
74
80
  onSendMessage,
75
81
  onStopExecution,
76
82
  onRunWorkflow,
83
+ awaitEnableRun = true,
77
84
  enableCommands = false,
78
85
  commandFeedback = null,
79
86
  onDismissCommandFeedback
@@ -90,13 +97,6 @@
90
97
 
91
98
  const noInputsAvailable = $derived(!showTextarea && !showRunButton);
92
99
 
93
- /**
94
- * Tracks whether the Run button is enabled. Starts as true; becomes false
95
- * after Run is clicked; re-enabled when the backend sends a message with
96
- * enableRun: true metadata.
97
- */
98
- let runEnabled = $state(true);
99
-
100
100
  let inputValue = $state('');
101
101
  let inputField: HTMLTextAreaElement | undefined = $state();
102
102
 
@@ -176,28 +176,8 @@
176
176
  inputValue.trim().length > 0 && (inputIsCommand || fd.playground.canSendMessage)
177
177
  );
178
178
 
179
- // Count of enableRun messages seen so far. A plain `let`, not `$state`: it is
180
- // bookkeeping for the effects below, never read during render. Because it is
181
- // not reactive, writing to it inside an effect creates no dependency and
182
- // needs no `untrack`.
183
- let seenEnableRunCount = 0;
184
-
185
- $effect(() => {
186
- const count = fd.playground.messages.filter((msg) => hasEnableRunFlag(msg.metadata)).length;
187
- if (count > seenEnableRunCount) {
188
- seenEnableRunCount = count;
189
- runEnabled = true;
190
- }
191
- });
192
-
193
- $effect(() => {
194
- if (fd.playground.currentSession?.id) {
195
- seenEnableRunCount = 0;
196
- runEnabled = true;
197
- }
198
- });
199
-
200
- // Same rationale as `seenEnableRunCount`: plain `let`, no `untrack` needed.
179
+ // A plain `let`, not `$state`: bookkeeping for the effect below, never read
180
+ // during render, so writing it inside the effect creates no dependency.
201
181
  let wasExecuting = false;
202
182
 
203
183
  /** Auto-focus input when execution completes */
@@ -277,8 +257,8 @@
277
257
  }
278
258
 
279
259
  function handleRun(): void {
280
- if (fd.playground.isExecuting || !runEnabled) return;
281
- runEnabled = false;
260
+ if (!fd.playground.canRun) return;
261
+ if (awaitEnableRun) fd.playground.lockRunUntilEnabled();
282
262
 
283
263
  const action = resolveRunAction({
284
264
  canLaunch: onRunWorkflow != null,
@@ -292,6 +272,10 @@
292
272
  }
293
273
 
294
274
  onSendMessage?.(action.content);
275
+
276
+ // A slash command (a `predefinedMessage` of `/help`, say) runs without
277
+ // taking a turn, so no `enableRun` message will ever follow to free the lock.
278
+ if (awaitEnableRun && isCommandInput(action.content)) fd.playground.releaseRunLock();
295
279
  }
296
280
 
297
281
  function handleInput(): void {
@@ -414,12 +398,12 @@
414
398
  {actions.send}
415
399
  </button>
416
400
  {:else if showRunButton}
417
- {@const runLabel = runEnabled ? actions.runTitle : actions.runWaitingTitle}
401
+ {@const runLabel = fd.playground.canRun ? actions.runTitle : actions.runWaitingTitle}
418
402
  <button
419
403
  type="button"
420
404
  class="chat-input__run-btn"
421
405
  onclick={handleRun}
422
- disabled={!runEnabled}
406
+ disabled={!fd.playground.canRun}
423
407
  title={runLabel}
424
408
  aria-label={runLabel}
425
409
  >
@@ -26,6 +26,13 @@ interface Props {
26
26
  * button that launches instead.
27
27
  */
28
28
  onRunWorkflow?: () => void;
29
+ /**
30
+ * When true (the default, the original protocol for hosts using ChatInput
31
+ * directly), a Run click locks Run until the backend posts a message with
32
+ * `enableRun` metadata. The Playground turns it off for turn-port
33
+ * workflows, whose server never sends that message.
34
+ */
35
+ awaitEnableRun?: boolean;
29
36
  /**
30
37
  * Enable the slash-command lane (default: false).
31
38
  *
@@ -10,6 +10,8 @@
10
10
  <script lang="ts">
11
11
  import Icon from '@iconify/svelte';
12
12
  import ChatInput from './ChatInput.svelte';
13
+ import InterfaceInputForm from './InterfaceInputForm.svelte';
14
+ import type { WorkflowInterfaceEntry } from '../../types/index.js';
13
15
  import { getInstance } from '../../stores/getInstance.svelte.js';
14
16
  import { m } from '../../messages/index.js';
15
17
  import type { CommandOutcome } from '../../playground/commands/index.js';
@@ -27,6 +29,8 @@
27
29
  onStopExecution: () => void;
28
30
  /** Start a run without posting a chat message. See ChatInput. */
29
31
  onRunWorkflow?: () => void;
32
+ /** Whether a Run click waits for the backend's `enableRun`. See ChatInput. */
33
+ awaitEnableRun?: boolean;
30
34
  /**
31
35
  * Enable the slash-command lane (default: false).
32
36
  *
@@ -48,6 +52,15 @@
48
52
  showRunButton?: boolean;
49
53
  predefinedMessage?: string;
50
54
  placeholder?: string;
55
+ /**
56
+ * Interface inputs to collect in a form above the composer (inputs
57
+ * without a chat turn). Empty or absent renders no form.
58
+ */
59
+ formEntries?: WorkflowInterfaceEntry[];
60
+ /** Current form values, keyed by entry id. */
61
+ formValues?: Record<string, unknown>;
62
+ /** Called with the complete form values on every change. */
63
+ onFormChange?: (values: Record<string, unknown>) => void;
51
64
  // Session UI config
52
65
  showSessionHeader?: boolean;
53
66
  showNewSessionButton?: boolean;
@@ -63,6 +76,7 @@
63
76
  onSendMessage,
64
77
  onStopExecution,
65
78
  onRunWorkflow,
79
+ awaitEnableRun = true,
66
80
  enableCommands = false,
67
81
  commandFeedback = null,
68
82
  onDismissCommandFeedback,
@@ -74,6 +88,9 @@
74
88
  showRunButton = true,
75
89
  predefinedMessage,
76
90
  placeholder,
91
+ formEntries = [],
92
+ formValues = {},
93
+ onFormChange,
77
94
  showSessionHeader = true,
78
95
  showNewSessionButton = true,
79
96
  showSessionList = true,
@@ -267,6 +284,15 @@
267
284
  </header>
268
285
  {/if}
269
286
 
287
+ {#if formEntries.length > 0}
288
+ <InterfaceInputForm
289
+ entries={formEntries}
290
+ values={formValues}
291
+ onChange={(values) => onFormChange?.(values)}
292
+ disabled={fd.playground.isExecuting}
293
+ />
294
+ {/if}
295
+
270
296
  <ChatInput
271
297
  showTextarea={showChatInput}
272
298
  {showRunButton}
@@ -275,6 +301,7 @@
275
301
  {onSendMessage}
276
302
  {onStopExecution}
277
303
  {onRunWorkflow}
304
+ {awaitEnableRun}
278
305
  {enableCommands}
279
306
  {commandFeedback}
280
307
  {onDismissCommandFeedback}