@widgetic/chat 0.1.22 → 0.1.23
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.
|
@@ -812,11 +812,19 @@
|
|
|
812
812
|
window.location.assign('/workspaces/personal/settings/billing');
|
|
813
813
|
}
|
|
814
814
|
|
|
815
|
+
function turnIsDesignCardOnly(turn: ChatTurn): boolean {
|
|
816
|
+
const hasCard = turn.replies.some((reply) => !!reply.designControls);
|
|
817
|
+
return hasCard && !getTurnCommitReply(turn);
|
|
818
|
+
}
|
|
819
|
+
|
|
815
820
|
function turnNeedsRetry(turn: ChatTurn, turnIndex: number): boolean {
|
|
816
821
|
// Never show Retry while a send/codegen is still running.
|
|
817
822
|
if (isLoading || isGenerating) return false;
|
|
818
823
|
const userMsg = turn.user;
|
|
819
824
|
if (!userMsg?.messageContent?.trim()) return false;
|
|
825
|
+
// A design card already applied the change. Retry would send it to the model,
|
|
826
|
+
// add another bubble, and leave the card on the old one.
|
|
827
|
+
if (turnIsDesignCardOnly(turn)) return false;
|
|
820
828
|
// The earlier copy of a prompt that was already run again stays without Retry.
|
|
821
829
|
if (promptWasRetriedLater(turn, turnIndex)) return false;
|
|
822
830
|
return true;
|
|
@@ -850,13 +858,29 @@
|
|
|
850
858
|
* up). Disconnected on destroy.
|
|
851
859
|
*/
|
|
852
860
|
let containerResizeObserver: ResizeObserver | null = null;
|
|
861
|
+
let contentGrowthObserver: MutationObserver | null = null;
|
|
853
862
|
|
|
854
|
-
function
|
|
863
|
+
function scrollMessagesToEnd(): void {
|
|
855
864
|
if (!messagesContainer) return;
|
|
856
|
-
messagesContainer.
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
865
|
+
messagesContainer.scrollTop = messagesContainer.scrollHeight;
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
// The last bubble grows after the first scroll (text wrap, the card under it).
|
|
869
|
+
// One assignment lands short of the end, which is the clipped last message.
|
|
870
|
+
function settleMessagesToEnd(): void {
|
|
871
|
+
let frames = 0;
|
|
872
|
+
const step = () => {
|
|
873
|
+
if (!messagesContainer || pendingOlderScroll || isLoading) return;
|
|
874
|
+
const gap = messagesContainer.scrollHeight - messagesContainer.clientHeight - messagesContainer.scrollTop;
|
|
875
|
+
if (shouldPinChatToBottom() || !initialBottomPinned) scrollMessagesToEnd();
|
|
876
|
+
frames += 1;
|
|
877
|
+
if (frames < 12 && gap > 1) {
|
|
878
|
+
requestAnimationFrame(step);
|
|
879
|
+
return;
|
|
880
|
+
}
|
|
881
|
+
initialBottomPinned = true;
|
|
882
|
+
};
|
|
883
|
+
requestAnimationFrame(step);
|
|
860
884
|
}
|
|
861
885
|
|
|
862
886
|
// Auto-scroll to bottom when new messages arrive or on initial load.
|
|
@@ -869,20 +893,12 @@
|
|
|
869
893
|
const pinToBottom = shouldPinChatToBottom();
|
|
870
894
|
const messageCount = visibleMessages.length;
|
|
871
895
|
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
|
-
});
|
|
896
|
+
void tick().then(() => settleMessagesToEnd());
|
|
881
897
|
}
|
|
882
898
|
if (messagesContainer && pinToBottom && messageCount > 0 && !pendingOlderScroll && initialBottomPinned) {
|
|
883
899
|
tick().then(() => {
|
|
884
900
|
if (!messagesContainer || pendingOlderScroll || !shouldPinChatToBottom()) return;
|
|
885
|
-
|
|
901
|
+
scrollMessagesToEnd();
|
|
886
902
|
});
|
|
887
903
|
}
|
|
888
904
|
});
|
|
@@ -891,24 +907,32 @@
|
|
|
891
907
|
onMount(() => {
|
|
892
908
|
tick().then(() => {
|
|
893
909
|
if (messagesContainer && visibleMessages.length > 0 && !isLoading && shouldPinChatToBottom()) {
|
|
894
|
-
|
|
895
|
-
initialBottomPinned = true;
|
|
910
|
+
settleMessagesToEnd();
|
|
896
911
|
}
|
|
897
912
|
// Re-pin after late container resizes (panel open animation, parent
|
|
898
913
|
// layout settling, height restored from prefs).
|
|
899
914
|
if (messagesContainer && typeof ResizeObserver !== 'undefined') {
|
|
900
915
|
containerResizeObserver = new ResizeObserver(() => {
|
|
901
916
|
if (pendingOlderScroll || !initialBottomPinned) return;
|
|
902
|
-
if (shouldPinChatToBottom())
|
|
917
|
+
if (shouldPinChatToBottom()) scrollMessagesToEnd();
|
|
903
918
|
});
|
|
904
919
|
containerResizeObserver.observe(messagesContainer);
|
|
905
920
|
}
|
|
921
|
+
if (messagesContainer && typeof MutationObserver !== 'undefined') {
|
|
922
|
+
contentGrowthObserver = new MutationObserver(() => {
|
|
923
|
+
if (pendingOlderScroll || !initialBottomPinned) return;
|
|
924
|
+
if (shouldPinChatToBottom()) scrollMessagesToEnd();
|
|
925
|
+
});
|
|
926
|
+
contentGrowthObserver.observe(messagesContainer, { childList: true, subtree: true });
|
|
927
|
+
}
|
|
906
928
|
});
|
|
907
929
|
});
|
|
908
930
|
|
|
909
931
|
onDestroy(() => {
|
|
910
932
|
containerResizeObserver?.disconnect();
|
|
911
933
|
containerResizeObserver = null;
|
|
934
|
+
contentGrowthObserver?.disconnect();
|
|
935
|
+
contentGrowthObserver = null;
|
|
912
936
|
});
|
|
913
937
|
|
|
914
938
|
let olderRequestInFlight = false;
|