@widgetic/chat 0.1.35 → 0.1.37
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/README.md +34 -6
- package/dist/components/ActionBar.svelte +8 -0
- package/dist/components/Chat.svelte +120 -106
- package/dist/components/Chat.svelte.d.ts +19 -1
- package/dist/components/ChatComposer.svelte +166 -0
- package/dist/components/ChatComposer.svelte.d.ts +30 -0
- package/dist/components/ChatMessages.svelte +483 -393
- package/dist/components/ChatMessages.svelte.d.ts +16 -6
- package/dist/components/IconButton.svelte +125 -0
- package/dist/components/IconButton.svelte.d.ts +22 -0
- package/dist/components/MessageActions.svelte +48 -0
- package/dist/components/MessageActions.svelte.d.ts +13 -0
- package/dist/components/PanelChatHeader.svelte +79 -0
- package/dist/components/PanelChatHeader.svelte.d.ts +19 -0
- package/dist/components/PanelFollowUpSuggestions.svelte +34 -0
- package/dist/components/PanelFollowUpSuggestions.svelte.d.ts +8 -0
- package/dist/components/PanelSuggestionButtons.svelte +60 -0
- package/dist/components/PanelSuggestionButtons.svelte.d.ts +10 -0
- package/dist/components/SuggestionButtons.svelte +11 -163
- package/dist/i18n/index.d.ts +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/i18n/messages.d.ts +54 -13
- package/dist/i18n/messages.js +54 -13
- package/dist/i18n/suggestions.d.ts +6 -0
- package/dist/i18n/suggestions.js +24 -0
- package/dist/types/message.d.ts +7 -0
- package/dist/utils/generationActivity.d.ts +12 -0
- package/dist/utils/generationActivity.js +47 -0
- package/dist/utils/generationPlan.d.ts +32 -0
- package/dist/utils/generationPlan.js +89 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/messageActions.d.ts +54 -0
- package/dist/utils/messageActions.js +104 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -161,12 +161,30 @@ You can also use individual components:
|
|
|
161
161
|
/>
|
|
162
162
|
```
|
|
163
163
|
|
|
164
|
+
### The icons of the messages
|
|
165
|
+
|
|
166
|
+
Three kinds of icon sit around the messages. None of them is shown while something is being generated.
|
|
167
|
+
|
|
168
|
+
- **At the end of the last message**, one row of up to four icons: **copy** (the words the assistant said, else the title of the commit the turn
|
|
169
|
+
made; the icon says "Copied" for a moment), **regenerate** (runs the prompt of that turn again, through `onRetryMessage`; left out when the
|
|
170
|
+
prompt cannot be run again), and **thumbs up** and **thumbs down** (see [Rating a version](#rating-a-version)). An icon that has nothing to do
|
|
171
|
+
is left out, and the whole row with it.
|
|
172
|
+
- **On a message the person sent**, one **restore** icon ("Restore Checkpoint") at the end of the message, shown when the pointer is over the
|
|
173
|
+
message or the keyboard is on the icon (always shown on a screen with no hover). It puts the widget back to how it was **before that
|
|
174
|
+
message**: the chat asks the page, through `onRestoreCheckpointBackend`, to restore the version of the nearest earlier prompt that made one,
|
|
175
|
+
and then adds the restored prompt and "Restored from Version N" to the list. Only a message that made a version has the icon, and no icon is
|
|
176
|
+
drawn when the page gave no `onRestoreCheckpointBackend`. The first version has nothing before it: while the widget sits on it, its icon undoes
|
|
177
|
+
it (the page decides what that means); once later versions exist it has no icon. After a restore, the next message goes back to the restored version.
|
|
178
|
+
|
|
179
|
+
There is no "You are here" mark: the person is always at the end of the conversation. The `viewingVersion` prop of `Chat` is still accepted and
|
|
180
|
+
ignored, so a page that passes it keeps compiling.
|
|
181
|
+
|
|
164
182
|
### Rating a version
|
|
165
183
|
|
|
166
|
-
|
|
167
|
-
that version is good
|
|
168
|
-
|
|
169
|
-
`down`, or `none` (the person took their rating back).
|
|
184
|
+
At the end of the last message (the reply that announced a change of the widget) the chat can draw two thumbs, so a person can say whether
|
|
185
|
+
that version is good: a thumbs up helps the code generator learn what works, a thumbs down what does not. The thumbs are **opt-in**: give
|
|
186
|
+
`Chat` an `onRateVersion` callback and they appear, leave it out and the chat draws no thumbs. The chat keeps no rating of its own: the page
|
|
187
|
+
decides where a rating goes. A rating is one of three words: `up`, `down`, or `none` (the person took their rating back).
|
|
170
188
|
|
|
171
189
|
```svelte
|
|
172
190
|
<script lang="ts">
|
|
@@ -192,7 +210,7 @@ works as it always did. The chat keeps no rating of its own: the page decides wh
|
|
|
192
210
|
again. What the person pressed in this chat is shown over it. Without it, the thumbs start empty each time the chat opens.
|
|
193
211
|
- Only a version the backend saved can be rated: not a reply still on its way or one that failed, not the copy a restore appends, not the
|
|
194
212
|
stand-in the chat draws while the widget's head is ahead of every saved message, and not a version a restore undid. Nothing is drawn while
|
|
195
|
-
the chat is loading.
|
|
213
|
+
the chat is loading or generating, and the thumbs belong to the last message only.
|
|
196
214
|
- Words: `chat.messages.rateGroup`, `chat.messages.rateUp` and `chat.messages.rateDown` (see [Languages](#languages)).
|
|
197
215
|
|
|
198
216
|
## State Management
|
|
@@ -259,6 +277,16 @@ const customConfig = {
|
|
|
259
277
|
};
|
|
260
278
|
```
|
|
261
279
|
|
|
280
|
+
### Code generation activity (host-driven)
|
|
281
|
+
|
|
282
|
+
While the host runs widget codegen, pass **`isGenerating`**, and optionally **`generationThinking`**,
|
|
283
|
+
**`generationStream`**, and **`generationPlan`**: rolling tails from `operation.metadata.thinkingTail` /
|
|
284
|
+
`thinking_tail` and `streamTail` / `stream_tail`, plus the gateway build plan (`metadata.plan`; `null` hides the
|
|
285
|
+
card). The messages list shows a read-only **`PlanCard`** above one activity card — streamed reasoning first,
|
|
286
|
+
then live code in the same bubble. Parse wire data with **`readGenerationPlanFromMetadata`** from
|
|
287
|
+
`@widgetic/chat`. When **`features.screenshot`** is `false`, the action bar hides the screenshot control;
|
|
288
|
+
ordinary image upload and screen recording are unchanged.
|
|
289
|
+
|
|
262
290
|
## Languages
|
|
263
291
|
|
|
264
292
|
The chat shows English until it is told otherwise. Two props of `Chat` change that, and both can change while the chat
|
|
@@ -302,7 +330,7 @@ console.log(CHAT_MESSAGES['chat.attachment.more']); // '{count, plural, one {+#
|
|
|
302
330
|
| Keys start with | The words of |
|
|
303
331
|
| --- | --- |
|
|
304
332
|
| `chat.header.`, `chat.contextPreview.`, `chat.contextType.`, `chat.conversation.` | the header, the list of conversations, the collapsed chat, the name of what a chat is about ("frame", "text"), and the title of a new conversation |
|
|
305
|
-
| `chat.messages.` | the list of messages: the empty state, "thinking",
|
|
333
|
+
| `chat.messages.` | the list of messages: the empty state, "thinking", the icons (copy, regenerate, restore, thumbs), versions and commit ids |
|
|
306
334
|
| `chat.input.`, `chat.actions.` | the box you type in, and the screenshot, record, upload and "mark complete" buttons |
|
|
307
335
|
| `chat.suggestions.` | the ideas offered to start with (five for each kind of thing a chat is about) and their headings |
|
|
308
336
|
| `chat.attachment.`, `chat.size.` | attachments, and file sizes ("1.5 MB") |
|
|
@@ -247,6 +247,14 @@
|
|
|
247
247
|
pointer-events: none;
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
+
/*
|
|
251
|
+
* Nothing to hold: every button is off and the page's extras drew no control (the creator's extras are for debug only, and
|
|
252
|
+
* outside it they are an empty wrapper), so the bar is not drawn at all, instead of an empty strip above the composer.
|
|
253
|
+
*/
|
|
254
|
+
.action-bar:not(:has(button, label, input, select, textarea, a)) {
|
|
255
|
+
display: none;
|
|
256
|
+
}
|
|
257
|
+
|
|
250
258
|
.action-bar-extras {
|
|
251
259
|
display: contents;
|
|
252
260
|
}
|
|
@@ -11,8 +11,10 @@
|
|
|
11
11
|
import type { ClarificationSuggestion, DesignControlRequest, VersionRating } from '../types/message.js';
|
|
12
12
|
import type { AttachmentInput, SelectedElementChatReference } from '../types/attachment.js';
|
|
13
13
|
import ChatMessages from './ChatMessages.svelte';
|
|
14
|
-
import
|
|
14
|
+
import ChatComposer, { type ComposerModelOption } from './ChatComposer.svelte';
|
|
15
|
+
import { Chip } from '@widgetic/design-system/components/chat/index';
|
|
15
16
|
import ActionBar from './ActionBar.svelte';
|
|
17
|
+
import PanelChatHeader from './PanelChatHeader.svelte';
|
|
16
18
|
import StatusIndicator from './StatusIndicator.svelte';
|
|
17
19
|
import { provideChatLanguage } from '../i18n/language.js';
|
|
18
20
|
import { actionFailureKey, contextTypeLabel } from '../i18n/labels.js';
|
|
@@ -117,6 +119,12 @@
|
|
|
117
119
|
options?: { onProgress?: (percentage: number) => void; source?: string },
|
|
118
120
|
) => Promise<{ id: string; url: string; fileType: string; fileName: string; fileSize: number }>;
|
|
119
121
|
showHeader?: boolean;
|
|
122
|
+
/** DS panel header (history, new chat, console). Used beside the canvas in the widget creator. */
|
|
123
|
+
showPanelHeader?: boolean;
|
|
124
|
+
/** When true with `onToggleConsole`, shows the debug console icon in the panel header. */
|
|
125
|
+
showConsoleControl?: boolean;
|
|
126
|
+
consoleOpen?: boolean;
|
|
127
|
+
onToggleConsole?: () => void;
|
|
120
128
|
/** Custom title displayed in the header. If empty/undefined, defaults to context.title or context.id. */
|
|
121
129
|
headerTitle?: string;
|
|
122
130
|
/** When false, hides the icon + type description row below the title, making the header compact. */
|
|
@@ -152,12 +160,19 @@
|
|
|
152
160
|
versionLabelByPrompt?: Record<string, string>;
|
|
153
161
|
/** Saved versions, so a prompt that produced two commits can show two turns. */
|
|
154
162
|
versionTimeline?: Array<{ version: number; sha: string; prompt: string }>;
|
|
155
|
-
/**
|
|
163
|
+
/**
|
|
164
|
+
* @deprecated The chat no longer marks one version as "you are here" (the person is always at the end of the conversation).
|
|
165
|
+
* Still accepted, so a host that passes it keeps compiling; it is ignored.
|
|
166
|
+
*/
|
|
156
167
|
viewingVersion?: number | null;
|
|
157
168
|
/** Host is running widget codegen — send button becomes stop. */
|
|
158
169
|
isGenerating?: boolean;
|
|
159
170
|
/** Tail of the model stream while codegen is in flight. */
|
|
160
171
|
generationStream?: string;
|
|
172
|
+
/** Rolling tail of streamed model reasoning while codegen is in flight. */
|
|
173
|
+
generationThinking?: string;
|
|
174
|
+
/** Gateway build plan (`operation.metadata.plan`), or `null` to hide the plan card. */
|
|
175
|
+
generationPlan?: import('../utils/generationPlan.js').GenerationPlanWire | null;
|
|
161
176
|
onStopGeneration?: () => void;
|
|
162
177
|
/**
|
|
163
178
|
* Renders the inline design-control card attached to an assistant reply
|
|
@@ -192,6 +207,10 @@
|
|
|
192
207
|
onRemoveSelectedElement?: (elementId: string) => void;
|
|
193
208
|
/** Fired when all selected widget elements should be cleared (e.g. after sending). */
|
|
194
209
|
onClearSelectedElements?: () => void;
|
|
210
|
+
/** Model list for the DS composer Assistant menu; hidden when empty. */
|
|
211
|
+
composerModels?: ComposerModelOption[];
|
|
212
|
+
selectedComposerModelId?: string | null;
|
|
213
|
+
onSelectComposerModel?: (modelId: string) => void;
|
|
195
214
|
}
|
|
196
215
|
|
|
197
216
|
// Expose methods to parent component
|
|
@@ -231,7 +250,7 @@
|
|
|
231
250
|
updateLastUserMessageAttachments: (attachments: Array<{ id?: string; url: string; file_type?: string; file_name?: string | null }>) => void;
|
|
232
251
|
}
|
|
233
252
|
|
|
234
|
-
let { context, config = {}, class: className = '', locale = null, messages: languageMessages = null, dir = undefined, style = '', isCompleted = false, onStatsUpdate, onChatReady, onCompletionToggle, onSendMessage, onLoadConversations, onLoadMessages, onCreateConversation, onSaveMessage, onRestoreCheckpointBackend, onRateVersion, versionRatings: ratingsFromHost = {}, onTakeScreenshot, onConversationChange, onDraftChange, onRetryMessage, onUpgradePlans, onUploadChatFile, showHeader = true, headerTitle = '', showDescriptionHeader = true, showLogs = true, resizeExpandsContainer = false, onMessagesResize, onMessagesDrag, onMessagesDragEnd, onLoadOlderMessages, widgetHeadCommitSha = null, versionLabelByCommitSha = {}, versionLabelByPrompt = {}, versionTimeline = [],
|
|
253
|
+
let { context, config = {}, class: className = '', locale = null, messages: languageMessages = null, dir = undefined, style = '', isCompleted = false, onStatsUpdate, onChatReady, onCompletionToggle, onSendMessage, onLoadConversations, onLoadMessages, onCreateConversation, onSaveMessage, onRestoreCheckpointBackend, onRateVersion, versionRatings: ratingsFromHost = {}, onTakeScreenshot, onConversationChange, onDraftChange, onRetryMessage, onUpgradePlans, onUploadChatFile, showHeader = true, showPanelHeader = false, showConsoleControl = false, consoleOpen = false, onToggleConsole, headerTitle = '', showDescriptionHeader = true, showLogs = true, resizeExpandsContainer = false, onMessagesResize, onMessagesDrag, onMessagesDragEnd, onLoadOlderMessages, widgetHeadCommitSha = null, versionLabelByCommitSha = {}, versionLabelByPrompt = {}, versionTimeline = [], isGenerating = false, generationStream = '', generationThinking = '', generationPlan = null, onStopGeneration, renderDesignControls, actionBarExtras, completeReplacement, replaceComplete = false, showSelector = false, isSelectorActive = false, selectedElements = [], onToggleSelector, onRemoveSelectedElement, onClearSelectedElements, composerExtras, storedLineLabel, composerModels = [], selectedComposerModelId = null, onSelectComposerModel }: Props = $props();
|
|
235
254
|
|
|
236
255
|
// The words of everything inside the chat, in the language the page chose. The page can change the language while the
|
|
237
256
|
// chat is open: the settings are read again whenever they change (and setting the same language again does nothing).
|
|
@@ -271,7 +290,20 @@
|
|
|
271
290
|
}
|
|
272
291
|
|
|
273
292
|
const promptVersionLabels = $derived(versionLabelByPrompt ?? {});
|
|
274
|
-
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* The action bar holds what the composer does not do itself: screenshot, recording, the element selector, completion and
|
|
296
|
+
* whatever the page adds. Attaching a file is the "+" of the composer (Figma), so a page that turns all of those off
|
|
297
|
+
* (the creator) has no bar above its composer.
|
|
298
|
+
*/
|
|
299
|
+
const showActionBar = $derived(
|
|
300
|
+
config?.features?.screenshot !== false ||
|
|
301
|
+
config?.features?.screenRecording !== false ||
|
|
302
|
+
!!showSelector ||
|
|
303
|
+
config?.features?.markComplete !== false ||
|
|
304
|
+
!!actionBarExtras ||
|
|
305
|
+
!!(replaceComplete && completeReplacement)
|
|
306
|
+
);
|
|
275
307
|
|
|
276
308
|
// Apply log suppression immediately
|
|
277
309
|
$effect(() => {
|
|
@@ -293,6 +325,12 @@
|
|
|
293
325
|
let localIsSending = $state(false);
|
|
294
326
|
let localIsUploading = $state(false);
|
|
295
327
|
|
|
328
|
+
// The host hears about the draft when the person types (the setter of the composer binding below), not from an
|
|
329
|
+
// effect: an effect would call the host's callback inside its own tracking, and every piece of host state the
|
|
330
|
+
// callback reads would become a dependency of this effect. The creator's callback reads and writes the panel
|
|
331
|
+
// snapshots, so that made an update loop that froze the page for seconds. A text the host sets itself
|
|
332
|
+
// (setDraftText) is not announced back to it, as before.
|
|
333
|
+
|
|
296
334
|
// Reactive state from store - using proper store subscription initialized synchronously
|
|
297
335
|
let chatState = $state<any>(getCurrentState());
|
|
298
336
|
let storeUnsubscribe: (() => void) | null = null;
|
|
@@ -337,20 +375,6 @@
|
|
|
337
375
|
return !!list && (list as { hasOlder?: boolean }).hasOlder === true;
|
|
338
376
|
}
|
|
339
377
|
|
|
340
|
-
function loadedMessagesCoverVersion(version: number): boolean {
|
|
341
|
-
const entry = (versionTimeline || []).find((row) => row.version === version);
|
|
342
|
-
if (!entry) return true;
|
|
343
|
-
const sha = (entry.sha || '').slice(0, 7).toLowerCase();
|
|
344
|
-
const prompt = (entry.prompt || '').trim();
|
|
345
|
-
if (!sha && !prompt) return true;
|
|
346
|
-
const list = currentConversationId ? getCurrentMessages(currentConversationId) : [];
|
|
347
|
-
return list.some((message) => {
|
|
348
|
-
const text = message.messageContent || '';
|
|
349
|
-
if (sha && text.toLowerCase().includes(sha)) return true;
|
|
350
|
-
return !!prompt && text.trim() === prompt;
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
|
|
354
378
|
async function loadOlderMessages(): Promise<boolean> {
|
|
355
379
|
if (!currentConversationId || !onLoadOlderMessages || loadingOlderMessages || !hasOlderMessages) return false;
|
|
356
380
|
loadingOlderMessages = true;
|
|
@@ -375,27 +399,6 @@
|
|
|
375
399
|
}
|
|
376
400
|
}
|
|
377
401
|
|
|
378
|
-
let versionPageToken = 0;
|
|
379
|
-
$effect(() => {
|
|
380
|
-
const version = selectedViewingVersion;
|
|
381
|
-
const id = currentConversationId;
|
|
382
|
-
if (version == null || !id || !hasOlderMessages) return;
|
|
383
|
-
if (loadedMessagesCoverVersion(version)) return;
|
|
384
|
-
const token = ++versionPageToken;
|
|
385
|
-
void (async () => {
|
|
386
|
-
let guard = 0;
|
|
387
|
-
while (
|
|
388
|
-
token === versionPageToken
|
|
389
|
-
&& guard < 20
|
|
390
|
-
&& hasOlderMessages
|
|
391
|
-
&& !loadedMessagesCoverVersion(version)
|
|
392
|
-
) {
|
|
393
|
-
guard += 1;
|
|
394
|
-
const loaded = await loadOlderMessages();
|
|
395
|
-
if (!loaded) break;
|
|
396
|
-
}
|
|
397
|
-
})();
|
|
398
|
-
});
|
|
399
402
|
let availableConversations = $derived(
|
|
400
403
|
context && conversations ? conversations.byContextId[context.id] || [] : []
|
|
401
404
|
);
|
|
@@ -1169,11 +1172,21 @@
|
|
|
1169
1172
|
}
|
|
1170
1173
|
|
|
1171
1174
|
async function handleSuggestionSelected(suggestion: string) {
|
|
1172
|
-
|
|
1175
|
+
const trimmed = suggestion.trim();
|
|
1176
|
+
if (!trimmed) return;
|
|
1177
|
+
if (showPanelHeader) {
|
|
1178
|
+
if (isGenerating || localIsSending || isSendingOrLoading) return;
|
|
1179
|
+
try {
|
|
1180
|
+
await sendMessage(trimmed, undefined, { skipIntentGate: true });
|
|
1181
|
+
} catch (err) {
|
|
1182
|
+
console.error('[Chat] Panel suggestion send failed:', err);
|
|
1183
|
+
showFailure('chat.error.sendSuggestion');
|
|
1184
|
+
}
|
|
1185
|
+
return;
|
|
1186
|
+
}
|
|
1173
1187
|
// Autocomplete into input instead of sending immediately — lets user review,
|
|
1174
|
-
// edit, and attach an image before sending
|
|
1175
|
-
|
|
1176
|
-
setDraftText(suggestion);
|
|
1188
|
+
// edit, and attach an image before sending.
|
|
1189
|
+
setDraftText(trimmed);
|
|
1177
1190
|
}
|
|
1178
1191
|
|
|
1179
1192
|
/** Tapping a suggestion chip attached to an assistant clarification card sends it
|
|
@@ -1917,11 +1930,26 @@
|
|
|
1917
1930
|
|
|
1918
1931
|
<div
|
|
1919
1932
|
bind:this={chatContainer}
|
|
1920
|
-
class="{className ? className : 'prompt-chat-ct'} relative flex flex-col overflow-hidden
|
|
1933
|
+
class="{className ? className : 'prompt-chat-ct'} border-border bg-background relative flex h-full min-h-0 max-w-full flex-col overflow-hidden border {showPanelHeader ? 'w-full' : 'w-chat-panel'} {className ? '' : 'rounded-panel'}"
|
|
1921
1934
|
dir={$textDirection}
|
|
1922
1935
|
style={style}
|
|
1923
1936
|
>
|
|
1924
|
-
{#if
|
|
1937
|
+
{#if showPanelHeader}
|
|
1938
|
+
{@const panelTitle =
|
|
1939
|
+
(currentMessages?.length ?? 0) > 0 || isGenerating
|
|
1940
|
+
? (headerTitle?.trim() || context.title || '')
|
|
1941
|
+
: ''}
|
|
1942
|
+
<PanelChatHeader
|
|
1943
|
+
title={panelTitle}
|
|
1944
|
+
showConsole={showConsoleControl}
|
|
1945
|
+
{consoleOpen}
|
|
1946
|
+
onToggleConsole={onToggleConsole}
|
|
1947
|
+
onNewConversation={onCreateConversation || onLoadConversations ? () => void createNewConversation() : undefined}
|
|
1948
|
+
conversations={availableConversations}
|
|
1949
|
+
currentConversationId={currentConversationId}
|
|
1950
|
+
onSelectConversation={(id) => void loadConversation(id)}
|
|
1951
|
+
/>
|
|
1952
|
+
{:else if showHeader}
|
|
1925
1953
|
<!-- Simple Chat Header -->
|
|
1926
1954
|
<div class="prompt-chat-header {showDescriptionHeader ? 'p-4' : 'px-4 py-2'} border-b border-gray-200 bg-gray-50">
|
|
1927
1955
|
<div class="flex items-center gap-3">
|
|
@@ -1953,7 +1981,7 @@
|
|
|
1953
1981
|
|
|
1954
1982
|
<!-- Chat Interface -->
|
|
1955
1983
|
<div
|
|
1956
|
-
class="prompt-chat-messages-area flex min-h-0 flex-col overflow-hidden"
|
|
1984
|
+
class="prompt-chat-messages-area flex min-h-0 flex-col overflow-hidden {showPanelHeader ? 'flex-1' : ''}"
|
|
1957
1985
|
style="{messagesAreaHeight !== null
|
|
1958
1986
|
? `flex: 0 0 ${messagesAreaHeight}px; height: ${messagesAreaHeight}px;`
|
|
1959
1987
|
: 'flex: 1 1 auto; min-height: 0;'}"
|
|
@@ -1964,6 +1992,7 @@
|
|
|
1964
1992
|
isLoading={isLoading}
|
|
1965
1993
|
isInitialized={isInitialized}
|
|
1966
1994
|
{showEmptyState}
|
|
1995
|
+
panelLayout={showPanelHeader}
|
|
1967
1996
|
{context}
|
|
1968
1997
|
isCompleted={isCompleted}
|
|
1969
1998
|
enableAutoCodeDetection={config?.features?.autoCodeDetection === true}
|
|
@@ -1972,14 +2001,15 @@
|
|
|
1972
2001
|
versionLabelByCommitSha={versionLabelByCommitSha}
|
|
1973
2002
|
versionLabelByPrompt={promptVersionLabels}
|
|
1974
2003
|
{versionTimeline}
|
|
1975
|
-
viewingVersion={selectedViewingVersion}
|
|
1976
2004
|
{hasOlderMessages}
|
|
1977
2005
|
onRequestOlderMessages={() => loadOlderMessages()}
|
|
1978
2006
|
showCommitMeta={showLogs}
|
|
1979
2007
|
isGenerating={isGenerating || isLoading}
|
|
1980
2008
|
generationStream={isGenerating ? generationStream : ''}
|
|
2009
|
+
generationThinking={isGenerating ? generationThinking : ''}
|
|
2010
|
+
generationPlan={isGenerating ? generationPlan : null}
|
|
1981
2011
|
onSuggestionSelected={handleSuggestionSelected}
|
|
1982
|
-
onRestoreCheckpoint={handleRestoreCheckpoint}
|
|
2012
|
+
onRestoreCheckpoint={onRestoreCheckpointBackend ? handleRestoreCheckpoint : undefined}
|
|
1983
2013
|
onRateVersion={onRateVersion ? handleRateVersion : undefined}
|
|
1984
2014
|
versionRatings={shownVersionRatings}
|
|
1985
2015
|
onRetryMessage={handleRetryMessage}
|
|
@@ -1990,6 +2020,7 @@
|
|
|
1990
2020
|
/>
|
|
1991
2021
|
</div>
|
|
1992
2022
|
|
|
2023
|
+
{#if !showPanelHeader}
|
|
1993
2024
|
<div
|
|
1994
2025
|
class="prompt-chat-messages-resize-handle flex items-center justify-center cursor-ns-resize select-none border-t border-b border-gray-300 bg-gray-100"
|
|
1995
2026
|
class:bg-blue-100={isResizingMessages}
|
|
@@ -2003,8 +2034,12 @@
|
|
|
2003
2034
|
>
|
|
2004
2035
|
<div class="drag-grip w-14 h-1 rounded-full bg-gray-500 {isResizingMessages ? 'bg-blue-400' : ''}"></div>
|
|
2005
2036
|
</div>
|
|
2037
|
+
{/if}
|
|
2006
2038
|
|
|
2007
|
-
<div
|
|
2039
|
+
<div
|
|
2040
|
+
class="prompt-chat-footer-ct shrink-0 flex flex-col {showPanelHeader ? 'px-4 pb-4 max-lg:px-3' : ''}"
|
|
2041
|
+
>
|
|
2042
|
+
{#if showActionBar}
|
|
2008
2043
|
<ActionBar
|
|
2009
2044
|
{context}
|
|
2010
2045
|
conversationId={currentConversationId}
|
|
@@ -2013,7 +2048,7 @@
|
|
|
2013
2048
|
disabled={isLoading}
|
|
2014
2049
|
showScreenshot={config?.features?.screenshot !== false}
|
|
2015
2050
|
showRecord={config?.features?.screenRecording !== false}
|
|
2016
|
-
showUpload={
|
|
2051
|
+
showUpload={false}
|
|
2017
2052
|
{showSelector}
|
|
2018
2053
|
{isSelectorActive}
|
|
2019
2054
|
showComplete={config?.features?.markComplete !== false}
|
|
@@ -2031,6 +2066,7 @@
|
|
|
2031
2066
|
{@render actionBarExtras()}
|
|
2032
2067
|
{/if}
|
|
2033
2068
|
</ActionBar>
|
|
2069
|
+
{/if}
|
|
2034
2070
|
{#if composerExtras}
|
|
2035
2071
|
<div class="prompt-chat-generation-options shrink-0 flex flex-col" bind:this={generationOptionsEl}>
|
|
2036
2072
|
{@render composerExtras()}
|
|
@@ -2043,44 +2079,22 @@
|
|
|
2043
2079
|
data-testid="chat-selected-elements-tray"
|
|
2044
2080
|
>
|
|
2045
2081
|
{#each selectedElements as item, index (item.id)}
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
{
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
<span class="text-gray-400">·</span>
|
|
2063
|
-
<span class="max-w-[180px] truncate text-[11px] text-gray-600">
|
|
2064
|
-
{item.textSnippet}
|
|
2065
|
-
</span>
|
|
2066
|
-
{:else if item.selector}
|
|
2067
|
-
<span class="text-gray-400">·</span>
|
|
2068
|
-
<span class="max-w-[160px] truncate font-mono text-[10px] text-gray-500">
|
|
2069
|
-
{item.selector}
|
|
2070
|
-
</span>
|
|
2071
|
-
{/if}
|
|
2072
|
-
{#if onRemoveSelectedElement}
|
|
2073
|
-
<button
|
|
2074
|
-
type="button"
|
|
2075
|
-
class="ms-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-full text-gray-400 hover:bg-gray-200 hover:text-gray-700 cursor-pointer"
|
|
2076
|
-
onclick={() => onRemoveSelectedElement?.(item.id)}
|
|
2077
|
-
title={$t('chat.selector.removeElement')}
|
|
2078
|
-
aria-label={$t('chat.selector.removeElement')}
|
|
2079
|
-
>
|
|
2080
|
-
✕
|
|
2081
|
-
</button>
|
|
2082
|
-
{/if}
|
|
2083
|
-
</div>
|
|
2082
|
+
{@const chipLabel = `<${item.tagName}${item.idAttr ? `#${item.idAttr}` : ''}>${item.note?.trim() ? ` · ${item.note.trim()}` : item.textSnippet ? ` · ${item.textSnippet}` : item.selector ? ` · ${item.selector}` : ''}`}
|
|
2083
|
+
<span class="prompt-chat-selected-element-chip max-w-full" title={item.selector} data-testid="chat-selected-element-chip">
|
|
2084
|
+
<Chip
|
|
2085
|
+
class="max-w-full"
|
|
2086
|
+
label={chipLabel}
|
|
2087
|
+
showRemove={!!onRemoveSelectedElement}
|
|
2088
|
+
removeLabel={$t('chat.selector.removeElement')}
|
|
2089
|
+
onRemove={() => onRemoveSelectedElement?.(item.id)}
|
|
2090
|
+
>
|
|
2091
|
+
{#snippet leading()}
|
|
2092
|
+
<span class="bg-primary text-primary-foreground flex h-4 w-4 shrink-0 items-center justify-center rounded-full text-[10px] font-bold">
|
|
2093
|
+
{index + 1}
|
|
2094
|
+
</span>
|
|
2095
|
+
{/snippet}
|
|
2096
|
+
</Chip>
|
|
2097
|
+
</span>
|
|
2084
2098
|
{/each}
|
|
2085
2099
|
{#if selectedElements.length > 1 && onClearSelectedElements}
|
|
2086
2100
|
<button
|
|
@@ -2137,31 +2151,31 @@
|
|
|
2137
2151
|
</div>
|
|
2138
2152
|
{/if}
|
|
2139
2153
|
|
|
2140
|
-
<
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2154
|
+
<ChatComposer
|
|
2155
|
+
panelLayout={showPanelHeader}
|
|
2156
|
+
placeholder={showPanelHeader
|
|
2157
|
+
? (currentMessages?.length ?? 0) > 0
|
|
2158
|
+
? $t('chat.input.placeholderFollowUp')
|
|
2159
|
+
: $t('chat.input.placeholderCreate')
|
|
2160
|
+
: undefined}
|
|
2161
|
+
bind:value={() => localInputText, (nextInputText) => {
|
|
2162
|
+
localInputText = nextInputText;
|
|
2163
|
+
notifyDraftChange();
|
|
2164
|
+
}}
|
|
2145
2165
|
isSending={localIsSending}
|
|
2146
|
-
isUploading={localIsUploading}
|
|
2147
2166
|
isGenerating={isGenerating || isLoading}
|
|
2167
|
+
models={composerModels}
|
|
2168
|
+
selectedModelId={selectedComposerModelId}
|
|
2169
|
+
onSelectModel={onSelectComposerModel}
|
|
2148
2170
|
onStop={() => onStopGeneration?.()}
|
|
2149
|
-
onSend={(content
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
onInputChange={(text) => {
|
|
2153
|
-
// chatLog('Input change for chat', context.id, ':', text);
|
|
2154
|
-
localInputText = text;
|
|
2155
|
-
notifyDraftChange();
|
|
2156
|
-
}}
|
|
2157
|
-
onAttachmentsChange={(attachments) => {
|
|
2158
|
-
// chatLog('Attachments change for chat', context.id, ':', attachments.length);
|
|
2159
|
-
localAttachments = attachments;
|
|
2160
|
-
notifyDraftChange();
|
|
2171
|
+
onSend={(content) => {
|
|
2172
|
+
const attachmentInputs = localAttachments.length > 0 ? localAttachments : undefined;
|
|
2173
|
+
void sendMessage(content, attachmentInputs);
|
|
2161
2174
|
}}
|
|
2162
2175
|
onFilesDropped={(files) => {
|
|
2163
2176
|
void addFilesAsAttachments(files);
|
|
2164
2177
|
}}
|
|
2178
|
+
onAttach={config?.features?.fileUpload !== false ? () => void handleUpload() : undefined}
|
|
2165
2179
|
canSendWithoutText={(selectedElements ?? []).some((element) => !!element.note?.trim())}
|
|
2166
2180
|
/>
|
|
2167
2181
|
</div>
|
|
@@ -3,6 +3,7 @@ import { type TextDirection } from '@widgetic/design-system/components/textDirec
|
|
|
3
3
|
import type { ChatConfig, ChatContext } from '../types/index.js';
|
|
4
4
|
import type { ClarificationSuggestion, DesignControlRequest, VersionRating } from '../types/message.js';
|
|
5
5
|
import type { AttachmentInput, SelectedElementChatReference } from '../types/attachment.js';
|
|
6
|
+
import { type ComposerModelOption } from './ChatComposer.svelte';
|
|
6
7
|
interface ChatMethods {
|
|
7
8
|
sendMessage: (content: string, attachments?: Array<File | AttachmentInput>, options?: {
|
|
8
9
|
skipIntentGate?: boolean;
|
|
@@ -155,6 +156,12 @@ interface Props {
|
|
|
155
156
|
fileSize: number;
|
|
156
157
|
}>;
|
|
157
158
|
showHeader?: boolean;
|
|
159
|
+
/** DS panel header (history, new chat, console). Used beside the canvas in the widget creator. */
|
|
160
|
+
showPanelHeader?: boolean;
|
|
161
|
+
/** When true with `onToggleConsole`, shows the debug console icon in the panel header. */
|
|
162
|
+
showConsoleControl?: boolean;
|
|
163
|
+
consoleOpen?: boolean;
|
|
164
|
+
onToggleConsole?: () => void;
|
|
158
165
|
/** Custom title displayed in the header. If empty/undefined, defaults to context.title or context.id. */
|
|
159
166
|
headerTitle?: string;
|
|
160
167
|
/** When false, hides the icon + type description row below the title, making the header compact. */
|
|
@@ -194,12 +201,19 @@ interface Props {
|
|
|
194
201
|
sha: string;
|
|
195
202
|
prompt: string;
|
|
196
203
|
}>;
|
|
197
|
-
/**
|
|
204
|
+
/**
|
|
205
|
+
* @deprecated The chat no longer marks one version as "you are here" (the person is always at the end of the conversation).
|
|
206
|
+
* Still accepted, so a host that passes it keeps compiling; it is ignored.
|
|
207
|
+
*/
|
|
198
208
|
viewingVersion?: number | null;
|
|
199
209
|
/** Host is running widget codegen — send button becomes stop. */
|
|
200
210
|
isGenerating?: boolean;
|
|
201
211
|
/** Tail of the model stream while codegen is in flight. */
|
|
202
212
|
generationStream?: string;
|
|
213
|
+
/** Rolling tail of streamed model reasoning while codegen is in flight. */
|
|
214
|
+
generationThinking?: string;
|
|
215
|
+
/** Gateway build plan (`operation.metadata.plan`), or `null` to hide the plan card. */
|
|
216
|
+
generationPlan?: import('../utils/generationPlan.js').GenerationPlanWire | null;
|
|
203
217
|
onStopGeneration?: () => void;
|
|
204
218
|
/**
|
|
205
219
|
* Renders the inline design-control card attached to an assistant reply
|
|
@@ -234,6 +248,10 @@ interface Props {
|
|
|
234
248
|
onRemoveSelectedElement?: (elementId: string) => void;
|
|
235
249
|
/** Fired when all selected widget elements should be cleared (e.g. after sending). */
|
|
236
250
|
onClearSelectedElements?: () => void;
|
|
251
|
+
/** Model list for the DS composer Assistant menu; hidden when empty. */
|
|
252
|
+
composerModels?: ComposerModelOption[];
|
|
253
|
+
selectedComposerModelId?: string | null;
|
|
254
|
+
onSelectComposerModel?: (modelId: string) => void;
|
|
237
255
|
}
|
|
238
256
|
declare const Chat: import("svelte").Component<Props, {}, "">;
|
|
239
257
|
type Chat = ReturnType<typeof Chat>;
|