@widgetic/chat 0.1.8 → 0.1.10
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.
|
@@ -1331,7 +1331,20 @@
|
|
|
1331
1331
|
if (localHasHead && !loadedHasHead) {
|
|
1332
1332
|
// chatLog('[Chat] Keep local HEAD commit message — DB reload has no commit yet');
|
|
1333
1333
|
} else {
|
|
1334
|
-
|
|
1334
|
+
// DB may lag behind the live session: the backend persists the codegen
|
|
1335
|
+
// summary asynchronously, so a reload fired shortly after generation can
|
|
1336
|
+
// still miss the newest commit. Only adopt the reload when it would not
|
|
1337
|
+
// regress the local HEAD to a different (older) commit.
|
|
1338
|
+
const localHeadSha = extractLatestLocalCommitSha(localMsgs);
|
|
1339
|
+
const loadedHeadSha = extractLatestLocalCommitSha(loaded);
|
|
1340
|
+
const wouldRegressHead =
|
|
1341
|
+
!!localHeadSha
|
|
1342
|
+
&& (!loadedHeadSha || !loadedHeadSha.toLowerCase().startsWith(localHeadSha.slice(0, 7).toLowerCase()));
|
|
1343
|
+
if (wouldRegressHead) {
|
|
1344
|
+
// chatLog('[Chat] Keep local messages — DB reload would regress HEAD commit');
|
|
1345
|
+
} else {
|
|
1346
|
+
chatStore.actions.setMessages(currentConversationId, loaded);
|
|
1347
|
+
}
|
|
1335
1348
|
}
|
|
1336
1349
|
}
|
|
1337
1350
|
markWidgetHeadAtLatestCommit();
|
|
@@ -1341,6 +1354,16 @@
|
|
|
1341
1354
|
}
|
|
1342
1355
|
}
|
|
1343
1356
|
|
|
1357
|
+
/** Newest commit SHA present in a message list (local session or DB reload). */
|
|
1358
|
+
function extractLatestLocalCommitSha(msgs: Array<{ messageContent?: string | null }> | null | undefined): string | null {
|
|
1359
|
+
if (!msgs) return null;
|
|
1360
|
+
for (let i = msgs.length - 1; i >= 0; i--) {
|
|
1361
|
+
const sha = extractCommitShaFromContent(msgs[i]?.messageContent || '');
|
|
1362
|
+
if (sha) return sha;
|
|
1363
|
+
}
|
|
1364
|
+
return null;
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1344
1367
|
function clearStalePreviewBuildFailures() {
|
|
1345
1368
|
if (!currentConversationId) return;
|
|
1346
1369
|
const msgs = getCurrentMessages(currentConversationId);
|
|
@@ -1521,6 +1544,7 @@
|
|
|
1521
1544
|
class="prompt-chat-messages h-full"
|
|
1522
1545
|
messages={currentMessages || []}
|
|
1523
1546
|
isLoading={isLoading}
|
|
1547
|
+
isInitialized={isInitialized}
|
|
1524
1548
|
{context}
|
|
1525
1549
|
isCompleted={isCompleted}
|
|
1526
1550
|
enableAutoCodeDetection={config?.features?.autoCodeDetection === true}
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
class?: string;
|
|
13
13
|
messages: ChatMessage[];
|
|
14
14
|
isLoading?: boolean;
|
|
15
|
+
/** True after the conversation list/messages finished initializing — gates the empty state so suggestions never flash at mount. */
|
|
16
|
+
isInitialized?: boolean;
|
|
15
17
|
context: ChatContext;
|
|
16
18
|
isCompleted?: boolean;
|
|
17
19
|
/**
|
|
@@ -43,6 +45,7 @@
|
|
|
43
45
|
class: className = '',
|
|
44
46
|
messages,
|
|
45
47
|
isLoading = false,
|
|
48
|
+
isInitialized = true,
|
|
46
49
|
context,
|
|
47
50
|
isCompleted = false,
|
|
48
51
|
enableAutoCodeDetection = false,
|
|
@@ -766,8 +769,9 @@
|
|
|
766
769
|
use:detectMessagesScrollbar
|
|
767
770
|
onscroll={handleScroll}
|
|
768
771
|
>
|
|
769
|
-
<!-- Empty state with suggestions
|
|
770
|
-
|
|
772
|
+
<!-- Empty state with suggestions — hidden until initialization completes so
|
|
773
|
+
suggestions never flash before the loaded messages arrive. -->
|
|
774
|
+
{#if isInitialized && messages.length === 0 && !isLoading}
|
|
771
775
|
<div class="empty-state-ct flex flex-col items-center justify-center text-center max-w-sm w-full" style="align-self: center;">
|
|
772
776
|
<h3 class="text-lg font-semibold text-gray-900 dark:text-gray-100 mb-2">💬 Start a conversation</h3>
|
|
773
777
|
<p class="text-gray-600 dark:text-gray-400 text-sm mb-6">
|
|
@@ -3,6 +3,8 @@ interface Props {
|
|
|
3
3
|
class?: string;
|
|
4
4
|
messages: ChatMessage[];
|
|
5
5
|
isLoading?: boolean;
|
|
6
|
+
/** True after the conversation list/messages finished initializing — gates the empty state so suggestions never flash at mount. */
|
|
7
|
+
isInitialized?: boolean;
|
|
6
8
|
context: ChatContext;
|
|
7
9
|
isCompleted?: boolean;
|
|
8
10
|
/**
|