impact-chatbot 2.3.75 → 2.3.77
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 +119 -31
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +119 -31
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -5217,6 +5217,12 @@ const sseevent = (message, messageToStoreRef) => {
|
|
|
5217
5217
|
};
|
|
5218
5218
|
}
|
|
5219
5219
|
}
|
|
5220
|
+
// Strip large debugging metadata that is never used for rendering.
|
|
5221
|
+
// The meta field contains text_chunks, supplemental_chunks, image_ids
|
|
5222
|
+
// arrays that accumulate in memory and contribute to OOM crashes.
|
|
5223
|
+
if (parsedData?.meta) {
|
|
5224
|
+
delete parsedData.meta;
|
|
5225
|
+
}
|
|
5220
5226
|
if (messageToStoreRef.current.currentMode === "agent" &&
|
|
5221
5227
|
(parsedData?.chat_id || parsedData?.session_id)) {
|
|
5222
5228
|
messageToStoreRef.current.uniqueChatId = parsedData?.chat_id
|
|
@@ -5715,6 +5721,10 @@ const ButtonContent = ({ bodyText, isFormDisabled = false, isStepFormSubmit = fa
|
|
|
5715
5721
|
stepFormStreamControl.uniqueChatId = data?.chat_id ? data.chat_id : "";
|
|
5716
5722
|
// Clear sessionStorage so stale session_id isn't picked up by future non-init calls
|
|
5717
5723
|
sessionStorage.setItem("stepForm_sessionId", "");
|
|
5724
|
+
// Notify SmartBot to update its initValue/sessionId state
|
|
5725
|
+
window.dispatchEvent(new CustomEvent("stepFormInitStateUpdate", {
|
|
5726
|
+
detail: { initValue: true, sessionId: "", uniqueChatId: data?.chat_id || "" },
|
|
5727
|
+
}));
|
|
5718
5728
|
}
|
|
5719
5729
|
// Stream ended — dispatch all collected chunks at once
|
|
5720
5730
|
stepFormStreamControl.isStreaming = false;
|
|
@@ -8108,7 +8118,7 @@ const Steps$1 = ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, s
|
|
|
8108
8118
|
}, children: jsxRuntime.jsx(ProgressBarItem$1, { question: "Thinking", questionSteps: [{ header: "", sub_header: "", step_status: "not-completed" }], isLast: true, classes: classes, formData: null, isFormDisabled: isFormDisabled }) }))] }));
|
|
8109
8119
|
};
|
|
8110
8120
|
|
|
8111
|
-
const renderWidgetItem = (item, index) => {
|
|
8121
|
+
const renderWidgetItem = (item, index, isFormDisabled) => {
|
|
8112
8122
|
try {
|
|
8113
8123
|
const parsedData = parseResponse(item, item.type, "", "", true);
|
|
8114
8124
|
if (!parsedData)
|
|
@@ -8121,6 +8131,22 @@ const renderWidgetItem = (item, index) => {
|
|
|
8121
8131
|
return jsxRuntime.jsx(TableContent, { bodyText: parsedData.bodyText }, key);
|
|
8122
8132
|
case "graph":
|
|
8123
8133
|
return jsxRuntime.jsx(GraphContent, { bodyText: parsedData.bodyText }, key);
|
|
8134
|
+
case "radio":
|
|
8135
|
+
return jsxRuntime.jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
|
|
8136
|
+
case "checkbox":
|
|
8137
|
+
return jsxRuntime.jsx(CheckboxContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
|
|
8138
|
+
case "select":
|
|
8139
|
+
return jsxRuntime.jsx(SelectContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
|
|
8140
|
+
case "slider":
|
|
8141
|
+
return jsxRuntime.jsx(SliderContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
|
|
8142
|
+
case "button":
|
|
8143
|
+
return jsxRuntime.jsx(ButtonContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
|
|
8144
|
+
case "input":
|
|
8145
|
+
return jsxRuntime.jsx(InputContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
|
|
8146
|
+
case "datePicker":
|
|
8147
|
+
return jsxRuntime.jsx(DatePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
|
|
8148
|
+
case "dateRangePicker":
|
|
8149
|
+
return jsxRuntime.jsx(DateRangePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
|
|
8124
8150
|
default:
|
|
8125
8151
|
return null;
|
|
8126
8152
|
}
|
|
@@ -8131,11 +8157,11 @@ const renderWidgetItem = (item, index) => {
|
|
|
8131
8157
|
}
|
|
8132
8158
|
};
|
|
8133
8159
|
const AgentResponse$1 = (props) => {
|
|
8134
|
-
const { content, isStreaming, streamingWidgetData = [] } = props;
|
|
8160
|
+
const { content, isStreaming, streamingWidgetData = [], isFormDisabled = false } = props;
|
|
8135
8161
|
const classes = useStyles$6();
|
|
8136
8162
|
const chatClasses = useStyles$9();
|
|
8137
8163
|
const renderedWidgets = streamingWidgetData
|
|
8138
|
-
.map((item, index) => renderWidgetItem(item, index))
|
|
8164
|
+
.map((item, index) => renderWidgetItem(item, index, isFormDisabled))
|
|
8139
8165
|
.filter(Boolean);
|
|
8140
8166
|
return (jsxRuntime.jsxs("div", { className: chatClasses.agentResponseContainer, children: [content ? (jsxRuntime.jsxs(material.Typography, { className: chatClasses.bodyTextStyling, children: [jsxRuntime.jsx(TextRenderer, { text: content }), isStreaming && renderedWidgets.length === 0 && jsxRuntime.jsx("span", { className: classes.cursor })] })) : null, renderedWidgets.length > 0 && (jsxRuntime.jsx("div", { className: "streaming-widget-content", children: renderedWidgets })), isStreaming && (renderedWidgets.length > 0 || !content) && (jsxRuntime.jsx("span", { className: classes.cursor }))] }));
|
|
8141
8167
|
};
|
|
@@ -8206,7 +8232,7 @@ const StepsResponseTab = (props) => {
|
|
|
8206
8232
|
},
|
|
8207
8233
|
], tabPanels: [
|
|
8208
8234
|
jsxRuntime.jsx(Steps$1, { steps: steps, setSteps: setSteps, done: stepsDone, setDone: setStepsDone, setTabValue: setTabValue, finalStepDone: finalStepDone, setFinalStepDone: setFinalStepDone, stepChange: stepChange, currentMode: currentMode, questions: questions, questionsStepsMap: questionsStepsMap, stepFormDataMap: stepFormDataMap, isFormDisabled: isFormDisabled || isTimedOut }),
|
|
8209
|
-
jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(AgentResponse$1, { content: content, isStreaming: isStreaming, streamingWidgetData: streamingWidgetData }), timeoutMessage && (jsxRuntime.jsx("div", { style: { marginTop: "8px", padding: "0 8px" }, children: jsxRuntime.jsx(TextRenderer, { text: timeoutMessage, thinking: "" }) }))] }),
|
|
8235
|
+
jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(AgentResponse$1, { content: content, isStreaming: isStreaming, streamingWidgetData: streamingWidgetData, isFormDisabled: isFormDisabled || isTimedOut }), timeoutMessage && (jsxRuntime.jsx("div", { style: { marginTop: "8px", padding: "0 8px" }, children: jsxRuntime.jsx(TextRenderer, { text: timeoutMessage, thinking: "" }) }))] }),
|
|
8210
8236
|
], value: tabValue }) }));
|
|
8211
8237
|
};
|
|
8212
8238
|
|
|
@@ -9351,6 +9377,16 @@ const StreamedContent = ({ botData }) => {
|
|
|
9351
9377
|
];
|
|
9352
9378
|
botData.utilityObject.setInitValue(messageToStoreRef.current.initValue);
|
|
9353
9379
|
botData.utilityObject.setSessionId(messageToStoreRef.current.sessionId);
|
|
9380
|
+
// Also update currentSessionId via event so the send button uses the correct session_id
|
|
9381
|
+
if (messageToStoreRef.current.status === "completed" || messageToStoreRef.current.status === "follow-up") {
|
|
9382
|
+
window.dispatchEvent(new CustomEvent("stepFormInitStateUpdate", {
|
|
9383
|
+
detail: {
|
|
9384
|
+
initValue: messageToStoreRef.current.initValue,
|
|
9385
|
+
sessionId: messageToStoreRef.current.sessionId,
|
|
9386
|
+
uniqueChatId: messageToStoreRef.current.uniqueChatId,
|
|
9387
|
+
},
|
|
9388
|
+
}));
|
|
9389
|
+
}
|
|
9354
9390
|
botData.utilityObject.setAdditionalArgs(!isEmpty(messageToStoreRef.current.additionalArgs)
|
|
9355
9391
|
? messageToStoreRef.current.additionalArgs
|
|
9356
9392
|
: {});
|
|
@@ -9429,10 +9465,10 @@ const StreamedContent = ({ botData }) => {
|
|
|
9429
9465
|
processResponse(response, botData.inputBody, currentMode, botData.utilityObject.customChatConfig, {
|
|
9430
9466
|
newChatData: chatDataInfoRef,
|
|
9431
9467
|
isTabEnabled: true,
|
|
9432
|
-
steps:
|
|
9468
|
+
steps: stepRef.current.map(s => ({ ...s })),
|
|
9433
9469
|
currentTabValue: (stepsDone && !hasStepFormWidgets) ? "agent_response" : "steps",
|
|
9434
|
-
questions:
|
|
9435
|
-
questionsStepsMap:
|
|
9470
|
+
questions: [...questionsRef.current],
|
|
9471
|
+
questionsStepsMap: { ...questionsStepsMapRef.current },
|
|
9436
9472
|
stepFormDataMap: { ...stepFormDataMapRef.current },
|
|
9437
9473
|
}, activeConversationId);
|
|
9438
9474
|
// [
|
|
@@ -9537,10 +9573,10 @@ const StreamedContent = ({ botData }) => {
|
|
|
9537
9573
|
processResponse(response, botData.inputBody, currentMode, botData.utilityObject.customChatConfig, {
|
|
9538
9574
|
newChatData: chatDataInfoRef,
|
|
9539
9575
|
isTabEnabled: true,
|
|
9540
|
-
steps:
|
|
9576
|
+
steps: stepRef.current.map(s => ({ ...s })),
|
|
9541
9577
|
currentTabValue: stepsDone ? "agent_response" : "steps",
|
|
9542
|
-
questions:
|
|
9543
|
-
questionsStepsMap:
|
|
9578
|
+
questions: [...questionsRef.current],
|
|
9579
|
+
questionsStepsMap: { ...questionsStepsMapRef.current },
|
|
9544
9580
|
stepFormDataMap: { ...stepFormDataMapRef.current },
|
|
9545
9581
|
}, activeConversationId);
|
|
9546
9582
|
}
|
|
@@ -10112,6 +10148,22 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
|
|
|
10112
10148
|
return jsxRuntime.jsx(TableContent, { bodyText: parsedData.bodyText }, key);
|
|
10113
10149
|
case "graph":
|
|
10114
10150
|
return jsxRuntime.jsx(GraphContent, { bodyText: parsedData.bodyText }, key);
|
|
10151
|
+
case "radio":
|
|
10152
|
+
return jsxRuntime.jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
|
|
10153
|
+
case "checkbox":
|
|
10154
|
+
return jsxRuntime.jsx(CheckboxContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
|
|
10155
|
+
case "select":
|
|
10156
|
+
return jsxRuntime.jsx(SelectContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
|
|
10157
|
+
case "slider":
|
|
10158
|
+
return jsxRuntime.jsx(SliderContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
|
|
10159
|
+
case "button":
|
|
10160
|
+
return jsxRuntime.jsx(ButtonContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
|
|
10161
|
+
case "input":
|
|
10162
|
+
return jsxRuntime.jsx(InputContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
|
|
10163
|
+
case "datePicker":
|
|
10164
|
+
return jsxRuntime.jsx(DatePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
|
|
10165
|
+
case "dateRangePicker":
|
|
10166
|
+
return jsxRuntime.jsx(DateRangePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
|
|
10115
10167
|
default:
|
|
10116
10168
|
return null;
|
|
10117
10169
|
}
|
|
@@ -10412,6 +10464,29 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
|
|
|
10412
10464
|
setQuestionsStepsMapState(lodash.cloneDeep(newQuestionsStepsMap));
|
|
10413
10465
|
setStepFormDataMapState(lodash.cloneDeep(newStepFormDataMap));
|
|
10414
10466
|
if (newWidgets.length > 0) {
|
|
10467
|
+
// If widget data contains form components (radio, select, checkbox, etc.),
|
|
10468
|
+
// append a Submit button so the user can submit their selection
|
|
10469
|
+
const formTypes = ["radio", "select", "checkbox", "slider", "input", "datePicker", "dateRangePicker"];
|
|
10470
|
+
const hasFormWidget = newWidgets.some((item) => formTypes.includes(item?.type));
|
|
10471
|
+
const hasStepForm = chunks.some((c) => c.status === "step_form");
|
|
10472
|
+
if (hasFormWidget && !hasStepForm) {
|
|
10473
|
+
const sendButton = document.getElementById("chat-input-send-button");
|
|
10474
|
+
newWidgets.push({
|
|
10475
|
+
type: "button",
|
|
10476
|
+
data: {
|
|
10477
|
+
message: "",
|
|
10478
|
+
buttons: [
|
|
10479
|
+
{
|
|
10480
|
+
label: "Submit",
|
|
10481
|
+
variant: "primary",
|
|
10482
|
+
size: "medium",
|
|
10483
|
+
disabled: false,
|
|
10484
|
+
onClick: () => sendButton?.click(),
|
|
10485
|
+
},
|
|
10486
|
+
],
|
|
10487
|
+
},
|
|
10488
|
+
});
|
|
10489
|
+
}
|
|
10415
10490
|
// Replace (not append) to avoid duplicates from real-time widget_chunk dispatches
|
|
10416
10491
|
setWidgetContent(newWidgets);
|
|
10417
10492
|
}
|
|
@@ -14793,11 +14868,25 @@ const SmartBot = (props) => {
|
|
|
14793
14868
|
console.error("Error updating timestamp after step form stream:", e);
|
|
14794
14869
|
}
|
|
14795
14870
|
};
|
|
14871
|
+
// Update SmartBot-level initValue/sessionId when ButtonContent's stream receives completed/follow-up
|
|
14872
|
+
const handleStepFormInitStateUpdate = (e) => {
|
|
14873
|
+
const { initValue: newInitValue, sessionId: newSessionId, uniqueChatId: newChatId } = e.detail || {};
|
|
14874
|
+
if (newInitValue !== undefined)
|
|
14875
|
+
setInitValue(newInitValue);
|
|
14876
|
+
if (newSessionId !== undefined) {
|
|
14877
|
+
setSessionId(newSessionId);
|
|
14878
|
+
setCurrentSessionId(newSessionId);
|
|
14879
|
+
}
|
|
14880
|
+
if (newChatId !== undefined)
|
|
14881
|
+
setUniqueChatId(newChatId);
|
|
14882
|
+
};
|
|
14796
14883
|
window.addEventListener("stepFormStreamStart", handleStepFormStreamStart);
|
|
14797
14884
|
window.addEventListener("stepFormStreamEnd", handleStepFormStreamEnd);
|
|
14885
|
+
window.addEventListener("stepFormInitStateUpdate", handleStepFormInitStateUpdate);
|
|
14798
14886
|
return () => {
|
|
14799
14887
|
window.removeEventListener("stepFormStreamStart", handleStepFormStreamStart);
|
|
14800
14888
|
window.removeEventListener("stepFormStreamEnd", handleStepFormStreamEnd);
|
|
14889
|
+
window.removeEventListener("stepFormInitStateUpdate", handleStepFormInitStateUpdate);
|
|
14801
14890
|
};
|
|
14802
14891
|
}, []);
|
|
14803
14892
|
const fetchCustomBotConfigurations = async () => {
|
|
@@ -15319,7 +15408,7 @@ const SmartBot = (props) => {
|
|
|
15319
15408
|
let newChatData = chatDataState?.[currentMode]?.conversations?.[activeConversationId]?.messages;
|
|
15320
15409
|
let newChatDataLength = newChatData?.length - 1;
|
|
15321
15410
|
if (newChatDataLength) {
|
|
15322
|
-
chatDataInfoRef.current[currentMode].conversations[activeConversationId].messages[chatDataInfoRefLength - 1] =
|
|
15411
|
+
chatDataInfoRef.current[currentMode].conversations[activeConversationId].messages[chatDataInfoRefLength - 1] = { ...newChatData?.[newChatDataLength] };
|
|
15323
15412
|
}
|
|
15324
15413
|
}
|
|
15325
15414
|
// let chatDataForReference = JSON.stringify(
|
|
@@ -15356,15 +15445,11 @@ const SmartBot = (props) => {
|
|
|
15356
15445
|
// ;
|
|
15357
15446
|
message.isFormDisabled = index !== lastBotMessageIndex;
|
|
15358
15447
|
message.messageIndex = index;
|
|
15359
|
-
|
|
15360
|
-
|
|
15361
|
-
|
|
15362
|
-
|
|
15363
|
-
|
|
15364
|
-
}
|
|
15365
|
-
if (originalThinkingResponse) {
|
|
15366
|
-
newMessage.thinkingResponse = originalThinkingResponse;
|
|
15367
|
-
}
|
|
15448
|
+
// Shallow copy — avoids cloneDeep which causes OOM on large
|
|
15449
|
+
// bodyText (images, widget data, meta objects).
|
|
15450
|
+
// utilityObject, thinkingResponse, and bodyText are preserved
|
|
15451
|
+
// by reference since child components only read them.
|
|
15452
|
+
let newMessage = { ...message };
|
|
15368
15453
|
message.jsx = (jsxRuntime.jsx(BotMessage, { botData: newMessage, state: loadingState, handleLikeDislike: handleLikeDislike, props: properties }));
|
|
15369
15454
|
let actualProps = {
|
|
15370
15455
|
botData: newMessage,
|
|
@@ -15377,17 +15462,20 @@ const SmartBot = (props) => {
|
|
|
15377
15462
|
// message.enableLikes = true;
|
|
15378
15463
|
}
|
|
15379
15464
|
});
|
|
15380
|
-
//
|
|
15381
|
-
|
|
15382
|
-
|
|
15383
|
-
|
|
15384
|
-
|
|
15385
|
-
|
|
15386
|
-
|
|
15387
|
-
|
|
15388
|
-
|
|
15389
|
-
|
|
15390
|
-
|
|
15465
|
+
// Shallow-clone the conversation structure to trigger React re-render
|
|
15466
|
+
// without deep-cloning large message payloads (which caused OOM crashes).
|
|
15467
|
+
const modeData = chatDataInfoRef?.current[currentMode];
|
|
15468
|
+
const convMessages = modeData?.conversations?.[activeConversationId]?.messages || [];
|
|
15469
|
+
let newChat = {
|
|
15470
|
+
...modeData,
|
|
15471
|
+
conversations: {
|
|
15472
|
+
...modeData?.conversations,
|
|
15473
|
+
[activeConversationId]: {
|
|
15474
|
+
...modeData?.conversations?.[activeConversationId],
|
|
15475
|
+
messages: convMessages.map(msg => ({ ...msg })),
|
|
15476
|
+
},
|
|
15477
|
+
},
|
|
15478
|
+
};
|
|
15391
15479
|
setConversation(newChat);
|
|
15392
15480
|
}
|
|
15393
15481
|
else if (showModal) {
|