impact-chatbot 2.3.75 → 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
@@ -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
  }
@@ -15319,7 +15325,7 @@ const SmartBot = (props) => {
15319
15325
  let newChatData = chatDataState?.[currentMode]?.conversations?.[activeConversationId]?.messages;
15320
15326
  let newChatDataLength = newChatData?.length - 1;
15321
15327
  if (newChatDataLength) {
15322
- chatDataInfoRef.current[currentMode].conversations[activeConversationId].messages[chatDataInfoRefLength - 1] = lodash.cloneDeep(newChatData?.[newChatDataLength]);
15328
+ chatDataInfoRef.current[currentMode].conversations[activeConversationId].messages[chatDataInfoRefLength - 1] = { ...newChatData?.[newChatDataLength] };
15323
15329
  }
15324
15330
  }
15325
15331
  // let chatDataForReference = JSON.stringify(
@@ -15356,15 +15362,11 @@ const SmartBot = (props) => {
15356
15362
  // ;
15357
15363
  message.isFormDisabled = index !== lastBotMessageIndex;
15358
15364
  message.messageIndex = index;
15359
- let originalUtilityObject = message.utilityObject;
15360
- let originalThinkingResponse = message.thinkingResponse;
15361
- let newMessage = lodash.cloneDeep(message);
15362
- if (originalUtilityObject) {
15363
- newMessage.utilityObject = originalUtilityObject;
15364
- }
15365
- if (originalThinkingResponse) {
15366
- newMessage.thinkingResponse = originalThinkingResponse;
15367
- }
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 };
15368
15370
  message.jsx = (jsxRuntime.jsx(BotMessage, { botData: newMessage, state: loadingState, handleLikeDislike: handleLikeDislike, props: properties }));
15369
15371
  let actualProps = {
15370
15372
  botData: newMessage,
@@ -15377,17 +15379,20 @@ const SmartBot = (props) => {
15377
15379
  // message.enableLikes = true;
15378
15380
  }
15379
15381
  });
15380
- // Create a deep clone and remove JSX properties to avoid circular references
15381
- let newChat = lodash.cloneDeep(chatDataInfoRef?.current[currentMode]);
15382
- // Restore thinkingResponse (may contain JSX components like ThinkinHeaderInfo)
15383
- // which cloneDeep serializes into plain objects
15384
- const originalMessages = chatDataInfoRef?.current[currentMode]?.conversations?.[activeConversationId]?.messages || [];
15385
- const clonedMessages = newChat?.conversations?.[activeConversationId]?.messages || [];
15386
- originalMessages.forEach((origMsg, idx) => {
15387
- if (origMsg.thinkingResponse && clonedMessages[idx]) {
15388
- clonedMessages[idx].thinkingResponse = origMsg.thinkingResponse;
15389
- }
15390
- });
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
+ };
15391
15396
  setConversation(newChat);
15392
15397
  }
15393
15398
  else if (showModal) {