@flowdrop/flowdrop 2.0.0-beta.9 → 2.0.1
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 +87 -0
- package/dist/chat/batchFeedback.js +1 -1
- package/dist/chat/commandClassifier.d.ts +11 -0
- package/dist/chat/commandClassifier.js +20 -0
- package/dist/chat/historyBuilder.d.ts +39 -0
- package/dist/chat/historyBuilder.js +82 -0
- package/dist/chat/index.d.ts +2 -1
- package/dist/chat/index.js +2 -1
- package/dist/chat/responseParser.js +16 -12
- package/dist/commands/parser.d.ts +12 -0
- package/dist/commands/parser.js +33 -6
- package/dist/commands/storeIntegration.svelte.js +11 -1
- package/dist/components/App.svelte +56 -17
- package/dist/components/ConfigForm.svelte +98 -23
- package/dist/components/ConfigForm.svelte.d.ts +21 -2
- package/dist/components/ConfigModal.svelte +9 -0
- package/dist/components/ConfigPanel.svelte +0 -1
- package/dist/components/SettingsPanel.svelte +9 -0
- package/dist/components/WorkflowEditor.svelte +5 -2
- package/dist/components/chat/AIChatPanel.svelte +42 -6
- package/dist/components/chat/CommandPreview.svelte +10 -1
- package/dist/components/form/FormPorts.svelte +21 -3
- package/dist/components/form/FormRangeField.svelte +5 -3
- package/dist/components/form/FormToggle.svelte +27 -2
- package/dist/components/form/FormToggle.svelte.d.ts +5 -0
- package/dist/components/playground/ChatInput.svelte +316 -26
- package/dist/components/playground/ChatInput.svelte.d.ts +31 -1
- package/dist/components/playground/ControlPanel.svelte +22 -0
- package/dist/components/playground/ControlPanel.svelte.d.ts +13 -0
- package/dist/components/playground/Playground.svelte +217 -4
- package/dist/components/surfaces/SurfaceOverlay.svelte +0 -1
- package/dist/config/endpoints.d.ts +48 -1
- package/dist/config/endpoints.js +18 -5
- package/dist/messages/defaults.d.ts +98 -0
- package/dist/messages/defaults.js +58 -1
- package/dist/playground/commands/args.d.ts +32 -0
- package/dist/playground/commands/args.js +50 -0
- package/dist/playground/commands/dispatch.d.ts +143 -0
- package/dist/playground/commands/dispatch.js +162 -0
- package/dist/playground/commands/index.d.ts +14 -0
- package/dist/playground/commands/index.js +10 -0
- package/dist/playground/commands/parser.d.ts +38 -0
- package/dist/playground/commands/parser.js +163 -0
- package/dist/playground/commands/registry.d.ts +42 -0
- package/dist/playground/commands/registry.js +122 -0
- package/dist/playground/commands/suggest.d.ts +37 -0
- package/dist/playground/commands/suggest.js +46 -0
- package/dist/playground/commands/types.d.ts +111 -0
- package/dist/playground/commands/types.js +15 -0
- package/dist/playground/index.d.ts +19 -0
- package/dist/playground/index.js +25 -0
- package/dist/playground/runAction.d.ts +48 -0
- package/dist/playground/runAction.js +31 -0
- package/dist/services/historyService.d.ts +30 -8
- package/dist/services/historyService.js +51 -15
- package/dist/services/pipelineSignalService.d.ts +97 -0
- package/dist/services/pipelineSignalService.js +94 -0
- package/dist/services/playgroundService.d.ts +12 -0
- package/dist/services/playgroundService.js +22 -0
- package/dist/services/workflowLaunchService.d.ts +74 -0
- package/dist/services/workflowLaunchService.js +74 -0
- package/dist/stores/historyStore.svelte.d.ts +17 -3
- package/dist/stores/historyStore.svelte.js +30 -3
- package/dist/stores/instanceContainer.svelte.js +5 -0
- package/dist/stores/workflowStore.svelte.d.ts +41 -4
- package/dist/stores/workflowStore.svelte.js +103 -13
- package/dist/types/chat.d.ts +5 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.js +1 -1
- package/dist/types/settings.d.ts +11 -0
- package/dist/types/settings.js +2 -1
- package/dist/utils/canvasSelection.d.ts +25 -0
- package/dist/utils/canvasSelection.js +37 -0
- package/dist/utils/nodeFormSchema.d.ts +51 -0
- package/dist/utils/nodeFormSchema.js +87 -0
- package/package.json +1 -1
|
@@ -10,10 +10,18 @@
|
|
|
10
10
|
|
|
11
11
|
<script lang="ts">
|
|
12
12
|
import Icon from '@iconify/svelte';
|
|
13
|
-
import { tick
|
|
13
|
+
import { tick } from 'svelte';
|
|
14
14
|
import { hasEnableRunFlag } from '../../types/playground.js';
|
|
15
15
|
import { getInstance } from '../../stores/getInstance.svelte.js';
|
|
16
16
|
import { m } from '../../messages/index.js';
|
|
17
|
+
import {
|
|
18
|
+
isCommandInput,
|
|
19
|
+
suggestCommands,
|
|
20
|
+
type CommandOutcome,
|
|
21
|
+
type CommandSuggestion
|
|
22
|
+
} from '../../playground/commands/index.js';
|
|
23
|
+
import { resolveRunAction } from '../../playground/runAction.js';
|
|
24
|
+
import ConsoleAutocomplete from '../console/ConsoleAutocomplete.svelte';
|
|
17
25
|
|
|
18
26
|
const fd = getInstance();
|
|
19
27
|
|
|
@@ -23,10 +31,39 @@
|
|
|
23
31
|
showTextarea?: boolean;
|
|
24
32
|
/** Show the Run button when textarea is hidden (default: true) */
|
|
25
33
|
showRunButton?: boolean;
|
|
26
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Message sent when Run is clicked, for hosts that deliberately want the
|
|
36
|
+
* run to begin with a specific chat turn.
|
|
37
|
+
*
|
|
38
|
+
* Setting this opts *out* of {@link onRunWorkflow}: an explicitly
|
|
39
|
+
* configured message is a host's intentional choice and is honoured.
|
|
40
|
+
* Leaving it unset is what lets Run launch without fabricating a turn.
|
|
41
|
+
*/
|
|
27
42
|
predefinedMessage?: string;
|
|
28
43
|
onSendMessage?: (content: string) => void;
|
|
29
44
|
onStopExecution?: () => void;
|
|
45
|
+
/**
|
|
46
|
+
* Start a run without posting a chat message.
|
|
47
|
+
*
|
|
48
|
+
* Preferred over `onSendMessage` for the Run button. Sending a message to
|
|
49
|
+
* start a run fabricates a user turn that enters the conversation and is
|
|
50
|
+
* replayed as input on the following turn — indistinguishable downstream
|
|
51
|
+
* from something the user actually typed. Hosts that provide this get a Run
|
|
52
|
+
* button that launches instead.
|
|
53
|
+
*/
|
|
54
|
+
onRunWorkflow?: () => void;
|
|
55
|
+
/**
|
|
56
|
+
* Enable the slash-command lane (default: false).
|
|
57
|
+
*
|
|
58
|
+
* Opt-in because the lane is only safe where the `onSendMessage` handler
|
|
59
|
+
* actually dispatches commands. A surface that forwards input straight to a
|
|
60
|
+
* backend (ChatPanel) would post `/stop` as literal text — faking a command
|
|
61
|
+
* that nothing implements.
|
|
62
|
+
*/
|
|
63
|
+
enableCommands?: boolean;
|
|
64
|
+
/** Transient result of the last slash command. Never a session message. */
|
|
65
|
+
commandFeedback?: CommandOutcome | null;
|
|
66
|
+
onDismissCommandFeedback?: () => void;
|
|
30
67
|
}
|
|
31
68
|
|
|
32
69
|
let {
|
|
@@ -35,13 +72,19 @@
|
|
|
35
72
|
showRunButton = true,
|
|
36
73
|
predefinedMessage,
|
|
37
74
|
onSendMessage,
|
|
38
|
-
onStopExecution
|
|
75
|
+
onStopExecution,
|
|
76
|
+
onRunWorkflow,
|
|
77
|
+
enableCommands = false,
|
|
78
|
+
commandFeedback = null,
|
|
79
|
+
onDismissCommandFeedback
|
|
39
80
|
}: Props = $props();
|
|
40
81
|
|
|
41
82
|
const actions = $derived(m().playground.actions);
|
|
42
83
|
const chat = $derived(m().playground.chat);
|
|
43
84
|
const states = $derived(m().playground.states);
|
|
44
85
|
|
|
86
|
+
const commandMessages = $derived(m().playground.commands);
|
|
87
|
+
|
|
45
88
|
const resolvedPlaceholder = $derived(placeholder ?? chat.placeholder);
|
|
46
89
|
const resolvedPredefinedMessage = $derived(predefinedMessage ?? chat.predefinedRun);
|
|
47
90
|
|
|
@@ -57,29 +100,104 @@
|
|
|
57
100
|
let inputValue = $state('');
|
|
58
101
|
let inputField: HTMLTextAreaElement | undefined = $state();
|
|
59
102
|
|
|
60
|
-
|
|
61
|
-
|
|
103
|
+
/**
|
|
104
|
+
* Whether the current input is control traffic rather than pipeline data.
|
|
105
|
+
*
|
|
106
|
+
* Used only to relax the send gate (see {@link canSubmit}). Note that this
|
|
107
|
+
* does *not* make commands typable during a run: the textarea is disabled
|
|
108
|
+
* while `isExecuting`, and stopping a run is the Stop button's job.
|
|
109
|
+
*/
|
|
110
|
+
const inputIsCommand = $derived(enableCommands && isCommandInput(inputValue));
|
|
111
|
+
|
|
112
|
+
// Unique per instance so two playgrounds on one page don't collide, and
|
|
113
|
+
// shared with the listbox so aria-controls/activedescendant stay consistent.
|
|
114
|
+
const uid = $props.id();
|
|
115
|
+
const listboxId = `${uid}-command-palette-listbox`;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Command palette state.
|
|
119
|
+
*
|
|
120
|
+
* `dismissed` is separate from "no suggestions": pressing Escape must keep the
|
|
121
|
+
* palette shut while the user keeps typing the same command, and only a fresh
|
|
122
|
+
* edit that changes the completion set should bring it back.
|
|
123
|
+
*/
|
|
124
|
+
let paletteDismissed = $state(false);
|
|
125
|
+
|
|
126
|
+
const paletteSuggestions = $derived(
|
|
127
|
+
enableCommands ? suggestCommands(inputValue, fd.api.config, commandMessages.catalog) : []
|
|
128
|
+
);
|
|
129
|
+
const paletteVisible = $derived(!paletteDismissed && paletteSuggestions.length > 0);
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Where the user has moved the highlight, and where it actually lands.
|
|
133
|
+
*
|
|
134
|
+
* Clamped on read rather than corrected in an effect: effects run *after* the
|
|
135
|
+
* DOM updates, so a list that narrows under typing would render one frame
|
|
136
|
+
* with `aria-activedescendant` pointing at an option that no longer exists.
|
|
137
|
+
*/
|
|
138
|
+
let paletteCursor = $state(0);
|
|
139
|
+
const paletteIndex = $derived(
|
|
140
|
+
paletteSuggestions.length === 0 ? 0 : Math.min(paletteCursor, paletteSuggestions.length - 1)
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Match the textarea's height to its content, capped.
|
|
145
|
+
*
|
|
146
|
+
* Called from every path that changes `inputValue`, not just typing — the
|
|
147
|
+
* height is a function of the content, so anything that sets the content owes
|
|
148
|
+
* it an update.
|
|
149
|
+
*/
|
|
150
|
+
function resizeTextarea(): void {
|
|
151
|
+
if (!inputField) return;
|
|
152
|
+
inputField.style.height = 'auto';
|
|
153
|
+
inputField.style.height = `${Math.min(inputField.scrollHeight, 120)}px`;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function acceptSuggestion(suggestion: CommandSuggestion): void {
|
|
157
|
+
inputValue = suggestion.value;
|
|
158
|
+
paletteDismissed = true;
|
|
159
|
+
paletteCursor = 0;
|
|
160
|
+
tick().then(() => {
|
|
161
|
+
resizeTextarea();
|
|
162
|
+
inputField?.focus({ preventScroll: true });
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Commands bypass the send gate; plain text still respects it.
|
|
168
|
+
*
|
|
169
|
+
* This matters for states that are not "executing" but still refuse messages
|
|
170
|
+
* — `awaiting_input` most of all, where the textarea is live but
|
|
171
|
+
* `canSendMessage` is false, so without this a command could be typed and
|
|
172
|
+
* never submitted. Execution itself needs no special case: the button chain
|
|
173
|
+
* already swaps Send for Stop while a run is in flight.
|
|
174
|
+
*/
|
|
175
|
+
const canSubmit = $derived(
|
|
176
|
+
inputValue.trim().length > 0 && (inputIsCommand || fd.playground.canSendMessage)
|
|
177
|
+
);
|
|
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`.
|
|
62
183
|
let seenEnableRunCount = 0;
|
|
63
184
|
|
|
64
185
|
$effect(() => {
|
|
65
|
-
const count = fd.playground.messages.filter((
|
|
186
|
+
const count = fd.playground.messages.filter((msg) => hasEnableRunFlag(msg.metadata)).length;
|
|
66
187
|
if (count > seenEnableRunCount) {
|
|
67
|
-
|
|
68
|
-
seenEnableRunCount = count;
|
|
69
|
-
});
|
|
188
|
+
seenEnableRunCount = count;
|
|
70
189
|
runEnabled = true;
|
|
71
190
|
}
|
|
72
191
|
});
|
|
73
192
|
|
|
74
193
|
$effect(() => {
|
|
75
194
|
if (fd.playground.currentSession?.id) {
|
|
76
|
-
|
|
77
|
-
seenEnableRunCount = 0;
|
|
78
|
-
});
|
|
195
|
+
seenEnableRunCount = 0;
|
|
79
196
|
runEnabled = true;
|
|
80
197
|
}
|
|
81
198
|
});
|
|
82
199
|
|
|
200
|
+
// Same rationale as `seenEnableRunCount`: plain `let`, no `untrack` needed.
|
|
83
201
|
let wasExecuting = false;
|
|
84
202
|
|
|
85
203
|
/** Auto-focus input when execution completes */
|
|
@@ -88,28 +206,66 @@
|
|
|
88
206
|
if (wasExecuting && !nowExecuting && inputField) {
|
|
89
207
|
tick().then(() => inputField?.focus({ preventScroll: true }));
|
|
90
208
|
}
|
|
91
|
-
|
|
92
|
-
wasExecuting = nowExecuting;
|
|
93
|
-
});
|
|
209
|
+
wasExecuting = nowExecuting;
|
|
94
210
|
});
|
|
95
211
|
|
|
96
212
|
function handleSend(): void {
|
|
97
213
|
const trimmedValue = inputValue.trim();
|
|
98
|
-
if (!
|
|
214
|
+
if (!canSubmit) return;
|
|
99
215
|
|
|
216
|
+
onDismissCommandFeedback?.();
|
|
100
217
|
onSendMessage?.(trimmedValue);
|
|
101
218
|
inputValue = '';
|
|
102
219
|
|
|
103
|
-
if (inputField) {
|
|
104
|
-
inputField.style.height = 'auto';
|
|
105
|
-
}
|
|
106
|
-
|
|
107
220
|
tick().then(() => {
|
|
221
|
+
resizeTextarea();
|
|
108
222
|
inputField?.focus({ preventScroll: true });
|
|
109
223
|
});
|
|
110
224
|
}
|
|
111
225
|
|
|
112
226
|
function handleKeydown(event: KeyboardEvent): void {
|
|
227
|
+
// The palette owns navigation keys while it is open, mirroring the editor
|
|
228
|
+
// console so the two surfaces behave identically.
|
|
229
|
+
if (paletteVisible) {
|
|
230
|
+
if (event.key === 'ArrowUp') {
|
|
231
|
+
event.preventDefault();
|
|
232
|
+
paletteCursor = paletteIndex > 0 ? paletteIndex - 1 : paletteSuggestions.length - 1;
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
if (event.key === 'ArrowDown') {
|
|
236
|
+
event.preventDefault();
|
|
237
|
+
paletteCursor = paletteIndex < paletteSuggestions.length - 1 ? paletteIndex + 1 : 0;
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
if (event.key === 'Tab') {
|
|
241
|
+
event.preventDefault();
|
|
242
|
+
acceptSuggestion(paletteSuggestions[paletteIndex]);
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
if (event.key === 'Escape') {
|
|
246
|
+
event.preventDefault();
|
|
247
|
+
// Escape must not reach an ancestor here: PlaygroundModal closes on
|
|
248
|
+
// Escape, so without this, dismissing the palette would also close the
|
|
249
|
+
// whole playground.
|
|
250
|
+
event.stopPropagation();
|
|
251
|
+
paletteDismissed = true;
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
if (event.key === 'Enter' && !event.shiftKey) {
|
|
255
|
+
event.preventDefault();
|
|
256
|
+
const suggestion = paletteSuggestions[paletteIndex];
|
|
257
|
+
// Compare trimmed: a completion for an argument-taking command differs
|
|
258
|
+
// from a fully typed name only by its trailing space, and `/run` +
|
|
259
|
+
// Enter should start a run rather than silently insert a space.
|
|
260
|
+
if (suggestion.value.trim() !== inputValue.trim()) {
|
|
261
|
+
acceptSuggestion(suggestion);
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
handleSend();
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
113
269
|
if (event.key === 'Enter' && !event.shiftKey) {
|
|
114
270
|
event.preventDefault();
|
|
115
271
|
handleSend();
|
|
@@ -123,14 +279,33 @@
|
|
|
123
279
|
function handleRun(): void {
|
|
124
280
|
if (fd.playground.isExecuting || !runEnabled) return;
|
|
125
281
|
runEnabled = false;
|
|
126
|
-
|
|
282
|
+
|
|
283
|
+
const action = resolveRunAction({
|
|
284
|
+
canLaunch: onRunWorkflow != null,
|
|
285
|
+
predefinedMessage,
|
|
286
|
+
defaultMessage: resolvedPredefinedMessage
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
if (action.kind === 'launch') {
|
|
290
|
+
onRunWorkflow?.();
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
onSendMessage?.(action.content);
|
|
127
295
|
}
|
|
128
296
|
|
|
129
297
|
function handleInput(): void {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
298
|
+
// Typing re-opens the palette: a dismissal applies to the text it was
|
|
299
|
+
// dismissed on, not to the rest of the session.
|
|
300
|
+
paletteDismissed = false;
|
|
301
|
+
// ...and restarts the highlight at the top, as the editor console does.
|
|
302
|
+
// Without this the cursor survives a narrowing list: highlight the third
|
|
303
|
+
// entry, type one more character, and you are now pointed at whatever
|
|
304
|
+
// happens to be third in the *new* list, which is not what you were aiming
|
|
305
|
+
// at. Clamping keeps it in range; only resetting keeps it meaningful.
|
|
306
|
+
paletteCursor = 0;
|
|
307
|
+
|
|
308
|
+
resizeTextarea();
|
|
134
309
|
}
|
|
135
310
|
</script>
|
|
136
311
|
|
|
@@ -141,9 +316,60 @@
|
|
|
141
316
|
<span>{states.viewOnlyHelp}</span>
|
|
142
317
|
</div>
|
|
143
318
|
{:else}
|
|
319
|
+
<!--
|
|
320
|
+
The live region is always present and only its *contents* come and go.
|
|
321
|
+
A region inserted with its text already in place is usually announced by
|
|
322
|
+
nothing at all — screen readers watch established regions for changes.
|
|
323
|
+
|
|
324
|
+
One fixed politeness, too, rather than swapping role between `status` and
|
|
325
|
+
`alert`: the `{#if}` reuses this node, and role changes on a live node are
|
|
326
|
+
not reliably re-evaluated. Severity is carried visually instead.
|
|
327
|
+
-->
|
|
328
|
+
<div class="chat-input__command-feedback-region" role="status" aria-live="polite">
|
|
329
|
+
{#if commandFeedback}
|
|
330
|
+
<div
|
|
331
|
+
class="chat-input__command-feedback chat-input__command-feedback--{commandFeedback.status}"
|
|
332
|
+
>
|
|
333
|
+
<span class="chat-input__command-feedback-text">{commandFeedback.message}</span>
|
|
334
|
+
<button
|
|
335
|
+
type="button"
|
|
336
|
+
class="chat-input__command-feedback-dismiss"
|
|
337
|
+
onclick={() => onDismissCommandFeedback?.()}
|
|
338
|
+
aria-label={commandMessages.dismiss}
|
|
339
|
+
>
|
|
340
|
+
<Icon icon="mdi:close" />
|
|
341
|
+
</button>
|
|
342
|
+
</div>
|
|
343
|
+
{/if}
|
|
344
|
+
</div>
|
|
144
345
|
<div class="chat-input__container" class:chat-input__container--run-only={!showTextarea}>
|
|
145
346
|
{#if showTextarea}
|
|
146
347
|
<div class="chat-input__wrapper">
|
|
348
|
+
{#if enableCommands}
|
|
349
|
+
<ConsoleAutocomplete
|
|
350
|
+
suggestions={paletteSuggestions}
|
|
351
|
+
visible={paletteVisible}
|
|
352
|
+
selectedIndex={paletteIndex}
|
|
353
|
+
onAccept={acceptSuggestion}
|
|
354
|
+
{listboxId}
|
|
355
|
+
/>
|
|
356
|
+
{/if}
|
|
357
|
+
<!--
|
|
358
|
+
`role="combobox"` on a <textarea> is a deliberate, non-conforming
|
|
359
|
+
choice, recorded here so it is not "fixed" by guesswork later.
|
|
360
|
+
|
|
361
|
+
ARIA in HTML permits no role on <textarea> other than its implicit
|
|
362
|
+
`textbox`, and the ARIA 1.2 combobox pattern assumes a single-line
|
|
363
|
+
input. But there is no conforming pattern for "multi-line composer
|
|
364
|
+
with completions", and the strictly-valid alternative — implicit
|
|
365
|
+
`textbox` plus `aria-activedescendant`, dropping `aria-expanded`
|
|
366
|
+
(which `textbox` does not support) — leaves no way to announce that
|
|
367
|
+
the palette opened at all.
|
|
368
|
+
|
|
369
|
+
We take the announcement over the conformance, which is what
|
|
370
|
+
comparable chat composers ship. Revisit if ARIA gains a real pattern
|
|
371
|
+
for this, or if testing shows a screen reader handles it badly.
|
|
372
|
+
-->
|
|
147
373
|
<textarea
|
|
148
374
|
bind:this={inputField}
|
|
149
375
|
bind:value={inputValue}
|
|
@@ -153,6 +379,14 @@
|
|
|
153
379
|
disabled={fd.playground.isExecuting || !fd.playground.currentSession}
|
|
154
380
|
onkeydown={handleKeydown}
|
|
155
381
|
oninput={handleInput}
|
|
382
|
+
onblur={() => (paletteDismissed = true)}
|
|
383
|
+
autocomplete="off"
|
|
384
|
+
role={enableCommands ? 'combobox' : undefined}
|
|
385
|
+
aria-expanded={enableCommands ? paletteVisible : undefined}
|
|
386
|
+
aria-controls={enableCommands ? listboxId : undefined}
|
|
387
|
+
aria-activedescendant={paletteVisible
|
|
388
|
+
? `${listboxId}-option-${paletteIndex}`
|
|
389
|
+
: undefined}
|
|
156
390
|
></textarea>
|
|
157
391
|
</div>
|
|
158
392
|
{/if}
|
|
@@ -173,7 +407,7 @@
|
|
|
173
407
|
type="button"
|
|
174
408
|
class="chat-input__send-btn"
|
|
175
409
|
onclick={handleSend}
|
|
176
|
-
disabled={!
|
|
410
|
+
disabled={!canSubmit}
|
|
177
411
|
title={actions.sendTitle}
|
|
178
412
|
aria-label={actions.sendTitle}
|
|
179
413
|
>
|
|
@@ -217,10 +451,66 @@
|
|
|
217
451
|
justify-content: flex-end;
|
|
218
452
|
}
|
|
219
453
|
|
|
454
|
+
.chat-input__command-feedback {
|
|
455
|
+
display: flex;
|
|
456
|
+
align-items: flex-start;
|
|
457
|
+
gap: var(--fd-space-sm);
|
|
458
|
+
max-width: 760px;
|
|
459
|
+
margin: 0 auto var(--fd-space-sm);
|
|
460
|
+
padding: var(--fd-space-sm) var(--fd-space-md);
|
|
461
|
+
border-radius: var(--fd-radius-md);
|
|
462
|
+
font-size: var(--fd-font-size-sm);
|
|
463
|
+
line-height: 1.4;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
.chat-input__command-feedback-text {
|
|
467
|
+
flex: 1;
|
|
468
|
+
/* /help returns a newline-separated list — keep its shape. */
|
|
469
|
+
white-space: pre-wrap;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/*
|
|
473
|
+
* Status tokens, not literals: `--fd-*-muted` is a translucent tint that is
|
|
474
|
+
* redefined for dark mode, so these follow the theme. Hardcoded pastels do
|
|
475
|
+
* not, and rendered as bright blocks on a dark UI.
|
|
476
|
+
*/
|
|
477
|
+
.chat-input__command-feedback--ok {
|
|
478
|
+
background-color: var(--fd-success-muted);
|
|
479
|
+
color: var(--fd-success);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
.chat-input__command-feedback--info {
|
|
483
|
+
background-color: var(--fd-info-muted);
|
|
484
|
+
color: var(--fd-info);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
.chat-input__command-feedback--error {
|
|
488
|
+
background-color: var(--fd-error-muted);
|
|
489
|
+
color: var(--fd-error);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
.chat-input__command-feedback-dismiss {
|
|
493
|
+
flex-shrink: 0;
|
|
494
|
+
display: flex;
|
|
495
|
+
align-items: center;
|
|
496
|
+
background: none;
|
|
497
|
+
border: none;
|
|
498
|
+
padding: 0;
|
|
499
|
+
cursor: pointer;
|
|
500
|
+
color: inherit;
|
|
501
|
+
opacity: 0.7;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
.chat-input__command-feedback-dismiss:hover {
|
|
505
|
+
opacity: 1;
|
|
506
|
+
}
|
|
507
|
+
|
|
220
508
|
.chat-input__wrapper {
|
|
221
509
|
flex: 1;
|
|
222
510
|
display: flex;
|
|
223
511
|
align-items: flex-end;
|
|
512
|
+
/* Positioning context for the command palette, which sits above the input. */
|
|
513
|
+
position: relative;
|
|
224
514
|
background-color: var(--fd-background);
|
|
225
515
|
border: 1px solid var(--fd-border);
|
|
226
516
|
border-radius: var(--fd-radius-xl);
|
|
@@ -1,13 +1,43 @@
|
|
|
1
|
+
import { type CommandOutcome } from '../../playground/commands/index.js';
|
|
1
2
|
interface Props {
|
|
2
3
|
placeholder?: string;
|
|
3
4
|
/** Show the textarea (default: true). When false, only the Run button is shown. */
|
|
4
5
|
showTextarea?: boolean;
|
|
5
6
|
/** Show the Run button when textarea is hidden (default: true) */
|
|
6
7
|
showRunButton?: boolean;
|
|
7
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Message sent when Run is clicked, for hosts that deliberately want the
|
|
10
|
+
* run to begin with a specific chat turn.
|
|
11
|
+
*
|
|
12
|
+
* Setting this opts *out* of {@link onRunWorkflow}: an explicitly
|
|
13
|
+
* configured message is a host's intentional choice and is honoured.
|
|
14
|
+
* Leaving it unset is what lets Run launch without fabricating a turn.
|
|
15
|
+
*/
|
|
8
16
|
predefinedMessage?: string;
|
|
9
17
|
onSendMessage?: (content: string) => void;
|
|
10
18
|
onStopExecution?: () => void;
|
|
19
|
+
/**
|
|
20
|
+
* Start a run without posting a chat message.
|
|
21
|
+
*
|
|
22
|
+
* Preferred over `onSendMessage` for the Run button. Sending a message to
|
|
23
|
+
* start a run fabricates a user turn that enters the conversation and is
|
|
24
|
+
* replayed as input on the following turn — indistinguishable downstream
|
|
25
|
+
* from something the user actually typed. Hosts that provide this get a Run
|
|
26
|
+
* button that launches instead.
|
|
27
|
+
*/
|
|
28
|
+
onRunWorkflow?: () => void;
|
|
29
|
+
/**
|
|
30
|
+
* Enable the slash-command lane (default: false).
|
|
31
|
+
*
|
|
32
|
+
* Opt-in because the lane is only safe where the `onSendMessage` handler
|
|
33
|
+
* actually dispatches commands. A surface that forwards input straight to a
|
|
34
|
+
* backend (ChatPanel) would post `/stop` as literal text — faking a command
|
|
35
|
+
* that nothing implements.
|
|
36
|
+
*/
|
|
37
|
+
enableCommands?: boolean;
|
|
38
|
+
/** Transient result of the last slash command. Never a session message. */
|
|
39
|
+
commandFeedback?: CommandOutcome | null;
|
|
40
|
+
onDismissCommandFeedback?: () => void;
|
|
11
41
|
}
|
|
12
42
|
declare const ChatInput: import("svelte").Component<Props, {}, "">;
|
|
13
43
|
type ChatInput = ReturnType<typeof ChatInput>;
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
import ChatInput from './ChatInput.svelte';
|
|
13
13
|
import { getInstance } from '../../stores/getInstance.svelte.js';
|
|
14
14
|
import { m } from '../../messages/index.js';
|
|
15
|
+
import type { CommandOutcome } from '../../playground/commands/index.js';
|
|
15
16
|
|
|
16
17
|
const fd = getInstance();
|
|
17
18
|
|
|
@@ -24,6 +25,19 @@
|
|
|
24
25
|
// Orchestration
|
|
25
26
|
onSendMessage: (content: string) => void;
|
|
26
27
|
onStopExecution: () => void;
|
|
28
|
+
/** Start a run without posting a chat message. See ChatInput. */
|
|
29
|
+
onRunWorkflow?: () => void;
|
|
30
|
+
/**
|
|
31
|
+
* Enable the slash-command lane (default: false).
|
|
32
|
+
*
|
|
33
|
+
* Only safe when `onSendMessage` dispatches commands rather than forwarding
|
|
34
|
+
* them to the backend as text — Playground opts in; a host wiring
|
|
35
|
+
* ControlPanel to its own handler should not.
|
|
36
|
+
*/
|
|
37
|
+
enableCommands?: boolean;
|
|
38
|
+
// Slash-command feedback (transient; never a session message)
|
|
39
|
+
commandFeedback?: CommandOutcome | null;
|
|
40
|
+
onDismissCommandFeedback?: () => void;
|
|
27
41
|
// Header actions
|
|
28
42
|
onTogglePanel?: () => void;
|
|
29
43
|
isPipelinePanelOpen?: boolean;
|
|
@@ -48,6 +62,10 @@
|
|
|
48
62
|
onSessionNavigate,
|
|
49
63
|
onSendMessage,
|
|
50
64
|
onStopExecution,
|
|
65
|
+
onRunWorkflow,
|
|
66
|
+
enableCommands = false,
|
|
67
|
+
commandFeedback = null,
|
|
68
|
+
onDismissCommandFeedback,
|
|
51
69
|
onTogglePanel,
|
|
52
70
|
isPipelinePanelOpen = false,
|
|
53
71
|
onRefresh,
|
|
@@ -256,6 +274,10 @@
|
|
|
256
274
|
{predefinedMessage}
|
|
257
275
|
{onSendMessage}
|
|
258
276
|
{onStopExecution}
|
|
277
|
+
{onRunWorkflow}
|
|
278
|
+
{enableCommands}
|
|
279
|
+
{commandFeedback}
|
|
280
|
+
{onDismissCommandFeedback}
|
|
259
281
|
/>
|
|
260
282
|
</section>
|
|
261
283
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CommandOutcome } from '../../playground/commands/index.js';
|
|
1
2
|
interface Props {
|
|
2
3
|
onCreateSession: () => void;
|
|
3
4
|
onSelectSession: (id: string) => void;
|
|
@@ -5,6 +6,18 @@ interface Props {
|
|
|
5
6
|
onSessionNavigate?: (id: string) => void;
|
|
6
7
|
onSendMessage: (content: string) => void;
|
|
7
8
|
onStopExecution: () => void;
|
|
9
|
+
/** Start a run without posting a chat message. See ChatInput. */
|
|
10
|
+
onRunWorkflow?: () => void;
|
|
11
|
+
/**
|
|
12
|
+
* Enable the slash-command lane (default: false).
|
|
13
|
+
*
|
|
14
|
+
* Only safe when `onSendMessage` dispatches commands rather than forwarding
|
|
15
|
+
* them to the backend as text — Playground opts in; a host wiring
|
|
16
|
+
* ControlPanel to its own handler should not.
|
|
17
|
+
*/
|
|
18
|
+
enableCommands?: boolean;
|
|
19
|
+
commandFeedback?: CommandOutcome | null;
|
|
20
|
+
onDismissCommandFeedback?: () => void;
|
|
8
21
|
onTogglePanel?: () => void;
|
|
9
22
|
isPipelinePanelOpen?: boolean;
|
|
10
23
|
onRefresh: () => void;
|