@widgetic/chat 0.1.11 → 0.1.14
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 +85 -0
- package/dist/components/AttachmentDisplay.svelte +11 -2
- package/dist/components/Chat.svelte +97 -22
- package/dist/components/Chat.svelte.d.ts +25 -5
- package/dist/components/ChatMessages.svelte +335 -55
- package/dist/components/ChatMessages.svelte.d.ts +16 -1
- package/dist/types/message.d.ts +19 -0
- package/package.json +8 -4
package/README.md
CHANGED
|
@@ -403,6 +403,91 @@ import type {
|
|
|
403
403
|
|
|
404
404
|
## Development
|
|
405
405
|
|
|
406
|
+
### Sibling packages
|
|
407
|
+
|
|
408
|
+
This app compiles sibling `@widgetic/*` source in dev through the dev-alias
|
|
409
|
+
setup `@widgetic/dev-tools` owns. The alias tables, the `$lib` remap, and
|
|
410
|
+
everything else the mapping needs come from the installed
|
|
411
|
+
`@widgetic/dev-tools` dependency. An ordinary `npm install` is the whole
|
|
412
|
+
setup — there is no linking step.
|
|
413
|
+
|
|
414
|
+
The why and the silent-degrade failure mode live in
|
|
415
|
+
[the dev-tools README](../dev-tools/README.md).
|
|
416
|
+
|
|
417
|
+
## Publishing
|
|
418
|
+
|
|
419
|
+
Publishing starts here: `npm run package` builds the `dist/` directory that
|
|
420
|
+
is the only content the published tarball ships. Linked consumers keep
|
|
421
|
+
resolving this checkout’s files until the release lands, so a change is not
|
|
422
|
+
real for anyone else until it publishes. After publishing, each consumer
|
|
423
|
+
package bumps its dependency to the new version and refreshes its lockfile
|
|
424
|
+
with `npm install`, so `npm ci` resolves the release from the registry. A
|
|
425
|
+
consumer that skips the lockfile refresh keeps resolving the old version, so
|
|
426
|
+
the version bump and the lockfile refresh land as one commit.
|
|
427
|
+
|
|
428
|
+
#### Local development
|
|
429
|
+
|
|
430
|
+
```bash
|
|
431
|
+
npm run i
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
Installs dependencies and runs `npm run lps` first, which links the sibling
|
|
435
|
+
`@widgetic/*` checkouts (`dev-tools`, `api-sdk`, `design-system`) into
|
|
436
|
+
`node_modules`. `dev` and `package:watch` re-run the link script
|
|
437
|
+
automatically, and `npm run lps:check` verifies the links are healthy.
|
|
438
|
+
|
|
439
|
+
```bash
|
|
440
|
+
npm run dev
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
Starts Vite in development mode (`dev-sv`) and opens the app in a new
|
|
444
|
+
browser tab. This is the SvelteKit app wrapper around the library — for
|
|
445
|
+
consuming `@widgetic/chat` in another project, see Installation above.
|
|
446
|
+
|
|
447
|
+
#### Checks
|
|
448
|
+
|
|
449
|
+
```bash
|
|
450
|
+
npm run check # svelte-kit sync + svelte-check
|
|
451
|
+
npm run lint # prettier --check + eslint
|
|
452
|
+
npm run format # prettier --write
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
#### Building the library output
|
|
456
|
+
|
|
457
|
+
`npm run package` (svelte-package) emits `dist/` — the published package
|
|
458
|
+
shape the manifest promises
|
|
459
|
+
(`dist/{index,components,stores,services,types}/index.{js,d.ts}`), which
|
|
460
|
+
the link-doctor verifies exist. `npm run package:watch` re-emits on every
|
|
461
|
+
source edit; `npm run build` builds the demo app itself.
|
|
462
|
+
|
|
463
|
+
#### The link script (`npm run lps`)
|
|
464
|
+
|
|
465
|
+
`dev` and `package:watch` run `scripts/link-siblings.mjs` first, which keeps
|
|
466
|
+
the `node_modules/@widgetic/*` symlinks pointing at the sibling checkouts
|
|
467
|
+
(`dev-tools`, `api-sdk`, `design-system`). It is idempotent, repairs stale
|
|
468
|
+
links, and skips a sibling whose checkout is absent — so it is safe on every
|
|
469
|
+
machine and after every fresh install (`npm i` prunes unowned links).
|
|
470
|
+
`npm run lps:check` prints the link table for verification.
|
|
471
|
+
|
|
472
|
+
#### Publishing and the consumers
|
|
473
|
+
|
|
474
|
+
`@widgetic/chat` is consumed by the creator (dev source aliases plus
|
|
475
|
+
`node_modules/@widgetic/chat` for type-check and any non-aliased session) and
|
|
476
|
+
by the site. The published tarball is the contract for both, so before
|
|
477
|
+
depending on a new version elsewhere:
|
|
478
|
+
|
|
479
|
+
```sh
|
|
480
|
+
npm run lps:check # sibling links healthy
|
|
481
|
+
npm run package # dist/ is fresh — svelte-package output
|
|
482
|
+
npm publish
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
For iterating on chat features against the creator without publishing, run
|
|
486
|
+
`npm run package:watch` here and keep the creator's
|
|
487
|
+
`node_modules/@widgetic/chat` linked to this checkout — every saved edit
|
|
488
|
+
lands in the creator's installed package within seconds, no manual dist
|
|
489
|
+
copying. The same workflow generalizes to the other `@widgetic/*` siblings.
|
|
490
|
+
|
|
406
491
|
### Building
|
|
407
492
|
|
|
408
493
|
```bash
|
|
@@ -19,6 +19,15 @@
|
|
|
19
19
|
onRemove,
|
|
20
20
|
onView
|
|
21
21
|
}: Props = $props();
|
|
22
|
+
|
|
23
|
+
function portalToBody(node: HTMLElement) {
|
|
24
|
+
document.body.appendChild(node);
|
|
25
|
+
return {
|
|
26
|
+
destroy() {
|
|
27
|
+
node.remove();
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
22
31
|
|
|
23
32
|
// Helper functions
|
|
24
33
|
function getFileIcon(fileType: string): string {
|
|
@@ -246,7 +255,7 @@
|
|
|
246
255
|
{#if lightboxAttachment}
|
|
247
256
|
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
248
257
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
249
|
-
<div class="lightbox-overlay" onclick={closeLightbox}>
|
|
258
|
+
<div class="lightbox-overlay" use:portalToBody onclick={closeLightbox}>
|
|
250
259
|
<button class="lightbox-close" onclick={closeLightbox} title="Close">✕</button>
|
|
251
260
|
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
252
261
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
@@ -494,7 +503,7 @@
|
|
|
494
503
|
.lightbox-overlay {
|
|
495
504
|
position: fixed;
|
|
496
505
|
inset: 0;
|
|
497
|
-
z-index:
|
|
506
|
+
z-index: 100000;
|
|
498
507
|
display: flex;
|
|
499
508
|
align-items: center;
|
|
500
509
|
justify-content: center;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { createChatService } from '../services/chatService.js';
|
|
5
5
|
import { setLogsEnabled, chatLog, chatWarn } from '../utils/logger.js';
|
|
6
6
|
import type { ChatConfig, ChatContext } from '../types/index.js';
|
|
7
|
+
import type { ClarificationSuggestion } from '../types/message.js';
|
|
7
8
|
import type { AttachmentInput } from '../types/attachment.js';
|
|
8
9
|
import ChatMessages from './ChatMessages.svelte';
|
|
9
10
|
import ChatInput from './ChatInput.svelte';
|
|
@@ -22,7 +23,10 @@
|
|
|
22
23
|
onChatReady?: (chatMethods: ChatMethods) => void;
|
|
23
24
|
onCompletionToggle?: (detail?: { conversationId: string | null; completed: boolean }) => void;
|
|
24
25
|
/** When provided, called instead of the built-in mock service for sending messages.
|
|
25
|
-
* The parent handles the actual API call and can push assistant messages via addAssistantMessage.
|
|
26
|
+
* The parent handles the actual API call and can push assistant messages via addAssistantMessage.
|
|
27
|
+
* `options` carries per-send modifiers — e.g. `skipIntentGate: true` plus the tapped chip's
|
|
28
|
+
* `chipIntent` when the send is an explicit override of a clarification card (see
|
|
29
|
+
* handleClarificationSuggestionSelected). */
|
|
26
30
|
onSendMessage?: (
|
|
27
31
|
content: string,
|
|
28
32
|
attachments?: Array<{
|
|
@@ -33,6 +37,7 @@
|
|
|
33
37
|
fileName: string;
|
|
34
38
|
fileSize?: number;
|
|
35
39
|
}>,
|
|
40
|
+
options?: { skipIntentGate?: boolean; chipIntent?: ClarificationSuggestion['intent'] },
|
|
36
41
|
) => Promise<void>;
|
|
37
42
|
/** Backend integration callbacks — when provided, replace mock chatService methods */
|
|
38
43
|
onLoadConversations?: (contextId: string) => Promise<any[] | null>;
|
|
@@ -43,6 +48,7 @@
|
|
|
43
48
|
content: string,
|
|
44
49
|
messageType: string,
|
|
45
50
|
attachments?: Array<{ url?: string; file?: File; file_type?: string; file_name?: string | null; file_size?: number | null; display_order?: number }>,
|
|
51
|
+
suggestions?: ClarificationSuggestion[],
|
|
46
52
|
) => Promise<any>;
|
|
47
53
|
onRestoreCheckpointBackend?: (conversationId: string, checkpointMessageId: string) => Promise<any>;
|
|
48
54
|
onTakeScreenshot?: () => Promise<string | null>;
|
|
@@ -84,6 +90,16 @@
|
|
|
84
90
|
* still appears when assistant commit bubbles were never persisted.
|
|
85
91
|
*/
|
|
86
92
|
widgetHeadCommitSha?: string | null;
|
|
93
|
+
/**
|
|
94
|
+
* Short commit sha → human version label ("Version 4"). The host owns the
|
|
95
|
+
* mapping (it knows the widget's versions); the chat only renders it, so a
|
|
96
|
+
* turn reads as the version it produced instead of a commit hash.
|
|
97
|
+
*/
|
|
98
|
+
versionLabelByCommitSha?: Record<string, string>;
|
|
99
|
+
/** User prompt text → "Version N", when the turn has no commit line. */
|
|
100
|
+
versionLabelByPrompt?: Record<string, string>;
|
|
101
|
+
/** Version selected in the dropdown. You-are-here follows this number. */
|
|
102
|
+
viewingVersion?: number | null;
|
|
87
103
|
/** Host is running widget codegen — send button becomes stop. */
|
|
88
104
|
isGenerating?: boolean;
|
|
89
105
|
onStopGeneration?: () => void;
|
|
@@ -91,8 +107,8 @@
|
|
|
91
107
|
|
|
92
108
|
// Expose methods to parent component
|
|
93
109
|
interface ChatMethods {
|
|
94
|
-
sendMessage: (content: string, attachments?: Array<File | AttachmentInput
|
|
95
|
-
addAssistantMessage: (content: string, skipPersist?: boolean) => void;
|
|
110
|
+
sendMessage: (content: string, attachments?: Array<File | AttachmentInput>, options?: { skipIntentGate?: boolean; chipIntent?: ClarificationSuggestion['intent'] }) => Promise<void>;
|
|
111
|
+
addAssistantMessage: (content: string, skipPersist?: boolean, suggestions?: ClarificationSuggestion[]) => void;
|
|
96
112
|
addUserMessage: (content: string, attachments?: Array<{ id: string; url: string; file_type: string; file_name: string; file_size?: number }>) => void;
|
|
97
113
|
/** Returns the current conversation ID (null if no conversation is active). */
|
|
98
114
|
getConversationId: () => string | null;
|
|
@@ -124,12 +140,15 @@
|
|
|
124
140
|
updateLastUserMessageAttachments: (attachments: Array<{ id?: string; url: string; file_type?: string; file_name?: string | null }>) => void;
|
|
125
141
|
}
|
|
126
142
|
|
|
127
|
-
let { context, config = {}, class: className = '', style = '', isCompleted = false, onStatsUpdate, onChatReady, onCompletionToggle, onSendMessage, onLoadConversations, onLoadMessages, onCreateConversation, onSaveMessage, onRestoreCheckpointBackend, onTakeScreenshot, onConversationChange, onDraftChange, onRetryMessage, onUploadChatFile, showHeader = true, headerTitle = '', showDescriptionHeader = true, showLogs = true, resizeExpandsContainer = false, onMessagesResize, widgetHeadCommitSha = null, isGenerating = false, onStopGeneration }: Props = $props();
|
|
143
|
+
let { context, config = {}, class: className = '', style = '', isCompleted = false, onStatsUpdate, onChatReady, onCompletionToggle, onSendMessage, onLoadConversations, onLoadMessages, onCreateConversation, onSaveMessage, onRestoreCheckpointBackend, onTakeScreenshot, onConversationChange, onDraftChange, onRetryMessage, onUploadChatFile, showHeader = true, headerTitle = '', showDescriptionHeader = true, showLogs = true, resizeExpandsContainer = false, onMessagesResize, widgetHeadCommitSha = null, versionLabelByCommitSha = {}, versionLabelByPrompt = {}, viewingVersion = null, isGenerating = false, onStopGeneration }: Props = $props();
|
|
128
144
|
|
|
129
145
|
function notifyDraftChange() {
|
|
130
146
|
onDraftChange?.();
|
|
131
147
|
}
|
|
132
148
|
|
|
149
|
+
const promptVersionLabels = $derived(versionLabelByPrompt ?? {});
|
|
150
|
+
const selectedViewingVersion = $derived(viewingVersion ?? null);
|
|
151
|
+
|
|
133
152
|
// Apply log suppression immediately
|
|
134
153
|
$effect(() => {
|
|
135
154
|
setLogsEnabled(showLogs);
|
|
@@ -402,7 +421,7 @@
|
|
|
402
421
|
}
|
|
403
422
|
}
|
|
404
423
|
|
|
405
|
-
async function sendMessage(content: string, attachments?: Array<File | AttachmentInput
|
|
424
|
+
async function sendMessage(content: string, attachments?: Array<File | AttachmentInput>, options?: { skipIntentGate?: boolean; chipIntent?: ClarificationSuggestion['intent'] }) {
|
|
406
425
|
if (!currentConversationId) {
|
|
407
426
|
if (initializePromise) {
|
|
408
427
|
try {
|
|
@@ -491,7 +510,7 @@
|
|
|
491
510
|
activeConversationId,
|
|
492
511
|
submittedContent,
|
|
493
512
|
'user',
|
|
494
|
-
persistAttachments.length > 0 ? persistAttachments :
|
|
513
|
+
persistAttachments.length > 0 ? persistAttachments : undefined,
|
|
495
514
|
);
|
|
496
515
|
if (saved?.id && saved.id !== userMessage.id) {
|
|
497
516
|
chatStore.actions.updateMessageId(activeConversationId, userMessage.id, saved.id);
|
|
@@ -515,7 +534,7 @@
|
|
|
515
534
|
fileName: att.file?.name || 'attachment',
|
|
516
535
|
fileSize: att.file?.size,
|
|
517
536
|
}));
|
|
518
|
-
await onSendMessage(submittedContent, outgoing.length > 0 ? outgoing : undefined);
|
|
537
|
+
await onSendMessage(submittedContent, outgoing.length > 0 ? outgoing : undefined, options);
|
|
519
538
|
} else {
|
|
520
539
|
const aiResponse = await chatService.processAIResponse(activeConversationId, userMessage);
|
|
521
540
|
chatStore.actions.addMessage(activeConversationId, aiResponse);
|
|
@@ -534,7 +553,7 @@
|
|
|
534
553
|
/** Add an assistant message to the current conversation (called by parent via chatMethods).
|
|
535
554
|
* When skipPersist is true, the message is shown locally but not saved to DB
|
|
536
555
|
* (use when the backend already persists its own version). */
|
|
537
|
-
function addAssistantMessage(content: string, skipPersist = false) {
|
|
556
|
+
function addAssistantMessage(content: string, skipPersist = false, suggestions?: ClarificationSuggestion[]) {
|
|
538
557
|
if (!currentConversationId) return;
|
|
539
558
|
const assistantMsg = {
|
|
540
559
|
id: `assistant_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
|
|
@@ -548,7 +567,8 @@
|
|
|
548
567
|
updatedAt: new Date(),
|
|
549
568
|
_optimistic: false,
|
|
550
569
|
_failed: false,
|
|
551
|
-
_retryCount: 0
|
|
570
|
+
_retryCount: 0,
|
|
571
|
+
...(suggestions && suggestions.length > 0 ? { suggestions } : {})
|
|
552
572
|
};
|
|
553
573
|
chatStore.actions.addMessage(currentConversationId, assistantMsg);
|
|
554
574
|
|
|
@@ -560,7 +580,12 @@
|
|
|
560
580
|
|
|
561
581
|
if (onSaveMessage && !skipPersist) {
|
|
562
582
|
const convId = currentConversationId;
|
|
563
|
-
|
|
583
|
+
// Suggestions ride the same write as the reply, so the clarification
|
|
584
|
+
// card — chips included — survives a reload. The server-side gated-turn
|
|
585
|
+
// persistence (intent gate) already saved this turn when it served the
|
|
586
|
+
// card; this write is the client-driven path (local-only conversations,
|
|
587
|
+
// hosts without the gate) and lands with the same shape either way.
|
|
588
|
+
onSaveMessage(convId, content, 'assistant', undefined, suggestions).then(saved => {
|
|
564
589
|
if (saved?.id && saved.id !== assistantMsg.id) {
|
|
565
590
|
chatStore.actions.updateMessageId(convId, assistantMsg.id, saved.id);
|
|
566
591
|
}
|
|
@@ -916,6 +941,41 @@
|
|
|
916
941
|
setDraftText(suggestion);
|
|
917
942
|
}
|
|
918
943
|
|
|
944
|
+
/** Tapping a suggestion chip attached to an assistant clarification card sends it
|
|
945
|
+
* as the next user message. These suggestions resolve an ambiguity the intent
|
|
946
|
+
* gate already detected server-side, so each is a complete, valid ask — the
|
|
947
|
+
* card exists precisely to save the user from retyping it. Generic
|
|
948
|
+
* SuggestionButtons (empty state) keep their autocomplete behavior instead.
|
|
949
|
+
*
|
|
950
|
+
* Chips are structured objects ({ label, intent }): the label is display copy
|
|
951
|
+
* rendered verbatim, the intent is machine-readable behavior. The "generate
|
|
952
|
+
* anyway" chip is the card's escape hatch — identified by
|
|
953
|
+
* `intent === 'generate_anyway'`, never by matching its text — and re-sends
|
|
954
|
+
* with `skipIntentGate: true` (the server's own JSDoc for that flag says "set
|
|
955
|
+
* when the user explicitly chose to generate anyway after a gated response",
|
|
956
|
+
* and a chip tap is exactly that choice). Without the flag the server's
|
|
957
|
+
* verdict cache would re-serve the same card for the same message and the
|
|
958
|
+
* chip could never escape it. The refine chips send normally — they are new
|
|
959
|
+
* asks, and an ask that is still ambiguous should get the card again. The
|
|
960
|
+
* chip's intent rides the request as `chipIntent` so the server measures the
|
|
961
|
+
* conversion from the client's declaration instead of matching copy. */
|
|
962
|
+
async function handleClarificationSuggestionSelected(suggestion: ClarificationSuggestion) {
|
|
963
|
+
const trimmed = suggestion.label.trim();
|
|
964
|
+
if (!trimmed) return;
|
|
965
|
+
if (isGenerating || localIsSending || isSendingOrLoading) return;
|
|
966
|
+
try {
|
|
967
|
+
await sendMessage(trimmed, undefined, {
|
|
968
|
+
skipIntentGate: suggestion.intent === 'generate_anyway',
|
|
969
|
+
chipIntent: suggestion.intent,
|
|
970
|
+
});
|
|
971
|
+
} catch (err) {
|
|
972
|
+
console.error('[Chat] Clarification suggestion send failed:', err);
|
|
973
|
+
chatStore.actions.updateUI({
|
|
974
|
+
errorMessage: 'Failed to send the selected suggestion. Please try again.'
|
|
975
|
+
});
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
|
|
919
979
|
async function handleRetryMessage(content: string) {
|
|
920
980
|
const retryContent = content.trim();
|
|
921
981
|
if (!retryContent) return;
|
|
@@ -927,6 +987,16 @@
|
|
|
927
987
|
await sendMessage(retryContent);
|
|
928
988
|
}
|
|
929
989
|
|
|
990
|
+
function versionLabelForCommitContent(content?: string | null): string | null {
|
|
991
|
+
const match = String(content || '').match(/(?:Commit:?\s+|commit\s+id:\s+|Code saved\s*\()([a-f0-9]{7,40})/i);
|
|
992
|
+
const sha = match?.[1]?.toLowerCase();
|
|
993
|
+
if (!sha) return null;
|
|
994
|
+
return versionLabelByCommitSha[sha]
|
|
995
|
+
?? versionLabelByCommitSha[sha.slice(0, 8)]
|
|
996
|
+
?? versionLabelByCommitSha[sha.slice(0, 7)]
|
|
997
|
+
?? null;
|
|
998
|
+
}
|
|
999
|
+
|
|
930
1000
|
async function handleRestoreCheckpoint(messageId: string, messageIndex: number) {
|
|
931
1001
|
// chatLog('Restore checkpoint requested:', { messageId, messageIndex, conversationId: currentConversationId });
|
|
932
1002
|
|
|
@@ -969,21 +1039,19 @@
|
|
|
969
1039
|
}
|
|
970
1040
|
}
|
|
971
1041
|
|
|
972
|
-
const
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
}));
|
|
977
|
-
|
|
978
|
-
// chatLog(`Restoring to checkpoint user message ${checkpointUserId}, head assistant ${headAssistantId}`);
|
|
979
|
-
chatStore.actions.setMessages(currentConversationId, updatedMessages);
|
|
1042
|
+
const checkpointUser = currentMessages.find((msg: any) => msg.id === checkpointUserId);
|
|
1043
|
+
const headAssistant = currentMessages.find((msg: any) => msg.id === headAssistantId);
|
|
1044
|
+
const sourceLabel = versionLabelForCommitContent(headAssistant?.messageContent) || 'a previous version';
|
|
1045
|
+
const promptCopy = String(checkpointUser?.messageContent || '').trim();
|
|
980
1046
|
|
|
981
1047
|
if (onRestoreCheckpointBackend) {
|
|
982
1048
|
try {
|
|
983
1049
|
const result = await onRestoreCheckpointBackend(currentConversationId, checkpointUserId);
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
1050
|
+
const rollback = result?.gitRollback || result?.git_rollback || result?.data?.gitRollback || result?.data?.git_rollback;
|
|
1051
|
+
const newSha = String(rollback?.commitId || rollback?.commit_id || '').trim();
|
|
1052
|
+
if (rollback?.success && newSha && promptCopy) {
|
|
1053
|
+
addUserMessage(promptCopy);
|
|
1054
|
+
addAssistantMessage(`Restored from ${sourceLabel}\n\nCommit: ${newSha.slice(0, 8)}`);
|
|
987
1055
|
}
|
|
988
1056
|
} catch (backendError) {
|
|
989
1057
|
console.error('[Chat] Backend checkpoint restore failed, local state updated:', backendError);
|
|
@@ -1120,6 +1188,7 @@
|
|
|
1120
1188
|
/^Code generation completed/i.test(trimmed) ||
|
|
1121
1189
|
/^Compile fix applied/i.test(trimmed) ||
|
|
1122
1190
|
/^Code saved/i.test(trimmed) ||
|
|
1191
|
+
/^Restored from /i.test(trimmed) ||
|
|
1123
1192
|
isBackendCodegenSummary(trimmed)
|
|
1124
1193
|
)) {
|
|
1125
1194
|
return true;
|
|
@@ -1198,7 +1267,9 @@
|
|
|
1198
1267
|
// chatLog('[Chat] Widget HEAD marked on message:', headId);
|
|
1199
1268
|
}
|
|
1200
1269
|
|
|
1201
|
-
|
|
1270
|
+
// Terminal codegen status lines: the normal completion and the semantic-cache
|
|
1271
|
+
// "already done" affordance. Both are turn-deduped status bubbles.
|
|
1272
|
+
const CODEGEN_STATUS_MESSAGE_REGEX = /^(Code generation completed|Already done)/i;
|
|
1202
1273
|
|
|
1203
1274
|
function isCodegenStatusMessage(content?: string | null): boolean {
|
|
1204
1275
|
return CODEGEN_STATUS_MESSAGE_REGEX.test((content || '').trim());
|
|
@@ -1550,11 +1621,15 @@
|
|
|
1550
1621
|
enableAutoCodeDetection={config?.features?.autoCodeDetection === true}
|
|
1551
1622
|
showGenerationSummaries={config?.features?.showGenerationSummaries === true}
|
|
1552
1623
|
widgetHeadCommitSha={widgetHeadCommitSha}
|
|
1624
|
+
versionLabelByCommitSha={versionLabelByCommitSha}
|
|
1625
|
+
versionLabelByPrompt={promptVersionLabels}
|
|
1626
|
+
viewingVersion={selectedViewingVersion}
|
|
1553
1627
|
showCommitMeta={showLogs}
|
|
1554
1628
|
isGenerating={isGenerating || isLoading}
|
|
1555
1629
|
onSuggestionSelected={handleSuggestionSelected}
|
|
1556
1630
|
onRestoreCheckpoint={handleRestoreCheckpoint}
|
|
1557
1631
|
onRetryMessage={handleRetryMessage}
|
|
1632
|
+
onClarificationSuggestionSelected={handleClarificationSuggestionSelected}
|
|
1558
1633
|
/>
|
|
1559
1634
|
</div>
|
|
1560
1635
|
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import type { ChatConfig, ChatContext } from '../types/index.js';
|
|
2
|
+
import type { ClarificationSuggestion } from '../types/message.js';
|
|
2
3
|
import type { AttachmentInput } from '../types/attachment.js';
|
|
3
4
|
interface ChatMethods {
|
|
4
|
-
sendMessage: (content: string, attachments?: Array<File | AttachmentInput
|
|
5
|
-
|
|
5
|
+
sendMessage: (content: string, attachments?: Array<File | AttachmentInput>, options?: {
|
|
6
|
+
skipIntentGate?: boolean;
|
|
7
|
+
chipIntent?: ClarificationSuggestion['intent'];
|
|
8
|
+
}) => Promise<void>;
|
|
9
|
+
addAssistantMessage: (content: string, skipPersist?: boolean, suggestions?: ClarificationSuggestion[]) => void;
|
|
6
10
|
addUserMessage: (content: string, attachments?: Array<{
|
|
7
11
|
id: string;
|
|
8
12
|
url: string;
|
|
@@ -58,7 +62,10 @@ interface Props {
|
|
|
58
62
|
completed: boolean;
|
|
59
63
|
}) => void;
|
|
60
64
|
/** When provided, called instead of the built-in mock service for sending messages.
|
|
61
|
-
* The parent handles the actual API call and can push assistant messages via addAssistantMessage.
|
|
65
|
+
* The parent handles the actual API call and can push assistant messages via addAssistantMessage.
|
|
66
|
+
* `options` carries per-send modifiers — e.g. `skipIntentGate: true` plus the tapped chip's
|
|
67
|
+
* `chipIntent` when the send is an explicit override of a clarification card (see
|
|
68
|
+
* handleClarificationSuggestionSelected). */
|
|
62
69
|
onSendMessage?: (content: string, attachments?: Array<{
|
|
63
70
|
file?: File;
|
|
64
71
|
url?: string;
|
|
@@ -66,7 +73,10 @@ interface Props {
|
|
|
66
73
|
fileType: string;
|
|
67
74
|
fileName: string;
|
|
68
75
|
fileSize?: number;
|
|
69
|
-
}
|
|
76
|
+
}>, options?: {
|
|
77
|
+
skipIntentGate?: boolean;
|
|
78
|
+
chipIntent?: ClarificationSuggestion['intent'];
|
|
79
|
+
}) => Promise<void>;
|
|
70
80
|
/** Backend integration callbacks — when provided, replace mock chatService methods */
|
|
71
81
|
onLoadConversations?: (contextId: string) => Promise<any[] | null>;
|
|
72
82
|
onLoadMessages?: (conversationId: string) => Promise<any[]>;
|
|
@@ -78,7 +88,7 @@ interface Props {
|
|
|
78
88
|
file_name?: string | null;
|
|
79
89
|
file_size?: number | null;
|
|
80
90
|
display_order?: number;
|
|
81
|
-
}
|
|
91
|
+
}>, suggestions?: ClarificationSuggestion[]) => Promise<any>;
|
|
82
92
|
onRestoreCheckpointBackend?: (conversationId: string, checkpointMessageId: string) => Promise<any>;
|
|
83
93
|
onTakeScreenshot?: () => Promise<string | null>;
|
|
84
94
|
/** Fires whenever the active conversation ID changes (including initial null → uuid). */
|
|
@@ -125,6 +135,16 @@ interface Props {
|
|
|
125
135
|
* still appears when assistant commit bubbles were never persisted.
|
|
126
136
|
*/
|
|
127
137
|
widgetHeadCommitSha?: string | null;
|
|
138
|
+
/**
|
|
139
|
+
* Short commit sha → human version label ("Version 4"). The host owns the
|
|
140
|
+
* mapping (it knows the widget's versions); the chat only renders it, so a
|
|
141
|
+
* turn reads as the version it produced instead of a commit hash.
|
|
142
|
+
*/
|
|
143
|
+
versionLabelByCommitSha?: Record<string, string>;
|
|
144
|
+
/** User prompt text → "Version N", when the turn has no commit line. */
|
|
145
|
+
versionLabelByPrompt?: Record<string, string>;
|
|
146
|
+
/** Version selected in the dropdown. You-are-here follows this number. */
|
|
147
|
+
viewingVersion?: number | null;
|
|
128
148
|
/** Host is running widget codegen — send button becomes stop. */
|
|
129
149
|
isGenerating?: boolean;
|
|
130
150
|
onStopGeneration?: () => void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { ChatMessage, ChatContext } from '../types/index.js';
|
|
3
|
+
import type { ClarificationSuggestion } from '../types/message.js';
|
|
3
4
|
import { MESSAGE_COLORS } from '../constants/colors.js';
|
|
4
5
|
import { chatLog } from '../utils/logger.js';
|
|
5
6
|
import { AttachmentDisplay, SuggestionButtons } from './index.js';
|
|
@@ -32,13 +33,27 @@
|
|
|
32
33
|
showGenerationSummaries?: boolean;
|
|
33
34
|
/** Host widget HEAD sha — Head chrome when assistant commit bubbles are missing. */
|
|
34
35
|
widgetHeadCommitSha?: string | null;
|
|
35
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Short commit sha → human version label ("Version 4"), supplied by the host.
|
|
38
|
+
* A commit hash means nothing to someone who is not a developer, so the turn
|
|
39
|
+
* is labelled with the version it produced and the hash is debug-only.
|
|
40
|
+
*/
|
|
41
|
+
versionLabelByCommitSha?: Record<string, string>;
|
|
42
|
+
/** User prompt text → "Version N", for turns that never saved a commit line. */
|
|
43
|
+
versionLabelByPrompt?: Record<string, string>;
|
|
44
|
+
/** Dropdown selection. The badge follows this version, not only a commit sha. */
|
|
45
|
+
viewingVersion?: number | null;
|
|
46
|
+
/** When false, hide commit hashes next to the version label (user mode). */
|
|
36
47
|
showCommitMeta?: boolean;
|
|
37
48
|
/** True while codegen / send is in flight — suppresses premature Retry. */
|
|
38
49
|
isGenerating?: boolean;
|
|
39
50
|
onSuggestionSelected?: (suggestion: string) => void;
|
|
40
51
|
onRestoreCheckpoint?: (messageId: string, messageIndex: number) => void;
|
|
41
52
|
onRetryMessage?: (content: string) => void;
|
|
53
|
+
/** Tapping a clarification-card suggestion chip sends it as the next user message,
|
|
54
|
+
* carrying the chip's structured intent. Chips are disabled while the host
|
|
55
|
+
* runs widget codegen (`isGenerating`). */
|
|
56
|
+
onClarificationSuggestionSelected?: (suggestion: ClarificationSuggestion) => void;
|
|
42
57
|
}
|
|
43
58
|
|
|
44
59
|
let {
|
|
@@ -51,11 +66,15 @@
|
|
|
51
66
|
enableAutoCodeDetection = false,
|
|
52
67
|
showGenerationSummaries = false,
|
|
53
68
|
widgetHeadCommitSha = null,
|
|
69
|
+
versionLabelByCommitSha = {},
|
|
70
|
+
versionLabelByPrompt = {},
|
|
71
|
+
viewingVersion = null,
|
|
54
72
|
showCommitMeta = true,
|
|
55
73
|
isGenerating = false,
|
|
56
74
|
onSuggestionSelected,
|
|
57
75
|
onRestoreCheckpoint,
|
|
58
76
|
onRetryMessage,
|
|
77
|
+
onClarificationSuggestionSelected,
|
|
59
78
|
}: Props = $props();
|
|
60
79
|
|
|
61
80
|
let messagesHasScrollbar = $state(false);
|
|
@@ -142,7 +161,7 @@
|
|
|
142
161
|
}
|
|
143
162
|
|
|
144
163
|
function extractCommitFromContent(content: string): string | null {
|
|
145
|
-
const match = content.match(/(?:Commit:?\s+|\n\nCommit\s+|\(commit\s+|Code saved\s*\()([a-f0-9]{7,40})/i);
|
|
164
|
+
const match = content.match(/(?:Commit:?\s+|commit\s+id:\s+|\n\nCommit\s+|\(commit\s+|Code saved\s*\()([a-f0-9]{7,40})/i);
|
|
146
165
|
return match?.[1]?.toLowerCase() ?? null;
|
|
147
166
|
}
|
|
148
167
|
|
|
@@ -168,9 +187,22 @@
|
|
|
168
187
|
if (/^Code saved/i.test(trimmed) && /(?:Commit:?\s+|Code saved\s*\()[a-f0-9]{7,40}/i.test(trimmed)) {
|
|
169
188
|
return true;
|
|
170
189
|
}
|
|
190
|
+
if (isRestoreForkContent(trimmed) && /Commit:?\s+[a-f0-9]{7,40}/i.test(trimmed)) {
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
171
193
|
return isBackendCodegenSummary(trimmed);
|
|
172
194
|
}
|
|
173
195
|
|
|
196
|
+
/** A copy appended after Restore. It names the new HEAD commit and does not replace the original turn. */
|
|
197
|
+
function isRestoreForkContent(content?: string | null): boolean {
|
|
198
|
+
return /^Restored from /i.test((content || '').trim());
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function restoreForkLabel(content?: string | null): string | null {
|
|
202
|
+
const line = (content || '').trim().split('\n')[0]?.trim() || '';
|
|
203
|
+
return /^Restored from /i.test(line) ? line : null;
|
|
204
|
+
}
|
|
205
|
+
|
|
174
206
|
function turnHasCodegenFailure(turn: ChatTurn): boolean {
|
|
175
207
|
return turn.replies.some(isCodegenFailure);
|
|
176
208
|
}
|
|
@@ -242,6 +274,28 @@
|
|
|
242
274
|
return head.startsWith(sha) || sha.startsWith(head.slice(0, 7));
|
|
243
275
|
}
|
|
244
276
|
|
|
277
|
+
/** True when some reply carries the host's current HEAD commit. */
|
|
278
|
+
function conversationMatchesHeadSha(): boolean {
|
|
279
|
+
if (!widgetHeadCommitSha) return false;
|
|
280
|
+
return chatTurns.some((turn) =>
|
|
281
|
+
turn.replies.some(
|
|
282
|
+
(r) =>
|
|
283
|
+
messageHasCommit(r)
|
|
284
|
+
&& !isCodegenFailure(r)
|
|
285
|
+
&& commitShaMatchesHead(r.messageContent || ''),
|
|
286
|
+
),
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Head resolution. When the host tells us its HEAD commit, that is the
|
|
292
|
+
* authority: the reply mentioning it is Head. But HEAD routinely moves to a
|
|
293
|
+
* commit no persisted reply mentions — a generation whose summary has not been
|
|
294
|
+
* reloaded yet, or a turn whose status bubble records an earlier commit — and
|
|
295
|
+
* matching on the sha alone then left every turn without Head chrome. In that
|
|
296
|
+
* case `getFallbackHeadReply` puts it on the latest turn instead, so the local
|
|
297
|
+
* `isWidgetHead` flag is only consulted when the host names no HEAD at all.
|
|
298
|
+
*/
|
|
245
299
|
function isHeadCommitReply(reply: ChatMessage): boolean {
|
|
246
300
|
if (!messageHasCommit(reply) || isCodegenFailure(reply)) return false;
|
|
247
301
|
if (widgetHeadCommitSha) return commitShaMatchesHead(reply.messageContent || '');
|
|
@@ -249,7 +303,10 @@
|
|
|
249
303
|
}
|
|
250
304
|
|
|
251
305
|
function turnHasWidgetHead(turn: ChatTurn): boolean {
|
|
252
|
-
|
|
306
|
+
if (turn.replies.some((r) => isHeadCommitReply(r))) return true;
|
|
307
|
+
// A synthesized Head reply is not in `replies`, so the turn highlight has to
|
|
308
|
+
// ask for it explicitly or the badge appears without its turn chrome.
|
|
309
|
+
return !!getFallbackHeadReply(turn);
|
|
253
310
|
}
|
|
254
311
|
|
|
255
312
|
function isCodegenFailure(message: ChatMessage): boolean {
|
|
@@ -266,6 +323,7 @@
|
|
|
266
323
|
}
|
|
267
324
|
|
|
268
325
|
function canRestoreToMessage(message: ChatMessage): boolean {
|
|
326
|
+
if (isRestoreForkContent(message.messageContent)) return false;
|
|
269
327
|
if (isHeadCommitReply(message)) return false;
|
|
270
328
|
if (!message.messageContent) return false;
|
|
271
329
|
const trimmed = message.messageContent.trim();
|
|
@@ -280,12 +338,93 @@
|
|
|
280
338
|
}
|
|
281
339
|
|
|
282
340
|
function extractCommitShort(content: string): string | null {
|
|
283
|
-
const match = content.match(/(?:Commit:?\s+|\n\nCommit\s+|Code saved\s*\()([a-f0-9]{7,40})/i);
|
|
341
|
+
const match = content.match(/(?:Commit:?\s+|commit\s+id:\s+|\n\nCommit\s+|Code saved\s*\()([a-f0-9]{7,40})/i);
|
|
284
342
|
return match?.[1]?.slice(0, 8) ?? null;
|
|
285
343
|
}
|
|
286
344
|
|
|
345
|
+
/**
|
|
346
|
+
* The reply this turn's commit chrome describes. The Head fallback wins over
|
|
347
|
+
* the turn's own commit reply: when it exists, HEAD is on a commit that reply
|
|
348
|
+
* does not name, so showing the reply would label the turn with a stale sha
|
|
349
|
+
* and drop the Head badge from the conversation entirely.
|
|
350
|
+
*/
|
|
351
|
+
function getTurnHeadOrCommitReply(turn: ChatTurn): ChatMessage | null {
|
|
352
|
+
return getFallbackHeadReply(turn) || getTurnCommitReply(turn);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/** The version this turn produced, when the host knows it. */
|
|
356
|
+
function versionLabelFromSha(turn: ChatTurn): string | null {
|
|
357
|
+
const forkLabel = restoreForkLabel(getTurnCommitReply(turn)?.messageContent);
|
|
358
|
+
if (forkLabel) return forkLabel;
|
|
359
|
+
const short = getTurnOwnCommitShort(turn) || getTurnCommitShort(turn);
|
|
360
|
+
if (!short) return null;
|
|
361
|
+
const key7 = short.slice(0, 7).toLowerCase();
|
|
362
|
+
const key8 = short.slice(0, 8).toLowerCase();
|
|
363
|
+
return versionLabelByCommitSha[key7]
|
|
364
|
+
?? versionLabelByCommitSha[key8]
|
|
365
|
+
?? versionLabelByCommitSha[short.toLowerCase()]
|
|
366
|
+
?? null;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function versionNumberFromLabel(label: string | null): number | null {
|
|
370
|
+
if (!label) return null;
|
|
371
|
+
const match = label.match(/Version\s+(\d+)/i);
|
|
372
|
+
return match ? Number(match[1]) : null;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
function getTurnVersionLabel(turn: ChatTurn): string | null {
|
|
376
|
+
const fromSha = versionLabelFromSha(turn);
|
|
377
|
+
if (fromSha) return fromSha;
|
|
378
|
+
const fromPrompt = versionLabelFromPrompt(turn);
|
|
379
|
+
if (fromPrompt) return fromPrompt;
|
|
380
|
+
if (turnHasCodegenFailure(turn)) return null;
|
|
381
|
+
if (!showCommitMetaOnUserTurn(turn)) return null;
|
|
382
|
+
const metaTurns = chatTurns.filter((candidate) =>
|
|
383
|
+
!!candidate.user
|
|
384
|
+
&& !turnHasCodegenFailure(candidate)
|
|
385
|
+
&& (!!getTurnHeadOrCommitReply(candidate) || canRestoreLegacyUserTurn(candidate)),
|
|
386
|
+
);
|
|
387
|
+
const numbered = metaTurns.map((candidate) => ({
|
|
388
|
+
turn: candidate,
|
|
389
|
+
n: versionNumberFromLabel(versionLabelFromSha(candidate)),
|
|
390
|
+
}));
|
|
391
|
+
const index = numbered.findIndex((row) => row.turn === turn);
|
|
392
|
+
if (index < 0) return null;
|
|
393
|
+
const prev = [...numbered.slice(0, index)].reverse().find((row) => row.n != null);
|
|
394
|
+
const next = numbered.slice(index + 1).find((row) => row.n != null);
|
|
395
|
+
if (prev?.n != null && next?.n != null && next.n - prev.n === 2) return `Version ${prev.n + 1}`;
|
|
396
|
+
if (prev?.n != null && next == null) return `Version ${prev.n + 1}`;
|
|
397
|
+
if (prev == null && next?.n != null && next.n > 1) return `Version ${next.n - 1}`;
|
|
398
|
+
return null;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/** Sha of the commit this turn itself produced — never the synthesized Head stand-in. */
|
|
402
|
+
function versionPromptKey(text: string | null | undefined): string {
|
|
403
|
+
return String(text || '').replace(/\s+/g, ' ').trim();
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
function versionLabelFromPrompt(turn: ChatTurn): string | null {
|
|
407
|
+
const key = versionPromptKey(turn.user?.messageContent);
|
|
408
|
+
if (!key) return null;
|
|
409
|
+
return versionLabelByPrompt[key] ?? null;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/** The dropdown's version, else the commit sha, decides which turn is current. */
|
|
413
|
+
function isViewingTurn(turn: ChatTurn): boolean {
|
|
414
|
+
if (viewingVersion != null) {
|
|
415
|
+
const versionNumber = versionNumberFromLabel(getTurnVersionLabel(turn));
|
|
416
|
+
if (versionNumber != null) return versionNumber === Number(viewingVersion);
|
|
417
|
+
}
|
|
418
|
+
const reply = getTurnHeadOrCommitReply(turn);
|
|
419
|
+
return !!(reply && isHeadCommitReply(reply));
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
function getTurnOwnCommitShort(turn: ChatTurn): string | null {
|
|
423
|
+
return extractCommitShort(getTurnCommitReply(turn)?.messageContent || '');
|
|
424
|
+
}
|
|
425
|
+
|
|
287
426
|
function getTurnCommitShort(turn: ChatTurn): string | null {
|
|
288
|
-
const commitReply =
|
|
427
|
+
const commitReply = getTurnHeadOrCommitReply(turn);
|
|
289
428
|
const fromReply = extractCommitShort(commitReply?.messageContent || '');
|
|
290
429
|
if (fromReply) return fromReply;
|
|
291
430
|
for (const reply of turn.replies) {
|
|
@@ -303,6 +442,22 @@
|
|
|
303
442
|
return null;
|
|
304
443
|
}
|
|
305
444
|
|
|
445
|
+
/**
|
|
446
|
+
* What this turn shipped, in the commit's own words — the title persisted
|
|
447
|
+
* beside `is_commit` ("feat: make the badge blue"). Read off the same reply
|
|
448
|
+
* the chrome's version label and sha come from, so the three always describe
|
|
449
|
+
* one commit: when HEAD has moved past every persisted reply, the chrome's
|
|
450
|
+
* commit reply is a synthesized stand-in with no title, and this returns
|
|
451
|
+
* null rather than an older commit's subject next to HEAD's sha.
|
|
452
|
+
*
|
|
453
|
+
* Rows written before title persistence carry none, so legacy turns simply
|
|
454
|
+
* render no title line.
|
|
455
|
+
*/
|
|
456
|
+
function getTurnCommitTitle(turn: ChatTurn): string | null {
|
|
457
|
+
const title = getTurnHeadOrCommitReply(turn)?.commitTitle?.trim();
|
|
458
|
+
return title || null;
|
|
459
|
+
}
|
|
460
|
+
|
|
306
461
|
function conversationHasCommitReply(): boolean {
|
|
307
462
|
return chatTurns.some((t) => !!getTurnCommitReply(t));
|
|
308
463
|
}
|
|
@@ -314,12 +469,21 @@
|
|
|
314
469
|
return false;
|
|
315
470
|
}
|
|
316
471
|
|
|
317
|
-
/**
|
|
472
|
+
/**
|
|
473
|
+
* Head chrome for the latest turn when no persisted reply carries HEAD: the
|
|
474
|
+
* history holds only user prompts, the generation summary has not been
|
|
475
|
+
* reloaded yet, or the turn's own status bubble records an earlier commit
|
|
476
|
+
* than the one the widget now sits on.
|
|
477
|
+
*/
|
|
318
478
|
function getFallbackHeadReply(turn: ChatTurn): ChatMessage | null {
|
|
479
|
+
// Only while a generation is in flight, before its commit summary is saved.
|
|
480
|
+
// After Restore, HEAD is a new sha: painting it on the last turn made that
|
|
481
|
+
// bubble look like the restored version had moved. The fork copy carries it instead.
|
|
482
|
+
if (!isGenerating) return null;
|
|
319
483
|
if (!widgetHeadCommitSha || !turn.user) return null;
|
|
320
|
-
if (getTurnCommitReply(turn)) return null;
|
|
321
484
|
if (!isLastUserTurn(turn)) return null;
|
|
322
|
-
if (
|
|
485
|
+
if (turnHasCodegenFailure(turn)) return null;
|
|
486
|
+
if (conversationMatchesHeadSha()) return null;
|
|
323
487
|
const sha = widgetHeadCommitSha.slice(0, 8);
|
|
324
488
|
return {
|
|
325
489
|
...turn.user,
|
|
@@ -331,7 +495,7 @@
|
|
|
331
495
|
}
|
|
332
496
|
|
|
333
497
|
/** Older user turns with no persisted assistant commit — Restore still uses the user message id. */
|
|
334
|
-
|
|
498
|
+
function canRestoreLegacyUserTurn(turn: ChatTurn): boolean {
|
|
335
499
|
if (!turn.user) return false;
|
|
336
500
|
if (getTurnCommitReply(turn)) return false;
|
|
337
501
|
if (turnHasWidgetHead(turn) || canUndoHeadUserTurn(turn)) return false;
|
|
@@ -339,13 +503,35 @@
|
|
|
339
503
|
return conversationHasCommitReply();
|
|
340
504
|
}
|
|
341
505
|
|
|
506
|
+
/** Failed last prompt: Restore goes back to the previous successful commit. */
|
|
507
|
+
function canRestoreFailedLastTurn(turn: ChatTurn): boolean {
|
|
508
|
+
if (!turn.user) return false;
|
|
509
|
+
if (!isLastUserTurn(turn)) return false;
|
|
510
|
+
if (!turnHasCodegenFailure(turn)) return false;
|
|
511
|
+
return conversationHasCommitReply();
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
function restoreTargetMessageId(turn: ChatTurn, commitReply: ChatMessage | null): string {
|
|
515
|
+
if (commitReply && canRestoreToMessage(commitReply)) return commitReply.id;
|
|
516
|
+
if (canRestoreFailedLastTurn(turn)) {
|
|
517
|
+
for (let i = chatTurns.length - 1; i >= 0; i--) {
|
|
518
|
+
if (chatTurns[i] === turn) continue;
|
|
519
|
+
const previous = getTurnCommitReply(chatTurns[i]);
|
|
520
|
+
if (previous) return previous.id;
|
|
521
|
+
if (chatTurns[i].user) return chatTurns[i].user!.id;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
return turn.user!.id;
|
|
525
|
+
}
|
|
526
|
+
|
|
342
527
|
function isCodegenStatusBubble(content?: string | null): boolean {
|
|
343
528
|
const trimmed = (content || '').trim();
|
|
344
529
|
return (
|
|
345
530
|
/^Code generation completed/i.test(trimmed) ||
|
|
346
531
|
/^Code saved/i.test(trimmed) ||
|
|
347
532
|
/^Compile fix applied/i.test(trimmed) ||
|
|
348
|
-
/^Preview recompiled/i.test(trimmed)
|
|
533
|
+
/^Preview recompiled/i.test(trimmed) ||
|
|
534
|
+
/^Restored from /i.test(trimmed)
|
|
349
535
|
);
|
|
350
536
|
}
|
|
351
537
|
|
|
@@ -362,7 +548,10 @@
|
|
|
362
548
|
* Previously this was gated to Debug OFF (assistant reply hidden), but we want the buttons
|
|
363
549
|
* available in Debug ON too — the assistant summary and the user-side chrome coexist. */
|
|
364
550
|
function showCommitMetaOnUserTurn(turn: ChatTurn): boolean {
|
|
365
|
-
return !!
|
|
551
|
+
return !!getTurnHeadOrCommitReply(turn)
|
|
552
|
+
|| canRestoreLegacyUserTurn(turn)
|
|
553
|
+
|| canRestoreFailedLastTurn(turn)
|
|
554
|
+
|| !!versionLabelFromPrompt(turn);
|
|
366
555
|
}
|
|
367
556
|
|
|
368
557
|
type ChatTurn = {
|
|
@@ -390,6 +579,19 @@
|
|
|
390
579
|
chatTurns = rebalancePreviewRecompiledAcrossTurns(turns);
|
|
391
580
|
});
|
|
392
581
|
|
|
582
|
+
/** Version dropdown changes which commit is "here" — bring that turn into view. */
|
|
583
|
+
$effect(() => {
|
|
584
|
+
const version = viewingVersion;
|
|
585
|
+
const sha = widgetHeadCommitSha;
|
|
586
|
+
if ((version == null && !sha) || !messagesContainer) return;
|
|
587
|
+
void tick().then(() => {
|
|
588
|
+
const here = messagesContainer?.querySelector('[data-you-are-here="true"]');
|
|
589
|
+
if (here && typeof here.scrollIntoView === 'function') {
|
|
590
|
+
here.scrollIntoView({ block: 'nearest', behavior: 'smooth' });
|
|
591
|
+
}
|
|
592
|
+
});
|
|
593
|
+
});
|
|
594
|
+
|
|
393
595
|
function messageImpliesAttachedFile(content: string): boolean {
|
|
394
596
|
return /imaginea ata[sș]at[ăa]|attached (reference )?(image|document|file|pdf|video)|reference image|din imagine|ata[sș]at[ăa]?\s+(document|pdf|fi[sș]ier|video)|attached document/i.test(
|
|
395
597
|
content,
|
|
@@ -422,6 +624,12 @@
|
|
|
422
624
|
let messagesContainer: HTMLElement;
|
|
423
625
|
let showSuggestionsInline = $state(false);
|
|
424
626
|
let autoScroll = $state(true);
|
|
627
|
+
|
|
628
|
+
// Collapse an expanded suggestions panel as soon as a generation starts, so it
|
|
629
|
+
// does not reappear under the new turn when generation ends.
|
|
630
|
+
$effect(() => {
|
|
631
|
+
if (isGenerating && showSuggestionsInline) showSuggestionsInline = false;
|
|
632
|
+
});
|
|
425
633
|
/**
|
|
426
634
|
* Opening on a small screen often resizes the container (parent panel layout)
|
|
427
635
|
* AFTER mount, which resets scroll to the top and clips the input below the
|
|
@@ -799,8 +1007,10 @@
|
|
|
799
1007
|
onscroll={handleScroll}
|
|
800
1008
|
>
|
|
801
1009
|
<!-- Empty state with suggestions — hidden until initialization completes so
|
|
802
|
-
suggestions never flash before the loaded messages arrive
|
|
803
|
-
|
|
1010
|
+
suggestions never flash before the loaded messages arrive, and hidden
|
|
1011
|
+
while a generation is in flight (the optimistic user bubble lands a tick
|
|
1012
|
+
after send, so the list is briefly empty again). -->
|
|
1013
|
+
{#if isInitialized && messages.length === 0 && !isLoading && !isGenerating}
|
|
804
1014
|
<div class="empty-state-ct flex flex-col items-center justify-center text-center max-w-sm w-full" style="align-self: center;">
|
|
805
1015
|
<h3 class="text-lg font-semibold text-gray-900 dark:text-gray-100 mb-2">💬 Start a conversation</h3>
|
|
806
1016
|
<p class="text-gray-600 dark:text-gray-400 text-sm mb-6">
|
|
@@ -819,18 +1029,29 @@
|
|
|
819
1029
|
<!-- Conversation turns (user prompt + assistant status grouped) -->
|
|
820
1030
|
{#each chatTurns as turn, turnIndex (turn.user?.id ?? turn.replies[0]?.id ?? turnIndex)}
|
|
821
1031
|
<div class="wc-chat-turn-ct space-y-1.5 rounded-lg border border-transparent p-0.5"
|
|
822
|
-
class:wc-chat-turn-head={
|
|
1032
|
+
class:wc-chat-turn-head={isViewingTurn(turn)}
|
|
1033
|
+
data-you-are-here={isViewingTurn(turn) ? 'true' : undefined}
|
|
823
1034
|
>
|
|
824
1035
|
{#if turn.user}
|
|
825
1036
|
{@const userMsg = turn.user}
|
|
826
|
-
{@const commitReply =
|
|
827
|
-
<div class="message-container wc-chat-turn-user
|
|
1037
|
+
{@const commitReply = getTurnHeadOrCommitReply(turn)}
|
|
1038
|
+
<div class="message-container wc-chat-turn-user w-full flex flex-col items-stretch"
|
|
828
1039
|
class:opacity-75={userMsg._optimistic}
|
|
829
1040
|
class:opacity-50={userMsg._failed}
|
|
830
1041
|
class:has-attachments={userMsg.attachments && userMsg.attachments.length > 0}
|
|
831
1042
|
>
|
|
832
|
-
<div
|
|
833
|
-
|
|
1043
|
+
<div class="wc-user-bubble-row flex w-full items-start gap-2">
|
|
1044
|
+
{#if isViewingTurn(turn)}
|
|
1045
|
+
<div class="checkpoint-label wc-head-commit-label mt-1 shrink-0" title="This is the version you are looking at">
|
|
1046
|
+
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
|
|
1047
|
+
<path d="M20 6L9 17l-5-5"/>
|
|
1048
|
+
</svg>
|
|
1049
|
+
You are here
|
|
1050
|
+
<span class="wc-head-commit-arrow" aria-hidden="true">→</span>
|
|
1051
|
+
</div>
|
|
1052
|
+
{/if}
|
|
1053
|
+
<div
|
|
1054
|
+
class="message-bubble relative ml-auto w-fit max-w-[80%] rounded-lg shadow-sm text-sm leading-relaxed select-text"
|
|
834
1055
|
class:p-3={!userMsg.attachments || userMsg.attachments.length === 0}
|
|
835
1056
|
class:p-0={userMsg.attachments && userMsg.attachments.length > 0}
|
|
836
1057
|
class:bubble-fit-content={userMsg.attachments && userMsg.attachments.length > 0}
|
|
@@ -874,6 +1095,7 @@
|
|
|
874
1095
|
</div>
|
|
875
1096
|
{/if}
|
|
876
1097
|
</div>
|
|
1098
|
+
</div>
|
|
877
1099
|
{#if turnNeedsRetry(turn) && !isLoading}
|
|
878
1100
|
<div class="retry-codegen-row flex justify-end mt-1">
|
|
879
1101
|
<button
|
|
@@ -890,27 +1112,39 @@
|
|
|
890
1112
|
</div>
|
|
891
1113
|
{/if}
|
|
892
1114
|
{#if showCommitMetaOnUserTurn(turn)}
|
|
1115
|
+
{@const commitTitle = getTurnCommitTitle(turn)}
|
|
1116
|
+
{#if showCommitMeta && commitTitle}
|
|
1117
|
+
<div class="wc-user-commit-title-row flex w-full min-w-0 mt-1">
|
|
1118
|
+
<span class="wc-user-commit-title text-xs text-gray-600" title={commitTitle}>
|
|
1119
|
+
{commitTitle}
|
|
1120
|
+
</span>
|
|
1121
|
+
</div>
|
|
1122
|
+
{/if}
|
|
893
1123
|
<div class="wc-user-commit-meta-ct flex w-full items-center justify-between gap-2 mt-1">
|
|
894
1124
|
<div class="wc-user-commit-meta-left flex items-center gap-2 min-w-0">
|
|
895
|
-
{#if
|
|
896
|
-
<
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
</svg>
|
|
900
|
-
Head at commit
|
|
901
|
-
</div>
|
|
1125
|
+
{#if getTurnVersionLabel(turn)}
|
|
1126
|
+
<span class="wc-user-version-label text-xs text-gray-500">
|
|
1127
|
+
{getTurnVersionLabel(turn)}
|
|
1128
|
+
</span>
|
|
902
1129
|
{/if}
|
|
903
1130
|
{#if showCommitMeta && getTurnCommitShort(turn)}
|
|
904
1131
|
<span class="wc-user-commit-sha font-mono text-xs text-gray-500">
|
|
905
|
-
|
|
1132
|
+
(commit id: {getTurnCommitShort(turn)})
|
|
906
1133
|
</span>
|
|
907
1134
|
{/if}
|
|
908
1135
|
</div>
|
|
909
|
-
{#if !isLoading && ((commitReply && canRestoreToMessage(commitReply)) || canRestoreLegacyUserTurn(turn))}
|
|
1136
|
+
{#if !isLoading && ((commitReply && (canRestoreToMessage(commitReply) || isHeadCommitReply(commitReply))) || canRestoreLegacyUserTurn(turn) || canRestoreFailedLastTurn(turn))}
|
|
1137
|
+
{@const restoreIsCurrentHead = !!(commitReply && isHeadCommitReply(commitReply))}
|
|
910
1138
|
<button
|
|
911
1139
|
class="restore-checkpoint-btn shrink-0"
|
|
912
|
-
|
|
913
|
-
|
|
1140
|
+
disabled={restoreIsCurrentHead}
|
|
1141
|
+
onclick={() => {
|
|
1142
|
+
if (restoreIsCurrentHead) return;
|
|
1143
|
+
handleRestoreCheckpoint(restoreTargetMessageId(turn, commitReply));
|
|
1144
|
+
}}
|
|
1145
|
+
title={restoreIsCurrentHead
|
|
1146
|
+
? 'This checkpoint is already HEAD'
|
|
1147
|
+
: 'Restore widget code to this prompt\'s commit'}
|
|
914
1148
|
>
|
|
915
1149
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
916
1150
|
<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/>
|
|
@@ -960,6 +1194,22 @@
|
|
|
960
1194
|
{/if}
|
|
961
1195
|
</div>
|
|
962
1196
|
|
|
1197
|
+
{#if reply.suggestions && reply.suggestions.length > 0}
|
|
1198
|
+
<div class="clarification-suggestions flex flex-wrap gap-1.5 mt-1.5">
|
|
1199
|
+
{#each reply.suggestions as suggestion, i (i)}
|
|
1200
|
+
<button
|
|
1201
|
+
type="button"
|
|
1202
|
+
class="clarification-chip"
|
|
1203
|
+
disabled={!onClarificationSuggestionSelected || isLoading || isGenerating}
|
|
1204
|
+
onclick={() => onClarificationSuggestionSelected?.(suggestion)}
|
|
1205
|
+
title={suggestion.label}
|
|
1206
|
+
>
|
|
1207
|
+
{suggestion.label}
|
|
1208
|
+
</button>
|
|
1209
|
+
{/each}
|
|
1210
|
+
</div>
|
|
1211
|
+
{/if}
|
|
1212
|
+
|
|
963
1213
|
{#if isCodegenFailure(reply) && isLastCodegenFailureInTurn(turn, reply) && getRetryPromptForTurn(turn, turnIndex) && !isLoading}
|
|
964
1214
|
<div class="retry-codegen-row flex justify-start mt-1">
|
|
965
1215
|
<button
|
|
@@ -982,7 +1232,7 @@
|
|
|
982
1232
|
{/each}
|
|
983
1233
|
|
|
984
1234
|
<!-- Show suggestions toggle (when there are messages) -->
|
|
985
|
-
{#if messages.length > 0 && !isLoading}
|
|
1235
|
+
{#if messages.length > 0 && !isLoading && !isGenerating}
|
|
986
1236
|
<div class="suggestions-toggle-ct flex justify-center py-2">
|
|
987
1237
|
{#if showSuggestionsInline}
|
|
988
1238
|
<SuggestionButtons
|
|
@@ -1098,10 +1348,27 @@
|
|
|
1098
1348
|
margin-bottom: 0;
|
|
1099
1349
|
}
|
|
1100
1350
|
|
|
1351
|
+
.wc-head-commit-arrow {
|
|
1352
|
+
font-size: 11px;
|
|
1353
|
+
line-height: 1;
|
|
1354
|
+
font-weight: 700;
|
|
1355
|
+
margin-left: 2px;
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1101
1358
|
.wc-head-commit-meta-ct .wc-head-commit-label {
|
|
1102
1359
|
margin-top: 0;
|
|
1103
1360
|
}
|
|
1104
1361
|
|
|
1362
|
+
/* What the turn shipped, in the commit's own words. Truncated at the turn's
|
|
1363
|
+
width — the full subject stays in the tooltip — so a prompt-derived title
|
|
1364
|
+
cannot widen the bubble past its 80% cap. */
|
|
1365
|
+
.wc-user-commit-title {
|
|
1366
|
+
display: block;
|
|
1367
|
+
overflow: hidden;
|
|
1368
|
+
text-overflow: ellipsis;
|
|
1369
|
+
white-space: nowrap;
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1105
1372
|
.restore-checkpoint-row {
|
|
1106
1373
|
margin-top: 4px;
|
|
1107
1374
|
}
|
|
@@ -1133,6 +1400,12 @@
|
|
|
1133
1400
|
color: #555;
|
|
1134
1401
|
border-color: #bbb;
|
|
1135
1402
|
}
|
|
1403
|
+
|
|
1404
|
+
.restore-checkpoint-btn:disabled {
|
|
1405
|
+
opacity: 0.45;
|
|
1406
|
+
cursor: not-allowed;
|
|
1407
|
+
pointer-events: none;
|
|
1408
|
+
}
|
|
1136
1409
|
|
|
1137
1410
|
.retry-codegen-btn {
|
|
1138
1411
|
color: #b91c1c;
|
|
@@ -1146,35 +1419,42 @@
|
|
|
1146
1419
|
border-color: #fca5a5;
|
|
1147
1420
|
}
|
|
1148
1421
|
|
|
1149
|
-
|
|
1150
|
-
.
|
|
1151
|
-
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
|
-
/* Copy message button — top-right, visible on hover */
|
|
1155
|
-
.copy-msg-btn {
|
|
1156
|
-
position: absolute;
|
|
1157
|
-
top: 4px;
|
|
1158
|
-
right: 4px;
|
|
1159
|
-
display: flex;
|
|
1422
|
+
/* Clarification-card suggestion chips — tap to send as the next user message */
|
|
1423
|
+
.clarification-chip {
|
|
1424
|
+
display: inline-flex;
|
|
1160
1425
|
align-items: center;
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
border:
|
|
1166
|
-
|
|
1167
|
-
|
|
1426
|
+
max-width: 100%;
|
|
1427
|
+
padding: 4px 12px;
|
|
1428
|
+
background: #fff;
|
|
1429
|
+
color: #2563eb;
|
|
1430
|
+
border: 1px solid #bfdbfe;
|
|
1431
|
+
border-radius: 999px;
|
|
1432
|
+
font-size: 12px;
|
|
1433
|
+
font-weight: 500;
|
|
1168
1434
|
cursor: pointer;
|
|
1169
|
-
|
|
1170
|
-
|
|
1435
|
+
text-align: left;
|
|
1436
|
+
overflow-wrap: anywhere;
|
|
1437
|
+
white-space: normal;
|
|
1438
|
+
transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
|
|
1171
1439
|
}
|
|
1172
|
-
|
|
1173
|
-
|
|
1440
|
+
|
|
1441
|
+
.clarification-chip:hover:not(:disabled) {
|
|
1442
|
+
background: #eff6ff;
|
|
1443
|
+
border-color: #93c5fd;
|
|
1174
1444
|
}
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1445
|
+
|
|
1446
|
+
.clarification-chip:active:not(:disabled) {
|
|
1447
|
+
background: #dbeafe;
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
.clarification-chip:disabled {
|
|
1451
|
+
opacity: 0.5;
|
|
1452
|
+
cursor: default;
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
.restore-checkpoint-btn svg,
|
|
1456
|
+
.retry-codegen-btn svg {
|
|
1457
|
+
flex-shrink: 0;
|
|
1178
1458
|
}
|
|
1179
1459
|
|
|
1180
1460
|
/* Checkpoint label — shown above the restored message */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ChatMessage, ChatContext } from '../types/index.js';
|
|
2
|
+
import type { ClarificationSuggestion } from '../types/message.js';
|
|
2
3
|
interface Props {
|
|
3
4
|
class?: string;
|
|
4
5
|
messages: ChatMessage[];
|
|
@@ -23,13 +24,27 @@ interface Props {
|
|
|
23
24
|
showGenerationSummaries?: boolean;
|
|
24
25
|
/** Host widget HEAD sha — Head chrome when assistant commit bubbles are missing. */
|
|
25
26
|
widgetHeadCommitSha?: string | null;
|
|
26
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* Short commit sha → human version label ("Version 4"), supplied by the host.
|
|
29
|
+
* A commit hash means nothing to someone who is not a developer, so the turn
|
|
30
|
+
* is labelled with the version it produced and the hash is debug-only.
|
|
31
|
+
*/
|
|
32
|
+
versionLabelByCommitSha?: Record<string, string>;
|
|
33
|
+
/** User prompt text → "Version N", for turns that never saved a commit line. */
|
|
34
|
+
versionLabelByPrompt?: Record<string, string>;
|
|
35
|
+
/** Dropdown selection. The badge follows this version, not only a commit sha. */
|
|
36
|
+
viewingVersion?: number | null;
|
|
37
|
+
/** When false, hide commit hashes next to the version label (user mode). */
|
|
27
38
|
showCommitMeta?: boolean;
|
|
28
39
|
/** True while codegen / send is in flight — suppresses premature Retry. */
|
|
29
40
|
isGenerating?: boolean;
|
|
30
41
|
onSuggestionSelected?: (suggestion: string) => void;
|
|
31
42
|
onRestoreCheckpoint?: (messageId: string, messageIndex: number) => void;
|
|
32
43
|
onRetryMessage?: (content: string) => void;
|
|
44
|
+
/** Tapping a clarification-card suggestion chip sends it as the next user message,
|
|
45
|
+
* carrying the chip's structured intent. Chips are disabled while the host
|
|
46
|
+
* runs widget codegen (`isGenerating`). */
|
|
47
|
+
onClarificationSuggestionSelected?: (suggestion: ClarificationSuggestion) => void;
|
|
33
48
|
}
|
|
34
49
|
declare const ChatMessages: import("svelte").Component<Props, {}, "">;
|
|
35
50
|
type ChatMessages = ReturnType<typeof ChatMessages>;
|
package/dist/types/message.d.ts
CHANGED
|
@@ -23,6 +23,12 @@ export interface ChatMessage {
|
|
|
23
23
|
messageType: 'user' | 'assistant';
|
|
24
24
|
attachments?: ContentItemOutput[];
|
|
25
25
|
isCommit?: boolean;
|
|
26
|
+
/** What this commit turn shipped, in the commit's own words ("feat: make
|
|
27
|
+
* the badge blue") — persisted beside `is_commit` by the codegen pipeline
|
|
28
|
+
* and rendered on the turn's commit chrome. Absent on rows written before
|
|
29
|
+
* title persistence, and on a synthesized Head reply (the host's HEAD has
|
|
30
|
+
* moved past every persisted reply, so no title for it exists here). */
|
|
31
|
+
commitTitle?: string | null;
|
|
26
32
|
userId: string;
|
|
27
33
|
createdAt: Date;
|
|
28
34
|
updatedAt: Date;
|
|
@@ -34,6 +40,19 @@ export interface ChatMessage {
|
|
|
34
40
|
rolledBackAt?: string | null;
|
|
35
41
|
/** Latest successful repo commit — show "Head at commit" on this assistant message. */
|
|
36
42
|
isWidgetHead?: boolean;
|
|
43
|
+
/** Clarification-card follow-up chips (assistant only), as structured
|
|
44
|
+
* objects: `label` is display copy rendered verbatim, `intent` is the
|
|
45
|
+
* machine-readable behavior the chip's tap declares back on the next
|
|
46
|
+
* generate request (`chipIntent`). Bare-string rows from before the
|
|
47
|
+
* contract are normalized to refine suggestions by the server on read. */
|
|
48
|
+
suggestions?: ClarificationSuggestion[];
|
|
49
|
+
}
|
|
50
|
+
/** One suggestion chip on a clarification card — display copy plus the
|
|
51
|
+
* machine-readable behavior of tapping it. The client keys off `intent`;
|
|
52
|
+
* `label` is never parsed. */
|
|
53
|
+
export interface ClarificationSuggestion {
|
|
54
|
+
label: string;
|
|
55
|
+
intent: 'refine' | 'generate_anyway';
|
|
37
56
|
}
|
|
38
57
|
/**
|
|
39
58
|
* Message input type for creating new messages
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@widgetic/chat",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -37,12 +37,16 @@
|
|
|
37
37
|
"scripts": {
|
|
38
38
|
"i": "npm run clean-modules && npm i && npm run lps",
|
|
39
39
|
"clean-modules": "rm -rf node_modules",
|
|
40
|
-
"lps": "
|
|
40
|
+
"lps": "node scripts/link-siblings.mjs",
|
|
41
|
+
"llinks": "ls -la node_modules/@widgetic",
|
|
42
|
+
"lps:check": "node scripts/link-siblings.mjs && npm run llinks",
|
|
43
|
+
"predev": "npm run lps",
|
|
41
44
|
"dev": "npm run dev-sv -- --open",
|
|
42
45
|
"dev-sv": "NODE_ENV=development vite dev",
|
|
43
46
|
"build": "vite build",
|
|
44
47
|
"package": "svelte-package",
|
|
45
48
|
"package:watch": "svelte-package --watch",
|
|
49
|
+
"prepackage:watch": "npm run lps",
|
|
46
50
|
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --diagnostic-sources \"js,svelte\"",
|
|
47
51
|
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
|
48
52
|
"lint": "prettier --check . && eslint .",
|
|
@@ -64,10 +68,10 @@
|
|
|
64
68
|
"@sveltejs/package": "^2.3.7",
|
|
65
69
|
"@sveltejs/vite-plugin-svelte": "^5.0.3",
|
|
66
70
|
"@tailwindcss/postcss": "^4.1.4",
|
|
67
|
-
"@types/eslint": "^9.6.0",
|
|
68
71
|
"@types/node": "^26.4.1",
|
|
69
72
|
"@widgetic/api-sdk": "^1.0.10",
|
|
70
|
-
"@widgetic/design-system": "^0.
|
|
73
|
+
"@widgetic/design-system": "^0.5.12",
|
|
74
|
+
"@widgetic/dev-tools": "^0.2.0",
|
|
71
75
|
"autoprefixer": "^10.4.20",
|
|
72
76
|
"eslint": "^9.0.0",
|
|
73
77
|
"eslint-config-prettier": "^9.1.0",
|