@widgetic/chat 0.1.21 → 0.1.22
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.
|
@@ -694,7 +694,6 @@
|
|
|
694
694
|
* available in Debug ON too — the assistant summary and the user-side chrome coexist. */
|
|
695
695
|
function showCommitMetaOnUserTurn(turn: ChatTurn): boolean {
|
|
696
696
|
return !!getTurnHeadOrCommitReply(turn)
|
|
697
|
-
|| canRestoreLegacyUserTurn(turn)
|
|
698
697
|
|| canRestoreFailedLastTurn(turn)
|
|
699
698
|
|| !!versionLabelFromPrompt(turn);
|
|
700
699
|
}
|
|
@@ -833,6 +832,10 @@
|
|
|
833
832
|
let messagesContainer: HTMLElement;
|
|
834
833
|
let showSuggestionsInline = $state(false);
|
|
835
834
|
let autoScroll = $state(true);
|
|
835
|
+
// The first paint is shorter than the loaded page. Scrolling then, or treating
|
|
836
|
+
// that short box as "the user is at the top", loads older pages and never
|
|
837
|
+
// lands on the newest message. Pin once, after this load has finished.
|
|
838
|
+
let initialBottomPinned = $state(false);
|
|
836
839
|
|
|
837
840
|
// Collapse an expanded suggestions panel as soon as a generation starts, so it
|
|
838
841
|
// does not reappear under the new turn when generation ends.
|
|
@@ -859,9 +862,24 @@
|
|
|
859
862
|
// Auto-scroll to bottom when new messages arrive or on initial load.
|
|
860
863
|
// Also scrolls on mount/conversation-switch when messages are already present.
|
|
861
864
|
$effect(() => {
|
|
865
|
+
if (isLoading) {
|
|
866
|
+
initialBottomPinned = false;
|
|
867
|
+
return;
|
|
868
|
+
}
|
|
862
869
|
const pinToBottom = shouldPinChatToBottom();
|
|
863
870
|
const messageCount = visibleMessages.length;
|
|
864
|
-
if (
|
|
871
|
+
if (!initialBottomPinned && messagesContainer && messageCount > 0 && !pendingOlderScroll) {
|
|
872
|
+
void tick().then(() => {
|
|
873
|
+
requestAnimationFrame(() => {
|
|
874
|
+
if (!messagesContainer || pendingOlderScroll || isLoading) return;
|
|
875
|
+
if (shouldPinChatToBottom()) {
|
|
876
|
+
messagesContainer.scrollTop = messagesContainer.scrollHeight;
|
|
877
|
+
}
|
|
878
|
+
initialBottomPinned = true;
|
|
879
|
+
});
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
if (messagesContainer && pinToBottom && messageCount > 0 && !pendingOlderScroll && initialBottomPinned) {
|
|
865
883
|
tick().then(() => {
|
|
866
884
|
if (!messagesContainer || pendingOlderScroll || !shouldPinChatToBottom()) return;
|
|
867
885
|
messagesContainer.scrollTop = messagesContainer.scrollHeight;
|
|
@@ -872,14 +890,15 @@
|
|
|
872
890
|
// Force scroll to bottom on initial mount (messages may already be loaded)
|
|
873
891
|
onMount(() => {
|
|
874
892
|
tick().then(() => {
|
|
875
|
-
if (messagesContainer && visibleMessages.length > 0 && shouldPinChatToBottom()) {
|
|
893
|
+
if (messagesContainer && visibleMessages.length > 0 && !isLoading && shouldPinChatToBottom()) {
|
|
876
894
|
scrollToBottomInstant();
|
|
895
|
+
initialBottomPinned = true;
|
|
877
896
|
}
|
|
878
897
|
// Re-pin after late container resizes (panel open animation, parent
|
|
879
898
|
// layout settling, height restored from prefs).
|
|
880
899
|
if (messagesContainer && typeof ResizeObserver !== 'undefined') {
|
|
881
900
|
containerResizeObserver = new ResizeObserver(() => {
|
|
882
|
-
if (pendingOlderScroll) return;
|
|
901
|
+
if (pendingOlderScroll || !initialBottomPinned) return;
|
|
883
902
|
if (shouldPinChatToBottom()) scrollToBottomInstant();
|
|
884
903
|
});
|
|
885
904
|
containerResizeObserver.observe(messagesContainer);
|
|
@@ -898,7 +917,7 @@
|
|
|
898
917
|
function handleScroll() {
|
|
899
918
|
if (!messagesContainer) return;
|
|
900
919
|
const { scrollTop, scrollHeight, clientHeight } = messagesContainer;
|
|
901
|
-
if (pendingOlderScroll) return;
|
|
920
|
+
if (pendingOlderScroll || !initialBottomPinned) return;
|
|
902
921
|
autoScroll = scrollTop + clientHeight >= scrollHeight - 10;
|
|
903
922
|
if (scrollTop > 80 || !hasOlderMessages || olderRequestInFlight || !onRequestOlderMessages) return;
|
|
904
923
|
autoScroll = false;
|
|
@@ -1378,7 +1397,7 @@
|
|
|
1378
1397
|
</span>
|
|
1379
1398
|
{/if}
|
|
1380
1399
|
</div>
|
|
1381
|
-
{#if !turn.user?.id?.startsWith('version-fork-') && !isLoading && ((commitReply && (canRestoreToMessage(commitReply) || isHeadCommitReply(commitReply))) ||
|
|
1400
|
+
{#if !turn.user?.id?.startsWith('version-fork-') && !isLoading && ((commitReply && (canRestoreToMessage(commitReply) || isHeadCommitReply(commitReply))) || canRestoreFailedLastTurn(turn))}
|
|
1382
1401
|
{@const restoreIsCurrentHead = !!(commitReply && isHeadCommitReply(commitReply))}
|
|
1383
1402
|
<button
|
|
1384
1403
|
class="restore-checkpoint-btn shrink-0"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@widgetic/chat",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.22",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"dev-sv": "NODE_ENV=development vite dev",
|
|
46
46
|
"build": "vite build",
|
|
47
47
|
"package": "svelte-kit sync && svelte-package",
|
|
48
|
-
"publish-to-npm": "
|
|
48
|
+
"publish-to-npm": "node ../dev-tools/bin/publish-package.mjs",
|
|
49
49
|
"package:watch": "svelte-kit sync && svelte-package --watch",
|
|
50
50
|
"prepackage:watch": "npm run lps",
|
|
51
51
|
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --diagnostic-sources \"js,svelte\"",
|