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.cjs.js CHANGED
@@ -234,10 +234,10 @@ const triggerRefresh = async (baseUrl) => {
234
234
  return null;
235
235
  }
236
236
  };
237
- const fetchChatbotFilterConfig = async (dimension = "product") => {
237
+ const fetchChatbotFilterConfig = async () => {
238
238
  try {
239
239
  return axiosInstance({
240
- url: `core/filter/generic-schema-mapping?dimension=${dimension}&screen_name=Chatbot`,
240
+ url: `core/filter/generic-schema-mapping?screen_name=Chatbot`,
241
241
  method: "GET",
242
242
  });
243
243
  }
@@ -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
@@ -9429,10 +9435,10 @@ const StreamedContent = ({ botData }) => {
9429
9435
  processResponse(response, botData.inputBody, currentMode, botData.utilityObject.customChatConfig, {
9430
9436
  newChatData: chatDataInfoRef,
9431
9437
  isTabEnabled: true,
9432
- steps: lodash.cloneDeep(stepRef.current),
9438
+ steps: stepRef.current.map(s => ({ ...s })),
9433
9439
  currentTabValue: (stepsDone && !hasStepFormWidgets) ? "agent_response" : "steps",
9434
- questions: lodash.cloneDeep(questionsRef.current),
9435
- questionsStepsMap: lodash.cloneDeep(questionsStepsMapRef.current),
9440
+ questions: [...questionsRef.current],
9441
+ questionsStepsMap: { ...questionsStepsMapRef.current },
9436
9442
  stepFormDataMap: { ...stepFormDataMapRef.current },
9437
9443
  }, activeConversationId);
9438
9444
  // [
@@ -9537,10 +9543,10 @@ const StreamedContent = ({ botData }) => {
9537
9543
  processResponse(response, botData.inputBody, currentMode, botData.utilityObject.customChatConfig, {
9538
9544
  newChatData: chatDataInfoRef,
9539
9545
  isTabEnabled: true,
9540
- steps: lodash.cloneDeep(stepRef.current),
9546
+ steps: stepRef.current.map(s => ({ ...s })),
9541
9547
  currentTabValue: stepsDone ? "agent_response" : "steps",
9542
- questions: lodash.cloneDeep(questionsRef.current),
9543
- questionsStepsMap: lodash.cloneDeep(questionsStepsMapRef.current),
9548
+ questions: [...questionsRef.current],
9549
+ questionsStepsMap: { ...questionsStepsMapRef.current },
9544
9550
  stepFormDataMap: { ...stepFormDataMapRef.current },
9545
9551
  }, activeConversationId);
9546
9552
  }
@@ -14867,14 +14873,11 @@ const SmartBot = (props) => {
14867
14873
  },
14868
14874
  ]);
14869
14875
  }
14870
- const [response, responseStore] = await Promise.all([
14871
- fetchChatbotFilterConfig("product"),
14872
- fetchChatbotFilterConfig("store"),
14873
- ]);
14876
+ const response = await fetchChatbotFilterConfig();
14877
+ const responseData = response?.data?.data || {};
14874
14878
  const combinedOptions = [
14875
- ...(response?.data?.data || []),
14876
- ...(responseStore?.data?.data || []),
14877
- ...(chatbotFilterCustomConfig?.data || []), // Add custom filter config for testing
14879
+ ...Object.values(responseData).flat(),
14880
+ ...(chatbotFilterCustomConfig?.data || []) // Add custom filter config for testing
14878
14881
  ];
14879
14882
  // Create hierarchy key-value pairs object
14880
14883
  const hierarchyKeyValuePairs = {};
@@ -15322,7 +15325,7 @@ const SmartBot = (props) => {
15322
15325
  let newChatData = chatDataState?.[currentMode]?.conversations?.[activeConversationId]?.messages;
15323
15326
  let newChatDataLength = newChatData?.length - 1;
15324
15327
  if (newChatDataLength) {
15325
- chatDataInfoRef.current[currentMode].conversations[activeConversationId].messages[chatDataInfoRefLength - 1] = lodash.cloneDeep(newChatData?.[newChatDataLength]);
15328
+ chatDataInfoRef.current[currentMode].conversations[activeConversationId].messages[chatDataInfoRefLength - 1] = { ...newChatData?.[newChatDataLength] };
15326
15329
  }
15327
15330
  }
15328
15331
  // let chatDataForReference = JSON.stringify(
@@ -15359,15 +15362,11 @@ const SmartBot = (props) => {
15359
15362
  // ;
15360
15363
  message.isFormDisabled = index !== lastBotMessageIndex;
15361
15364
  message.messageIndex = index;
15362
- let originalUtilityObject = message.utilityObject;
15363
- let originalThinkingResponse = message.thinkingResponse;
15364
- let newMessage = lodash.cloneDeep(message);
15365
- if (originalUtilityObject) {
15366
- newMessage.utilityObject = originalUtilityObject;
15367
- }
15368
- if (originalThinkingResponse) {
15369
- newMessage.thinkingResponse = originalThinkingResponse;
15370
- }
15365
+ // Shallow copy — avoids cloneDeep which causes OOM on large
15366
+ // bodyText (images, widget data, meta objects).
15367
+ // utilityObject, thinkingResponse, and bodyText are preserved
15368
+ // by reference since child components only read them.
15369
+ let newMessage = { ...message };
15371
15370
  message.jsx = (jsxRuntime.jsx(BotMessage, { botData: newMessage, state: loadingState, handleLikeDislike: handleLikeDislike, props: properties }));
15372
15371
  let actualProps = {
15373
15372
  botData: newMessage,
@@ -15380,17 +15379,20 @@ const SmartBot = (props) => {
15380
15379
  // message.enableLikes = true;
15381
15380
  }
15382
15381
  });
15383
- // Create a deep clone and remove JSX properties to avoid circular references
15384
- let newChat = lodash.cloneDeep(chatDataInfoRef?.current[currentMode]);
15385
- // Restore thinkingResponse (may contain JSX components like ThinkinHeaderInfo)
15386
- // which cloneDeep serializes into plain objects
15387
- const originalMessages = chatDataInfoRef?.current[currentMode]?.conversations?.[activeConversationId]?.messages || [];
15388
- const clonedMessages = newChat?.conversations?.[activeConversationId]?.messages || [];
15389
- originalMessages.forEach((origMsg, idx) => {
15390
- if (origMsg.thinkingResponse && clonedMessages[idx]) {
15391
- clonedMessages[idx].thinkingResponse = origMsg.thinkingResponse;
15392
- }
15393
- });
15382
+ // Shallow-clone the conversation structure to trigger React re-render
15383
+ // without deep-cloning large message payloads (which caused OOM crashes).
15384
+ const modeData = chatDataInfoRef?.current[currentMode];
15385
+ const convMessages = modeData?.conversations?.[activeConversationId]?.messages || [];
15386
+ let newChat = {
15387
+ ...modeData,
15388
+ conversations: {
15389
+ ...modeData?.conversations,
15390
+ [activeConversationId]: {
15391
+ ...modeData?.conversations?.[activeConversationId],
15392
+ messages: convMessages.map(msg => ({ ...msg })),
15393
+ },
15394
+ },
15395
+ };
15394
15396
  setConversation(newChat);
15395
15397
  }
15396
15398
  else if (showModal) {