@ensembleapp/client-sdk 0.0.20 → 0.0.21
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/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/widget/widget.global.js +30 -30
- package/dist/widget/widget.global.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -18684,10 +18684,9 @@ function useChat({
|
|
|
18684
18684
|
onData?.(dataPart);
|
|
18685
18685
|
}
|
|
18686
18686
|
});
|
|
18687
|
-
const [isLoadingInitial, setIsLoadingInitial] = useState(
|
|
18687
|
+
const [isLoadingInitial, setIsLoadingInitial] = useState(true);
|
|
18688
18688
|
useEffect(() => {
|
|
18689
18689
|
const fetchInitialMessages = async () => {
|
|
18690
|
-
setIsLoadingInitial(true);
|
|
18691
18690
|
try {
|
|
18692
18691
|
const response = await fetch(`${baseUrl}/chat/messages`, {
|
|
18693
18692
|
method: "GET",
|
|
@@ -24467,6 +24466,7 @@ function ChatWidget({
|
|
|
24467
24466
|
const {
|
|
24468
24467
|
messages,
|
|
24469
24468
|
status,
|
|
24469
|
+
isLoadingInitial,
|
|
24470
24470
|
sendMessage,
|
|
24471
24471
|
stop,
|
|
24472
24472
|
setMessages
|
|
@@ -24533,21 +24533,21 @@ function ChatWidget({
|
|
|
24533
24533
|
};
|
|
24534
24534
|
}, [voice]);
|
|
24535
24535
|
useEffect4(() => {
|
|
24536
|
-
if (initialAssistantMessage && !initialUserMessage && messages.length === 0) {
|
|
24536
|
+
if (initialAssistantMessage && !initialUserMessage && !isLoadingInitial && messages.length === 0) {
|
|
24537
24537
|
setMessages([{
|
|
24538
24538
|
id: "welcome-message",
|
|
24539
24539
|
role: "assistant",
|
|
24540
24540
|
parts: [{ type: "text", text: initialAssistantMessage }]
|
|
24541
24541
|
}]);
|
|
24542
24542
|
}
|
|
24543
|
-
}, [initialAssistantMessage, initialUserMessage, messages.length, setMessages]);
|
|
24543
|
+
}, [initialAssistantMessage, initialUserMessage, isLoadingInitial, messages.length, setMessages]);
|
|
24544
24544
|
const initialMessageSentRef = useRef3(false);
|
|
24545
24545
|
useEffect4(() => {
|
|
24546
|
-
if (initialUserMessage && !initialMessageSentRef.current && status === "ready" && messages.length === 0) {
|
|
24546
|
+
if (initialUserMessage && !initialMessageSentRef.current && !isLoadingInitial && status === "ready" && messages.length === 0) {
|
|
24547
24547
|
initialMessageSentRef.current = true;
|
|
24548
24548
|
sendMessage({ text: initialUserMessage });
|
|
24549
24549
|
}
|
|
24550
|
-
}, [initialUserMessage, status, messages.length, sendMessage]);
|
|
24550
|
+
}, [initialUserMessage, isLoadingInitial, status, messages.length, sendMessage]);
|
|
24551
24551
|
const handleScroll = useCallback4(() => {
|
|
24552
24552
|
if (!scrollContainerRef.current) return;
|
|
24553
24553
|
const { scrollTop, scrollHeight, clientHeight } = scrollContainerRef.current;
|