@widgetic/chat 0.1.45 → 0.1.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +148 -20
- package/dist/components/AttachmentDisplay.svelte +22 -130
- package/dist/components/AttachmentPreviewDialog.svelte +428 -0
- package/dist/components/AttachmentPreviewDialog.svelte.d.ts +14 -0
- package/dist/components/Chat.svelte +509 -94
- package/dist/components/Chat.svelte.d.ts +15 -2
- package/dist/components/ChatComposer.svelte +63 -69
- package/dist/components/ChatComposer.svelte.d.ts +8 -3
- package/dist/components/ChatDropOverlay.svelte +58 -0
- package/dist/components/ChatDropOverlay.svelte.d.ts +8 -0
- package/dist/components/ChatMessages.svelte +322 -98
- package/dist/components/ChatMessages.svelte.d.ts +11 -2
- package/dist/components/ComposerAttachmentsTray.svelte +144 -56
- package/dist/components/ComposerAttachmentsTray.svelte.d.ts +11 -1
- package/dist/components/FileGlyphIcon.svelte +34 -0
- package/dist/components/FileGlyphIcon.svelte.d.ts +8 -0
- package/dist/components/RestoreCheckpointDialog.svelte +66 -0
- package/dist/components/RestoreCheckpointDialog.svelte.d.ts +11 -0
- package/dist/components/SentAttachments.svelte +118 -0
- package/dist/components/SentAttachments.svelte.d.ts +12 -0
- package/dist/components/agent/AgentTurn.svelte +17 -2
- package/dist/components/agent/CodeCard.svelte +9 -3
- package/dist/i18n/messages.d.ts +43 -3
- package/dist/i18n/messages.js +49 -5
- package/dist/services/index.d.ts +4 -2
- package/dist/services/index.js +2 -1
- package/dist/services/limitRefusal.d.ts +42 -0
- package/dist/services/limitRefusal.js +60 -0
- package/dist/services/sketchAssistantClient.d.ts +11 -3
- package/dist/services/sketchAssistantClient.js +37 -10
- package/dist/services/sketchAssistantErrors.d.ts +16 -1
- package/dist/services/sketchAssistantErrors.js +25 -4
- package/dist/services/sketchAssistantOrchestrator.d.ts +7 -1
- package/dist/services/sketchAssistantOrchestrator.js +2 -2
- package/dist/types/attachment.d.ts +11 -0
- package/dist/utils/agentTurn.d.ts +32 -1
- package/dist/utils/agentTurn.js +46 -3
- package/dist/utils/attachmentDuplicates.d.ts +48 -0
- package/dist/utils/attachmentDuplicates.js +70 -0
- package/dist/utils/attachmentPolicy.d.ts +88 -0
- package/dist/utils/attachmentPolicy.js +135 -0
- package/dist/utils/attachmentPreview.d.ts +146 -0
- package/dist/utils/attachmentPreview.js +224 -0
- package/dist/utils/attachmentTray.d.ts +35 -0
- package/dist/utils/attachmentTray.js +27 -0
- package/dist/utils/chatFileDrag.d.ts +39 -0
- package/dist/utils/chatFileDrag.js +29 -0
- package/dist/utils/composerPreview.d.ts +33 -0
- package/dist/utils/composerPreview.js +31 -0
- package/dist/utils/generationArchiveStore.d.ts +5 -1
- package/dist/utils/generationArchiveStore.js +9 -4
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/limitFailureLine.d.ts +20 -0
- package/dist/utils/limitFailureLine.js +40 -0
- package/dist/utils/panelListPadding.d.ts +20 -0
- package/dist/utils/panelListPadding.js +31 -0
- package/dist/utils/pasteInsertion.d.ts +43 -0
- package/dist/utils/pasteInsertion.js +94 -0
- package/dist/utils/pastedContent.d.ts +13 -0
- package/dist/utils/pastedContent.js +18 -1
- package/dist/utils/referenceItems.js +11 -3
- package/dist/utils/sentAttachments.d.ts +43 -0
- package/dist/utils/sentAttachments.js +38 -0
- package/dist/utils/sentReferenceBadges.d.ts +11 -1
- package/dist/utils/sentReferenceBadges.js +47 -2
- package/package.json +3 -3
|
@@ -12,9 +12,16 @@
|
|
|
12
12
|
import { chatLog, chatWarn } from '../utils/logger.js';
|
|
13
13
|
import type { CodeChanges } from '../utils/codeChanges.js';
|
|
14
14
|
import { shrinkWrapBubble } from '../utils/bubbleShrinkWrap.js';
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
fetchPastedTextExcerpt,
|
|
17
|
+
isPastedTextOfMessage,
|
|
18
|
+
sentAttachmentsOf,
|
|
19
|
+
sentBadgePictureOf,
|
|
20
|
+
sentBadgeTitleOf
|
|
21
|
+
} from '../utils/sentReferenceBadges.js';
|
|
16
22
|
// The file badge of a sent message: the words that name a file, and the pill drawn for each (the design system's kit for `#` references)
|
|
17
23
|
import {
|
|
24
|
+
FILE_GLYPH_PATHS,
|
|
18
25
|
SENT_BADGE_CLASSES,
|
|
19
26
|
SENT_BADGE_LABEL_CLASSES,
|
|
20
27
|
SENT_BADGE_THUMBNAIL_CLASSES,
|
|
@@ -51,6 +58,12 @@
|
|
|
51
58
|
import FollowUpCard from './FollowUpCard.svelte';
|
|
52
59
|
import CodeBlock from './CodeBlock.svelte';
|
|
53
60
|
import MessageActions from './MessageActions.svelte';
|
|
61
|
+
import RestoreCheckpointDialog from './RestoreCheckpointDialog.svelte';
|
|
62
|
+
import SentAttachments from './SentAttachments.svelte';
|
|
63
|
+
import AttachmentPreviewDialog from './AttachmentPreviewDialog.svelte';
|
|
64
|
+
import type { PreviewableFile } from '../utils/attachmentPreview.js';
|
|
65
|
+
import { arrangeSentAttachments, attachmentIndexesNamedByBadges, hasSentTiles } from '../utils/sentAttachments.js';
|
|
66
|
+
import { PANEL_LIST_INLINE_PADDING_PX, panelListEndPaddingPx } from '../utils/panelListPadding.js';
|
|
54
67
|
import AgentTurn from './agent/AgentTurn.svelte';
|
|
55
68
|
import GenerationModule from './agent/GenerationModule.svelte';
|
|
56
69
|
import MemberAvatar from './agent/MemberAvatar.svelte';
|
|
@@ -58,6 +71,7 @@
|
|
|
58
71
|
import type { Snippet } from 'svelte';
|
|
59
72
|
import { useChatLanguage } from '../i18n/language.js';
|
|
60
73
|
import { CHAT_MESSAGES } from '../i18n/messages.js';
|
|
74
|
+
import { isLimitFailureLine, limitFailureSentencesOf } from '../utils/limitFailureLine.js';
|
|
61
75
|
import { versionLabelText } from '../i18n/labels.js';
|
|
62
76
|
import { dirForUserText, useTextDirection } from '@widgetic/design-system/components/textDirection';
|
|
63
77
|
import IconSparkles from '@tabler/icons-svelte/icons/sparkles';
|
|
@@ -80,12 +94,14 @@
|
|
|
80
94
|
keptWorkIsOutdated,
|
|
81
95
|
liveAgentLook,
|
|
82
96
|
liveModulesView,
|
|
97
|
+
outcomeToShow,
|
|
83
98
|
pageNamesPeople,
|
|
84
99
|
resolveChatMember,
|
|
85
100
|
settledAgentLook,
|
|
86
101
|
soundStateOf,
|
|
87
102
|
turnOutcome,
|
|
88
103
|
withChangesOfTheRun,
|
|
104
|
+
withSummaryOfTheRun,
|
|
89
105
|
type AgentAvatarSize,
|
|
90
106
|
type AgentLook,
|
|
91
107
|
type FinishedGeneration,
|
|
@@ -110,6 +126,10 @@
|
|
|
110
126
|
// The words of the messages area, in the language of the chat above
|
|
111
127
|
const { t } = useChatLanguage();
|
|
112
128
|
|
|
129
|
+
// The sentences the sketch assistant says when the credits or the plan refused a request, in English (what a host saves) and in the
|
|
130
|
+
// page's language. A reply that is, as a whole, one of them is a failure that the way out of is to upgrade (see `isPlanLimitMessage`).
|
|
131
|
+
const limitFailureSentences = $derived(limitFailureSentencesOf($t));
|
|
132
|
+
|
|
113
133
|
// The way the screen is read: what a person wrote reads by its own first letter on a right to left screen.
|
|
114
134
|
const textDirection = useTextDirection();
|
|
115
135
|
|
|
@@ -180,6 +200,14 @@
|
|
|
180
200
|
* began, so a host that forgets to clear it never shows a run the changes of the run before.
|
|
181
201
|
*/
|
|
182
202
|
generationChanges?: CodeChanges | null;
|
|
203
|
+
/**
|
|
204
|
+
* The agent's own words about what the last run changed, from the host (the gateway sends them with the completed operation,
|
|
205
|
+
* as `metadata.summary`). The conclusion under the run says them instead of "Done. Your changes are ready.". Give it when the
|
|
206
|
+
* operation completes (before or after `isGenerating` turns false: a value that comes after goes into the work of the run that
|
|
207
|
+
* just ended), and clear it when the next run starts; like the changes, the chat ignores the very value it held when a run began.
|
|
208
|
+
* Without it the conclusion keeps its catalog sentence.
|
|
209
|
+
*/
|
|
210
|
+
generationSummary?: string | null;
|
|
183
211
|
onSuggestionSelected?: (suggestion: string) => void;
|
|
184
212
|
/**
|
|
185
213
|
* What is in the message box now. The follow-up card under the last reply (ideas for what to improve next, as small pills)
|
|
@@ -190,9 +218,10 @@
|
|
|
190
218
|
/**
|
|
191
219
|
* Draws a restore icon on the messages the person sent, shown when the pointer is over the message. Pressing it asks the host to
|
|
192
220
|
* put the widget back to how it was BEFORE that message: called with the id of the saved reply that stands for that earlier state
|
|
193
|
-
* and its place in `messages`. Without it no restore icon is drawn.
|
|
221
|
+
* and its place in `messages`. Without it no restore icon is drawn. The third word says whether it is a restore (which throws away
|
|
222
|
+
* what came after the checkpoint, so the chat asks to confirm it) or a redo (which brings that work back).
|
|
194
223
|
*/
|
|
195
|
-
onRestoreCheckpoint?: (messageId: string, messageIndex: number) => void;
|
|
224
|
+
onRestoreCheckpoint?: (messageId: string, messageIndex: number, kind?: 'restore' | 'redo') => void;
|
|
196
225
|
/**
|
|
197
226
|
* Gives the last message a thumbs up and a thumbs down (next to copy and regenerate). Called with the id of the assistant message
|
|
198
227
|
* that announced the version and the thumb that was pressed; the host keeps the rating. Without it no thumbs are drawn.
|
|
@@ -282,6 +311,7 @@
|
|
|
282
311
|
generationPlan = null,
|
|
283
312
|
generationPlanPending = false,
|
|
284
313
|
generationChanges = null,
|
|
314
|
+
generationSummary = null,
|
|
285
315
|
onSuggestionSelected,
|
|
286
316
|
draftText = '',
|
|
287
317
|
onRestoreCheckpoint,
|
|
@@ -313,6 +343,31 @@
|
|
|
313
343
|
// Said once, however many messages fail the same way
|
|
314
344
|
let warnedAboutBadges = false;
|
|
315
345
|
|
|
346
|
+
/**
|
|
347
|
+
* The beginning of the texts that were pasted into sent messages, by the address of their file. A message keeps the file and not
|
|
348
|
+
* its beginning, so it is read when the pointer first rests on a badge of the text; the badge then says it (cut short with an
|
|
349
|
+
* ellipsis) where it said the file's name.
|
|
350
|
+
*/
|
|
351
|
+
let pastedTextExcerpts = $state<Record<string, string>>({});
|
|
352
|
+
// Bookkeeping, not state: which addresses were asked for already (a file is read once)
|
|
353
|
+
const pastedTextExcerptsRequested = new Set<string>();
|
|
354
|
+
|
|
355
|
+
/** Reads the beginning of the text a badge stands for, once, when the pointer rests on the badge. */
|
|
356
|
+
function rememberPastedTextExcerpt(file: ContentItemOutput | undefined): void {
|
|
357
|
+
const url = file?.url;
|
|
358
|
+
if (typeof url !== 'string' || url === '' || !isPastedTextOfMessage(file) || pastedTextExcerptsRequested.has(url)) return;
|
|
359
|
+
pastedTextExcerptsRequested.add(url);
|
|
360
|
+
void fetchPastedTextExcerpt(url).then((excerpt) => {
|
|
361
|
+
if (excerpt) pastedTextExcerpts = { ...pastedTextExcerpts, [url]: excerpt };
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/** What a badge says when the pointer rests on it: the beginning of a pasted text once it was read, else the name of the file. */
|
|
366
|
+
function sentBadgeHoverText(file: ContentItemOutput | undefined): string | undefined {
|
|
367
|
+
const excerpt = typeof file?.url === 'string' ? pastedTextExcerpts[file.url] : undefined;
|
|
368
|
+
return excerpt || sentBadgeTitleOf(file);
|
|
369
|
+
}
|
|
370
|
+
|
|
316
371
|
function sentSegmentsOf(text: string | null | undefined, attachments: readonly ContentItemOutput[]): SentSegment[] | null {
|
|
317
372
|
if (!referenceBadges || !text || attachments.length === 0 || !text.includes('#')) return null;
|
|
318
373
|
try {
|
|
@@ -357,14 +412,17 @@
|
|
|
357
412
|
function check() {
|
|
358
413
|
messagesHasScrollbar = node.scrollHeight > node.clientHeight + 4;
|
|
359
414
|
if (panelLayout) {
|
|
360
|
-
// The docked panel keeps
|
|
361
|
-
//
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
415
|
+
// The docked panel keeps 12px on both sides (set in the style of the list), the same as the message box under it, so the
|
|
416
|
+
// face of the assistant starts where the box starts and a bubble ends where it ends. A scrollbar that takes room of its own
|
|
417
|
+
// (classic bars) is part of the gap at the end: the padding there gives up the room of the bar (see `panelListEndPaddingPx`).
|
|
418
|
+
// One that floats over the list (overlay bars, as on a Mac with a trackpad) takes none, so the style's 12px stay. The start
|
|
419
|
+
// is never overridden: this used to force the 16px / 8px of an older design over the 12px of the style, and the words stood
|
|
420
|
+
// 4px off the box at both sides.
|
|
421
|
+
const scrollbarWidth = node.offsetWidth - node.clientWidth;
|
|
422
|
+
const endPadding = panelListEndPaddingPx(messagesHasScrollbar, scrollbarWidth);
|
|
423
|
+
node.style.removeProperty('padding-inline-start');
|
|
424
|
+
if (endPadding === null) node.style.removeProperty('padding-inline-end');
|
|
425
|
+
else node.style.setProperty('padding-inline-end', `${endPadding}px`, 'important');
|
|
368
426
|
return;
|
|
369
427
|
}
|
|
370
428
|
// A scrollbar that takes room of its own (classic bars) is the gap itself. One that floats over the list (overlay bars, as on
|
|
@@ -704,6 +762,8 @@
|
|
|
704
762
|
const trimmed = message.messageContent.trim();
|
|
705
763
|
return (
|
|
706
764
|
/^Code generation failed/i.test(trimmed) ||
|
|
765
|
+
// The sketch assistant's sentences for a refusal because of the credits or the plan: a failure, with its way out
|
|
766
|
+
isLimitFailureLine(trimmed, limitFailureSentences) ||
|
|
707
767
|
/^⚠️/.test(trimmed) ||
|
|
708
768
|
/Too many generation requests/i.test(trimmed) ||
|
|
709
769
|
/temporarily unavailable/i.test(trimmed) ||
|
|
@@ -1265,8 +1325,11 @@
|
|
|
1265
1325
|
: null;
|
|
1266
1326
|
const outcome = turnOutcome(visibleReplies.map(replyFactsOf), finished !== null);
|
|
1267
1327
|
if (outcome === null) return NO_ASSISTANT_VIEW;
|
|
1268
|
-
// A success the person did not just watch
|
|
1269
|
-
|
|
1328
|
+
// A success the person did not just watch is not celebrated: not when the conversation was loaded (no work was kept), not when
|
|
1329
|
+
// the work came back from the archive of this browser (a reload, or the conversation opened again: it is the work of an earlier
|
|
1330
|
+
// run, the avatar celebrated it then, and on a refresh it stays as it was: at rest), and not when a debug line says so
|
|
1331
|
+
const successWasWatched = finished !== null && keptWorkIsFromARunThatEndedHere;
|
|
1332
|
+
const shownOutcome = outcomeToShow(outcome, successWasWatched);
|
|
1270
1333
|
// The run is over, but the effects that keep its work and clear its traces have not run yet. The page tells a failure or a
|
|
1271
1334
|
// stop in the same tick the run ends (the creator adds the message, then clears isGenerating), so the avatar that appears in
|
|
1272
1335
|
// this very pass is the end of that run, and the one of a success appears a pass later. It takes over from the live avatar
|
|
@@ -1312,8 +1375,14 @@
|
|
|
1312
1375
|
return false;
|
|
1313
1376
|
}
|
|
1314
1377
|
|
|
1378
|
+
/**
|
|
1379
|
+
* Whether the way out of a failed reply is to upgrade. The sentences the chat itself says for a limit are known by their whole
|
|
1380
|
+
* words; any other line is read by the words a failure about the plan or the credits uses (the lines the widget creator saves
|
|
1381
|
+
* for a code generation, which it keeps "Upgrade your plan" in).
|
|
1382
|
+
*/
|
|
1315
1383
|
function isPlanLimitMessage(message: string | null | undefined): boolean {
|
|
1316
1384
|
if (!message) return false;
|
|
1385
|
+
if (isLimitFailureLine(message, limitFailureSentences)) return true;
|
|
1317
1386
|
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);
|
|
1318
1387
|
}
|
|
1319
1388
|
|
|
@@ -1463,6 +1532,16 @@
|
|
|
1463
1532
|
return changesGiven;
|
|
1464
1533
|
}
|
|
1465
1534
|
|
|
1535
|
+
/** The summary the host held when the run that is working began. It is an earlier run's. A plain variable, not state. */
|
|
1536
|
+
let summaryHeldAtRunStart: string | null = null;
|
|
1537
|
+
|
|
1538
|
+
/** The summary of the run that just ended: what the host gave since the run began, or nothing (never the earlier run's). */
|
|
1539
|
+
function summaryOfTheRunThatEnded(): string | null {
|
|
1540
|
+
const summaryGiven = generationSummary;
|
|
1541
|
+
if (!summaryGiven || summaryGiven === summaryHeldAtRunStart) return null;
|
|
1542
|
+
return summaryGiven;
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1466
1545
|
/**
|
|
1467
1546
|
* The id of the message of the person that the kept work answered. A user message after it means a new turn, even if its words
|
|
1468
1547
|
* are the same (see `keptWorkIsOutdated`). It is set together with `finishedGeneration`, which is what makes the turns draw
|
|
@@ -1477,10 +1556,11 @@
|
|
|
1477
1556
|
/**
|
|
1478
1557
|
* The kept work is that of a run this chat saw end, and not work that came back from the archive. The changes that come after a
|
|
1479
1558
|
* run ended belong only to the first: work from the archive is of an earlier turn, and must never be given the changes of a run it
|
|
1480
|
-
* is not the work of (nor have them written into its archive record).
|
|
1481
|
-
*
|
|
1559
|
+
* is not the work of (nor have them written into its archive record). It is also what tells the assistant's avatar whether the
|
|
1560
|
+
* person just watched the work succeed (the avatar celebrates only then, never for work that came back after a reload or when the
|
|
1561
|
+
* conversation was opened again), so the turns are drawn from it: state, set in the same pass as `finishedGeneration`.
|
|
1482
1562
|
*/
|
|
1483
|
-
let keptWorkIsFromARunThatEndedHere = false;
|
|
1563
|
+
let keptWorkIsFromARunThatEndedHere = $state(false);
|
|
1484
1564
|
|
|
1485
1565
|
/** The work of the last run is not the newest work any more (a new run, another conversation, an empty thread). */
|
|
1486
1566
|
function forgetKeptWork(): void {
|
|
@@ -1525,6 +1605,7 @@
|
|
|
1525
1605
|
if (working) {
|
|
1526
1606
|
// A new run starts: what the last one kept is not the newest work any more, and no avatar of it is left to take over from
|
|
1527
1607
|
changesHeldAtRunStart = generationChanges;
|
|
1608
|
+
summaryHeldAtRunStart = generationSummary;
|
|
1528
1609
|
forgetKeptWork();
|
|
1529
1610
|
lastLiveLook = null;
|
|
1530
1611
|
runWasWatched = true;
|
|
@@ -1542,6 +1623,7 @@
|
|
|
1542
1623
|
code: keptCode,
|
|
1543
1624
|
thoughtSeconds: keptThoughtSeconds,
|
|
1544
1625
|
changes: changesOfTheRunThatEnded(),
|
|
1626
|
+
summary: summaryOfTheRunThatEnded(),
|
|
1545
1627
|
});
|
|
1546
1628
|
// Said with the work, so that a prompt sent after it (even with the same words) is not taken for the one it answered
|
|
1547
1629
|
keptForUserMessageId = finishedGeneration ? (answeredMessage?.id ?? null) : null;
|
|
@@ -1593,6 +1675,33 @@
|
|
|
1593
1675
|
});
|
|
1594
1676
|
});
|
|
1595
1677
|
|
|
1678
|
+
// The agent's summary of a run comes with the completed operation too, and so can come after the run ended, for the same reason as
|
|
1679
|
+
// the changes above, under the same rules: into the work the run that just ended kept, when that work has no summary yet; never
|
|
1680
|
+
// while a run works, never the value held when the run began, never into work from the archive. The conclusion then says it in place
|
|
1681
|
+
// of its catalog sentence.
|
|
1682
|
+
$effect(() => {
|
|
1683
|
+
const summaryGiven = generationSummary;
|
|
1684
|
+
// Only a new value of what the host gave makes this run again; what is read below is not what makes it run
|
|
1685
|
+
untrack(() => {
|
|
1686
|
+
try {
|
|
1687
|
+
if (!summaryGiven || assistantIsWorking || summaryGiven === summaryHeldAtRunStart) return;
|
|
1688
|
+
const keptWork = finishedGeneration;
|
|
1689
|
+
if (!keptWork || !keptWorkIsFromARunThatEndedHere) return;
|
|
1690
|
+
const keptWorkWithSummary = withSummaryOfTheRun(keptWork, summaryGiven);
|
|
1691
|
+
// The same object back: the work has a summary already, or what was given is not usable
|
|
1692
|
+
if (keptWorkWithSummary === keptWork) return;
|
|
1693
|
+
finishedGeneration = keptWorkWithSummary;
|
|
1694
|
+
chatLog('[Chat] the summary of the run that ended came after it, and was put with its work:', {
|
|
1695
|
+
'Summary Characters': keptWorkWithSummary.summary?.length ?? 0,
|
|
1696
|
+
});
|
|
1697
|
+
// The archive of this browser has the work as it was kept: it gets the summary too, so a reload brings it back
|
|
1698
|
+
void saveGenerationArchive(conversationId, keptWorkWithSummary);
|
|
1699
|
+
} catch (error) {
|
|
1700
|
+
chatWarn('[Chat] Could not put the summary that came after the run with its work:', error);
|
|
1701
|
+
}
|
|
1702
|
+
});
|
|
1703
|
+
});
|
|
1704
|
+
|
|
1596
1705
|
// After a reload, or when a conversation is opened, the work of its last run comes back from what this browser kept, so the
|
|
1597
1706
|
// newest turn shows its thinking and its code again. Only the id of the conversation makes this run again.
|
|
1598
1707
|
let archiveConversationId: string | null = null;
|
|
@@ -1617,6 +1726,7 @@
|
|
|
1617
1726
|
code: record.code,
|
|
1618
1727
|
thoughtSeconds: record.thoughtSeconds,
|
|
1619
1728
|
changes: record.changes,
|
|
1729
|
+
summary: record.summary,
|
|
1620
1730
|
});
|
|
1621
1731
|
// The archive knows the words of the prompt and nothing else: they find the turn again, and the effect below tells the
|
|
1622
1732
|
// work which message that is as soon as the history is there
|
|
@@ -2034,19 +2144,73 @@
|
|
|
2034
2144
|
return match?.[1] ?? null;
|
|
2035
2145
|
}
|
|
2036
2146
|
|
|
2037
|
-
|
|
2147
|
+
/**
|
|
2148
|
+
* Whether the person's message of this turn follows another message of the same side with nothing from the assistant between them
|
|
2149
|
+
* (two prompts in a row, one sent while the first still waited). The panel keeps such messages closer than a message and the
|
|
2150
|
+
* answer to it, as people read them as one thing said in two parts.
|
|
2151
|
+
*/
|
|
2152
|
+
function followsTurnOfSameSender(turn: ChatTurn, turnIndex: number): boolean {
|
|
2153
|
+
if (turnIndex === 0 || !turn.user) return false;
|
|
2154
|
+
const previousTurn = chatTurns[turnIndex - 1];
|
|
2155
|
+
return !!previousTurn?.user && !assistantViewOf(previousTurn).hasContent;
|
|
2156
|
+
}
|
|
2157
|
+
|
|
2158
|
+
/** The message a restore waits on while the question "Restore this checkpoint?" is open, or null when no question is open. */
|
|
2159
|
+
let restoreAwaitingConfirmationId = $state<string | null>(null);
|
|
2160
|
+
|
|
2161
|
+
/** The files the open preview steps through (the files of the message whose file was pressed) and the place of the open one; null while none is open. */
|
|
2162
|
+
let sentPreview = $state<{ files: PreviewableFile[]; openIndex: number } | null>(null);
|
|
2163
|
+
|
|
2164
|
+
/** A thumbnail or a file chip of a sent message was pressed: its file opens in the preview, with the files of the same message next to it. */
|
|
2165
|
+
function openSentPreview(files: PreviewableFile[], openIndex: number) {
|
|
2166
|
+
sentPreview = { files, openIndex };
|
|
2167
|
+
}
|
|
2168
|
+
|
|
2169
|
+
/**
|
|
2170
|
+
* The restore or the redo of a checkpoint. The host's callback is told which of the two it is: a restore throws away what came after
|
|
2171
|
+
* the checkpoint, so the chat asks the person to confirm it first; a redo brings that work back and needs no question.
|
|
2172
|
+
*/
|
|
2173
|
+
function handleRestoreCheckpoint(messageId: string, kind: 'restore' | 'redo' = 'restore') {
|
|
2174
|
+
// Nothing to ask and nothing to do when the page gave no way to restore
|
|
2175
|
+
if (!onRestoreCheckpoint) return;
|
|
2038
2176
|
// Find the index of the message to restore to
|
|
2039
2177
|
const messageIndex = messages.findIndex(msg => msg.id === messageId);
|
|
2040
2178
|
if (messageIndex === -1) return;
|
|
2041
2179
|
|
|
2042
|
-
//
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2180
|
+
// A restore comes first as a question (the button sits under a message, where a click can be a mistake); the page is told only
|
|
2181
|
+
// when the person confirms. A redo gets the work back, so it needs no question.
|
|
2182
|
+
if (kind === 'restore') {
|
|
2183
|
+
restoreAwaitingConfirmationId = messageId;
|
|
2184
|
+
// chatLog('Restore checkpoint asked for message:', messageId, 'at index:', messageIndex);
|
|
2185
|
+
return;
|
|
2186
|
+
}
|
|
2187
|
+
runCheckpointRestore(messageId, kind);
|
|
2188
|
+
}
|
|
2189
|
+
|
|
2190
|
+
/** Tells the page to restore (or redo) a checkpoint: what `handleRestoreCheckpoint` does at once for a redo, and after the question for a restore. */
|
|
2191
|
+
function runCheckpointRestore(messageId: string, kind: 'restore' | 'redo') {
|
|
2192
|
+
try {
|
|
2193
|
+
const messageIndex = messages.findIndex(msg => msg.id === messageId);
|
|
2194
|
+
if (messageIndex === -1 || !onRestoreCheckpoint) return;
|
|
2195
|
+
// chatLog('Restore checkpoint requested for message:', messageId, 'at index:', messageIndex);
|
|
2196
|
+
onRestoreCheckpoint(messageId, messageIndex, kind);
|
|
2197
|
+
} catch (error) {
|
|
2198
|
+
chatWarn('[Chat] The restore of a checkpoint failed:', error);
|
|
2047
2199
|
}
|
|
2048
2200
|
}
|
|
2049
2201
|
|
|
2202
|
+
/** The person confirmed the question: the restore goes ahead. */
|
|
2203
|
+
function confirmCheckpointRestore() {
|
|
2204
|
+
const messageId = restoreAwaitingConfirmationId;
|
|
2205
|
+
restoreAwaitingConfirmationId = null;
|
|
2206
|
+
if (messageId) runCheckpointRestore(messageId, 'restore');
|
|
2207
|
+
}
|
|
2208
|
+
|
|
2209
|
+
/** The person closed the question: the widget stays as it is. */
|
|
2210
|
+
function cancelCheckpointRestore() {
|
|
2211
|
+
restoreAwaitingConfirmationId = null;
|
|
2212
|
+
}
|
|
2213
|
+
|
|
2050
2214
|
function getRetryPromptForTurn(turn: ChatTurn, turnIndex: number): string | null {
|
|
2051
2215
|
const own = turn.user?.messageContent?.trim();
|
|
2052
2216
|
if (own) return own;
|
|
@@ -2062,6 +2226,24 @@
|
|
|
2062
2226
|
return failures.length > 0 && failures[failures.length - 1]?.id === reply.id;
|
|
2063
2227
|
}
|
|
2064
2228
|
|
|
2229
|
+
/**
|
|
2230
|
+
* Whether the one-line failure of the panel already holds the refresh icon of this turn (see the failed notice below): then the row
|
|
2231
|
+
* of actions under the last message must not draw a second one. A stop is not a failure line, and a limit of the plan has no icon on
|
|
2232
|
+
* its line (its way out is the upgrade button, and running the prompt again is the regenerate icon of the row).
|
|
2233
|
+
*/
|
|
2234
|
+
function failureLineHoldsRetry(turn: ChatTurn, turnIndex: number): boolean {
|
|
2235
|
+
if (!panelLayout || !onRetryMessage) return false;
|
|
2236
|
+
return turn.replies.some(
|
|
2237
|
+
(reply) =>
|
|
2238
|
+
shouldShowAssistantReply(reply) &&
|
|
2239
|
+
!isStoppedByUser(reply) &&
|
|
2240
|
+
isCodegenFailure(reply) &&
|
|
2241
|
+
isLastCodegenFailureInTurn(turn, reply) &&
|
|
2242
|
+
!isPlanLimitMessage(reply.messageContent) &&
|
|
2243
|
+
turnNeedsRetry(turn, turnIndex)
|
|
2244
|
+
);
|
|
2245
|
+
}
|
|
2246
|
+
|
|
2065
2247
|
function handleRetryTurn(turn: ChatTurn, turnIndex: number) {
|
|
2066
2248
|
const retryContent = getRetryPromptForTurn(turn, turnIndex);
|
|
2067
2249
|
if (!retryContent) return;
|
|
@@ -2330,14 +2512,19 @@
|
|
|
2330
2512
|
</script>
|
|
2331
2513
|
|
|
2332
2514
|
<!-- A sent message that names its files: the text with a badge (the picture and `#name`) where a word names one. Written without
|
|
2333
|
-
whitespace between the pieces, because the text around them is pre-wrapped and every space here would show.
|
|
2334
|
-
|
|
2335
|
-
|
|
2515
|
+
whitespace between the pieces, because the text around them is pre-wrapped and every space here would show.
|
|
2516
|
+
A text that was pasted into the box has an address too (the file the message holds), but it is a text and not a picture: its badge
|
|
2517
|
+
draws the file glyph, and the address is never handed to an `<img>` (the browser drew its broken-picture icon there). -->
|
|
2518
|
+
{#snippet sentTextWithBadges(segments: SentSegment[], attachments: readonly ContentItemOutput[])}{#each segments as segment, segmentIndex (segmentIndex)}{#if segment.kind === 'badge'}{@const badgeFile = attachments[segment.attachmentIndex]}{@const badgePicture = isPastedTextOfMessage(badgeFile) ? '' : sentBadgePictureOf(badgeFile)}<!-- svelte-ignore a11y_no_static_element_interactions --><span class={SENT_BADGE_CLASSES} data-sent-badge data-testid="chat-sent-reference-badge" title={sentBadgeHoverText(badgeFile)} onmouseenter={() => rememberPastedTextExcerpt(badgeFile)}>{#if badgePicture}<img class={SENT_BADGE_THUMBNAIL_CLASSES} src={badgePicture} alt="" draggable="false" loading="lazy" decoding="async" />{:else if isPastedTextOfMessage(badgeFile)}<svg class="{SENT_BADGE_THUMBNAIL_CLASSES} text-muted-foreground p-0.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" data-testid="chat-sent-text-glyph">{#each FILE_GLYPH_PATHS as glyphPath (glyphPath)}<path d={glyphPath} />{/each}</svg>{/if}<span class={SENT_BADGE_LABEL_CLASSES} dir="auto">{segment.word}</span></span>{:else}{@render linkified(segment.text)}{/if}{/each}{/snippet}
|
|
2519
|
+
|
|
2520
|
+
<!-- A link in a message: the design system's hover, a grey ground (`hover:bg-accent`) that switches on the frame the pointer arrives and
|
|
2521
|
+
is the same under keyboard focus. It has no fade: the tint is faint, so a fade would only make the link look late (the foundations'
|
|
2522
|
+
rule for hover). `-mx-0.5 px-0.5` give the ground a little room round the words without moving them. -->
|
|
2336
2523
|
{#snippet linkified(text: string)}{#each splitTextIntoLinks(text) as segment, segmentIndex (segmentIndex)}{#if segment.type === 'link'}<a
|
|
2337
2524
|
href={segment.href}
|
|
2338
2525
|
target="_blank"
|
|
2339
2526
|
rel="noopener noreferrer"
|
|
2340
|
-
class="wc-chat-link text-foreground hover:
|
|
2527
|
+
class="wc-chat-link text-foreground hover:bg-accent focus-visible:bg-accent focus-visible:ring-ring -mx-0.5 rounded-sm px-0.5 underline underline-offset-2 [overflow-wrap:anywhere] [box-decoration-break:clone] focus-visible:ring-2 focus-visible:outline-none"
|
|
2341
2528
|
data-testid="chat-message-link">{segment.text}</a>{:else}{segment.text}{/if}{/each}{/snippet}
|
|
2342
2529
|
|
|
2343
2530
|
<!-- The follow-up card (Figma: Chat cards, "Follow-ups"). Drawn in one of two places: at the end of the last turn's assistant column,
|
|
@@ -2355,13 +2542,41 @@
|
|
|
2355
2542
|
{/if}
|
|
2356
2543
|
{/snippet}
|
|
2357
2544
|
|
|
2545
|
+
<!-- Copy, regenerate (retry) and the two thumbs of the last message: not while something is being generated or loaded. Drawn in one of
|
|
2546
|
+
two places (see the turns below): under the turn in the standard layout, inside the assistant's column in the panel. The row has
|
|
2547
|
+
nothing to draw (no words to copy, nothing to retry, no version to rate) and is then left out altogether. -->
|
|
2548
|
+
{#snippet lastMessageActions(turn: ChatTurn, turnIndex: number)}
|
|
2549
|
+
{#if !isLoading && !isGenerating}
|
|
2550
|
+
{@const copyText = textToCopy(
|
|
2551
|
+
turn.replies.filter(shouldShowAssistantReply).map((reply) => visibleMessageContent(reply.messageContent || '')),
|
|
2552
|
+
getTurnCommitTitle(turn),
|
|
2553
|
+
)}
|
|
2554
|
+
{@const canRegenerate = !!onRetryMessage && turnNeedsRetry(turn, turnIndex) && !failureLineHoldsRetry(turn, turnIndex)}
|
|
2555
|
+
{@const ratedMessageId = onRateVersion ? ratableVersionReplyId(turn) : null}
|
|
2556
|
+
{#if copyText !== '' || canRegenerate || ratedMessageId}
|
|
2557
|
+
<!-- In the column the row is pulled up 4 px: its buttons are 32 px tall and have room of their own around the icon, so the icons
|
|
2558
|
+
sit 8 px under the words as everything else in the column does -->
|
|
2559
|
+
<div class={panelLayout ? '-mt-1' : ''} data-testid="chat-last-message-actions">
|
|
2560
|
+
<MessageActions
|
|
2561
|
+
{copyText}
|
|
2562
|
+
{canRegenerate}
|
|
2563
|
+
onRegenerate={() => handleRetryTurn(turn, turnIndex)}
|
|
2564
|
+
{ratedMessageId}
|
|
2565
|
+
rating={ratedMessageId ? versionRatings[ratedMessageId] : 'none'}
|
|
2566
|
+
onRate={(messageId, pressed) => onRateVersion?.(messageId, pressed)}
|
|
2567
|
+
/>
|
|
2568
|
+
</div>
|
|
2569
|
+
{/if}
|
|
2570
|
+
{/if}
|
|
2571
|
+
{/snippet}
|
|
2572
|
+
|
|
2358
2573
|
<div class="{panelLayout ? 'panel-messages-shell flex h-full min-h-0 w-full flex-1 flex-col' : 'contents'}">
|
|
2359
2574
|
<div
|
|
2360
2575
|
bind:this={messagesContainer}
|
|
2361
2576
|
class="{className ? className : 'prompt-chat-messages-ct'} prompt-chat-messages-scroll flex flex-col overflow-y-auto {panelLayout && showEmptyState && !isLoading && !isGenerating ? 'pb-0' : ''} {panelLayout ? (showEmptyState && !isLoading && !isGenerating ? 'min-h-0 flex-1' : 'min-h-0 flex-1 pb-4') : 'space-y-4 pb-3'}"
|
|
2362
2577
|
class:loading={isLoading}
|
|
2363
2578
|
style={panelLayout
|
|
2364
|
-
? `padding: 8px
|
|
2579
|
+
? `padding: 8px ${PANEL_LIST_INLINE_PADDING_PX}px ${showEmptyState && !isLoading && !isGenerating ? 0 : 16}px; overflow-anchor: none;`
|
|
2365
2580
|
: 'padding: 8px 16px 12px; overflow-anchor: none;'}
|
|
2366
2581
|
use:detectMessagesScrollbar
|
|
2367
2582
|
onscroll={handleScroll}
|
|
@@ -2405,12 +2620,16 @@
|
|
|
2405
2620
|
{/if}
|
|
2406
2621
|
|
|
2407
2622
|
<div class="{panelLayout && chatTurns.length > 0 ? 'flex min-h-full flex-col' : 'contents'}">
|
|
2408
|
-
|
|
2623
|
+
<!-- The rhythm of the panel (Figma: Chat states, "Thread"): 20 px from one turn to the next, 12 px from what a person wrote to the
|
|
2624
|
+
answer of the assistant, 8 px between two things the same side said (`gap-2` of the assistant's column, and the `-mt-3` of a
|
|
2625
|
+
turn that follows a turn with no answer). The list has 12 px at each side, like the message box under it, so the face of the
|
|
2626
|
+
assistant starts where the box starts and a bubble ends where it ends. -->
|
|
2627
|
+
<div class="{panelLayout && chatTurns.length > 0 ? 'mt-auto flex w-full flex-col gap-5' : 'contents'}">
|
|
2409
2628
|
<!-- Conversation turns (user prompt + assistant status grouped) -->
|
|
2410
2629
|
{#each chatTurns as turn, turnIndex (turn.user?.id ?? turn.replies[0]?.id ?? turnIndex)}
|
|
2411
2630
|
{@const assistant = assistantViewOf(turn)}
|
|
2412
2631
|
<div
|
|
2413
|
-
class="wc-chat-turn-ct rounded-lg {panelLayout ?
|
|
2632
|
+
class="wc-chat-turn-ct rounded-lg {panelLayout ? `flex flex-col gap-3 ${followsTurnOfSameSender(turn, turnIndex) ? '-mt-3' : ''}` : 'space-y-1.5 border border-transparent p-0.5'}"
|
|
2414
2633
|
use:keepEndInView={turnIndex === chatTurns.length - 1}
|
|
2415
2634
|
>
|
|
2416
2635
|
{#if turn.user}
|
|
@@ -2418,11 +2637,30 @@
|
|
|
2418
2637
|
{@const shownAttachments = visibleUserAttachments(turn, turnIndex)}
|
|
2419
2638
|
{@const author = authorOfMessage(userMsg)}
|
|
2420
2639
|
{@const sentSegments = sentSegmentsOf(userMsg.messageContent, shownAttachments)}
|
|
2421
|
-
|
|
2640
|
+
<!-- In the panel the files of a message are drawn above its bubble (the chips first, then the thumbnails), as the message box drew
|
|
2641
|
+
them; the bubble holds the words. A pasted text that a badge of the words names is not drawn: its badge stands in the words. -->
|
|
2642
|
+
{@const sentTiles = panelLayout ? arrangeSentAttachments(shownAttachments, attachmentIndexesNamedByBadges(sentSegments)) : null}
|
|
2643
|
+
{@const hasTilesAboveBubble = sentTiles !== null && hasSentTiles(sentTiles)}
|
|
2644
|
+
<!-- A message of files only has no bubble: an empty one would only be a dot of colour -->
|
|
2645
|
+
{@const bubbleIsDrawn = !hasTilesAboveBubble || !!userMsg.messageContent}
|
|
2646
|
+
<!-- The standard layout keeps a margin to the right of a message (`.message-container`, 96% wide); in the panel a message and
|
|
2647
|
+
its face end at the edge of the list, where the message box ends. -->
|
|
2648
|
+
<div class="{panelLayout ? 'panel-user-turn' : 'message-container'} wc-chat-turn-user flex w-full flex-col {panelLayout ? 'items-end' : 'items-stretch'}"
|
|
2422
2649
|
class:opacity-75={userMsg._optimistic}
|
|
2423
2650
|
class:opacity-50={userMsg._failed}
|
|
2424
2651
|
class:has-attachments={shownAttachments.length > 0}
|
|
2425
2652
|
>
|
|
2653
|
+
{#if sentTiles && hasTilesAboveBubble}
|
|
2654
|
+
<!-- The files end where the bubble ends: when the face of the person sits beside the bubble, the room of the face (24 px and the
|
|
2655
|
+
8 px of the gap) is kept free at the end. With no bubble the face stands beside the files. -->
|
|
2656
|
+
<div class="wc-chat-turn-user-attachments flex w-full min-w-0 items-start justify-end gap-2 {bubbleIsDrawn ? 'mb-2' : ''} {author && bubbleIsDrawn ? 'pe-8' : ''}">
|
|
2657
|
+
<SentAttachments arrangement={sentTiles} onOpenPreview={openSentPreview} class="min-w-0 flex-1" />
|
|
2658
|
+
{#if author && !bubbleIsDrawn}
|
|
2659
|
+
<MemberAvatar member={author} class="mt-1.5" />
|
|
2660
|
+
{/if}
|
|
2661
|
+
</div>
|
|
2662
|
+
{/if}
|
|
2663
|
+
{#if bubbleIsDrawn}
|
|
2426
2664
|
<!-- The bubble and, at its end, the face of the person who wrote it (when the page told the chat who is who). -->
|
|
2427
2665
|
<div class="wc-chat-turn-user-row flex w-full min-w-0 items-start gap-2" data-bubble-row>
|
|
2428
2666
|
<Message
|
|
@@ -2433,7 +2671,7 @@
|
|
|
2433
2671
|
{#snippet children()}
|
|
2434
2672
|
<div
|
|
2435
2673
|
class="message-bubble-user text-sm select-text {panelLayout ? 'w-auto max-w-full leading-5' : 'w-full leading-relaxed'}"
|
|
2436
|
-
class:p-0={shownAttachments.length > 0}
|
|
2674
|
+
class:p-0={!panelLayout && shownAttachments.length > 0}
|
|
2437
2675
|
use:bubbleScrollPadding
|
|
2438
2676
|
>
|
|
2439
2677
|
{#if userMsg.messageContent}
|
|
@@ -2459,9 +2697,11 @@
|
|
|
2459
2697
|
{/if}
|
|
2460
2698
|
{/if}
|
|
2461
2699
|
{#if shownAttachments.length > 0}
|
|
2462
|
-
|
|
2463
|
-
<
|
|
2464
|
-
|
|
2700
|
+
{#if !panelLayout}
|
|
2701
|
+
<div class="message-attachments-container">
|
|
2702
|
+
<AttachmentDisplay attachments={shownAttachments} variant="message" showPreview={true} />
|
|
2703
|
+
</div>
|
|
2704
|
+
{/if}
|
|
2465
2705
|
{:else if userMsg.messageContent && messageImpliesAttachedFile(userMsg.messageContent) && !earlierTurnRepeatsThisPrompt(turn, turnIndex)}
|
|
2466
2706
|
<div class="wc-missing-attachment-placeholder message-attachments-container flex flex-col items-center gap-1 px-3 pb-3">
|
|
2467
2707
|
<div class="wc-missing-attachment-thumb flex h-20 w-28 flex-col items-center justify-center gap-1 rounded-md border border-dashed border-gray-300 bg-gray-100 text-gray-400" title={$t('chat.messages.attachmentMissingTitle')} aria-label={$t('chat.messages.attachmentMissingLabel')}>
|
|
@@ -2477,9 +2717,12 @@
|
|
|
2477
2717
|
{/snippet}
|
|
2478
2718
|
</Message>
|
|
2479
2719
|
{#if author}
|
|
2480
|
-
|
|
2720
|
+
<!-- The face is 24 px and a one-line bubble is 36 px (a 20 px line and 8 px above and below it): 6 px from the top puts the
|
|
2721
|
+
two on the same middle line, and a bubble of more lines keeps the face level with its first line. -->
|
|
2722
|
+
<MemberAvatar member={author} class="mt-1.5" />
|
|
2481
2723
|
{/if}
|
|
2482
2724
|
</div>
|
|
2725
|
+
{/if}
|
|
2483
2726
|
{#if showCommitMetaOnUserTurn(turn) && (!panelLayout || showCommitMeta)}
|
|
2484
2727
|
{@const commitTitle = getTurnCommitTitle(turn)}
|
|
2485
2728
|
{@const versionLabel = getTurnVersionLabel(turn)}
|
|
@@ -2503,8 +2746,8 @@
|
|
|
2503
2746
|
showRestore={!!restoreTargetId}
|
|
2504
2747
|
showRedo={!!headRedoId}
|
|
2505
2748
|
restoredToVersion={restoredVersion}
|
|
2506
|
-
onRestore={restoreTargetId ? () => handleRestoreCheckpoint(restoreTargetId) : undefined}
|
|
2507
|
-
onRedo={headRedoId ? () => handleRestoreCheckpoint(headRedoId) : undefined}
|
|
2749
|
+
onRestore={restoreTargetId ? () => handleRestoreCheckpoint(restoreTargetId, 'restore') : undefined}
|
|
2750
|
+
onRedo={headRedoId ? () => handleRestoreCheckpoint(headRedoId, 'redo') : undefined}
|
|
2508
2751
|
messages={{
|
|
2509
2752
|
version: CHAT_MESSAGES['chat.checkpoint.version'],
|
|
2510
2753
|
restored: CHAT_MESSAGES['chat.checkpoint.restored'],
|
|
@@ -2715,12 +2958,15 @@
|
|
|
2715
2958
|
{/if}
|
|
2716
2959
|
{/if}
|
|
2717
2960
|
|
|
2718
|
-
<!-- A failure about the plan or the credits: the way out is to upgrade
|
|
2961
|
+
<!-- A failure about the plan or the credits: the way out is to upgrade, so the button is the call to action of the reply (a filled
|
|
2962
|
+
button, in the colors of every primary action), right under the sentence that says what is missing. Running the prompt
|
|
2963
|
+
again is the regenerate icon of the last message, and it is not offered here. -->
|
|
2719
2964
|
{#if isCodegenFailure(reply) && isLastCodegenFailureInTurn(turn, reply) && isPlanLimitMessage(reply.messageContent) && turnNeedsRetry(turn, turnIndex)}
|
|
2720
|
-
<div class="
|
|
2965
|
+
<div class="mt-1.5 flex justify-start" data-testid="chat-upgrade-row">
|
|
2721
2966
|
<button
|
|
2722
2967
|
type="button"
|
|
2723
|
-
class="
|
|
2968
|
+
class="bg-primary text-primary-foreground hover:bg-primary/90 focus-visible:bg-primary/90 focus-visible:ring-ring ring-offset-background text-label-small duration-fast inline-flex h-8 cursor-pointer items-center justify-center rounded-lg px-3 whitespace-nowrap transition-colors focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden"
|
|
2969
|
+
data-testid="chat-upgrade-button"
|
|
2724
2970
|
onclick={openUpgradePlans}
|
|
2725
2971
|
title={$t('chat.messages.upgradeTitle')}
|
|
2726
2972
|
>
|
|
@@ -2735,13 +2981,19 @@
|
|
|
2735
2981
|
{@const doneLineHasModulesAbove =
|
|
2736
2982
|
!!assistant.finished &&
|
|
2737
2983
|
(finishedModulesView(assistant.finished).showThinking || finishedModulesView(assistant.finished).showCode)}
|
|
2984
|
+
<!-- The conclusion says what the agent said it changed (`generationSummary`), or the catalog's sentence when it said nothing -->
|
|
2738
2985
|
<p
|
|
2739
|
-
class="text-body text-foreground {doneLineHasModulesAbove ? '' : 'flex min-h-7 items-center'}"
|
|
2986
|
+
class="text-body text-foreground break-words {doneLineHasModulesAbove ? '' : 'flex min-h-7 items-center'}"
|
|
2740
2987
|
data-testid="agent-conclusion"
|
|
2741
2988
|
>
|
|
2742
|
-
{$t('chat.generation.doneMessage')}
|
|
2989
|
+
{assistant.finished?.summary || $t('chat.generation.doneMessage')}
|
|
2743
2990
|
</p>
|
|
2744
2991
|
{/if}
|
|
2992
|
+
<!-- The row of copy, retry and thumbs: right under the last words of the last turn, and above its ideas. It used to be left out of the
|
|
2993
|
+
panel on purpose (Figma 526:2706 drew no row there); the panel has it again, as the people who use it asked. -->
|
|
2994
|
+
{#if panelLayout && turnIndex === chatTurns.length - 1}
|
|
2995
|
+
{@render lastMessageActions(turn, turnIndex)}
|
|
2996
|
+
{/if}
|
|
2745
2997
|
<!-- Ideas for what to improve next: under the conclusion of the last turn, and nowhere else -->
|
|
2746
2998
|
{#if turnIndex === chatTurns.length - 1}
|
|
2747
2999
|
{@render followUpCardView()}
|
|
@@ -2753,25 +3005,13 @@
|
|
|
2753
3005
|
{@render followUpCardView()}
|
|
2754
3006
|
{/if}
|
|
2755
3007
|
|
|
2756
|
-
<!-- Copy, regenerate and the two thumbs
|
|
2757
|
-
|
|
2758
|
-
{#if !panelLayout && turnIndex === chatTurns.length - 1
|
|
2759
|
-
{@
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
)}
|
|
2763
|
-
{@const canRegenerate = !!onRetryMessage && turnNeedsRetry(turn, turnIndex)}
|
|
2764
|
-
{@const ratedMessageId = onRateVersion ? ratableVersionReplyId(turn) : null}
|
|
2765
|
-
{#if copyText !== '' || canRegenerate || ratedMessageId}
|
|
2766
|
-
<MessageActions
|
|
2767
|
-
{copyText}
|
|
2768
|
-
{canRegenerate}
|
|
2769
|
-
onRegenerate={() => handleRetryTurn(turn, turnIndex)}
|
|
2770
|
-
{ratedMessageId}
|
|
2771
|
-
rating={ratedMessageId ? versionRatings[ratedMessageId] : 'none'}
|
|
2772
|
-
onRate={(messageId, pressed) => onRateVersion?.(messageId, pressed)}
|
|
2773
|
-
/>
|
|
2774
|
-
{/if}
|
|
3008
|
+
<!-- Copy, regenerate and the two thumbs, at the end of the last message only. In the standard layout the row is under the turn; in the
|
|
3009
|
+
panel it is drawn inside the assistant's column, under the last words (above), so it starts where the words do. -->
|
|
3010
|
+
{#if !panelLayout && turnIndex === chatTurns.length - 1}
|
|
3011
|
+
{@render lastMessageActions(turn, turnIndex)}
|
|
3012
|
+
{:else if panelLayout && !assistant.hasContent && turnIndex === chatTurns.length - 1}
|
|
3013
|
+
<!-- A turn the panel draws no words for has no column to put the row in: it stands alone, at the start of the list -->
|
|
3014
|
+
{@render lastMessageActions(turn, turnIndex)}
|
|
2775
3015
|
{/if}
|
|
2776
3016
|
</div>
|
|
2777
3017
|
{/each}
|
|
@@ -2782,7 +3022,7 @@
|
|
|
2782
3022
|
(the turn spaces its reply closer than the list spaces a turn from the next). -->
|
|
2783
3023
|
{#if thinkingHold && assistantIsWorking}
|
|
2784
3024
|
<!-- (The wrapper is what the list sees grow: keepEndInView keeps the end of the list in view while the turn changes size.) -->
|
|
2785
|
-
<div class="loading-indicator-ct {panelLayout ? 'mt-
|
|
3025
|
+
<div class="loading-indicator-ct {panelLayout ? '-mt-2 pb-3' : '-mt-3'}" use:keepEndInView>
|
|
2786
3026
|
<AgentTurn look={liveLook} {renderAgentAvatar}>
|
|
2787
3027
|
<!-- One card from "Planning" to the finished plan: it is the same card, so it opens where it stood when the plan arrives -->
|
|
2788
3028
|
{#if planCardView || planIsBeingWritten}
|
|
@@ -2857,7 +3097,7 @@
|
|
|
2857
3097
|
{/if}
|
|
2858
3098
|
</div>
|
|
2859
3099
|
{#if panelLayout && panelAnchoredFollowUp}
|
|
2860
|
-
<div class="panel-anchored-followup ms-auto flex w-full max-w-full shrink-0 flex-col items-end px-
|
|
3100
|
+
<div class="panel-anchored-followup ms-auto flex w-full max-w-full shrink-0 flex-col items-end px-3 pb-2">
|
|
2861
3101
|
<PanelFollowUpSuggestions
|
|
2862
3102
|
labels={panelAnchoredFollowUp.labels}
|
|
2863
3103
|
disabled={isGenerating}
|
|
@@ -2867,14 +3107,28 @@
|
|
|
2867
3107
|
/>
|
|
2868
3108
|
</div>
|
|
2869
3109
|
{/if}
|
|
3110
|
+
<!-- The preview of a file of a sent message: one card for the whole list, over the files of the message whose file was pressed -->
|
|
3111
|
+
{#if sentPreview}
|
|
3112
|
+
<AttachmentPreviewDialog
|
|
3113
|
+
files={sentPreview.files}
|
|
3114
|
+
openIndex={sentPreview.openIndex}
|
|
3115
|
+
onNavigate={(index) => {
|
|
3116
|
+
if (sentPreview) sentPreview = { ...sentPreview, openIndex: index };
|
|
3117
|
+
}}
|
|
3118
|
+
onClose={() => (sentPreview = null)}
|
|
3119
|
+
/>
|
|
3120
|
+
{/if}
|
|
3121
|
+
<!-- The question before a restore: it says what is lost, and the page hears of the restore only after "Restore" is pressed -->
|
|
3122
|
+
<RestoreCheckpointDialog
|
|
3123
|
+
open={restoreAwaitingConfirmationId !== null}
|
|
3124
|
+
onConfirm={confirmCheckpointRestore}
|
|
3125
|
+
onCancel={cancelCheckpointRestore}
|
|
3126
|
+
/>
|
|
2870
3127
|
</div>
|
|
2871
3128
|
|
|
2872
3129
|
<style>
|
|
2873
|
-
/*
|
|
2874
|
-
|
|
2875
|
-
display: none;
|
|
2876
|
-
min-height: 0;
|
|
2877
|
-
}
|
|
3130
|
+
/* (The rule that hid the empty row of hover actions of a user bubble is gone: the design system's `Message` no longer draws a row
|
|
3131
|
+
when it has no action to put in it, so there is nothing to hide, and no rule that reaches into a component.) */
|
|
2878
3132
|
.thinking-sizer {
|
|
2879
3133
|
visibility: hidden;
|
|
2880
3134
|
}
|
|
@@ -2974,36 +3228,6 @@
|
|
|
2974
3228
|
}
|
|
2975
3229
|
}
|
|
2976
3230
|
|
|
2977
|
-
/* "Upgrade" under a failure about the plan or the credits: a plain button, because the failure itself is already said above it. */
|
|
2978
|
-
.wc-upgrade-row {
|
|
2979
|
-
margin-top: 4px;
|
|
2980
|
-
}
|
|
2981
|
-
|
|
2982
|
-
.wc-upgrade-btn {
|
|
2983
|
-
display: inline-flex;
|
|
2984
|
-
align-items: center;
|
|
2985
|
-
padding: 4px 12px;
|
|
2986
|
-
background: #ffffff;
|
|
2987
|
-
color: #111827;
|
|
2988
|
-
border: 1px solid #d1d5db;
|
|
2989
|
-
border-radius: 8px;
|
|
2990
|
-
font-size: 12px;
|
|
2991
|
-
font-weight: 500;
|
|
2992
|
-
cursor: pointer;
|
|
2993
|
-
white-space: nowrap;
|
|
2994
|
-
transition: background-color 0.15s ease, border-color 0.15s ease;
|
|
2995
|
-
}
|
|
2996
|
-
|
|
2997
|
-
.wc-upgrade-btn:hover {
|
|
2998
|
-
background: #f3f4f6;
|
|
2999
|
-
border-color: #9ca3af;
|
|
3000
|
-
}
|
|
3001
|
-
|
|
3002
|
-
.wc-upgrade-btn:focus-visible {
|
|
3003
|
-
outline: 2px solid #93c5fd;
|
|
3004
|
-
outline-offset: 1px;
|
|
3005
|
-
}
|
|
3006
|
-
|
|
3007
3231
|
/* Clarification-card suggestion chips — tap to send as the next user message */
|
|
3008
3232
|
.clarification-chip {
|
|
3009
3233
|
display: inline-flex;
|