impact-chatbot 2.3.74 → 2.3.76

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.esm.js CHANGED
@@ -212,10 +212,10 @@ const triggerRefresh = async (baseUrl) => {
212
212
  return null;
213
213
  }
214
214
  };
215
- const fetchChatbotFilterConfig = async (dimension = "product") => {
215
+ const fetchChatbotFilterConfig = async () => {
216
216
  try {
217
217
  return axiosInstance({
218
- url: `core/filter/generic-schema-mapping?dimension=${dimension}&screen_name=Chatbot`,
218
+ url: `core/filter/generic-schema-mapping?screen_name=Chatbot`,
219
219
  method: "GET",
220
220
  });
221
221
  }
@@ -5195,6 +5195,12 @@ const sseevent = (message, messageToStoreRef) => {
5195
5195
  };
5196
5196
  }
5197
5197
  }
5198
+ // Strip large debugging metadata that is never used for rendering.
5199
+ // The meta field contains text_chunks, supplemental_chunks, image_ids
5200
+ // arrays that accumulate in memory and contribute to OOM crashes.
5201
+ if (parsedData?.meta) {
5202
+ delete parsedData.meta;
5203
+ }
5198
5204
  if (messageToStoreRef.current.currentMode === "agent" &&
5199
5205
  (parsedData?.chat_id || parsedData?.session_id)) {
5200
5206
  messageToStoreRef.current.uniqueChatId = parsedData?.chat_id
@@ -9407,10 +9413,10 @@ const StreamedContent = ({ botData }) => {
9407
9413
  processResponse(response, botData.inputBody, currentMode, botData.utilityObject.customChatConfig, {
9408
9414
  newChatData: chatDataInfoRef,
9409
9415
  isTabEnabled: true,
9410
- steps: cloneDeep(stepRef.current),
9416
+ steps: stepRef.current.map(s => ({ ...s })),
9411
9417
  currentTabValue: (stepsDone && !hasStepFormWidgets) ? "agent_response" : "steps",
9412
- questions: cloneDeep(questionsRef.current),
9413
- questionsStepsMap: cloneDeep(questionsStepsMapRef.current),
9418
+ questions: [...questionsRef.current],
9419
+ questionsStepsMap: { ...questionsStepsMapRef.current },
9414
9420
  stepFormDataMap: { ...stepFormDataMapRef.current },
9415
9421
  }, activeConversationId);
9416
9422
  // [
@@ -9515,10 +9521,10 @@ const StreamedContent = ({ botData }) => {
9515
9521
  processResponse(response, botData.inputBody, currentMode, botData.utilityObject.customChatConfig, {
9516
9522
  newChatData: chatDataInfoRef,
9517
9523
  isTabEnabled: true,
9518
- steps: cloneDeep(stepRef.current),
9524
+ steps: stepRef.current.map(s => ({ ...s })),
9519
9525
  currentTabValue: stepsDone ? "agent_response" : "steps",
9520
- questions: cloneDeep(questionsRef.current),
9521
- questionsStepsMap: cloneDeep(questionsStepsMapRef.current),
9526
+ questions: [...questionsRef.current],
9527
+ questionsStepsMap: { ...questionsStepsMapRef.current },
9522
9528
  stepFormDataMap: { ...stepFormDataMapRef.current },
9523
9529
  }, activeConversationId);
9524
9530
  }
@@ -14845,14 +14851,11 @@ const SmartBot = (props) => {
14845
14851
  },
14846
14852
  ]);
14847
14853
  }
14848
- const [response, responseStore] = await Promise.all([
14849
- fetchChatbotFilterConfig("product"),
14850
- fetchChatbotFilterConfig("store"),
14851
- ]);
14854
+ const response = await fetchChatbotFilterConfig();
14855
+ const responseData = response?.data?.data || {};
14852
14856
  const combinedOptions = [
14853
- ...(response?.data?.data || []),
14854
- ...(responseStore?.data?.data || []),
14855
- ...(chatbotFilterCustomConfig?.data || []), // Add custom filter config for testing
14857
+ ...Object.values(responseData).flat(),
14858
+ ...(chatbotFilterCustomConfig?.data || []) // Add custom filter config for testing
14856
14859
  ];
14857
14860
  // Create hierarchy key-value pairs object
14858
14861
  const hierarchyKeyValuePairs = {};
@@ -15300,7 +15303,7 @@ const SmartBot = (props) => {
15300
15303
  let newChatData = chatDataState?.[currentMode]?.conversations?.[activeConversationId]?.messages;
15301
15304
  let newChatDataLength = newChatData?.length - 1;
15302
15305
  if (newChatDataLength) {
15303
- chatDataInfoRef.current[currentMode].conversations[activeConversationId].messages[chatDataInfoRefLength - 1] = cloneDeep(newChatData?.[newChatDataLength]);
15306
+ chatDataInfoRef.current[currentMode].conversations[activeConversationId].messages[chatDataInfoRefLength - 1] = { ...newChatData?.[newChatDataLength] };
15304
15307
  }
15305
15308
  }
15306
15309
  // let chatDataForReference = JSON.stringify(
@@ -15337,15 +15340,11 @@ const SmartBot = (props) => {
15337
15340
  // ;
15338
15341
  message.isFormDisabled = index !== lastBotMessageIndex;
15339
15342
  message.messageIndex = index;
15340
- let originalUtilityObject = message.utilityObject;
15341
- let originalThinkingResponse = message.thinkingResponse;
15342
- let newMessage = cloneDeep(message);
15343
- if (originalUtilityObject) {
15344
- newMessage.utilityObject = originalUtilityObject;
15345
- }
15346
- if (originalThinkingResponse) {
15347
- newMessage.thinkingResponse = originalThinkingResponse;
15348
- }
15343
+ // Shallow copy — avoids cloneDeep which causes OOM on large
15344
+ // bodyText (images, widget data, meta objects).
15345
+ // utilityObject, thinkingResponse, and bodyText are preserved
15346
+ // by reference since child components only read them.
15347
+ let newMessage = { ...message };
15349
15348
  message.jsx = (jsx(BotMessage, { botData: newMessage, state: loadingState, handleLikeDislike: handleLikeDislike, props: properties }));
15350
15349
  let actualProps = {
15351
15350
  botData: newMessage,
@@ -15358,17 +15357,20 @@ const SmartBot = (props) => {
15358
15357
  // message.enableLikes = true;
15359
15358
  }
15360
15359
  });
15361
- // Create a deep clone and remove JSX properties to avoid circular references
15362
- let newChat = cloneDeep(chatDataInfoRef?.current[currentMode]);
15363
- // Restore thinkingResponse (may contain JSX components like ThinkinHeaderInfo)
15364
- // which cloneDeep serializes into plain objects
15365
- const originalMessages = chatDataInfoRef?.current[currentMode]?.conversations?.[activeConversationId]?.messages || [];
15366
- const clonedMessages = newChat?.conversations?.[activeConversationId]?.messages || [];
15367
- originalMessages.forEach((origMsg, idx) => {
15368
- if (origMsg.thinkingResponse && clonedMessages[idx]) {
15369
- clonedMessages[idx].thinkingResponse = origMsg.thinkingResponse;
15370
- }
15371
- });
15360
+ // Shallow-clone the conversation structure to trigger React re-render
15361
+ // without deep-cloning large message payloads (which caused OOM crashes).
15362
+ const modeData = chatDataInfoRef?.current[currentMode];
15363
+ const convMessages = modeData?.conversations?.[activeConversationId]?.messages || [];
15364
+ let newChat = {
15365
+ ...modeData,
15366
+ conversations: {
15367
+ ...modeData?.conversations,
15368
+ [activeConversationId]: {
15369
+ ...modeData?.conversations?.[activeConversationId],
15370
+ messages: convMessages.map(msg => ({ ...msg })),
15371
+ },
15372
+ },
15373
+ };
15372
15374
  setConversation(newChat);
15373
15375
  }
15374
15376
  else if (showModal) {