@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.
Files changed (35) hide show
  1. package/README.md +34 -6
  2. package/dist/components/ActionBar.svelte +8 -0
  3. package/dist/components/Chat.svelte +120 -106
  4. package/dist/components/Chat.svelte.d.ts +19 -1
  5. package/dist/components/ChatComposer.svelte +166 -0
  6. package/dist/components/ChatComposer.svelte.d.ts +30 -0
  7. package/dist/components/ChatMessages.svelte +483 -393
  8. package/dist/components/ChatMessages.svelte.d.ts +16 -6
  9. package/dist/components/IconButton.svelte +125 -0
  10. package/dist/components/IconButton.svelte.d.ts +22 -0
  11. package/dist/components/MessageActions.svelte +48 -0
  12. package/dist/components/MessageActions.svelte.d.ts +13 -0
  13. package/dist/components/PanelChatHeader.svelte +79 -0
  14. package/dist/components/PanelChatHeader.svelte.d.ts +19 -0
  15. package/dist/components/PanelFollowUpSuggestions.svelte +34 -0
  16. package/dist/components/PanelFollowUpSuggestions.svelte.d.ts +8 -0
  17. package/dist/components/PanelSuggestionButtons.svelte +60 -0
  18. package/dist/components/PanelSuggestionButtons.svelte.d.ts +10 -0
  19. package/dist/components/SuggestionButtons.svelte +11 -163
  20. package/dist/i18n/index.d.ts +1 -1
  21. package/dist/i18n/index.js +1 -1
  22. package/dist/i18n/messages.d.ts +54 -13
  23. package/dist/i18n/messages.js +54 -13
  24. package/dist/i18n/suggestions.d.ts +6 -0
  25. package/dist/i18n/suggestions.js +24 -0
  26. package/dist/types/message.d.ts +7 -0
  27. package/dist/utils/generationActivity.d.ts +12 -0
  28. package/dist/utils/generationActivity.js +47 -0
  29. package/dist/utils/generationPlan.d.ts +32 -0
  30. package/dist/utils/generationPlan.js +89 -0
  31. package/dist/utils/index.d.ts +4 -0
  32. package/dist/utils/index.js +2 -0
  33. package/dist/utils/messageActions.d.ts +54 -0
  34. package/dist/utils/messageActions.js +104 -0
  35. package/package.json +3 -3
@@ -1,199 +1,47 @@
1
1
  <script lang="ts">
2
2
  import { createEventDispatcher } from 'svelte';
3
- import { chatLog } from '../utils/logger.js';
4
3
  import type { ChatContext } from '../types/context.js';
5
4
  import { useChatLanguage } from '../i18n/language.js';
6
5
  import { suggestionKeysFor, suggestionTitleKeyFor } from '../i18n/suggestions.js';
7
- import { dirForUserText, useTextDirection } from '@widgetic/design-system/components/textDirection';
6
+ import { SuggestionCard } from '@widgetic/design-system/components/chat/index';
8
7
 
9
- // The words of the ideas, in the language of the chat above
10
8
  const { t } = useChatLanguage();
11
9
 
12
- // The way the screen is read: a suggestion is a sentence the assistant wrote, and reads by its own first letter on a right to left screen.
13
- const textDirection = useTextDirection();
14
-
15
- // Props
16
10
  interface Props {
17
11
  context: ChatContext;
18
12
  visible?: boolean;
19
13
  onHide?: () => void;
20
14
  }
21
-
15
+
22
16
  let { context, visible = true, onHide }: Props = $props();
23
-
17
+
24
18
  const dispatch = createEventDispatcher();
25
-
19
+
26
20
  function handleSuggestionClick(suggestion: string) {
27
- // chatLog('Suggestion clicked:', suggestion);
28
21
  dispatch('suggestionSelected', { suggestion });
29
22
  }
30
-
31
- // Get suggestions for current context
23
+
32
24
  let suggestionKeys = $derived(suggestionKeysFor(context.type));
33
25
  let titleKey = $derived(suggestionTitleKeyFor(context.type));
34
26
  </script>
35
27
 
36
28
  {#if visible && suggestionKeys.length > 0}
37
- <div class="suggestion-container">
38
- <div class="suggestion-header">
39
- <h4 class="suggestion-title">
29
+ <div class="suggestion-container flex w-full max-w-full flex-col gap-1">
30
+ <div class="flex items-center justify-between gap-2">
31
+ <h4 class="text-caption text-muted-foreground">
40
32
  {$t(titleKey)}
41
33
  </h4>
42
34
  {#if onHide}
43
- <button
44
- class="hide-suggestions-btn"
45
- onclick={onHide}
46
- >
35
+ <button type="button" class="text-caption text-muted-foreground hover:text-foreground" onclick={onHide}>
47
36
  {$t('chat.suggestions.hide')}
48
37
  </button>
49
38
  {/if}
50
39
  </div>
51
-
52
- <div class="suggestion-grid">
40
+ <div class="flex w-full flex-col gap-1">
53
41
  {#each suggestionKeys as suggestionKey (suggestionKey)}
54
42
  {@const suggestion = $t(suggestionKey)}
55
- <button
56
- class="suggestion-button"
57
- onclick={() => handleSuggestionClick(suggestion)}
58
- title={suggestion}
59
- >
60
- <span class="suggestion-text" dir={dirForUserText($textDirection)}>{suggestion}</span>
61
- <svg class="suggestion-arrow" viewBox="0 0 20 20" fill="currentColor">
62
- <path fill-rule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clip-rule="evenodd" />
63
- </svg>
64
- </button>
43
+ <SuggestionCard title={suggestion} onclick={() => handleSuggestionClick(suggestion)} />
65
44
  {/each}
66
45
  </div>
67
-
68
46
  </div>
69
47
  {/if}
70
-
71
- <style>
72
- .suggestion-container {
73
- padding: 1.5rem;
74
- background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
75
- border-radius: 0.75rem;
76
- border: 1px solid #e2e8f0;
77
- margin: 1rem;
78
- }
79
-
80
- .suggestion-header {
81
- display: flex;
82
- flex-direction: column;
83
- align-items: center;
84
- gap: 0.5rem;
85
- margin-bottom: 1rem;
86
- }
87
-
88
- .suggestion-title {
89
- font-size: 0.875rem;
90
- font-weight: 600;
91
- color: #1e293b;
92
- margin: 0;
93
- display: flex;
94
- align-items: center;
95
- gap: 0.5rem;
96
- text-align: center;
97
- }
98
-
99
- .hide-suggestions-btn {
100
- font-size: 0.75rem;
101
- color: #64748b;
102
- background: none;
103
- border: 1px solid #e2e8f0;
104
- border-radius: 9999px;
105
- padding: 0.25rem 0.75rem;
106
- cursor: pointer;
107
- transition: all 0.15s ease;
108
- white-space: nowrap;
109
- }
110
-
111
- .hide-suggestions-btn:hover {
112
- color: #374151;
113
- border-color: #cbd5e1;
114
- background: #f8fafc;
115
- }
116
-
117
- .suggestion-grid {
118
- display: grid;
119
- gap: 0.75rem;
120
- grid-template-columns: 1fr;
121
- }
122
-
123
- .suggestion-button {
124
- display: flex;
125
- align-items: center;
126
- justify-content: space-between;
127
- padding: 0.875rem 1rem;
128
- background: white;
129
- border: 1px solid #e2e8f0;
130
- border-radius: 0.5rem;
131
- color: #374151;
132
- font-size: 0.875rem;
133
- text-align: start;
134
- cursor: pointer;
135
- transition: all 0.2s ease;
136
- box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
137
- }
138
-
139
- .suggestion-button:hover {
140
- background: #f8fafc;
141
- border-color: #3b82f6;
142
- color: #1d4ed8;
143
- transform: translateY(-1px);
144
- box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
145
- }
146
-
147
- .suggestion-button:active {
148
- transform: translateY(0);
149
- }
150
-
151
- .suggestion-text {
152
- flex: 1;
153
- line-height: 1.4;
154
- }
155
-
156
- .suggestion-arrow {
157
- width: 1rem;
158
- height: 1rem;
159
- margin-inline-start: 0.75rem;
160
- opacity: 0.5;
161
- transition: all 0.2s ease;
162
- flex-shrink: 0;
163
- }
164
-
165
- .suggestion-button:hover .suggestion-arrow {
166
- opacity: 1;
167
- transform: translateX(2px);
168
- }
169
-
170
-
171
- /* Responsive adjustments */
172
- @media (min-width: 400px) {
173
- .suggestion-grid {
174
- grid-template-columns: 1fr;
175
- }
176
- }
177
-
178
- /* Animation for initial appearance */
179
- .suggestion-container {
180
- animation: fadeInUp 0.3s ease-out;
181
- }
182
-
183
- @keyframes fadeInUp {
184
- from {
185
- opacity: 0;
186
- transform: translateY(10px);
187
- }
188
- to {
189
- opacity: 1;
190
- transform: translateY(0);
191
- }
192
- }
193
-
194
- /* Focus styles for accessibility */
195
- .suggestion-button:focus-visible {
196
- outline: none;
197
- box-shadow: 0 0 0 2px #3b82f6, 0 0 0 4px rgba(59, 130, 246, 0.1);
198
- }
199
- </style>
@@ -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';
@@ -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';
@@ -31,34 +31,59 @@ 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 conversation";
34
+ readonly 'chat.header.newConversationTitle': "New chat";
35
35
  readonly 'chat.header.newConversation': "Start new conversation";
36
+ /** Label for the debug console icon in the panel chat header. */
37
+ readonly 'chat.header.console': "Console";
36
38
  readonly 'chat.header.close': "Close chat";
37
39
  /** The name of the button that expands a chat that is shown as a small card. */
38
40
  readonly 'chat.contextPreview.expand': "Expand {name} chat context";
39
41
  readonly 'chat.conversation.defaultTitle': "Chat about {name}";
40
- readonly 'chat.messages.startTitle': "Start a conversation";
41
- readonly 'chat.messages.startHint': "Ask a question about your {type} to get started.";
42
+ /** The hero of an empty chat (Figma: Chat / Empty). */
43
+ readonly 'chat.messages.emptyTitle': "What do you want to build?";
44
+ readonly 'chat.messages.emptyHint': "Sketch it on the canvas, or describe it here.";
42
45
  readonly 'chat.messages.loadingHistory': "Loading chat history...";
43
46
  /** Said while the assistant works on an answer. */
44
47
  readonly 'chat.messages.thinking': "Assistant is thinking";
45
- /** The mark on the turn of the version that is open now, and the line that explains it. */
46
- readonly 'chat.messages.viewing': "You are here";
47
- readonly 'chat.messages.viewingTitle': "This is the version you are looking at";
48
+ /** Header while streamed reasoning is visible during codegen. */
49
+ readonly 'chat.generation.thinking': "Thinking";
50
+ /** Header while streamed code is visible during codegen. */
51
+ readonly 'chat.generation.writingCode': "Writing code";
52
+ /** Collapsed reasoning summary after code begins streaming. */
53
+ readonly 'chat.generation.thoughtFor': "Thought for {seconds} s";
54
+ readonly 'chat.generation.expandThought': "Show thinking";
55
+ readonly 'chat.generation.collapseThought': "Hide thinking";
56
+ /** Polite screen-reader line when codegen enters the thinking phase. */
57
+ readonly 'chat.generation.statusThinking': "Assistant is thinking";
58
+ /** Polite screen-reader line when codegen enters the writing-code phase. */
59
+ readonly 'chat.generation.statusWritingCode': "Assistant is writing code";
60
+ /** Heading when the gateway plan has no title. */
61
+ readonly 'chat.plan.title': "Build plan";
62
+ /** Progress badge on the plan card (`{current}` / `{total}`). */
63
+ readonly 'chat.plan.progress': "{current} of {total}";
64
+ readonly 'chat.plan.showMoreTasks': "Show {count} more tasks";
65
+ readonly 'chat.plan.showFewerTasks': "Show fewer tasks";
66
+ /** Accessible name for the plan region while codegen runs. */
67
+ readonly 'chat.plan.regionLabel': "Widget build plan";
48
68
  readonly 'chat.messages.attachmentMissingTitle': "Attachment not available";
49
69
  readonly 'chat.messages.attachmentMissingLabel': "Missing file attachment";
50
- readonly 'chat.messages.attachmentMissingCaption': "Attachment not saved. Re-attach with Upload, then Retry.";
51
- readonly 'chat.messages.retry': "Retry";
52
- readonly 'chat.messages.retryPromptTitle': "Run this prompt again as its own message. The sketch stays with the model, not on the bubble.";
53
- readonly 'chat.messages.retryLastTitle': "Retry the last user prompt (same generation request)";
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";
54
75
  readonly 'chat.messages.upgrade': "Upgrade";
55
76
  readonly 'chat.messages.upgradeTitle': "Open plans and billing";
56
77
  /** Under a prompt: the short id of the commit it made. */
57
78
  readonly 'chat.messages.commitId': "(commit id: {id})";
79
+ /** The icon on a message the person sent: puts the widget back to how it was before that message. Its tooltip and its name. */
58
80
  readonly 'chat.messages.restore': "Restore Checkpoint";
59
- readonly 'chat.messages.restoreTitle': "Restore widget code to this prompt's commit";
60
- readonly 'chat.messages.alreadyHead': "This checkpoint is already HEAD";
61
- /** The two thumbs next to a version's name, when the page gave the chat a way to keep a rating (`onRateVersion`). */
81
+ /** The icons at the end of the last message: the name of the row, copy (and what it says once done), run again, and the two thumbs. */
82
+ readonly 'chat.messages.actions': "Message actions";
83
+ readonly 'chat.messages.copy': "Copy";
84
+ readonly 'chat.messages.copied': "Copied";
85
+ readonly 'chat.messages.regenerate': "Regenerate";
86
+ /** The two thumbs, when the page gave the chat a way to keep a rating (`onRateVersion`). */
62
87
  readonly 'chat.messages.rateGroup': "Rate this version";
63
88
  readonly 'chat.messages.rateUp': "This version is good";
64
89
  readonly 'chat.messages.rateDown': "This version is not good";
@@ -71,12 +96,19 @@ export declare const CHAT_MESSAGES: {
71
96
  readonly 'chat.messages.restoredFrom': "Restored from {label}";
72
97
  readonly 'chat.messages.previousVersion': "a previous version";
73
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";
74
101
  readonly 'chat.suggestions.title.text': "Suggested text improvements";
75
102
  readonly 'chat.suggestions.title.image': "Suggested image analysis";
76
103
  readonly 'chat.suggestions.title.document': "Suggested document actions";
77
104
  readonly 'chat.suggestions.title.other': "Suggested questions";
78
105
  readonly 'chat.suggestions.hide': "Hide suggestions";
79
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";
80
112
  readonly 'chat.suggestions.frame.generateCode': "Generate code from this design";
81
113
  readonly 'chat.suggestions.frame.improveLayout': "Improve this layout";
82
114
  readonly 'chat.suggestions.frame.addInteractivity': "Add interactive functionality";
@@ -103,9 +135,18 @@ export declare const CHAT_MESSAGES: {
103
135
  readonly 'chat.suggestions.other.understand': "Help me understand this better";
104
136
  readonly 'chat.suggestions.other.options': "What can I do with this?";
105
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…";
106
140
  readonly 'chat.input.stop': "Stop generation";
107
141
  readonly 'chat.input.sending': "Sending message...";
108
142
  readonly 'chat.input.send': "Send message";
143
+ readonly 'chat.input.tooLong': "Message is too long";
144
+ readonly 'chat.composer.assistant': "Assistant";
145
+ readonly 'chat.messages.scrollToBottom': "Scroll to latest messages";
146
+ readonly 'chat.messages.clarificationPrompt': "Which option fits best?";
147
+ readonly 'chat.checkpoint.version': "Version {n}";
148
+ readonly 'chat.checkpoint.redo': "Redo";
149
+ readonly 'chat.checkpoint.restored': "Restored to version {n}";
109
150
  readonly 'chat.actions.screenshot': "Screenshot";
110
151
  readonly 'chat.actions.screenshotTitle': "Take Screenshot";
111
152
  readonly 'chat.actions.screenshotLabel': "Take screenshot of current content";
@@ -33,36 +33,61 @@ 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 conversation',
36
+ 'chat.header.newConversationTitle': 'New chat',
37
37
  'chat.header.newConversation': 'Start new conversation',
38
+ /** Label for the debug console icon in the panel chat header. */
39
+ 'chat.header.console': 'Console',
38
40
  'chat.header.close': 'Close chat',
39
41
  /** The name of the button that expands a chat that is shown as a small card. */
40
42
  'chat.contextPreview.expand': 'Expand {name} chat context',
41
43
  // ===== The name of a conversation the chat starts by itself =====
42
44
  'chat.conversation.defaultTitle': 'Chat about {name}',
43
45
  // ===== The messages area =====
44
- 'chat.messages.startTitle': 'Start a conversation',
45
- 'chat.messages.startHint': 'Ask a question about your {type} to get started.',
46
+ /** The hero of an empty chat (Figma: Chat / Empty). */
47
+ 'chat.messages.emptyTitle': 'What do you want to build?',
48
+ 'chat.messages.emptyHint': 'Sketch it on the canvas, or describe it here.',
46
49
  'chat.messages.loadingHistory': 'Loading chat history...',
47
50
  /** Said while the assistant works on an answer. */
48
51
  'chat.messages.thinking': 'Assistant is thinking',
49
- /** The mark on the turn of the version that is open now, and the line that explains it. */
50
- 'chat.messages.viewing': 'You are here',
51
- 'chat.messages.viewingTitle': 'This is the version you are looking at',
52
+ /** Header while streamed reasoning is visible during codegen. */
53
+ 'chat.generation.thinking': 'Thinking',
54
+ /** Header while streamed code is visible during codegen. */
55
+ 'chat.generation.writingCode': 'Writing code',
56
+ /** Collapsed reasoning summary after code begins streaming. */
57
+ 'chat.generation.thoughtFor': 'Thought for {seconds} s',
58
+ 'chat.generation.expandThought': 'Show thinking',
59
+ 'chat.generation.collapseThought': 'Hide thinking',
60
+ /** Polite screen-reader line when codegen enters the thinking phase. */
61
+ 'chat.generation.statusThinking': 'Assistant is thinking',
62
+ /** Polite screen-reader line when codegen enters the writing-code phase. */
63
+ 'chat.generation.statusWritingCode': 'Assistant is writing code',
64
+ /** Heading when the gateway plan has no title. */
65
+ 'chat.plan.title': 'Build plan',
66
+ /** Progress badge on the plan card (`{current}` / `{total}`). */
67
+ 'chat.plan.progress': '{current} of {total}',
68
+ 'chat.plan.showMoreTasks': 'Show {count} more tasks',
69
+ 'chat.plan.showFewerTasks': 'Show fewer tasks',
70
+ /** Accessible name for the plan region while codegen runs. */
71
+ 'chat.plan.regionLabel': 'Widget build plan',
52
72
  'chat.messages.attachmentMissingTitle': 'Attachment not available',
53
73
  'chat.messages.attachmentMissingLabel': 'Missing file attachment',
54
- 'chat.messages.attachmentMissingCaption': 'Attachment not saved. Re-attach with Upload, then Retry.',
55
- 'chat.messages.retry': 'Retry',
56
- 'chat.messages.retryPromptTitle': 'Run this prompt again as its own message. The sketch stays with the model, not on the bubble.',
57
- 'chat.messages.retryLastTitle': 'Retry the last user prompt (same generation request)',
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',
58
79
  'chat.messages.upgrade': 'Upgrade',
59
80
  'chat.messages.upgradeTitle': 'Open plans and billing',
60
81
  /** Under a prompt: the short id of the commit it made. */
61
82
  'chat.messages.commitId': '(commit id: {id})',
83
+ /** The icon on a message the person sent: puts the widget back to how it was before that message. Its tooltip and its name. */
62
84
  'chat.messages.restore': 'Restore Checkpoint',
63
- 'chat.messages.restoreTitle': 'Restore widget code to this prompt\'s commit',
64
- 'chat.messages.alreadyHead': 'This checkpoint is already HEAD',
65
- /** The two thumbs next to a version's name, when the page gave the chat a way to keep a rating (`onRateVersion`). */
85
+ /** The icons at the end of the last message: the name of the row, copy (and what it says once done), run again, and the two thumbs. */
86
+ 'chat.messages.actions': 'Message actions',
87
+ 'chat.messages.copy': 'Copy',
88
+ 'chat.messages.copied': 'Copied',
89
+ 'chat.messages.regenerate': 'Regenerate',
90
+ /** The two thumbs, when the page gave the chat a way to keep a rating (`onRateVersion`). */
66
91
  'chat.messages.rateGroup': 'Rate this version',
67
92
  'chat.messages.rateUp': 'This version is good',
68
93
  'chat.messages.rateDown': 'This version is not good',
@@ -76,12 +101,19 @@ export const CHAT_MESSAGES = {
76
101
  'chat.messages.previousVersion': 'a previous version',
77
102
  // ===== Ideas the chat offers to start with =====
78
103
  'chat.suggestions.title.frame': 'Suggested actions for this widget',
104
+ 'chat.suggestions.title.panelEmpty': 'Suggestions',
105
+ 'chat.suggestions.title.tryNext': 'Try next',
79
106
  'chat.suggestions.title.text': 'Suggested text improvements',
80
107
  'chat.suggestions.title.image': 'Suggested image analysis',
81
108
  'chat.suggestions.title.document': 'Suggested document actions',
82
109
  'chat.suggestions.title.other': 'Suggested questions',
83
110
  'chat.suggestions.hide': 'Hide suggestions',
84
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',
85
117
  'chat.suggestions.frame.generateCode': 'Generate code from this design',
86
118
  'chat.suggestions.frame.improveLayout': 'Improve this layout',
87
119
  'chat.suggestions.frame.addInteractivity': 'Add interactive functionality',
@@ -109,9 +141,18 @@ export const CHAT_MESSAGES = {
109
141
  'chat.suggestions.other.options': 'What can I do with this?',
110
142
  // ===== The box a message is typed in =====
111
143
  'chat.input.placeholder': 'Type your message...',
144
+ 'chat.input.placeholderCreate': 'Describe your widget…',
145
+ 'chat.input.placeholderFollowUp': 'Ask for a change…',
112
146
  'chat.input.stop': 'Stop generation',
113
147
  'chat.input.sending': 'Sending message...',
114
148
  'chat.input.send': 'Send message',
149
+ 'chat.input.tooLong': 'Message is too long',
150
+ 'chat.composer.assistant': 'Assistant',
151
+ 'chat.messages.scrollToBottom': 'Scroll to latest messages',
152
+ 'chat.messages.clarificationPrompt': 'Which option fits best?',
153
+ 'chat.checkpoint.version': 'Version {n}',
154
+ 'chat.checkpoint.redo': 'Redo',
155
+ 'chat.checkpoint.restored': 'Restored to version {n}',
115
156
  // ===== The buttons under the messages =====
116
157
  'chat.actions.screenshot': 'Screenshot',
117
158
  'chat.actions.screenshotTitle': 'Take Screenshot',
@@ -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;
@@ -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
+ }
@@ -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 {
@@ -0,0 +1,12 @@
1
+ import type { ChatMessageKey } from '../i18n/messages.js';
2
+ /** Rolling reasoning tail from codegen status metadata (gateway contract). */
3
+ export declare function readThinkingTail(metadata?: Record<string, unknown>): string;
4
+ /** Rolling code stream tail from codegen status metadata. */
5
+ export declare function readCodegenStreamTail(metadata?: Record<string, unknown>): string;
6
+ export type GenerationActivityPhase = 'idle' | 'shimmer-only' | 'thinking-stream' | 'thinking-and-code' | 'code-only';
7
+ /** Which surface to show while a generation is running. */
8
+ export declare function generationActivityPhase(isGenerating: boolean, thinkingTail: string, codeTail: string): GenerationActivityPhase;
9
+ /** Whole seconds between thinking start and the moment code streaming begins. */
10
+ export declare function thoughtDurationSeconds(startedAtMs: number | null, codeStartedAtMs: number | null): number | null;
11
+ /** Polite screen-reader line when the visible phase changes (not on every token). */
12
+ export declare function generationActivityAriaKey(phase: GenerationActivityPhase): ChatMessageKey | null;
@@ -0,0 +1,47 @@
1
+ /** Rolling reasoning tail from codegen status metadata (gateway contract). */
2
+ export function readThinkingTail(metadata) {
3
+ if (!metadata)
4
+ return '';
5
+ const raw = metadata.thinkingTail ?? metadata.thinking_tail;
6
+ return typeof raw === 'string' ? raw.slice(-2400) : '';
7
+ }
8
+ /** Rolling code stream tail from codegen status metadata. */
9
+ export function readCodegenStreamTail(metadata) {
10
+ if (!metadata)
11
+ return '';
12
+ const raw = metadata.streamTail ?? metadata.stream_tail;
13
+ return typeof raw === 'string' ? raw.slice(-1600) : '';
14
+ }
15
+ /** Which surface to show while a generation is running. */
16
+ export function generationActivityPhase(isGenerating, thinkingTail, codeTail) {
17
+ if (!isGenerating)
18
+ return 'idle';
19
+ const hasThinking = thinkingTail.trim().length > 0;
20
+ const hasCode = codeTail.trim().length > 0;
21
+ if (hasCode && hasThinking)
22
+ return 'thinking-and-code';
23
+ if (hasCode)
24
+ return 'code-only';
25
+ if (hasThinking)
26
+ return 'thinking-stream';
27
+ return 'shimmer-only';
28
+ }
29
+ /** Whole seconds between thinking start and the moment code streaming begins. */
30
+ export function thoughtDurationSeconds(startedAtMs, codeStartedAtMs) {
31
+ if (startedAtMs == null || codeStartedAtMs == null)
32
+ return null;
33
+ return Math.max(0, Math.round((codeStartedAtMs - startedAtMs) / 1000));
34
+ }
35
+ /** Polite screen-reader line when the visible phase changes (not on every token). */
36
+ export function generationActivityAriaKey(phase) {
37
+ switch (phase) {
38
+ case 'thinking-stream':
39
+ case 'shimmer-only':
40
+ return 'chat.generation.statusThinking';
41
+ case 'thinking-and-code':
42
+ case 'code-only':
43
+ return 'chat.generation.statusWritingCode';
44
+ default:
45
+ return null;
46
+ }
47
+ }
@@ -0,0 +1,32 @@
1
+ export type MappedPlanTaskStatus = 'pending' | 'active' | 'done';
2
+ export type MappedPlanTask = {
3
+ id: string;
4
+ label: string;
5
+ status: MappedPlanTaskStatus;
6
+ };
7
+ export type WidgetPlanTaskStatusWire = 'pending' | 'in_progress' | 'done' | 'failed';
8
+ /** Wire shape of `operation.metadata.plan` (display fields only). */
9
+ export type GenerationPlanWire = {
10
+ title: string;
11
+ tasks: Array<{
12
+ id: string;
13
+ label: string;
14
+ kind?: string;
15
+ status: WidgetPlanTaskStatusWire;
16
+ }>;
17
+ completed?: number;
18
+ activeIndex?: number | null;
19
+ decisions?: unknown;
20
+ };
21
+ export type MappedGenerationPlanCard = {
22
+ title: string;
23
+ tasks: MappedPlanTask[];
24
+ progressCurrent: number;
25
+ progressTotal: number;
26
+ };
27
+ /**
28
+ * Reads `metadata.plan`. Missing key → `undefined` (leave UI as-is); `null` → hide; bad shape → `null`.
29
+ */
30
+ export declare function readGenerationPlanFromMetadata(metadata?: Record<string, unknown>): GenerationPlanWire | null | undefined;
31
+ /** Maps gateway plan data to {@link PlanCard} props, or `null` when nothing should render. */
32
+ export declare function mapWidgetPlanToPlanCard(plan: GenerationPlanWire, fallbackTitle: string): MappedGenerationPlanCard | null;