impact-chatbot 2.3.49 → 2.3.50
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.cjs.js +22 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +22 -2
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -5474,6 +5474,15 @@ const ButtonContent = ({ bodyText, isFormDisabled = false, isStepFormSubmit = fa
|
|
|
5474
5474
|
try {
|
|
5475
5475
|
const data = JSON.parse(event.data);
|
|
5476
5476
|
console.log("[ButtonContent] SSE chunk:", data);
|
|
5477
|
+
// Always keep stepFormStreamControl.sessionId in sync with the latest chunk's session_id
|
|
5478
|
+
if (data?.session_id) {
|
|
5479
|
+
stepFormStreamControl.sessionId = data.session_id;
|
|
5480
|
+
sessionStorage.setItem("stepForm_sessionId", data.session_id);
|
|
5481
|
+
}
|
|
5482
|
+
if (data?.chat_id) {
|
|
5483
|
+
stepFormStreamControl.chatId = data.chat_id;
|
|
5484
|
+
sessionStorage.setItem("stepForm_chatId", data.chat_id);
|
|
5485
|
+
}
|
|
5477
5486
|
if (data?.status === "step" || data?.status === "step_form" || data?.status === "questions" || data?.status === "thinking" || data?.status === "widget") {
|
|
5478
5487
|
chunksRef.push(data);
|
|
5479
5488
|
// Dispatch widget chunks immediately for real-time rendering
|
|
@@ -5498,6 +5507,8 @@ const ButtonContent = ({ bodyText, isFormDisabled = false, isStepFormSubmit = fa
|
|
|
5498
5507
|
stepFormStreamControl.initValue = true;
|
|
5499
5508
|
stepFormStreamControl.sessionId = "";
|
|
5500
5509
|
stepFormStreamControl.uniqueChatId = data?.chat_id ? data.chat_id : "";
|
|
5510
|
+
// Clear sessionStorage so stale session_id isn't picked up by future non-init calls
|
|
5511
|
+
sessionStorage.setItem("stepForm_sessionId", "");
|
|
5501
5512
|
}
|
|
5502
5513
|
// Stream ended — dispatch all collected chunks at once
|
|
5503
5514
|
stepFormStreamControl.isStreaming = false;
|
|
@@ -7046,6 +7057,7 @@ const StreamedContent = ({ botData }) => {
|
|
|
7046
7057
|
const thinkingDoneRef = useRef(false);
|
|
7047
7058
|
const setThinkingContentRef = useRef(setThinkingContent); // Store current setThinkingContent function
|
|
7048
7059
|
const streamTimeoutRef = useRef(null); // Ref for stream timeout
|
|
7060
|
+
const streamingDoneProcessedRef = useRef(false); // Guard to prevent isStreamingDone effect running twice
|
|
7049
7061
|
// Stable key for the module-level streamStateMap (survives cloneDeep of botData)
|
|
7050
7062
|
const streamKey = useRef(`${currentMode}_${activeConversationId}_${JSON.stringify(botData.inputBody)}`).current;
|
|
7051
7063
|
// Look up existing stream state from the Map (persists across tab-switch remounts)
|
|
@@ -7478,7 +7490,8 @@ const StreamedContent = ({ botData }) => {
|
|
|
7478
7490
|
* Parses the accumulated response and updates the chat history
|
|
7479
7491
|
*/
|
|
7480
7492
|
useEffect(() => {
|
|
7481
|
-
if (isStreamingDone) {
|
|
7493
|
+
if (isStreamingDone && !streamingDoneProcessedRef.current) {
|
|
7494
|
+
streamingDoneProcessedRef.current = true;
|
|
7482
7495
|
localStorage.setItem("isStreaming", "false");
|
|
7483
7496
|
if (currentMode === "agent") {
|
|
7484
7497
|
setIsStop(false);
|
|
@@ -12577,7 +12590,7 @@ const SmartBot = (props) => {
|
|
|
12577
12590
|
let data = {
|
|
12578
12591
|
agentId: currentAgentId,
|
|
12579
12592
|
userInput: cloneDeep(userInput),
|
|
12580
|
-
sessionId: currentSessionId,
|
|
12593
|
+
sessionId: isEmpty$1(userInput) ? currentSessionId : "",
|
|
12581
12594
|
baseUrl: baseUrl,
|
|
12582
12595
|
userExplicitInput: userExplicitInput,
|
|
12583
12596
|
textWithColumnNames: textWithColumnNames,
|
|
@@ -12615,6 +12628,13 @@ const SmartBot = (props) => {
|
|
|
12615
12628
|
// Reset step form stream state so old TabularContent instances don't process new data
|
|
12616
12629
|
dispatch(setStepFormStreamData(null));
|
|
12617
12630
|
resetActiveTabularInstance();
|
|
12631
|
+
// Reset stepFormStreamControl so stale session_id doesn't leak into new prompts
|
|
12632
|
+
stepFormStreamControl.sessionId = "";
|
|
12633
|
+
stepFormStreamControl.chatId = "";
|
|
12634
|
+
stepFormStreamControl.initValue = false;
|
|
12635
|
+
stepFormStreamControl.uniqueChatId = "";
|
|
12636
|
+
sessionStorage.removeItem("stepForm_sessionId");
|
|
12637
|
+
sessionStorage.removeItem("stepForm_chatId");
|
|
12618
12638
|
// dispatch(setChatbotContext({}));
|
|
12619
12639
|
setUserInput(params?.text);
|
|
12620
12640
|
handleSendMessage(params?.text, params?.userExplicitInput, params?.textWithColumnNames);
|