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.cjs.js CHANGED
@@ -8705,8 +8705,26 @@ const StreamedContent = ({ botData }) => {
8705
8705
  stepRef.current = [...currentSteps];
8706
8706
  setSteps([...currentSteps]);
8707
8707
  }
8708
- const finalMessage = "Please reach out to IA for this, as this didn't work even after retry";
8709
- messageToStoreRef.current.chatData.response = finalMessage;
8708
+ // Append the error message at the bottom of any existing content.
8709
+ // If widgets already exist in appendedData, append as the last widget
8710
+ // so it renders AFTER the already-received content (not at the top).
8711
+ const finalMessage = "The service is temporarily unavailable because of an unusual load. Please wait a moment and try again.";
8712
+ const hasExistingWidgetsOnErr = messageToStoreRef.current.appendedData &&
8713
+ (isArray(messageToStoreRef.current.appendedData)
8714
+ ? messageToStoreRef.current.appendedData.length > 0
8715
+ : Object.keys(messageToStoreRef.current.appendedData).length > 0);
8716
+ if (hasExistingWidgetsOnErr) {
8717
+ const errorWidget = { type: "text", response: finalMessage };
8718
+ if (isArray(messageToStoreRef.current.appendedData)) {
8719
+ messageToStoreRef.current.appendedData.push(errorWidget);
8720
+ }
8721
+ else {
8722
+ messageToStoreRef.current.appendedData = [messageToStoreRef.current.appendedData, errorWidget];
8723
+ }
8724
+ }
8725
+ else {
8726
+ messageToStoreRef.current.chatData.response = finalMessage;
8727
+ }
8710
8728
  setContent(finalMessage);
8711
8729
  dispatch(smartBotActions.setMinimizedStreamData({
8712
8730
  isStreaming: false,
@@ -8748,9 +8766,10 @@ const StreamedContent = ({ botData }) => {
8748
8766
  startRetryCountdown();
8749
8767
  }
8750
8768
  else {
8751
- // Retries exhausted — show final elegant message
8769
+ // Retries exhausted — show final message
8752
8770
  setWasStreamingAborted(true);
8753
8771
  wasStreamingAbortedRef.current = true;
8772
+ // Mark the last in-progress step as completed
8754
8773
  const currentSteps = stepRef.current;
8755
8774
  if (currentSteps.length > 0) {
8756
8775
  const lastStep = currentSteps[currentSteps.length - 1];
@@ -8760,8 +8779,26 @@ const StreamedContent = ({ botData }) => {
8760
8779
  stepRef.current = [...currentSteps];
8761
8780
  setSteps([...currentSteps]);
8762
8781
  }
8763
- const finalMessage = "Please reach out to IA for this, as this didn't work even after retry";
8764
- messageToStoreRef.current.chatData.response = finalMessage;
8782
+ // Append the error message at the bottom of any existing content.
8783
+ // If widgets already exist in appendedData, append as the last widget
8784
+ // so it renders AFTER the already-received content (not at the top).
8785
+ const finalMessage = "The service is temporarily unavailable because of an unusual load. Please wait a moment and try again.";
8786
+ const hasExistingWidgets = messageToStoreRef.current.appendedData &&
8787
+ (isArray(messageToStoreRef.current.appendedData)
8788
+ ? messageToStoreRef.current.appendedData.length > 0
8789
+ : Object.keys(messageToStoreRef.current.appendedData).length > 0);
8790
+ if (hasExistingWidgets) {
8791
+ const errorWidget = { type: "text", response: finalMessage };
8792
+ if (isArray(messageToStoreRef.current.appendedData)) {
8793
+ messageToStoreRef.current.appendedData.push(errorWidget);
8794
+ }
8795
+ else {
8796
+ messageToStoreRef.current.appendedData = [messageToStoreRef.current.appendedData, errorWidget];
8797
+ }
8798
+ }
8799
+ else {
8800
+ messageToStoreRef.current.chatData.response = finalMessage;
8801
+ }
8765
8802
  setContent(finalMessage);
8766
8803
  dispatch(smartBotActions.setMinimizedStreamData({
8767
8804
  isStreaming: false,