@widgetic/chat 0.1.36 → 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/dist/components/Chat.svelte +36 -9
- package/dist/components/ChatComposer.svelte +13 -3
- package/dist/components/ChatComposer.svelte.d.ts +4 -0
- package/dist/components/ChatMessages.svelte +129 -42
- package/dist/components/ChatMessages.svelte.d.ts +2 -0
- package/dist/components/PanelChatHeader.svelte +46 -11
- package/dist/components/PanelChatHeader.svelte.d.ts +9 -2
- 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/i18n/index.d.ts +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/i18n/messages.d.ts +14 -1
- package/dist/i18n/messages.js +14 -1
- package/dist/i18n/suggestions.d.ts +6 -0
- package/dist/i18n/suggestions.js +24 -0
- package/dist/types/message.d.ts +7 -0
- package/package.json +1 -1
|
@@ -1172,11 +1172,21 @@
|
|
|
1172
1172
|
}
|
|
1173
1173
|
|
|
1174
1174
|
async function handleSuggestionSelected(suggestion: string) {
|
|
1175
|
-
|
|
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
|
+
}
|
|
1176
1187
|
// Autocomplete into input instead of sending immediately — lets user review,
|
|
1177
|
-
// edit, and attach an image before sending
|
|
1178
|
-
|
|
1179
|
-
setDraftText(suggestion);
|
|
1188
|
+
// edit, and attach an image before sending.
|
|
1189
|
+
setDraftText(trimmed);
|
|
1180
1190
|
}
|
|
1181
1191
|
|
|
1182
1192
|
/** Tapping a suggestion chip attached to an assistant clarification card sends it
|
|
@@ -1920,18 +1930,24 @@
|
|
|
1920
1930
|
|
|
1921
1931
|
<div
|
|
1922
1932
|
bind:this={chatContainer}
|
|
1923
|
-
class="{className ? className : 'prompt-chat-ct'} border-border bg-background relative flex h-full min-h-0
|
|
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'}"
|
|
1924
1934
|
dir={$textDirection}
|
|
1925
1935
|
style={style}
|
|
1926
1936
|
>
|
|
1927
1937
|
{#if showPanelHeader}
|
|
1938
|
+
{@const panelTitle =
|
|
1939
|
+
(currentMessages?.length ?? 0) > 0 || isGenerating
|
|
1940
|
+
? (headerTitle?.trim() || context.title || '')
|
|
1941
|
+
: ''}
|
|
1928
1942
|
<PanelChatHeader
|
|
1929
|
-
title={
|
|
1943
|
+
title={panelTitle}
|
|
1930
1944
|
showConsole={showConsoleControl}
|
|
1931
1945
|
{consoleOpen}
|
|
1932
1946
|
onToggleConsole={onToggleConsole}
|
|
1933
1947
|
onNewConversation={onCreateConversation || onLoadConversations ? () => void createNewConversation() : undefined}
|
|
1934
|
-
|
|
1948
|
+
conversations={availableConversations}
|
|
1949
|
+
currentConversationId={currentConversationId}
|
|
1950
|
+
onSelectConversation={(id) => void loadConversation(id)}
|
|
1935
1951
|
/>
|
|
1936
1952
|
{:else if showHeader}
|
|
1937
1953
|
<!-- Simple Chat Header -->
|
|
@@ -1965,7 +1981,7 @@
|
|
|
1965
1981
|
|
|
1966
1982
|
<!-- Chat Interface -->
|
|
1967
1983
|
<div
|
|
1968
|
-
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' : ''}"
|
|
1969
1985
|
style="{messagesAreaHeight !== null
|
|
1970
1986
|
? `flex: 0 0 ${messagesAreaHeight}px; height: ${messagesAreaHeight}px;`
|
|
1971
1987
|
: 'flex: 1 1 auto; min-height: 0;'}"
|
|
@@ -1976,6 +1992,7 @@
|
|
|
1976
1992
|
isLoading={isLoading}
|
|
1977
1993
|
isInitialized={isInitialized}
|
|
1978
1994
|
{showEmptyState}
|
|
1995
|
+
panelLayout={showPanelHeader}
|
|
1979
1996
|
{context}
|
|
1980
1997
|
isCompleted={isCompleted}
|
|
1981
1998
|
enableAutoCodeDetection={config?.features?.autoCodeDetection === true}
|
|
@@ -2003,6 +2020,7 @@
|
|
|
2003
2020
|
/>
|
|
2004
2021
|
</div>
|
|
2005
2022
|
|
|
2023
|
+
{#if !showPanelHeader}
|
|
2006
2024
|
<div
|
|
2007
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"
|
|
2008
2026
|
class:bg-blue-100={isResizingMessages}
|
|
@@ -2016,8 +2034,11 @@
|
|
|
2016
2034
|
>
|
|
2017
2035
|
<div class="drag-grip w-14 h-1 rounded-full bg-gray-500 {isResizingMessages ? 'bg-blue-400' : ''}"></div>
|
|
2018
2036
|
</div>
|
|
2037
|
+
{/if}
|
|
2019
2038
|
|
|
2020
|
-
<div
|
|
2039
|
+
<div
|
|
2040
|
+
class="prompt-chat-footer-ct shrink-0 flex flex-col {showPanelHeader ? 'px-4 pb-4 max-lg:px-3' : ''}"
|
|
2041
|
+
>
|
|
2021
2042
|
{#if showActionBar}
|
|
2022
2043
|
<ActionBar
|
|
2023
2044
|
{context}
|
|
@@ -2131,6 +2152,12 @@
|
|
|
2131
2152
|
{/if}
|
|
2132
2153
|
|
|
2133
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}
|
|
2134
2161
|
bind:value={() => localInputText, (nextInputText) => {
|
|
2135
2162
|
localInputText = nextInputText;
|
|
2136
2163
|
notifyDraftChange();
|
|
@@ -27,6 +27,10 @@
|
|
|
27
27
|
onFilesDropped?: (files: File[]) => void;
|
|
28
28
|
/** Opens the file picker. The "+" of the toolbar is drawn only when the page can attach files. */
|
|
29
29
|
onAttach?: () => void;
|
|
30
|
+
/** Figma side-panel composer: no top border on the shell; DS Composer keeps its own border. */
|
|
31
|
+
panelLayout?: boolean;
|
|
32
|
+
/** Figma panel composer (65:31): arrow-up send icon instead of paper-plane. */
|
|
33
|
+
sendIcon?: 'send' | 'arrow-up';
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
let {
|
|
@@ -44,9 +48,13 @@
|
|
|
44
48
|
onStop,
|
|
45
49
|
onInputChange,
|
|
46
50
|
onFilesDropped,
|
|
47
|
-
onAttach
|
|
51
|
+
onAttach,
|
|
52
|
+
panelLayout = false,
|
|
53
|
+
sendIcon = 'send',
|
|
48
54
|
}: Props = $props();
|
|
49
55
|
|
|
56
|
+
const composerSendIcon = $derived(panelLayout ? 'arrow-up' : sendIcon);
|
|
57
|
+
|
|
50
58
|
let isFileDragOver = $state(false);
|
|
51
59
|
|
|
52
60
|
const busy = $derived(isGenerating || isSending);
|
|
@@ -100,6 +108,7 @@
|
|
|
100
108
|
{#if onAttach}
|
|
101
109
|
<IconButton
|
|
102
110
|
variant="ghost"
|
|
111
|
+
data-testid="chat-composer-attach"
|
|
103
112
|
label={$t('chat.actions.uploadLabel')}
|
|
104
113
|
disabled={isSending && !isGenerating}
|
|
105
114
|
onclick={() => onAttach?.()}
|
|
@@ -123,7 +132,7 @@
|
|
|
123
132
|
|
|
124
133
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
125
134
|
<div
|
|
126
|
-
class="chat-composer-shell border-border bg-background shrink-0 border-t {className} {isFileDragOver
|
|
135
|
+
class="chat-composer-shell border-border bg-background shrink-0 {panelLayout ? '' : 'border-t'} {className} {isFileDragOver
|
|
127
136
|
? 'outline-primary outline-2 outline-dashed'
|
|
128
137
|
: ''}"
|
|
129
138
|
{style}
|
|
@@ -133,7 +142,8 @@
|
|
|
133
142
|
ondrop={handleFileDrop}
|
|
134
143
|
>
|
|
135
144
|
<Composer
|
|
136
|
-
class=
|
|
145
|
+
class={panelLayout ? 'w-full max-w-full' : 'rounded-none border-0'}
|
|
146
|
+
sendIcon={composerSendIcon}
|
|
137
147
|
bind:value
|
|
138
148
|
busy={isGenerating}
|
|
139
149
|
disabled={isSending && !isGenerating}
|
|
@@ -20,6 +20,10 @@ interface Props {
|
|
|
20
20
|
onFilesDropped?: (files: File[]) => void;
|
|
21
21
|
/** Opens the file picker. The "+" of the toolbar is drawn only when the page can attach files. */
|
|
22
22
|
onAttach?: () => void;
|
|
23
|
+
/** Figma side-panel composer: no top border on the shell; DS Composer keeps its own border. */
|
|
24
|
+
panelLayout?: boolean;
|
|
25
|
+
/** Figma panel composer (65:31): arrow-up send icon instead of paper-plane. */
|
|
26
|
+
sendIcon?: 'send' | 'arrow-up';
|
|
23
27
|
}
|
|
24
28
|
declare const ChatComposer: import("svelte").Component<Props, {}, "value">;
|
|
25
29
|
type ChatComposer = ReturnType<typeof ChatComposer>;
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
import { isRatableVersionReply, type VersionThumb } from '../utils/versionRatings.js';
|
|
7
7
|
import { isLocalMessageId, restoreBeforeTarget, textToCopy, type TurnRestorePoint } from '../utils/messageActions.js';
|
|
8
8
|
import { AttachmentDisplay, SuggestionButtons } from './index.js';
|
|
9
|
+
import PanelSuggestionButtons from './PanelSuggestionButtons.svelte';
|
|
10
|
+
import PanelFollowUpSuggestions from './PanelFollowUpSuggestions.svelte';
|
|
9
11
|
import CodeBlock from './CodeBlock.svelte';
|
|
10
12
|
import MessageActions from './MessageActions.svelte';
|
|
11
13
|
import { onDestroy, onMount, tick } from 'svelte';
|
|
@@ -14,6 +16,7 @@
|
|
|
14
16
|
import { CHAT_MESSAGES } from '../i18n/messages.js';
|
|
15
17
|
import { versionLabelText } from '../i18n/labels.js';
|
|
16
18
|
import { dirForUserText, useTextDirection } from '@widgetic/design-system/components/textDirection';
|
|
19
|
+
import IconSparkles from '@tabler/icons-svelte/icons/sparkles';
|
|
17
20
|
import {
|
|
18
21
|
generationActivityAriaKey,
|
|
19
22
|
generationActivityPhase,
|
|
@@ -24,6 +27,7 @@
|
|
|
24
27
|
// so a deep `.svelte` path types fine but cannot be resolved by Vite or Node.
|
|
25
28
|
import {
|
|
26
29
|
ActivityRow,
|
|
30
|
+
ChatAlertCard,
|
|
27
31
|
Message,
|
|
28
32
|
MessageCheckpointRow,
|
|
29
33
|
PlanCard,
|
|
@@ -124,6 +128,8 @@
|
|
|
124
128
|
hasOlderMessages?: boolean;
|
|
125
129
|
/** Called when the list is scrolled to the top, so the host can prepend the previous page. */
|
|
126
130
|
onRequestOlderMessages?: () => Promise<boolean | void>;
|
|
131
|
+
/** Widget creator side panel: Figma empty / follow-up suggestion cards. */
|
|
132
|
+
panelLayout?: boolean;
|
|
127
133
|
}
|
|
128
134
|
|
|
129
135
|
let {
|
|
@@ -156,8 +162,10 @@
|
|
|
156
162
|
storedLineLabel,
|
|
157
163
|
hasOlderMessages = false,
|
|
158
164
|
onRequestOlderMessages,
|
|
165
|
+
panelLayout = false,
|
|
159
166
|
}: Props = $props();
|
|
160
167
|
|
|
168
|
+
|
|
161
169
|
/** The property-edit sentence used to be stored with markdown the bubble does not render. */
|
|
162
170
|
function readablePropertyEditLine(content: string): string {
|
|
163
171
|
return content.replace(
|
|
@@ -185,6 +193,13 @@
|
|
|
185
193
|
function detectMessagesScrollbar(node: HTMLElement) {
|
|
186
194
|
function check() {
|
|
187
195
|
messagesHasScrollbar = node.scrollHeight > node.clientHeight + 1;
|
|
196
|
+
if (panelLayout) {
|
|
197
|
+
// The docked panel keeps Figma's 16px on both sides (set in the style of the list); with a scrollbar the bar
|
|
198
|
+
// takes the place of half of it.
|
|
199
|
+
if (messagesHasScrollbar) node.style.setProperty('padding-inline-end', '8px', 'important');
|
|
200
|
+
else node.style.removeProperty('padding-inline-end');
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
188
203
|
node.style.setProperty('padding-inline-end', messagesHasScrollbar ? '0px' : '12px', 'important');
|
|
189
204
|
}
|
|
190
205
|
const resizeObserver = new ResizeObserver(check);
|
|
@@ -778,6 +793,22 @@
|
|
|
778
793
|
return !isGenerationSummary(reply);
|
|
779
794
|
}
|
|
780
795
|
|
|
796
|
+
/** Figma ready frame: follow-up cards sit above the composer, outside the scroll area. */
|
|
797
|
+
const panelAnchoredFollowUp = $derived.by((): { labels: string[] } | null => {
|
|
798
|
+
if (!panelLayout || showEmptyState) return null;
|
|
799
|
+
for (let ti = chatTurns.length - 1; ti >= 0; ti--) {
|
|
800
|
+
const turn = chatTurns[ti];
|
|
801
|
+
for (let ri = turn.replies.length - 1; ri >= 0; ri--) {
|
|
802
|
+
const reply = turn.replies[ri];
|
|
803
|
+
const meta = reply.metadata as { panelFollowUp?: boolean } | undefined;
|
|
804
|
+
if (!reply.suggestions?.length || meta?.panelFollowUp === false) continue;
|
|
805
|
+
if (!shouldShowAssistantReply(reply)) continue;
|
|
806
|
+
return { labels: reply.suggestions.map((s) => s.label) };
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
return null;
|
|
810
|
+
});
|
|
811
|
+
|
|
781
812
|
/** Show the commit chrome (title, version label, the restore icon) on the user prompt whenever the turn has a commit.
|
|
782
813
|
* Previously this was gated to Debug OFF (assistant reply hidden), but we want it
|
|
783
814
|
* available in Debug ON too — the assistant summary and the user-side chrome coexist. */
|
|
@@ -872,6 +903,16 @@
|
|
|
872
903
|
return /credit balance|free trial|not available in your plan|not available on the free plan|upgrade your plan|upgrade to a solo/i.test(message);
|
|
873
904
|
}
|
|
874
905
|
|
|
906
|
+
/** What the alert card of a failed reply says under its title: the server's own words when they tell something specific
|
|
907
|
+
* (the plan or the credits, too many requests, the service is unavailable, the run was stopped), otherwise Figma's line. */
|
|
908
|
+
function failureAlertDescription(message: ChatMessage): string {
|
|
909
|
+
const serverText = visibleMessageContent(message.messageContent || '').trim();
|
|
910
|
+
const isSpecificFailure =
|
|
911
|
+
isPlanLimitMessage(message.messageContent) ||
|
|
912
|
+
/Too many generation requests|temporarily unavailable|Generation stopped/i.test(serverText);
|
|
913
|
+
return isSpecificFailure && serverText ? serverText : $t('chat.messages.failedHint');
|
|
914
|
+
}
|
|
915
|
+
|
|
875
916
|
function openUpgradePlans() {
|
|
876
917
|
// A host that is a guest on somebody else's page decides what "upgrade" means there; the billing page of the
|
|
877
918
|
// Widgetic site would take the visitor off the page they are on.
|
|
@@ -1508,11 +1549,12 @@
|
|
|
1508
1549
|
}
|
|
1509
1550
|
</script>
|
|
1510
1551
|
|
|
1552
|
+
<div class="{panelLayout ? 'panel-messages-shell flex h-full min-h-0 w-full flex-1 flex-col' : 'contents'}">
|
|
1511
1553
|
<div
|
|
1512
1554
|
bind:this={messagesContainer}
|
|
1513
|
-
class="{className ? className : 'prompt-chat-messages-ct'} prompt-chat-messages-scroll flex flex-col overflow-y-auto space-y-4 pb-3"
|
|
1555
|
+
class="{className ? className : 'prompt-chat-messages-ct'} prompt-chat-messages-scroll flex flex-col overflow-y-auto {panelLayout ? 'min-h-0 flex-1 gap-4 pb-1' : 'space-y-4 pb-3'}"
|
|
1514
1556
|
class:loading={isLoading}
|
|
1515
|
-
style=
|
|
1557
|
+
style={panelLayout ? 'padding: 8px 16px 0; overflow-anchor: none;' : 'padding: 8px 16px 12px; overflow-anchor: none;'}
|
|
1516
1558
|
use:detectMessagesScrollbar
|
|
1517
1559
|
onscroll={handleScroll}
|
|
1518
1560
|
>
|
|
@@ -1524,12 +1566,10 @@
|
|
|
1524
1566
|
middle of the messages, and the suggestions are pinned under it, above the composer. The block takes the
|
|
1525
1567
|
free height with flex-1 (not min-h-full): the sticky scroll-to-bottom row below it needs its own room, and a
|
|
1526
1568
|
block as tall as the whole area would push it out and make the list scroll. -->
|
|
1527
|
-
<div class="empty-state-ct flex w-full flex-1 flex-col gap-4">
|
|
1569
|
+
<div class="empty-state-ct flex w-full flex-1 flex-col gap-4 {panelLayout ? 'min-h-0 pb-2' : ''}">
|
|
1528
1570
|
<div class="empty-state-hero flex flex-1 flex-col items-center justify-center gap-3 px-2 text-center">
|
|
1529
1571
|
<span class="empty-state-icon-circle bg-muted text-foreground flex size-10 shrink-0 items-center justify-center rounded-full" aria-hidden="true">
|
|
1530
|
-
<
|
|
1531
|
-
<path d="M16 18a2 2 0 0 1 2 2a2 2 0 0 1 2 -2a2 2 0 0 1 -2 -2a2 2 0 0 1 -2 2zm0 -12a2 2 0 0 1 2 2a2 2 0 0 1 2 -2a2 2 0 0 1 -2 -2a2 2 0 0 1 -2 2zm-7 12a6 6 0 0 1 6 -6a6 6 0 0 1 -6 -6a6 6 0 0 1 -6 6a6 6 0 0 1 6 6z" />
|
|
1532
|
-
</svg>
|
|
1572
|
+
<IconSparkles class="size-4 stroke-2" />
|
|
1533
1573
|
</span>
|
|
1534
1574
|
<div class="flex flex-col gap-0.5">
|
|
1535
1575
|
<h3 class="text-body-medium text-foreground">{$t('chat.messages.emptyTitle')}</h3>
|
|
@@ -1537,30 +1577,40 @@
|
|
|
1537
1577
|
</div>
|
|
1538
1578
|
</div>
|
|
1539
1579
|
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1580
|
+
{#if panelLayout}
|
|
1581
|
+
<PanelSuggestionButtons
|
|
1582
|
+
disabled={isGenerating}
|
|
1583
|
+
onPick={(text) => onSuggestionSelected?.(text)}
|
|
1584
|
+
/>
|
|
1585
|
+
{:else}
|
|
1586
|
+
<SuggestionButtons
|
|
1587
|
+
{context}
|
|
1588
|
+
visible={true}
|
|
1589
|
+
on:suggestionSelected={handleSuggestionSelected}
|
|
1590
|
+
/>
|
|
1591
|
+
{/if}
|
|
1546
1592
|
</div>
|
|
1547
1593
|
{/if}
|
|
1548
1594
|
|
|
1549
1595
|
<!-- Conversation turns (user prompt + assistant status grouped) -->
|
|
1550
1596
|
{#each chatTurns as turn, turnIndex (turn.user?.id ?? turn.replies[0]?.id ?? turnIndex)}
|
|
1551
|
-
<div class="wc-chat-turn-ct space-y-1.5
|
|
1597
|
+
<div class="wc-chat-turn-ct rounded-lg {panelLayout ? 'flex flex-col gap-[52px]' : 'space-y-1.5 border border-transparent p-0.5'}">
|
|
1552
1598
|
{#if turn.user}
|
|
1553
1599
|
{@const userMsg = turn.user}
|
|
1554
1600
|
{@const shownAttachments = visibleUserAttachments(turn, turnIndex)}
|
|
1555
|
-
<div class="message-container wc-chat-turn-user w-full flex
|
|
1601
|
+
<div class="message-container wc-chat-turn-user flex w-full flex-col {panelLayout ? 'items-end' : 'items-stretch'}"
|
|
1556
1602
|
class:opacity-75={userMsg._optimistic}
|
|
1557
1603
|
class:opacity-50={userMsg._failed}
|
|
1558
1604
|
class:has-attachments={shownAttachments.length > 0}
|
|
1559
1605
|
>
|
|
1560
|
-
<Message
|
|
1606
|
+
<Message
|
|
1607
|
+
role="user"
|
|
1608
|
+
class="{panelLayout ? 'panel-layout-user-message ms-auto w-fit max-w-[85%]' : 'ms-auto w-full max-w-full'}"
|
|
1609
|
+
data-testid="chat-user-bubble"
|
|
1610
|
+
>
|
|
1561
1611
|
{#snippet children()}
|
|
1562
1612
|
<div
|
|
1563
|
-
class="message-bubble-user w-full
|
|
1613
|
+
class="message-bubble-user text-sm select-text {panelLayout ? 'w-auto max-w-full leading-5' : 'w-full leading-relaxed'}"
|
|
1564
1614
|
class:p-0={shownAttachments.length > 0}
|
|
1565
1615
|
use:bubbleScrollPadding
|
|
1566
1616
|
>
|
|
@@ -1582,7 +1632,7 @@
|
|
|
1582
1632
|
{/each}
|
|
1583
1633
|
</div>
|
|
1584
1634
|
{:else}
|
|
1585
|
-
<p class="whitespace-pre-wrap p-3" dir={dirForUserText($textDirection)}>{userMsg.messageContent}</p>
|
|
1635
|
+
<p class="whitespace-pre-wrap {panelLayout ? '' : 'p-3'}" dir={dirForUserText($textDirection)}>{userMsg.messageContent}</p>
|
|
1586
1636
|
{/if}
|
|
1587
1637
|
{/if}
|
|
1588
1638
|
{#if shownAttachments.length > 0}
|
|
@@ -1603,7 +1653,7 @@
|
|
|
1603
1653
|
</div>
|
|
1604
1654
|
{/snippet}
|
|
1605
1655
|
</Message>
|
|
1606
|
-
{#if showCommitMetaOnUserTurn(turn)}
|
|
1656
|
+
{#if showCommitMetaOnUserTurn(turn) && (!panelLayout || showCommitMeta)}
|
|
1607
1657
|
{@const commitTitle = getTurnCommitTitle(turn)}
|
|
1608
1658
|
{@const versionLabel = getTurnVersionLabel(turn)}
|
|
1609
1659
|
{#if showCommitMeta && commitTitle}
|
|
@@ -1641,6 +1691,22 @@
|
|
|
1641
1691
|
|
|
1642
1692
|
{#each turn.replies as reply (reply.id)}
|
|
1643
1693
|
{#if shouldShowAssistantReply(reply)}
|
|
1694
|
+
{#if panelLayout && isCodegenFailure(reply)}
|
|
1695
|
+
<!-- Figma Alert (526:3205): a failed reply in the docked panel is a card with a title, a line and "Try again",
|
|
1696
|
+
not a red line of text. The button runs the prompt of this turn again, on the last failure of the turn only. -->
|
|
1697
|
+
<ChatAlertCard
|
|
1698
|
+
class="wc-chat-turn-reply"
|
|
1699
|
+
title={$t('chat.messages.failedTitle')}
|
|
1700
|
+
description={failureAlertDescription(reply)}
|
|
1701
|
+
actionLabel={onRetryMessage &&
|
|
1702
|
+
isLastCodegenFailureInTurn(turn, reply) &&
|
|
1703
|
+
!isPlanLimitMessage(reply.messageContent) &&
|
|
1704
|
+
turnNeedsRetry(turn, turnIndex)
|
|
1705
|
+
? $t('chat.messages.failedRetry')
|
|
1706
|
+
: ''}
|
|
1707
|
+
onAction={() => handleRetryTurn(turn, turnIndex)}
|
|
1708
|
+
/>
|
|
1709
|
+
{:else}
|
|
1644
1710
|
<Message
|
|
1645
1711
|
role="assistant"
|
|
1646
1712
|
class="wc-chat-turn-reply max-w-full"
|
|
@@ -1648,7 +1714,7 @@
|
|
|
1648
1714
|
errorText={visibleMessageContent(reply.messageContent || '')}
|
|
1649
1715
|
>
|
|
1650
1716
|
{#snippet children()}
|
|
1651
|
-
{#if reply.messageContent && !(reply.suggestions && reply.suggestions.length > 0)}
|
|
1717
|
+
{#if reply.messageContent && (panelLayout || !(reply.suggestions && reply.suggestions.length > 0))}
|
|
1652
1718
|
<div class="message-content-assistant select-text text-sm leading-relaxed" use:bubbleScrollPadding>
|
|
1653
1719
|
{#if reply.messageContent}
|
|
1654
1720
|
{#if hasCodeBlocks(reply.messageContent)}
|
|
@@ -1675,6 +1741,7 @@
|
|
|
1675
1741
|
{/if}
|
|
1676
1742
|
{/snippet}
|
|
1677
1743
|
</Message>
|
|
1744
|
+
{/if}
|
|
1678
1745
|
|
|
1679
1746
|
{#if reply.designControls && renderDesignControls}
|
|
1680
1747
|
<div class="wc-design-controls mt-1.5 w-fit max-w-full overflow-visible">
|
|
@@ -1682,20 +1749,20 @@
|
|
|
1682
1749
|
</div>
|
|
1683
1750
|
{/if}
|
|
1684
1751
|
|
|
1685
|
-
{#if reply.suggestions && reply.suggestions.length > 0}
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1752
|
+
{#if reply.suggestions && reply.suggestions.length > 0 && !panelLayout}
|
|
1753
|
+
<QuestionCard
|
|
1754
|
+
class="mt-1.5 w-full max-w-full"
|
|
1755
|
+
question={(visibleMessageContent(reply.messageContent || '') || $t('chat.messages.clarificationPrompt')).trim()}
|
|
1756
|
+
options={reply.suggestions.map((suggestion, index) => ({
|
|
1757
|
+
id: String(index),
|
|
1758
|
+
label: suggestion.label
|
|
1759
|
+
}))}
|
|
1760
|
+
onSubmit={(selectedIds) => {
|
|
1761
|
+
const picked = Number(selectedIds[0]);
|
|
1762
|
+
const suggestion = reply.suggestions?.[picked];
|
|
1763
|
+
if (suggestion) onClarificationSuggestionSelected?.(suggestion);
|
|
1764
|
+
}}
|
|
1765
|
+
/>
|
|
1699
1766
|
{/if}
|
|
1700
1767
|
|
|
1701
1768
|
<!-- A failure about the plan or the credits: the way out is to upgrade. Running the prompt again is the regenerate icon of the last message. -->
|
|
@@ -1714,8 +1781,9 @@
|
|
|
1714
1781
|
{/if}
|
|
1715
1782
|
{/each}
|
|
1716
1783
|
|
|
1717
|
-
<!-- Copy, regenerate and the two thumbs: at the end of the last message only, and not while something is being generated.
|
|
1718
|
-
|
|
1784
|
+
<!-- Copy, regenerate and the two thumbs: at the end of the last message only, and not while something is being generated.
|
|
1785
|
+
Not in the panel either: the creator page's chat panel (Figma 526:2706, ready) draws no row of actions under the last message. -->
|
|
1786
|
+
{#if !panelLayout && turnIndex === chatTurns.length - 1 && !isLoading && !isGenerating}
|
|
1719
1787
|
{@const copyText = textToCopy(
|
|
1720
1788
|
turn.replies.filter(shouldShowAssistantReply).map((reply) => visibleMessageContent(reply.messageContent || '')),
|
|
1721
1789
|
getTurnCommitTitle(turn),
|
|
@@ -1827,19 +1895,38 @@
|
|
|
1827
1895
|
</div>
|
|
1828
1896
|
{/if}
|
|
1829
1897
|
|
|
1830
|
-
|
|
1831
|
-
<
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1898
|
+
{#if !panelLayout}
|
|
1899
|
+
<div class="sticky bottom-2 z-10 flex justify-center pb-1 pt-2">
|
|
1900
|
+
<ScrollToBottom
|
|
1901
|
+
visible={!autoScroll && messages.length > 0 && !isLoading}
|
|
1902
|
+
label={$t('chat.messages.scrollToBottom')}
|
|
1903
|
+
onScroll={() => {
|
|
1904
|
+
autoScroll = true;
|
|
1905
|
+
scrollMessagesToEnd();
|
|
1906
|
+
}}
|
|
1907
|
+
/>
|
|
1908
|
+
</div>
|
|
1909
|
+
{/if}
|
|
1910
|
+
</div>
|
|
1911
|
+
{#if panelLayout && panelAnchoredFollowUp}
|
|
1912
|
+
<div class="panel-anchored-followup ms-auto flex w-full max-w-full shrink-0 flex-col items-end px-4 pb-2">
|
|
1913
|
+
<PanelFollowUpSuggestions
|
|
1914
|
+
labels={panelAnchoredFollowUp.labels}
|
|
1915
|
+
disabled={isGenerating}
|
|
1916
|
+
onPick={(text) => {
|
|
1917
|
+
onSuggestionSelected?.(text);
|
|
1837
1918
|
}}
|
|
1838
1919
|
/>
|
|
1839
1920
|
</div>
|
|
1921
|
+
{/if}
|
|
1840
1922
|
</div>
|
|
1841
1923
|
|
|
1842
1924
|
<style>
|
|
1925
|
+
/* Figma panel: user bubble only — no hover action row consuming gap above the assistant text. */
|
|
1926
|
+
:global(.panel-layout-user-message > div.duration-fast) {
|
|
1927
|
+
display: none;
|
|
1928
|
+
min-height: 0;
|
|
1929
|
+
}
|
|
1843
1930
|
.thinking-sizer {
|
|
1844
1931
|
visibility: hidden;
|
|
1845
1932
|
}
|
|
@@ -93,6 +93,8 @@ interface Props {
|
|
|
93
93
|
hasOlderMessages?: boolean;
|
|
94
94
|
/** Called when the list is scrolled to the top, so the host can prepend the previous page. */
|
|
95
95
|
onRequestOlderMessages?: () => Promise<boolean | void>;
|
|
96
|
+
/** Widget creator side panel: Figma empty / follow-up suggestion cards. */
|
|
97
|
+
panelLayout?: boolean;
|
|
96
98
|
}
|
|
97
99
|
declare const ChatMessages: import("svelte").Component<Props, {}, "">;
|
|
98
100
|
type ChatMessages = ReturnType<typeof ChatMessages>;
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { ChatHeader } from '@widgetic/design-system/components
|
|
2
|
+
import { ChatHeader, DropdownMenu } from '@widgetic/design-system/components';
|
|
3
3
|
import { useChatLanguage } from '../i18n/language.js';
|
|
4
4
|
|
|
5
|
+
interface ConversationRow {
|
|
6
|
+
id?: string;
|
|
7
|
+
conversation_id?: string;
|
|
8
|
+
conversationId?: string;
|
|
9
|
+
title?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
5
12
|
interface Props {
|
|
6
13
|
title?: string;
|
|
7
14
|
showConsole?: boolean;
|
|
8
15
|
consoleOpen?: boolean;
|
|
9
16
|
onToggleConsole?: () => void;
|
|
10
17
|
onNewConversation?: () => void;
|
|
11
|
-
|
|
12
|
-
|
|
18
|
+
conversations?: ConversationRow[];
|
|
19
|
+
currentConversationId?: string | null;
|
|
20
|
+
onSelectConversation?: (conversationId: string) => void;
|
|
13
21
|
}
|
|
14
22
|
|
|
15
23
|
let {
|
|
@@ -18,27 +26,54 @@
|
|
|
18
26
|
consoleOpen = false,
|
|
19
27
|
onToggleConsole,
|
|
20
28
|
onNewConversation,
|
|
21
|
-
|
|
22
|
-
|
|
29
|
+
conversations = [],
|
|
30
|
+
currentConversationId = null,
|
|
31
|
+
onSelectConversation,
|
|
23
32
|
}: Props = $props();
|
|
24
33
|
|
|
25
34
|
const { t } = useChatLanguage();
|
|
35
|
+
let historyOpen = $state(false);
|
|
36
|
+
|
|
37
|
+
function conversationId(row: ConversationRow): string {
|
|
38
|
+
return String(row.id || row.conversation_id || row.conversationId || '');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const canSwitchConversations = $derived(
|
|
42
|
+
conversations.length > 0 && typeof onSelectConversation === 'function'
|
|
43
|
+
);
|
|
26
44
|
</script>
|
|
27
45
|
|
|
28
46
|
<ChatHeader
|
|
29
47
|
layout="panel"
|
|
30
|
-
|
|
31
|
-
|
|
48
|
+
data-testid="panel-chat-header"
|
|
49
|
+
class="panel-chat-header border-border bg-background"
|
|
50
|
+
{title}
|
|
32
51
|
{showConsole}
|
|
33
52
|
{consoleOpen}
|
|
34
53
|
onToggleConsole={onToggleConsole}
|
|
35
54
|
onNewChat={onNewConversation}
|
|
36
|
-
|
|
37
|
-
onTitleClick={onTitleClick}
|
|
55
|
+
onTitleClick={canSwitchConversations ? () => { historyOpen = !historyOpen; } : undefined}
|
|
38
56
|
messages={{
|
|
39
57
|
newChat: $t('chat.header.newConversationTitle'),
|
|
40
|
-
history: $t('chat.header.switchConversation'),
|
|
41
58
|
console: $t('chat.header.console'),
|
|
42
|
-
openHistory: $t('chat.header.switchConversation')
|
|
59
|
+
openHistory: $t('chat.header.switchConversation'),
|
|
43
60
|
}}
|
|
44
61
|
/>
|
|
62
|
+
|
|
63
|
+
{#if canSwitchConversations}
|
|
64
|
+
<DropdownMenu.Root bind:open={historyOpen}>
|
|
65
|
+
<DropdownMenu.Content align="start" class="max-h-64 w-64 overflow-y-auto">
|
|
66
|
+
{#each conversations as row (conversationId(row))}
|
|
67
|
+
{@const id = conversationId(row)}
|
|
68
|
+
<DropdownMenu.Item
|
|
69
|
+
class="justify-between gap-2"
|
|
70
|
+
onSelect={() => {
|
|
71
|
+
if (id && id !== currentConversationId) onSelectConversation?.(id);
|
|
72
|
+
}}
|
|
73
|
+
>
|
|
74
|
+
<span class="truncate">{row.title?.trim() || $t('chat.header.untitled')}</span>
|
|
75
|
+
</DropdownMenu.Item>
|
|
76
|
+
{/each}
|
|
77
|
+
</DropdownMenu.Content>
|
|
78
|
+
</DropdownMenu.Root>
|
|
79
|
+
{/if}
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
+
interface ConversationRow {
|
|
2
|
+
id?: string;
|
|
3
|
+
conversation_id?: string;
|
|
4
|
+
conversationId?: string;
|
|
5
|
+
title?: string;
|
|
6
|
+
}
|
|
1
7
|
interface Props {
|
|
2
8
|
title?: string;
|
|
3
9
|
showConsole?: boolean;
|
|
4
10
|
consoleOpen?: boolean;
|
|
5
11
|
onToggleConsole?: () => void;
|
|
6
12
|
onNewConversation?: () => void;
|
|
7
|
-
|
|
8
|
-
|
|
13
|
+
conversations?: ConversationRow[];
|
|
14
|
+
currentConversationId?: string | null;
|
|
15
|
+
onSelectConversation?: (conversationId: string) => void;
|
|
9
16
|
}
|
|
10
17
|
declare const PanelChatHeader: import("svelte").Component<Props, {}, "">;
|
|
11
18
|
type PanelChatHeader = ReturnType<typeof PanelChatHeader>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import IconClock from '@tabler/icons-svelte/icons/clock';
|
|
3
|
+
import IconSparkles from '@tabler/icons-svelte/icons/sparkles';
|
|
4
|
+
import IconMessage from '@tabler/icons-svelte/icons/message';
|
|
5
|
+
import { SuggestionCard } from '@widgetic/design-system/components/chat/index';
|
|
6
|
+
import { useChatLanguage } from '../i18n/language.js';
|
|
7
|
+
import { panelFollowUpSuggestionTitleKey } from '../i18n/suggestions.js';
|
|
8
|
+
|
|
9
|
+
const { t } = useChatLanguage();
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
labels: string[];
|
|
13
|
+
onPick: (text: string) => void;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let { labels, onPick, disabled = false }: Props = $props();
|
|
18
|
+
|
|
19
|
+
const ICONS = [IconClock, IconSparkles, IconMessage];
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<div class="panel-followup-suggestion-ct flex w-full max-w-full flex-col gap-1">
|
|
23
|
+
<h4 class="text-caption text-muted-foreground">{$t(panelFollowUpSuggestionTitleKey())}</h4>
|
|
24
|
+
<div class="flex w-full flex-col gap-1">
|
|
25
|
+
{#each labels as label, index (label + index)}
|
|
26
|
+
{@const Icon = ICONS[index % ICONS.length]}
|
|
27
|
+
<SuggestionCard title={label} {disabled} onclick={() => onPick(label)}>
|
|
28
|
+
{#snippet icon()}
|
|
29
|
+
<Icon class="size-4 stroke-2" aria-hidden="true" />
|
|
30
|
+
{/snippet}
|
|
31
|
+
</SuggestionCard>
|
|
32
|
+
{/each}
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
labels: string[];
|
|
3
|
+
onPick: (text: string) => void;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
}
|
|
6
|
+
declare const PanelFollowUpSuggestions: import("svelte").Component<Props, {}, "">;
|
|
7
|
+
type PanelFollowUpSuggestions = ReturnType<typeof PanelFollowUpSuggestions>;
|
|
8
|
+
export default PanelFollowUpSuggestions;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import IconClock from '@tabler/icons-svelte/icons/clock';
|
|
3
|
+
import IconMessage from '@tabler/icons-svelte/icons/message';
|
|
4
|
+
import IconPhoto from '@tabler/icons-svelte/icons/photo';
|
|
5
|
+
import IconArrowsMaximize from '@tabler/icons-svelte/icons/arrows-maximize';
|
|
6
|
+
import { SuggestionCard } from '@widgetic/design-system/components/chat/index';
|
|
7
|
+
import { useChatLanguage } from '../i18n/language.js';
|
|
8
|
+
import {
|
|
9
|
+
panelEmptySuggestionKeys,
|
|
10
|
+
panelEmptySuggestionTitleKey,
|
|
11
|
+
} from '../i18n/suggestions.js';
|
|
12
|
+
import type { ChatMessageKey } from '../i18n/messages.js';
|
|
13
|
+
|
|
14
|
+
const { t } = useChatLanguage();
|
|
15
|
+
|
|
16
|
+
interface Props {
|
|
17
|
+
onPick: (text: string) => void;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
titleKey?: ChatMessageKey;
|
|
20
|
+
suggestionKeys?: readonly ChatMessageKey[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let {
|
|
24
|
+
onPick,
|
|
25
|
+
disabled = false,
|
|
26
|
+
titleKey = panelEmptySuggestionTitleKey(),
|
|
27
|
+
suggestionKeys = panelEmptySuggestionKeys(),
|
|
28
|
+
}: Props = $props();
|
|
29
|
+
|
|
30
|
+
const ICON_BY_KEY: Partial<Record<ChatMessageKey, typeof IconClock>> = {
|
|
31
|
+
'chat.suggestions.panel.countdown': IconClock,
|
|
32
|
+
'chat.suggestions.panel.testimonials': IconMessage,
|
|
33
|
+
'chat.suggestions.panel.gallery': IconPhoto,
|
|
34
|
+
'chat.suggestions.panel.changeEndDate': IconClock,
|
|
35
|
+
'chat.suggestions.panel.biggerButton': IconArrowsMaximize,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
function iconForKey(key: ChatMessageKey) {
|
|
39
|
+
return ICON_BY_KEY[key] ?? IconMessage;
|
|
40
|
+
}
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<div class="panel-suggestion-ct flex w-full max-w-full flex-col gap-1">
|
|
44
|
+
<h4 class="text-caption text-muted-foreground">{$t(titleKey)}</h4>
|
|
45
|
+
<div class="flex w-full flex-col gap-1">
|
|
46
|
+
{#each suggestionKeys as suggestionKey (suggestionKey)}
|
|
47
|
+
{@const label = $t(suggestionKey)}
|
|
48
|
+
{@const Icon = iconForKey(suggestionKey)}
|
|
49
|
+
<SuggestionCard
|
|
50
|
+
title={label}
|
|
51
|
+
disabled={disabled}
|
|
52
|
+
onclick={() => onPick(label)}
|
|
53
|
+
>
|
|
54
|
+
{#snippet icon()}
|
|
55
|
+
<Icon class="size-4 stroke-2" aria-hidden="true" />
|
|
56
|
+
{/snippet}
|
|
57
|
+
</SuggestionCard>
|
|
58
|
+
{/each}
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ChatMessageKey } from '../i18n/messages.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
onPick: (text: string) => void;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
titleKey?: ChatMessageKey;
|
|
6
|
+
suggestionKeys?: readonly ChatMessageKey[];
|
|
7
|
+
}
|
|
8
|
+
declare const PanelSuggestionButtons: import("svelte").Component<Props, {}, "">;
|
|
9
|
+
type PanelSuggestionButtons = ReturnType<typeof PanelSuggestionButtons>;
|
|
10
|
+
export default PanelSuggestionButtons;
|
package/dist/i18n/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { CHAT_MESSAGES, type ChatMessageKey } from './messages.js';
|
|
2
2
|
export { checkChatMessages, provideChatLanguage, useChatLanguage } from './language.js';
|
|
3
3
|
export { actionFailureKey, contextTypeLabel, fileSizeText, versionLabelText } from './labels.js';
|
|
4
|
-
export { suggestionKeysFor, suggestionTitleKeyFor } from './suggestions.js';
|
|
4
|
+
export { suggestionKeysFor, suggestionTitleKeyFor, panelEmptySuggestionKeys, panelEmptySuggestionTitleKey, } from './suggestions.js';
|
package/dist/i18n/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { CHAT_MESSAGES } from './messages.js';
|
|
2
2
|
export { checkChatMessages, provideChatLanguage, useChatLanguage } from './language.js';
|
|
3
3
|
export { actionFailureKey, contextTypeLabel, fileSizeText, versionLabelText } from './labels.js';
|
|
4
|
-
export { suggestionKeysFor, suggestionTitleKeyFor } from './suggestions.js';
|
|
4
|
+
export { suggestionKeysFor, suggestionTitleKeyFor, panelEmptySuggestionKeys, panelEmptySuggestionTitleKey, } from './suggestions.js';
|
package/dist/i18n/messages.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export declare const CHAT_MESSAGES: {
|
|
|
31
31
|
readonly 'chat.header.new': "New";
|
|
32
32
|
/** The name of a conversation that has none. */
|
|
33
33
|
readonly 'chat.header.untitled': "Untitled";
|
|
34
|
-
readonly 'chat.header.newConversationTitle': "New
|
|
34
|
+
readonly 'chat.header.newConversationTitle': "New chat";
|
|
35
35
|
readonly 'chat.header.newConversation': "Start new conversation";
|
|
36
36
|
/** Label for the debug console icon in the panel chat header. */
|
|
37
37
|
readonly 'chat.header.console': "Console";
|
|
@@ -68,6 +68,10 @@ export declare const CHAT_MESSAGES: {
|
|
|
68
68
|
readonly 'chat.messages.attachmentMissingTitle': "Attachment not available";
|
|
69
69
|
readonly 'chat.messages.attachmentMissingLabel': "Missing file attachment";
|
|
70
70
|
readonly 'chat.messages.attachmentMissingCaption': "Attachment not saved. Re-attach with Upload, then send it again.";
|
|
71
|
+
/** The alert card a failed reply is shown in (docked panel): its title, its line, and the button that runs the prompt again. */
|
|
72
|
+
readonly 'chat.messages.failedTitle': "Could not build the widget";
|
|
73
|
+
readonly 'chat.messages.failedHint': "The build did not finish. Your sketch is safe, so you can try again.";
|
|
74
|
+
readonly 'chat.messages.failedRetry': "Try again";
|
|
71
75
|
readonly 'chat.messages.upgrade': "Upgrade";
|
|
72
76
|
readonly 'chat.messages.upgradeTitle': "Open plans and billing";
|
|
73
77
|
/** Under a prompt: the short id of the commit it made. */
|
|
@@ -92,12 +96,19 @@ export declare const CHAT_MESSAGES: {
|
|
|
92
96
|
readonly 'chat.messages.restoredFrom': "Restored from {label}";
|
|
93
97
|
readonly 'chat.messages.previousVersion': "a previous version";
|
|
94
98
|
readonly 'chat.suggestions.title.frame': "Suggested actions for this widget";
|
|
99
|
+
readonly 'chat.suggestions.title.panelEmpty': "Suggestions";
|
|
100
|
+
readonly 'chat.suggestions.title.tryNext': "Try next";
|
|
95
101
|
readonly 'chat.suggestions.title.text': "Suggested text improvements";
|
|
96
102
|
readonly 'chat.suggestions.title.image': "Suggested image analysis";
|
|
97
103
|
readonly 'chat.suggestions.title.document': "Suggested document actions";
|
|
98
104
|
readonly 'chat.suggestions.title.other': "Suggested questions";
|
|
99
105
|
readonly 'chat.suggestions.hide': "Hide suggestions";
|
|
100
106
|
/** The ideas for a widget: tapping one sends it as the person's own message. */
|
|
107
|
+
readonly 'chat.suggestions.panel.countdown': "A countdown to a sale";
|
|
108
|
+
readonly 'chat.suggestions.panel.testimonials': "Customer testimonials";
|
|
109
|
+
readonly 'chat.suggestions.panel.gallery': "A before and after gallery";
|
|
110
|
+
readonly 'chat.suggestions.panel.changeEndDate': "Change the end date";
|
|
111
|
+
readonly 'chat.suggestions.panel.biggerButton': "Make the button bigger";
|
|
101
112
|
readonly 'chat.suggestions.frame.generateCode': "Generate code from this design";
|
|
102
113
|
readonly 'chat.suggestions.frame.improveLayout': "Improve this layout";
|
|
103
114
|
readonly 'chat.suggestions.frame.addInteractivity': "Add interactive functionality";
|
|
@@ -124,6 +135,8 @@ export declare const CHAT_MESSAGES: {
|
|
|
124
135
|
readonly 'chat.suggestions.other.understand': "Help me understand this better";
|
|
125
136
|
readonly 'chat.suggestions.other.options': "What can I do with this?";
|
|
126
137
|
readonly 'chat.input.placeholder': "Type your message...";
|
|
138
|
+
readonly 'chat.input.placeholderCreate': "Describe your widget…";
|
|
139
|
+
readonly 'chat.input.placeholderFollowUp': "Ask for a change…";
|
|
127
140
|
readonly 'chat.input.stop': "Stop generation";
|
|
128
141
|
readonly 'chat.input.sending': "Sending message...";
|
|
129
142
|
readonly 'chat.input.send': "Send message";
|
package/dist/i18n/messages.js
CHANGED
|
@@ -33,7 +33,7 @@ export const CHAT_MESSAGES = {
|
|
|
33
33
|
'chat.header.new': 'New',
|
|
34
34
|
/** The name of a conversation that has none. */
|
|
35
35
|
'chat.header.untitled': 'Untitled',
|
|
36
|
-
'chat.header.newConversationTitle': 'New
|
|
36
|
+
'chat.header.newConversationTitle': 'New chat',
|
|
37
37
|
'chat.header.newConversation': 'Start new conversation',
|
|
38
38
|
/** Label for the debug console icon in the panel chat header. */
|
|
39
39
|
'chat.header.console': 'Console',
|
|
@@ -72,6 +72,10 @@ export const CHAT_MESSAGES = {
|
|
|
72
72
|
'chat.messages.attachmentMissingTitle': 'Attachment not available',
|
|
73
73
|
'chat.messages.attachmentMissingLabel': 'Missing file attachment',
|
|
74
74
|
'chat.messages.attachmentMissingCaption': 'Attachment not saved. Re-attach with Upload, then send it again.',
|
|
75
|
+
/** The alert card a failed reply is shown in (docked panel): its title, its line, and the button that runs the prompt again. */
|
|
76
|
+
'chat.messages.failedTitle': 'Could not build the widget',
|
|
77
|
+
'chat.messages.failedHint': 'The build did not finish. Your sketch is safe, so you can try again.',
|
|
78
|
+
'chat.messages.failedRetry': 'Try again',
|
|
75
79
|
'chat.messages.upgrade': 'Upgrade',
|
|
76
80
|
'chat.messages.upgradeTitle': 'Open plans and billing',
|
|
77
81
|
/** Under a prompt: the short id of the commit it made. */
|
|
@@ -97,12 +101,19 @@ export const CHAT_MESSAGES = {
|
|
|
97
101
|
'chat.messages.previousVersion': 'a previous version',
|
|
98
102
|
// ===== Ideas the chat offers to start with =====
|
|
99
103
|
'chat.suggestions.title.frame': 'Suggested actions for this widget',
|
|
104
|
+
'chat.suggestions.title.panelEmpty': 'Suggestions',
|
|
105
|
+
'chat.suggestions.title.tryNext': 'Try next',
|
|
100
106
|
'chat.suggestions.title.text': 'Suggested text improvements',
|
|
101
107
|
'chat.suggestions.title.image': 'Suggested image analysis',
|
|
102
108
|
'chat.suggestions.title.document': 'Suggested document actions',
|
|
103
109
|
'chat.suggestions.title.other': 'Suggested questions',
|
|
104
110
|
'chat.suggestions.hide': 'Hide suggestions',
|
|
105
111
|
/** The ideas for a widget: tapping one sends it as the person's own message. */
|
|
112
|
+
'chat.suggestions.panel.countdown': 'A countdown to a sale',
|
|
113
|
+
'chat.suggestions.panel.testimonials': 'Customer testimonials',
|
|
114
|
+
'chat.suggestions.panel.gallery': 'A before and after gallery',
|
|
115
|
+
'chat.suggestions.panel.changeEndDate': 'Change the end date',
|
|
116
|
+
'chat.suggestions.panel.biggerButton': 'Make the button bigger',
|
|
106
117
|
'chat.suggestions.frame.generateCode': 'Generate code from this design',
|
|
107
118
|
'chat.suggestions.frame.improveLayout': 'Improve this layout',
|
|
108
119
|
'chat.suggestions.frame.addInteractivity': 'Add interactive functionality',
|
|
@@ -130,6 +141,8 @@ export const CHAT_MESSAGES = {
|
|
|
130
141
|
'chat.suggestions.other.options': 'What can I do with this?',
|
|
131
142
|
// ===== The box a message is typed in =====
|
|
132
143
|
'chat.input.placeholder': 'Type your message...',
|
|
144
|
+
'chat.input.placeholderCreate': 'Describe your widget…',
|
|
145
|
+
'chat.input.placeholderFollowUp': 'Ask for a change…',
|
|
133
146
|
'chat.input.stop': 'Stop generation',
|
|
134
147
|
'chat.input.sending': 'Sending message...',
|
|
135
148
|
'chat.input.send': 'Send message',
|
|
@@ -3,3 +3,9 @@ import type { ChatMessageKey } from './messages.js';
|
|
|
3
3
|
export declare function suggestionKeysFor(type: string): readonly ChatMessageKey[];
|
|
4
4
|
/** The message of the heading over the ideas offered for a kind of thing. */
|
|
5
5
|
export declare function suggestionTitleKeyFor(type: string): ChatMessageKey;
|
|
6
|
+
/** Empty side-panel suggestions (creator dock), in display order. */
|
|
7
|
+
export declare function panelEmptySuggestionKeys(): readonly ChatMessageKey[];
|
|
8
|
+
/** Heading over the empty side-panel suggestions. */
|
|
9
|
+
export declare function panelEmptySuggestionTitleKey(): ChatMessageKey;
|
|
10
|
+
export declare function panelFollowUpSuggestionKeys(): readonly ChatMessageKey[];
|
|
11
|
+
export declare function panelFollowUpSuggestionTitleKey(): ChatMessageKey;
|
package/dist/i18n/suggestions.js
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
* are message keys, so the words follow the language of the page, and a key (not the text) is what tells two ideas apart
|
|
4
4
|
* in a list: two ideas that a language happens to say with the same words are still two.
|
|
5
5
|
*/
|
|
6
|
+
/** Figma side-panel empty state (widget creator): three starter ideas with icons. */
|
|
7
|
+
const PANEL_EMPTY_SUGGESTION_KEYS = [
|
|
8
|
+
'chat.suggestions.panel.countdown',
|
|
9
|
+
'chat.suggestions.panel.testimonials',
|
|
10
|
+
'chat.suggestions.panel.gallery',
|
|
11
|
+
];
|
|
12
|
+
const PANEL_FOLLOW_UP_SUGGESTION_KEYS = [
|
|
13
|
+
'chat.suggestions.panel.changeEndDate',
|
|
14
|
+
'chat.suggestions.panel.biggerButton',
|
|
15
|
+
];
|
|
6
16
|
const SUGGESTION_KEYS = {
|
|
7
17
|
frame: [
|
|
8
18
|
'chat.suggestions.frame.generateCode',
|
|
@@ -64,3 +74,17 @@ export function suggestionKeysFor(type) {
|
|
|
64
74
|
export function suggestionTitleKeyFor(type) {
|
|
65
75
|
return TITLE_KEYS[groupOf(type)];
|
|
66
76
|
}
|
|
77
|
+
/** Empty side-panel suggestions (creator dock), in display order. */
|
|
78
|
+
export function panelEmptySuggestionKeys() {
|
|
79
|
+
return PANEL_EMPTY_SUGGESTION_KEYS;
|
|
80
|
+
}
|
|
81
|
+
/** Heading over the empty side-panel suggestions. */
|
|
82
|
+
export function panelEmptySuggestionTitleKey() {
|
|
83
|
+
return 'chat.suggestions.title.panelEmpty';
|
|
84
|
+
}
|
|
85
|
+
export function panelFollowUpSuggestionKeys() {
|
|
86
|
+
return PANEL_FOLLOW_UP_SUGGESTION_KEYS;
|
|
87
|
+
}
|
|
88
|
+
export function panelFollowUpSuggestionTitleKey() {
|
|
89
|
+
return 'chat.suggestions.title.tryNext';
|
|
90
|
+
}
|
package/dist/types/message.d.ts
CHANGED
|
@@ -52,6 +52,13 @@ export interface ChatMessage {
|
|
|
52
52
|
* reply (beside `suggestions`), so a reload re-renders the card and re-fetches
|
|
53
53
|
* its current values from the composition it names. */
|
|
54
54
|
designControls?: DesignControlRequest;
|
|
55
|
+
/** Host-owned flags about how this reply is shown. `panelFollowUp: false`
|
|
56
|
+
* keeps this reply's suggestion chips out of the docked creator panel's
|
|
57
|
+
* follow-up list (the panel shows the chips of the last reply that has any,
|
|
58
|
+
* unless the host says otherwise). Absent for every reply that sets nothing. */
|
|
59
|
+
metadata?: {
|
|
60
|
+
panelFollowUp?: boolean;
|
|
61
|
+
} | null;
|
|
55
62
|
}
|
|
56
63
|
/** One design property the host wants rendered as an inline controller. */
|
|
57
64
|
export interface DesignControlProperty {
|