@widgetic/chat 0.1.41 → 0.1.43

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 (87) hide show
  1. package/README.md +461 -6
  2. package/dist/components/Chat.svelte +1117 -119
  3. package/dist/components/Chat.svelte.d.ts +112 -2
  4. package/dist/components/ChatComposer.svelte +389 -8
  5. package/dist/components/ChatComposer.svelte.d.ts +71 -2
  6. package/dist/components/ChatMessageQueue.svelte +56 -0
  7. package/dist/components/ChatMessageQueue.svelte.d.ts +20 -0
  8. package/dist/components/ChatMessages.svelte +477 -46
  9. package/dist/components/ChatMessages.svelte.d.ts +45 -2
  10. package/dist/components/ComposerAttachmentsTray.svelte +42 -10
  11. package/dist/components/ComposerAttachmentsTray.svelte.d.ts +5 -0
  12. package/dist/components/ComposerMentionChips.svelte +53 -0
  13. package/dist/components/ComposerMentionChips.svelte.d.ts +15 -0
  14. package/dist/components/FollowUpCard.svelte +134 -0
  15. package/dist/components/FollowUpCard.svelte.d.ts +17 -0
  16. package/dist/components/MentionChip.svelte +41 -0
  17. package/dist/components/MentionChip.svelte.d.ts +12 -0
  18. package/dist/components/MentionMenu.svelte +114 -0
  19. package/dist/components/MentionMenu.svelte.d.ts +19 -0
  20. package/dist/components/SelectedElementChip.svelte +73 -0
  21. package/dist/components/SelectedElementChip.svelte.d.ts +20 -0
  22. package/dist/components/agent/AgentAvatar.svelte +6 -4
  23. package/dist/components/agent/AgentAvatar.svelte.d.ts +1 -1
  24. package/dist/components/agent/CodeCard.svelte +122 -27
  25. package/dist/components/agent/CodeCard.svelte.d.ts +3 -0
  26. package/dist/components/agent/CodeDiff.svelte +180 -0
  27. package/dist/components/agent/CodeDiff.svelte.d.ts +10 -0
  28. package/dist/components/agent/GenerationModule.svelte +13 -2
  29. package/dist/components/agent/GenerationModule.svelte.d.ts +3 -0
  30. package/dist/components/index.d.ts +5 -0
  31. package/dist/components/index.js +12 -0
  32. package/dist/errors/logTechnicalUserError.d.ts +1 -0
  33. package/dist/errors/logTechnicalUserError.js +37 -0
  34. package/dist/i18n/messages.d.ts +106 -1
  35. package/dist/i18n/messages.js +112 -1
  36. package/dist/i18n/sketchLocales.js +8 -8
  37. package/dist/messageQueue.d.ts +83 -0
  38. package/dist/messageQueue.js +84 -0
  39. package/dist/services/sketchAssistantClient.js +6 -2
  40. package/dist/services/sketchAssistantErrors.d.ts +4 -0
  41. package/dist/services/sketchAssistantErrors.js +22 -0
  42. package/dist/services/sketchAssistantOrchestrator.d.ts +1 -6
  43. package/dist/services/sketchAssistantOrchestrator.js +10 -24
  44. package/dist/services/sketchAssistantReply.js +3 -1
  45. package/dist/stores/chatStore.d.ts +5 -0
  46. package/dist/stores/chatStore.js +21 -0
  47. package/dist/types/agent.d.ts +4 -3
  48. package/dist/types/attachment.d.ts +16 -0
  49. package/dist/types/config.d.ts +6 -0
  50. package/dist/types/index.d.ts +1 -0
  51. package/dist/types/index.js +2 -0
  52. package/dist/types/mention.d.ts +40 -0
  53. package/dist/types/mention.js +8 -0
  54. package/dist/types/message.d.ts +60 -1
  55. package/dist/utils/agentTurn.d.ts +40 -9
  56. package/dist/utils/agentTurn.js +43 -11
  57. package/dist/utils/attachmentProgress.d.ts +12 -0
  58. package/dist/utils/attachmentProgress.js +18 -0
  59. package/dist/utils/bubbleRichFit.d.ts +68 -0
  60. package/dist/utils/bubbleRichFit.js +45 -0
  61. package/dist/utils/bubbleShrinkWrap.d.ts +8 -1
  62. package/dist/utils/bubbleShrinkWrap.js +113 -17
  63. package/dist/utils/codeChanges.d.ts +103 -0
  64. package/dist/utils/codeChanges.js +226 -0
  65. package/dist/utils/codeHighlight.js +1 -0
  66. package/dist/utils/codeStreamFormat.d.ts +5 -2
  67. package/dist/utils/composerMentions.d.ts +96 -0
  68. package/dist/utils/composerMentions.js +217 -0
  69. package/dist/utils/followUps.d.ts +74 -0
  70. package/dist/utils/followUps.js +116 -0
  71. package/dist/utils/generationArchiveStore.d.ts +6 -0
  72. package/dist/utils/generationArchiveStore.js +11 -3
  73. package/dist/utils/index.d.ts +14 -0
  74. package/dist/utils/index.js +22 -0
  75. package/dist/utils/orderedLine.d.ts +29 -0
  76. package/dist/utils/orderedLine.js +17 -0
  77. package/dist/utils/pastedContent.d.ts +99 -0
  78. package/dist/utils/pastedContent.js +258 -0
  79. package/dist/utils/questionCards.d.ts +131 -0
  80. package/dist/utils/questionCards.js +287 -0
  81. package/dist/utils/referenceItems.d.ts +36 -0
  82. package/dist/utils/referenceItems.js +56 -0
  83. package/dist/utils/selectedElementChip.d.ts +47 -0
  84. package/dist/utils/selectedElementChip.js +73 -0
  85. package/dist/utils/sentReferenceBadges.d.ts +26 -0
  86. package/dist/utils/sentReferenceBadges.js +32 -0
  87. package/package.json +1 -1
@@ -12,6 +12,11 @@ export { default as LoadingIndicator } from './LoadingIndicator.svelte';
12
12
  export { default as AgentAvatar } from './agent/AgentAvatar.svelte';
13
13
  export { default as AgentTurn } from './agent/AgentTurn.svelte';
14
14
  export { default as CodeCard } from './agent/CodeCard.svelte';
15
+ export { default as CodeDiff } from './agent/CodeDiff.svelte';
15
16
  export { default as GenerationModule } from './agent/GenerationModule.svelte';
16
17
  export { default as MemberAvatar } from './agent/MemberAvatar.svelte';
18
+ export { default as SelectedElementChip } from './SelectedElementChip.svelte';
19
+ export { default as ChatComposer } from './ChatComposer.svelte';
20
+ export { default as MentionMenu } from './MentionMenu.svelte';
21
+ export { default as MentionChip } from './MentionChip.svelte';
17
22
  export type { ComponentProps } from 'svelte';
@@ -17,5 +17,17 @@ export { default as LoadingIndicator } from './LoadingIndicator.svelte';
17
17
  export { default as AgentAvatar } from './agent/AgentAvatar.svelte';
18
18
  export { default as AgentTurn } from './agent/AgentTurn.svelte';
19
19
  export { default as CodeCard } from './agent/CodeCard.svelte';
20
+ export { default as CodeDiff } from './agent/CodeDiff.svelte';
20
21
  export { default as GenerationModule } from './agent/GenerationModule.svelte';
21
22
  export { default as MemberAvatar } from './agent/MemberAvatar.svelte';
23
+ // The chip of a part the person picked on the preview (the numbered badge, the first words of its note, the cross), for a page
24
+ // that builds its own message box. Inside `Chat` the chips are drawn for the page, in the message box.
25
+ export { default as SelectedElementChip } from './SelectedElementChip.svelte';
26
+ // The chat's own message box (the text, Enter to send, Shift+Enter for a new line, the arrow-up send button), for a page that
27
+ // needs a box like it outside the chat: the note of a part picked on the preview is written in one. Used on its own it speaks
28
+ // English, except for the words the page gives it (`placeholder`, `inputLabel`, `sendLabel`).
29
+ export { default as ChatComposer } from './ChatComposer.svelte';
30
+ // The @ menu and the chip of a pick, for a page that builds its own message box (the rules they follow are in the utilities:
31
+ // `buildMentionRows`, `findActiveMentionTrigger`, ...). Inside `Chat` they are drawn for the page, from its `mentionSources`.
32
+ export { default as MentionMenu } from './MentionMenu.svelte';
33
+ export { default as MentionChip } from './MentionChip.svelte';
@@ -0,0 +1 @@
1
+ export declare function logTechnicalUserError(context: string, error: unknown, detail?: string | null): void;
@@ -0,0 +1,37 @@
1
+ const loggedObjects = new WeakSet();
2
+ const loggedStringKeys = new Set();
3
+ const MAX_DEDUPED_STRING_KEYS = 200;
4
+ function rememberStringKey(key) {
5
+ if (loggedStringKeys.has(key))
6
+ return false;
7
+ if (loggedStringKeys.size >= MAX_DEDUPED_STRING_KEYS) {
8
+ const first = loggedStringKeys.values().next().value;
9
+ if (typeof first === 'string')
10
+ loggedStringKeys.delete(first);
11
+ }
12
+ loggedStringKeys.add(key);
13
+ return true;
14
+ }
15
+ export function logTechnicalUserError(context, error, detail) {
16
+ const prefix = `[chat] ${context}`;
17
+ if (error !== null && error !== undefined && typeof error === 'object') {
18
+ if (loggedObjects.has(error))
19
+ return;
20
+ loggedObjects.add(error);
21
+ console.error(prefix, error);
22
+ return;
23
+ }
24
+ const fallback = detail?.trim() || (typeof error === 'string' ? error.trim() : '');
25
+ const dedupeKey = `${context}\0${fallback || String(error)}`;
26
+ if (!rememberStringKey(dedupeKey))
27
+ return;
28
+ if (error !== undefined && error !== null) {
29
+ console.error(prefix, error);
30
+ }
31
+ else if (fallback) {
32
+ console.error(prefix, fallback);
33
+ }
34
+ else {
35
+ console.error(prefix);
36
+ }
37
+ }
@@ -62,6 +62,8 @@ export declare const CHAT_MESSAGES: {
62
62
  readonly 'chat.generation.codeTitle': "Code";
63
63
  /** The status line of the code card once the assistant has finished writing the code (while it writes, the line is `chat.generation.writingCode`). */
64
64
  readonly 'chat.generation.codeWritten': "Code written";
65
+ /** The status line of the code card when it shows what a later round changed (the first line of the card's footer under "Changes"). */
66
+ readonly 'chat.generation.codeUpdated': "Code updated";
65
67
  /** The size of the code in the code card: its lines as they are laid out. */
66
68
  readonly 'chat.generation.codeLineCount': "{count, plural, one {# line} other {# lines}}";
67
69
  readonly 'chat.generation.expandCode': "Show code";
@@ -89,6 +91,12 @@ export declare const CHAT_MESSAGES: {
89
91
  readonly 'chat.plan.showFewerTasks': "Show fewer tasks";
90
92
  /** Accessible name for the plan region while codegen runs. */
91
93
  readonly 'chat.plan.regionLabel': "Widget build plan";
94
+ /** The word on the closed plan card while the plan is still being written (shown in a shimmer). */
95
+ readonly 'chat.plan.planning': "Planning";
96
+ /** Said before each task of the plan by a screen reader (the marks are only drawn), for the state the task is in. */
97
+ readonly 'chat.plan.taskPending': "To do";
98
+ readonly 'chat.plan.taskActive': "In progress";
99
+ readonly 'chat.plan.taskDone': "Done";
92
100
  readonly 'chat.messages.attachmentMissingTitle': "Attachment not available";
93
101
  readonly 'chat.messages.attachmentMissingLabel': "Missing file attachment";
94
102
  readonly 'chat.messages.attachmentMissingCaption': "Attachment not saved. Re-attach with Upload, then send it again.";
@@ -135,6 +143,11 @@ export declare const CHAT_MESSAGES: {
135
143
  readonly 'chat.suggestions.panel.gallery': "A before and after gallery";
136
144
  readonly 'chat.suggestions.panel.changeEndDate': "Change the end date";
137
145
  readonly 'chat.suggestions.panel.biggerButton': "Make the button bigger";
146
+ /**
147
+ * The follow-up card under the last reply (ideas for what to improve next, as small pills). The cross of a pill takes it out of
148
+ * the card: `{title}` is the few words the pill shows ("Add a sale banner"). The heading of the card is `chat.suggestions.title.tryNext`.
149
+ */
150
+ readonly 'chat.followUp.remove': "Remove \"{title}\"";
138
151
  readonly 'chat.suggestions.frame.generateCode': "Generate code from this design";
139
152
  readonly 'chat.suggestions.frame.improveLayout': "Improve this layout";
140
153
  readonly 'chat.suggestions.frame.addInteractivity': "Add interactive functionality";
@@ -168,8 +181,54 @@ export declare const CHAT_MESSAGES: {
168
181
  readonly 'chat.input.send': "Send message";
169
182
  readonly 'chat.input.tooLong': "Message is too long";
170
183
  readonly 'chat.input.publishNudge': "First generate your widget, then you can publish it.";
184
+ /** The name of the send control while an agent works and a message is typed: the message waits its turn. */
185
+ readonly 'chat.input.queue': "Add to queue";
186
+ /** The header of the card above the composer; the count is how many messages wait. */
187
+ readonly 'chat.queue.title': "{count, plural, one {# Queued} other {# Queued}}";
188
+ /** At the end of the header after the person pressed Stop: the queue holds still until one message is sent now. */
189
+ readonly 'chat.queue.paused': "Paused";
190
+ /** The button of a waiting message that stops the agent and sends that message at once. */
191
+ readonly 'chat.queue.sendNow': "Send now";
192
+ readonly 'chat.queue.edit': "Edit queued message";
193
+ readonly 'chat.queue.delete': "Delete queued message";
194
+ /** Said on the row of the message that is open in the composer, and as the name of the pill above the composer's text. */
195
+ readonly 'chat.queue.editing': "Editing";
196
+ /** The name of the mark that closes the pill: the changes are dropped and the message stays as it was. */
197
+ readonly 'chat.queue.stopEditing': "Discard changes";
198
+ /** The name of the check that takes the place of Send while a message is edited. */
199
+ readonly 'chat.queue.confirmEdit': "Save changes";
200
+ /** How many files go with a waiting message. */
201
+ readonly 'chat.queue.attachments': "{count, plural, one {# file} other {# files}}";
202
+ /** The banner when the person goes to another conversation: what waited is not sent into it. */
203
+ readonly 'chat.queue.discarded': "{count, plural, one {A queued message was not sent because the conversation changed.} other {# queued messages were not sent because the conversation changed.}}";
204
+ /** The banner when the agent did not stop for "Send now": the message is still in the queue. */
205
+ readonly 'chat.queue.sendNowTimeout': "The agent did not stop in time, so the message stays in the queue.";
206
+ readonly 'chat.input.completionHint': "Tab to accept";
207
+ readonly 'chat.input.completionHintTouch': "Tap the suggestion to accept";
208
+ readonly 'chat.input.referenceHint': "Type # to reference an attached file";
209
+ readonly 'chat.input.referenceMenuLabel': "Attached files";
210
+ readonly 'chat.input.referenceRemove': "Remove {name}";
171
211
  readonly 'chat.messages.scrollToBottom': "Scroll to latest messages";
172
212
  readonly 'chat.messages.clarificationPrompt': "Which option fits best?";
213
+ /**
214
+ * The question card (the assistant asking for clarity): the small title over the question (`title`, or `titleMany` when it
215
+ * asks several), the step between the arrows of its pager (`{current}` of `{total}`; the pager only shows for several
216
+ * questions), the names of the two arrows, and its buttons. Skip puts the card away and leaves the question as a plain message.
217
+ * On the card the assistant puts before it builds, Skip and Next leave questions to the assistant: `multipleHint` is said under a
218
+ * question that takes several picks, `noOptionsHint` in place of the options of a question that has none, and `skipped` in the
219
+ * summary of a card for every question that has no pick.
220
+ */
221
+ readonly 'chat.question.title': "Question";
222
+ readonly 'chat.question.titleMany': "Questions";
223
+ readonly 'chat.question.step': "{current} of {total}";
224
+ readonly 'chat.question.back': "Previous question";
225
+ readonly 'chat.question.forward': "Next question";
226
+ readonly 'chat.question.next': "Next";
227
+ readonly 'chat.question.submit': "Submit";
228
+ readonly 'chat.question.skip': "Skip";
229
+ readonly 'chat.question.multipleHint': "Select all that apply";
230
+ readonly 'chat.question.noOptionsHint': "Write your answer in the message box, or skip this question.";
231
+ readonly 'chat.question.skipped': "Skipped";
173
232
  readonly 'chat.checkpoint.version': "Version {n}";
174
233
  readonly 'chat.checkpoint.redo': "Redo";
175
234
  readonly 'chat.checkpoint.restored': "Restored to version {n}";
@@ -191,6 +250,16 @@ export declare const CHAT_MESSAGES: {
191
250
  readonly 'chat.actions.selectorLabel': "Toggle widget element selector";
192
251
  readonly 'chat.selector.removeElement': "Remove selected element";
193
252
  readonly 'chat.selector.clearAll': "Clear all";
253
+ /** The name of the menu that opens over the message box when the person types @. */
254
+ readonly 'chat.mentions.menuLabel': "Mention something in your message";
255
+ /** Said on the rows of the menu that wait for room: one message holds only so many picks. */
256
+ readonly 'chat.mentions.limitReached': "A message can mention up to {count, plural, one {# thing} other {# things}}";
257
+ /** The name of the group of chips that shows what the message mentions. */
258
+ readonly 'chat.mentions.chipsLabel': "Mentioned in this message";
259
+ /** The name of the cross on a chip, for screen readers and its tooltip. */
260
+ readonly 'chat.mentions.remove': "Remove {name} from this message";
261
+ /** A button beside the chips, offered when the message holds a link that one of the lists is made for: a tap picks that row. */
262
+ readonly 'chat.mentions.linkHint': "Read this link with {name}";
194
263
  readonly 'chat.actions.complete': "Complete";
195
264
  readonly 'chat.actions.completed': "Completed";
196
265
  readonly 'chat.actions.markCompleteTitle': "Mark this chat as done. You can still send messages and iterate on the widget.";
@@ -213,6 +282,8 @@ export declare const CHAT_MESSAGES: {
213
282
  readonly 'chat.attachment.viewFile': "Click to view file";
214
283
  readonly 'chat.attachment.more': "{count, plural, one {+# more file} other {+# more files}}";
215
284
  readonly 'chat.attachment.remove': "Remove attachment";
285
+ /** What a screen reader says for a file chip while its file goes up: `{percent}` is the share sent, from 1 to 99. */
286
+ readonly 'chat.attachment.uploadProgress': "Uploading, {percent}%";
216
287
  readonly 'chat.attachment.close': "Close";
217
288
  /** The size of a file, from bytes to gigabytes: `{size}` is the number, written the way the language writes numbers ("1.5", "1,5"). */
218
289
  readonly 'chat.size.bytes': "{size} B";
@@ -222,6 +293,40 @@ export declare const CHAT_MESSAGES: {
222
293
  readonly 'chat.code.copy': "Copy";
223
294
  readonly 'chat.code.copyTitle': "Copy code";
224
295
  readonly 'chat.code.copied': "Copied!";
296
+ /** The tooltip and the name of the button that copies what the round changed (as one diff) while the code card shows "Changes". */
297
+ readonly 'chat.code.copyChangesTitle': "Copy changes";
298
+ /** The name of the two views of the code card, for a screen reader: the changes of the round, or all the code. */
299
+ readonly 'chat.code.viewLabel': "View";
300
+ /** The view of the code card that shows what the round changed, lines taken out in red and lines put in in green. */
301
+ readonly 'chat.code.changesTab': "Changes";
302
+ /** The view of the code card that shows all the code the assistant wrote. */
303
+ readonly 'chat.code.codeTab': "Code";
304
+ /** The name of the panel that shows the changes, for a screen reader. */
305
+ readonly 'chat.code.changesTitle': "Changes to the code";
306
+ /** The badge of a file the round made new, next to its path (a file that was only edited has no badge). */
307
+ readonly 'chat.code.fileAdded': "New";
308
+ /** The badge of a file the round deleted. */
309
+ readonly 'chat.code.fileDeleted': "Deleted";
310
+ /** The badge of a file the round renamed. */
311
+ readonly 'chat.code.fileRenamed': "Renamed";
312
+ /** What a screen reader says of a file's header: the lines the round put in it (the header shows them as "+12"). */
313
+ readonly 'chat.code.linesAdded': "{count, plural, one {# line added} other {# lines added}}";
314
+ /** What a screen reader says of a file's header: the lines the round took out of it (the header shows them as "−3"). */
315
+ readonly 'chat.code.linesRemoved': "{count, plural, one {# line removed} other {# lines removed}}";
316
+ /** The second line of the card's footer under "Changes": how many files the round changed. */
317
+ readonly 'chat.code.filesChanged': "{count, plural, one {# file changed} other {# files changed}}";
318
+ /** What a screen reader says before a line the round put in (the row shows it on green, with a "+"). */
319
+ readonly 'chat.code.lineAdded': "Added";
320
+ /** What a screen reader says before a line the round took out (the row shows it on red, with a "−"). */
321
+ readonly 'chat.code.lineRemoved': "Removed";
322
+ /** The row that stands for the lines between two changes that did not change (they are not shown). */
323
+ readonly 'chat.code.unchangedLines': "{count, plural, one {# unchanged line} other {# unchanged lines}}";
324
+ /** Under a file whose changes were too large to be sent: only its header is shown. */
325
+ readonly 'chat.code.changeTooLarge': "This change is too large to show here.";
326
+ /** Under a file whose changes were cut for their size: what is shown is the start of them. */
327
+ readonly 'chat.code.changeTruncated': "The rest of this change is not shown.";
328
+ /** After the files, when the round changed more files than were sent. */
329
+ readonly 'chat.code.moreFiles': "{count, plural, one {# more file changed} other {# more files changed}}";
225
330
  readonly 'chat.status.active': "Active";
226
331
  readonly 'chat.status.completed': "Completed";
227
332
  readonly 'chat.status.processing': "Processing...";
@@ -250,7 +355,7 @@ export declare const CHAT_MESSAGES: {
250
355
  readonly 'chat.sketch.addedShapes': "Added wireframe shapes on the canvas.";
251
356
  readonly 'chat.sketch.followUp': "Ask me to move, label, or delete anything on the board.";
252
357
  readonly 'chat.sketch.genericDone': "Updated the sketch on the canvas.";
253
- readonly 'chat.sketch.failed': "Could not update the sketch: {detail}";
358
+ readonly 'chat.sketch.failed': "Could not update the sketch. Please try again.";
254
359
  readonly 'chat.sketch.failedUnknown': "Could not update the sketch.";
255
360
  readonly 'chat.sketch.stepCap': "Sketch assistant stopped after too many steps.";
256
361
  readonly 'chat.sketch.noCredits': "You are out of credits, so I cannot draw right now. Add credits and ask me again.";
@@ -66,6 +66,8 @@ export const CHAT_MESSAGES = {
66
66
  'chat.generation.codeTitle': 'Code',
67
67
  /** The status line of the code card once the assistant has finished writing the code (while it writes, the line is `chat.generation.writingCode`). */
68
68
  'chat.generation.codeWritten': 'Code written',
69
+ /** The status line of the code card when it shows what a later round changed (the first line of the card's footer under "Changes"). */
70
+ 'chat.generation.codeUpdated': 'Code updated',
69
71
  /** The size of the code in the code card: its lines as they are laid out. */
70
72
  'chat.generation.codeLineCount': '{count, plural, one {# line} other {# lines}}',
71
73
  'chat.generation.expandCode': 'Show code',
@@ -93,6 +95,12 @@ export const CHAT_MESSAGES = {
93
95
  'chat.plan.showFewerTasks': 'Show fewer tasks',
94
96
  /** Accessible name for the plan region while codegen runs. */
95
97
  'chat.plan.regionLabel': 'Widget build plan',
98
+ /** The word on the closed plan card while the plan is still being written (shown in a shimmer). */
99
+ 'chat.plan.planning': 'Planning',
100
+ /** Said before each task of the plan by a screen reader (the marks are only drawn), for the state the task is in. */
101
+ 'chat.plan.taskPending': 'To do',
102
+ 'chat.plan.taskActive': 'In progress',
103
+ 'chat.plan.taskDone': 'Done',
96
104
  'chat.messages.attachmentMissingTitle': 'Attachment not available',
97
105
  'chat.messages.attachmentMissingLabel': 'Missing file attachment',
98
106
  'chat.messages.attachmentMissingCaption': 'Attachment not saved. Re-attach with Upload, then send it again.',
@@ -140,6 +148,11 @@ export const CHAT_MESSAGES = {
140
148
  'chat.suggestions.panel.gallery': 'A before and after gallery',
141
149
  'chat.suggestions.panel.changeEndDate': 'Change the end date',
142
150
  'chat.suggestions.panel.biggerButton': 'Make the button bigger',
151
+ /**
152
+ * The follow-up card under the last reply (ideas for what to improve next, as small pills). The cross of a pill takes it out of
153
+ * the card: `{title}` is the few words the pill shows ("Add a sale banner"). The heading of the card is `chat.suggestions.title.tryNext`.
154
+ */
155
+ 'chat.followUp.remove': 'Remove "{title}"',
143
156
  'chat.suggestions.frame.generateCode': 'Generate code from this design',
144
157
  'chat.suggestions.frame.improveLayout': 'Improve this layout',
145
158
  'chat.suggestions.frame.addInteractivity': 'Add interactive functionality',
@@ -174,8 +187,58 @@ export const CHAT_MESSAGES = {
174
187
  'chat.input.send': 'Send message',
175
188
  'chat.input.tooLong': 'Message is too long',
176
189
  'chat.input.publishNudge': 'First generate your widget, then you can publish it.',
190
+ /** The name of the send control while an agent works and a message is typed: the message waits its turn. */
191
+ 'chat.input.queue': 'Add to queue',
192
+ // ===== The messages that wait for the agent =====
193
+ /** The header of the card above the composer; the count is how many messages wait. */
194
+ 'chat.queue.title': '{count, plural, one {# Queued} other {# Queued}}',
195
+ /** At the end of the header after the person pressed Stop: the queue holds still until one message is sent now. */
196
+ 'chat.queue.paused': 'Paused',
197
+ /** The button of a waiting message that stops the agent and sends that message at once. */
198
+ 'chat.queue.sendNow': 'Send now',
199
+ 'chat.queue.edit': 'Edit queued message',
200
+ 'chat.queue.delete': 'Delete queued message',
201
+ /** Said on the row of the message that is open in the composer, and as the name of the pill above the composer's text. */
202
+ 'chat.queue.editing': 'Editing',
203
+ /** The name of the mark that closes the pill: the changes are dropped and the message stays as it was. */
204
+ 'chat.queue.stopEditing': 'Discard changes',
205
+ /** The name of the check that takes the place of Send while a message is edited. */
206
+ 'chat.queue.confirmEdit': 'Save changes',
207
+ /** How many files go with a waiting message. */
208
+ 'chat.queue.attachments': '{count, plural, one {# file} other {# files}}',
209
+ /** The banner when the person goes to another conversation: what waited is not sent into it. */
210
+ 'chat.queue.discarded': '{count, plural, one {A queued message was not sent because the conversation changed.} other {# queued messages were not sent because the conversation changed.}}',
211
+ /** The banner when the agent did not stop for "Send now": the message is still in the queue. */
212
+ 'chat.queue.sendNowTimeout': 'The agent did not stop in time, so the message stays in the queue.',
213
+ // What to do with the grey suggestion after the caret: shown in the toolbar while one shows, and said to a screen reader with it
214
+ 'chat.input.completionHint': 'Tab to accept',
215
+ 'chat.input.completionHintTouch': 'Tap the suggestion to accept',
216
+ // Referring to an attached file with # in the message: the line under the box while a file is attached, the name a screen reader
217
+ // gives the list of files that # opens, and the name of the X of a badge in the text ({name} is the file's own name)
218
+ 'chat.input.referenceHint': 'Type # to reference an attached file',
219
+ 'chat.input.referenceMenuLabel': 'Attached files',
220
+ 'chat.input.referenceRemove': 'Remove {name}',
177
221
  'chat.messages.scrollToBottom': 'Scroll to latest messages',
178
222
  'chat.messages.clarificationPrompt': 'Which option fits best?',
223
+ /**
224
+ * The question card (the assistant asking for clarity): the small title over the question (`title`, or `titleMany` when it
225
+ * asks several), the step between the arrows of its pager (`{current}` of `{total}`; the pager only shows for several
226
+ * questions), the names of the two arrows, and its buttons. Skip puts the card away and leaves the question as a plain message.
227
+ * On the card the assistant puts before it builds, Skip and Next leave questions to the assistant: `multipleHint` is said under a
228
+ * question that takes several picks, `noOptionsHint` in place of the options of a question that has none, and `skipped` in the
229
+ * summary of a card for every question that has no pick.
230
+ */
231
+ 'chat.question.title': 'Question',
232
+ 'chat.question.titleMany': 'Questions',
233
+ 'chat.question.step': '{current} of {total}',
234
+ 'chat.question.back': 'Previous question',
235
+ 'chat.question.forward': 'Next question',
236
+ 'chat.question.next': 'Next',
237
+ 'chat.question.submit': 'Submit',
238
+ 'chat.question.skip': 'Skip',
239
+ 'chat.question.multipleHint': 'Select all that apply',
240
+ 'chat.question.noOptionsHint': 'Write your answer in the message box, or skip this question.',
241
+ 'chat.question.skipped': 'Skipped',
179
242
  'chat.checkpoint.version': 'Version {n}',
180
243
  'chat.checkpoint.redo': 'Redo',
181
244
  'chat.checkpoint.restored': 'Restored to version {n}',
@@ -198,6 +261,17 @@ export const CHAT_MESSAGES = {
198
261
  'chat.actions.selectorLabel': 'Toggle widget element selector',
199
262
  'chat.selector.removeElement': 'Remove selected element',
200
263
  'chat.selector.clearAll': 'Clear all',
264
+ // ===== Mentions with @ (the page gives the lists of what can be picked; the chat shows the menu and the chips) =====
265
+ /** The name of the menu that opens over the message box when the person types @. */
266
+ 'chat.mentions.menuLabel': 'Mention something in your message',
267
+ /** Said on the rows of the menu that wait for room: one message holds only so many picks. */
268
+ 'chat.mentions.limitReached': 'A message can mention up to {count, plural, one {# thing} other {# things}}',
269
+ /** The name of the group of chips that shows what the message mentions. */
270
+ 'chat.mentions.chipsLabel': 'Mentioned in this message',
271
+ /** The name of the cross on a chip, for screen readers and its tooltip. */
272
+ 'chat.mentions.remove': 'Remove {name} from this message',
273
+ /** A button beside the chips, offered when the message holds a link that one of the lists is made for: a tap picks that row. */
274
+ 'chat.mentions.linkHint': 'Read this link with {name}',
201
275
  'chat.actions.complete': 'Complete',
202
276
  'chat.actions.completed': 'Completed',
203
277
  'chat.actions.markCompleteTitle': 'Mark this chat as done. You can still send messages and iterate on the widget.',
@@ -221,6 +295,8 @@ export const CHAT_MESSAGES = {
221
295
  'chat.attachment.viewFile': 'Click to view file',
222
296
  'chat.attachment.more': '{count, plural, one {+# more file} other {+# more files}}',
223
297
  'chat.attachment.remove': 'Remove attachment',
298
+ /** What a screen reader says for a file chip while its file goes up: `{percent}` is the share sent, from 1 to 99. */
299
+ 'chat.attachment.uploadProgress': 'Uploading, {percent}%',
224
300
  'chat.attachment.close': 'Close',
225
301
  /** The size of a file, from bytes to gigabytes: `{size}` is the number, written the way the language writes numbers ("1.5", "1,5"). */
226
302
  'chat.size.bytes': '{size} B',
@@ -231,6 +307,41 @@ export const CHAT_MESSAGES = {
231
307
  'chat.code.copy': 'Copy',
232
308
  'chat.code.copyTitle': 'Copy code',
233
309
  'chat.code.copied': 'Copied!',
310
+ /** The tooltip and the name of the button that copies what the round changed (as one diff) while the code card shows "Changes". */
311
+ 'chat.code.copyChangesTitle': 'Copy changes',
312
+ // ===== What a round changed (the code card of a later round) =====
313
+ /** The name of the two views of the code card, for a screen reader: the changes of the round, or all the code. */
314
+ 'chat.code.viewLabel': 'View',
315
+ /** The view of the code card that shows what the round changed, lines taken out in red and lines put in in green. */
316
+ 'chat.code.changesTab': 'Changes',
317
+ /** The view of the code card that shows all the code the assistant wrote. */
318
+ 'chat.code.codeTab': 'Code',
319
+ /** The name of the panel that shows the changes, for a screen reader. */
320
+ 'chat.code.changesTitle': 'Changes to the code',
321
+ /** The badge of a file the round made new, next to its path (a file that was only edited has no badge). */
322
+ 'chat.code.fileAdded': 'New',
323
+ /** The badge of a file the round deleted. */
324
+ 'chat.code.fileDeleted': 'Deleted',
325
+ /** The badge of a file the round renamed. */
326
+ 'chat.code.fileRenamed': 'Renamed',
327
+ /** What a screen reader says of a file's header: the lines the round put in it (the header shows them as "+12"). */
328
+ 'chat.code.linesAdded': '{count, plural, one {# line added} other {# lines added}}',
329
+ /** What a screen reader says of a file's header: the lines the round took out of it (the header shows them as "−3"). */
330
+ 'chat.code.linesRemoved': '{count, plural, one {# line removed} other {# lines removed}}',
331
+ /** The second line of the card's footer under "Changes": how many files the round changed. */
332
+ 'chat.code.filesChanged': '{count, plural, one {# file changed} other {# files changed}}',
333
+ /** What a screen reader says before a line the round put in (the row shows it on green, with a "+"). */
334
+ 'chat.code.lineAdded': 'Added',
335
+ /** What a screen reader says before a line the round took out (the row shows it on red, with a "−"). */
336
+ 'chat.code.lineRemoved': 'Removed',
337
+ /** The row that stands for the lines between two changes that did not change (they are not shown). */
338
+ 'chat.code.unchangedLines': '{count, plural, one {# unchanged line} other {# unchanged lines}}',
339
+ /** Under a file whose changes were too large to be sent: only its header is shown. */
340
+ 'chat.code.changeTooLarge': 'This change is too large to show here.',
341
+ /** Under a file whose changes were cut for their size: what is shown is the start of them. */
342
+ 'chat.code.changeTruncated': 'The rest of this change is not shown.',
343
+ /** After the files, when the round changed more files than were sent. */
344
+ 'chat.code.moreFiles': '{count, plural, one {# more file changed} other {# more files changed}}',
234
345
  // ===== The state of a conversation =====
235
346
  'chat.status.active': 'Active',
236
347
  'chat.status.completed': 'Completed',
@@ -262,7 +373,7 @@ export const CHAT_MESSAGES = {
262
373
  'chat.sketch.addedShapes': 'Added wireframe shapes on the canvas.',
263
374
  'chat.sketch.followUp': 'Ask me to move, label, or delete anything on the board.',
264
375
  'chat.sketch.genericDone': 'Updated the sketch on the canvas.',
265
- 'chat.sketch.failed': 'Could not update the sketch: {detail}',
376
+ 'chat.sketch.failed': 'Could not update the sketch. Please try again.',
266
377
  'chat.sketch.failedUnknown': 'Could not update the sketch.',
267
378
  'chat.sketch.stepCap': 'Sketch assistant stopped after too many steps.',
268
379
  'chat.sketch.noCredits': 'You are out of credits, so I cannot draw right now. Add credits and ask me again.',
@@ -6,7 +6,7 @@ export const CHAT_SKETCH_LOCALE_MESSAGES = {
6
6
  'chat.sketch.deletedAll': 'Alle Skizzen von der Leinwand entfernt.',
7
7
  'chat.sketch.namedComponents': 'Jede Komponente beschriftet und mit einem Pfeil versehen.',
8
8
  'chat.sketch.followUp': 'Bitte mich, etwas zu verschieben, zu beschriften oder zu löschen.',
9
- 'chat.sketch.failed': 'Skizze konnte nicht aktualisiert werden: {detail}',
9
+ 'chat.sketch.failed': 'Skizze konnte nicht aktualisiert werden. Bitte versuchen Sie es erneut.',
10
10
  'chat.sketch.failedUnknown': 'Skizze konnte nicht aktualisiert werden.',
11
11
  'chat.sketch.undoLabel': 'Zeichnung rückgängig'
12
12
  },
@@ -16,7 +16,7 @@ export const CHAT_SKETCH_LOCALE_MESSAGES = {
16
16
  'chat.sketch.deletedAll': 'Toutes les esquisses ont été supprimées du canevas.',
17
17
  'chat.sketch.namedComponents': 'Chaque composant est étiqueté avec une flèche.',
18
18
  'chat.sketch.followUp': 'Demandez-moi de déplacer, étiqueter ou supprimer un élément.',
19
- 'chat.sketch.failed': "Impossible de mettre à jour l'esquisse : {detail}",
19
+ 'chat.sketch.failed': "Impossible de mettre à jour l'esquisse. Veuillez réessayer.",
20
20
  'chat.sketch.failedUnknown': "Impossible de mettre à jour l'esquisse.",
21
21
  'chat.sketch.undoLabel': 'Annuler le dessin'
22
22
  },
@@ -26,7 +26,7 @@ export const CHAT_SKETCH_LOCALE_MESSAGES = {
26
26
  'chat.sketch.deletedAll': 'Se eliminaron todos los bocetos del lienzo.',
27
27
  'chat.sketch.namedComponents': 'Cada componente tiene una etiqueta y una flecha.',
28
28
  'chat.sketch.followUp': 'Pídeme mover, etiquetar o borrar algo del lienzo.',
29
- 'chat.sketch.failed': 'No se pudo actualizar el boceto: {detail}',
29
+ 'chat.sketch.failed': 'No se pudo actualizar el boceto. Inténtelo de nuevo.',
30
30
  'chat.sketch.failedUnknown': 'No se pudo actualizar el boceto.',
31
31
  'chat.sketch.undoLabel': 'Deshacer dibujo'
32
32
  },
@@ -36,7 +36,7 @@ export const CHAT_SKETCH_LOCALE_MESSAGES = {
36
36
  'chat.sketch.deletedAll': 'Rimossi tutti gli schizzi dalla tela.',
37
37
  'chat.sketch.namedComponents': 'Ogni componente ha un’etichetta e una freccia.',
38
38
  'chat.sketch.followUp': 'Chiedimi di spostare, etichettare o cancellare qualcosa.',
39
- 'chat.sketch.failed': 'Impossibile aggiornare lo schizzo: {detail}',
39
+ 'chat.sketch.failed': 'Impossibile aggiornare lo schizzo. Riprova.',
40
40
  'chat.sketch.failedUnknown': 'Impossibile aggiornare lo schizzo.',
41
41
  'chat.sketch.undoLabel': 'Annulla disegno'
42
42
  },
@@ -46,7 +46,7 @@ export const CHAT_SKETCH_LOCALE_MESSAGES = {
46
46
  'chat.sketch.deletedAll': 'Todos os rascunhos foram removidos da tela.',
47
47
  'chat.sketch.namedComponents': 'Cada componente foi etiquetado com uma seta.',
48
48
  'chat.sketch.followUp': 'Peça para mover, etiquetar ou apagar algo no quadro.',
49
- 'chat.sketch.failed': 'Não foi possível atualizar o rascunho: {detail}',
49
+ 'chat.sketch.failed': 'Não foi possível atualizar o rascunho. Tente novamente.',
50
50
  'chat.sketch.failedUnknown': 'Não foi possível atualizar o rascunho.',
51
51
  'chat.sketch.undoLabel': 'Desfazer desenho'
52
52
  },
@@ -56,7 +56,7 @@ export const CHAT_SKETCH_LOCALE_MESSAGES = {
56
56
  'chat.sketch.deletedAll': 'Usunięto wszystkie szkice z kanwy.',
57
57
  'chat.sketch.namedComponents': 'Każdy element ma etykietę i strzałkę.',
58
58
  'chat.sketch.followUp': 'Poproś o przesunięcie, opisanie lub usunięcie czegoś.',
59
- 'chat.sketch.failed': 'Nie udało się zaktualizować szkicu: {detail}',
59
+ 'chat.sketch.failed': 'Nie udało się zaktualizować szkicu. Spróbuj ponownie.',
60
60
  'chat.sketch.failedUnknown': 'Nie udało się zaktualizować szkicu.',
61
61
  'chat.sketch.undoLabel': 'Cofnij rysunek'
62
62
  },
@@ -66,7 +66,7 @@ export const CHAT_SKETCH_LOCALE_MESSAGES = {
66
66
  'chat.sketch.deletedAll': 'Alle schetsen van het canvas verwijderd.',
67
67
  'chat.sketch.namedComponents': 'Elk onderdeel heeft een label en pijl.',
68
68
  'chat.sketch.followUp': 'Vraag me om iets te verplaatsen, te labelen of te verwijderen.',
69
- 'chat.sketch.failed': 'Kon de schets niet bijwerken: {detail}',
69
+ 'chat.sketch.failed': 'Kon de schets niet bijwerken. Probeer het opnieuw.',
70
70
  'chat.sketch.failedUnknown': 'Kon de schets niet bijwerken.',
71
71
  'chat.sketch.undoLabel': 'Tekening ongedaan maken'
72
72
  },
@@ -76,7 +76,7 @@ export const CHAT_SKETCH_LOCALE_MESSAGES = {
76
76
  'chat.sketch.deletedAll': 'キャンバス上のスケッチをすべて削除しました。',
77
77
  'chat.sketch.namedComponents': '各コンポーネントにラベルと矢印を追加しました。',
78
78
  'chat.sketch.followUp': '移動・ラベル付け・削除を依頼できます。',
79
- 'chat.sketch.failed': 'スケッチを更新できませんでした: {detail}',
79
+ 'chat.sketch.failed': 'スケッチを更新できませんでした。もう一度お試しください。',
80
80
  'chat.sketch.failedUnknown': 'スケッチを更新できませんでした。',
81
81
  'chat.sketch.undoLabel': '描画を元に戻す'
82
82
  }
@@ -0,0 +1,83 @@
1
+ import type { AttachmentInput } from './types/attachment.js';
2
+ import type { ClarificationSuggestion } from './types/message.js';
3
+ /**
4
+ * The queue of the messages that wait for the agent.
5
+ *
6
+ * While an agent works, what the person sends does not interrupt it: the message waits here, the oldest first, and is sent as
7
+ * soon as the agent is done (or at once, when the person presses "Send now", which stops the agent first). This file is the part
8
+ * that needs no screen: the shape of a waiting message, the operations on the list (none of them changes the list it is given)
9
+ * and the one decision the chat makes again and again, "what happens next to the queue". `Chat.svelte` holds the state and does
10
+ * what this file decides.
11
+ */
12
+ /**
13
+ * How long the agent must have been idle before the next waiting message is sent. A host that runs an agent in phases (plan,
14
+ * then build) can be idle for a moment between two of them, and a message must not be sent into that gap.
15
+ */
16
+ export declare const QUEUE_SETTLE_MS = 600;
17
+ /**
18
+ * How long "Send now" waits for the agent to stop. Past it the message stays in the queue and the person is told, so a host
19
+ * whose Stop does not work never makes a message disappear.
20
+ */
21
+ export declare const QUEUE_SEND_NOW_TIMEOUT_MS = 15000;
22
+ /** A message that waits for the agent: what the person wrote, with the files that go with it. */
23
+ export interface QueuedMessage {
24
+ id: string;
25
+ /** What was written, trimmed. A message with no text is never queued. */
26
+ text: string;
27
+ /**
28
+ * The files of the message, as they were in the composer: the entries keep their uploads and their `blob:` previews, so the
29
+ * message is sent exactly as pressing Send would have sent it.
30
+ */
31
+ attachments: AttachmentInput[];
32
+ /** The clarification chip that was in the draft when the message was queued; it goes with the message, not with the draft. */
33
+ chipIntent?: ClarificationSuggestion['intent'];
34
+ skipIntentGate?: boolean;
35
+ }
36
+ /** What the composer held before a queued message was opened in it. It comes back when the edit ends. */
37
+ export interface StashedDraft {
38
+ text: string;
39
+ attachments: AttachmentInput[];
40
+ chipIntent: ClarificationSuggestion['intent'] | null;
41
+ skipIntentGate: boolean;
42
+ }
43
+ /** A new id for a waiting message: unique within the page, and never the same twice in one millisecond. */
44
+ export declare function createQueuedMessageId(): string;
45
+ /** The queue with the message at the bottom: the newest waits last. */
46
+ export declare function appendQueuedMessage(queue: readonly QueuedMessage[], message: QueuedMessage): QueuedMessage[];
47
+ export declare function findQueuedMessage(queue: readonly QueuedMessage[], id: string | null | undefined): QueuedMessage | undefined;
48
+ export declare function removeQueuedMessage(queue: readonly QueuedMessage[], id: string): QueuedMessage[];
49
+ /** The queue with one message changed in its place (its row keeps its turn). Another id changes nothing. */
50
+ export declare function updateQueuedMessage(queue: readonly QueuedMessage[], id: string, changes: Partial<Omit<QueuedMessage, 'id'>>): QueuedMessage[];
51
+ /** What the chat knows when it asks "what happens next to the queue". */
52
+ export interface QueueStepInput {
53
+ /** How many messages wait. */
54
+ queueLength: number;
55
+ /** The agent is working: the host runs a generation, a message is loading or one is being sent. */
56
+ agentBusy: boolean;
57
+ /** The person pressed Stop while messages waited: nothing is sent by itself until one is sent now. */
58
+ paused: boolean;
59
+ /** A waiting message is open in the composer: the queue holds still, so the message being edited is never sent from under the person. */
60
+ editing: boolean;
61
+ /** "Send now" was pressed and the agent has not stopped yet. */
62
+ sendNowPending: boolean;
63
+ }
64
+ /**
65
+ * - `nothing`: no message waits.
66
+ * - `wait`: messages wait, and it is not their turn (the agent works, the queue is paused, or one is being edited).
67
+ * - `sendNow`: the agent has stopped and the person asked for one message now: send that one, at once.
68
+ * - `drain`: the agent is idle and nothing holds the queue: send the oldest message (after `QUEUE_SETTLE_MS` of idleness).
69
+ */
70
+ export type QueueStep = 'nothing' | 'wait' | 'sendNow' | 'drain';
71
+ export declare function decideQueueStep(input: QueueStepInput): QueueStep;
72
+ /** The `blob:` addresses of the pictures of some attachments, each once: the ones the page made and has to give back. */
73
+ export declare function blobPreviewsOf(attachments: readonly Pick<AttachmentInput, 'preview'>[]): string[];
74
+ /**
75
+ * The pictures of a message that the person took out of it while editing it: when the edit is saved they are no longer
76
+ * attached to anything, so the page gives them back. (Until then they are kept: closing the edit brings the message back whole.)
77
+ */
78
+ export declare function previewsDroppedByEdit(original: readonly Pick<AttachmentInput, 'preview'>[], edited: readonly Pick<AttachmentInput, 'preview'>[]): string[];
79
+ /**
80
+ * The pictures the person added while editing a message: when the edit is closed without saving they belong to nothing, so the
81
+ * page gives them back.
82
+ */
83
+ export declare function previewsAddedByEdit(original: readonly Pick<AttachmentInput, 'preview'>[], edited: readonly Pick<AttachmentInput, 'preview'>[]): string[];