impact-chatbot 2.3.64 → 2.3.65

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
@@ -8683,8 +8683,26 @@ const StreamedContent = ({ botData }) => {
8683
8683
  stepRef.current = [...currentSteps];
8684
8684
  setSteps([...currentSteps]);
8685
8685
  }
8686
- const finalMessage = "Please reach out to IA for this, as this didn't work even after retry";
8687
- messageToStoreRef.current.chatData.response = finalMessage;
8686
+ // Append the error message at the bottom of any existing content.
8687
+ // If widgets already exist in appendedData, append as the last widget
8688
+ // so it renders AFTER the already-received content (not at the top).
8689
+ const finalMessage = "The service is temporarily unavailable because of an unusual load. Please wait a moment and try again.";
8690
+ const hasExistingWidgetsOnErr = messageToStoreRef.current.appendedData &&
8691
+ (isArray(messageToStoreRef.current.appendedData)
8692
+ ? messageToStoreRef.current.appendedData.length > 0
8693
+ : Object.keys(messageToStoreRef.current.appendedData).length > 0);
8694
+ if (hasExistingWidgetsOnErr) {
8695
+ const errorWidget = { type: "text", response: finalMessage };
8696
+ if (isArray(messageToStoreRef.current.appendedData)) {
8697
+ messageToStoreRef.current.appendedData.push(errorWidget);
8698
+ }
8699
+ else {
8700
+ messageToStoreRef.current.appendedData = [messageToStoreRef.current.appendedData, errorWidget];
8701
+ }
8702
+ }
8703
+ else {
8704
+ messageToStoreRef.current.chatData.response = finalMessage;
8705
+ }
8688
8706
  setContent(finalMessage);
8689
8707
  dispatch(setMinimizedStreamData({
8690
8708
  isStreaming: false,
@@ -8726,9 +8744,10 @@ const StreamedContent = ({ botData }) => {
8726
8744
  startRetryCountdown();
8727
8745
  }
8728
8746
  else {
8729
- // Retries exhausted — show final elegant message
8747
+ // Retries exhausted — show final message
8730
8748
  setWasStreamingAborted(true);
8731
8749
  wasStreamingAbortedRef.current = true;
8750
+ // Mark the last in-progress step as completed
8732
8751
  const currentSteps = stepRef.current;
8733
8752
  if (currentSteps.length > 0) {
8734
8753
  const lastStep = currentSteps[currentSteps.length - 1];
@@ -8738,8 +8757,26 @@ const StreamedContent = ({ botData }) => {
8738
8757
  stepRef.current = [...currentSteps];
8739
8758
  setSteps([...currentSteps]);
8740
8759
  }
8741
- const finalMessage = "Please reach out to IA for this, as this didn't work even after retry";
8742
- messageToStoreRef.current.chatData.response = finalMessage;
8760
+ // Append the error message at the bottom of any existing content.
8761
+ // If widgets already exist in appendedData, append as the last widget
8762
+ // so it renders AFTER the already-received content (not at the top).
8763
+ const finalMessage = "The service is temporarily unavailable because of an unusual load. Please wait a moment and try again.";
8764
+ const hasExistingWidgets = messageToStoreRef.current.appendedData &&
8765
+ (isArray(messageToStoreRef.current.appendedData)
8766
+ ? messageToStoreRef.current.appendedData.length > 0
8767
+ : Object.keys(messageToStoreRef.current.appendedData).length > 0);
8768
+ if (hasExistingWidgets) {
8769
+ const errorWidget = { type: "text", response: finalMessage };
8770
+ if (isArray(messageToStoreRef.current.appendedData)) {
8771
+ messageToStoreRef.current.appendedData.push(errorWidget);
8772
+ }
8773
+ else {
8774
+ messageToStoreRef.current.appendedData = [messageToStoreRef.current.appendedData, errorWidget];
8775
+ }
8776
+ }
8777
+ else {
8778
+ messageToStoreRef.current.chatData.response = finalMessage;
8779
+ }
8743
8780
  setContent(finalMessage);
8744
8781
  dispatch(setMinimizedStreamData({
8745
8782
  isStreaming: false,