impact-chatbot 2.3.35 → 2.3.37

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
@@ -2027,7 +2027,11 @@ const useAgentFlow = (dateFormat, chatDataRef, currentMode, setShowChatPlacehold
2027
2027
  };
2028
2028
  };
2029
2029
 
2030
- const useChatFlow = (chatDataRef, setLoader, setFlowType, setScreenName, setUserInput, setQuestionIndex, setCurrentAppLink, flowType, screenName, questionIndex, userInput, dateFormat, currentMode, activeConversationId, setIsModuleChanged, chatBodyRef, filterReducerState, dispatch, navigate, setShowChatPlaceholder, baseUrl, setChatDataState, setCurrentSessionId, customChatConfig, chatDataInfoRef, chatbotContext, setInitValue, setSessionId, thinkingContent, setThinkingContent, isThinking, setIsThinking, chatId, setChatId, isStop, setIsStop, functionsRef, functionsState, setFunctionsState, thinkingHeaderMessage, setThinkingHeaderMessage, uniqueChatId, initValue, sessionId, fieldNumber, setFieldNumber, additionalArgs, setActiveConversationId) => {
2030
+ const useChatFlow = (chatDataRef, setLoader, setFlowType, setScreenName, setUserInput, setQuestionIndex, setCurrentAppLink, flowType, screenName, questionIndex, userInput, dateFormat, currentMode, activeConversationId, setIsModuleChanged, chatBodyRef, filterReducerState, dispatch, navigate, setShowChatPlaceholder, baseUrl, setChatDataState, setCurrentSessionId, customChatConfig, chatDataInfoRef, chatbotContext, setInitValue, setSessionId, thinkingContent, setThinkingContent, isThinking, setIsThinking, chatId, setChatId, isStop, setIsStop, functionsRef, functionsState, setFunctionsState, thinkingHeaderMessage, setThinkingHeaderMessage, uniqueChatId, initValue, sessionId, fieldNumber, setFieldNumber, additionalArgs, setActiveConversationId, navSessionId, setNavSessionId) => {
2031
+ const navSessionIdRef = useRef(navSessionId);
2032
+ useEffect(() => {
2033
+ navSessionIdRef.current = navSessionId;
2034
+ }, [navSessionId]);
2031
2035
  const { prepareDataAndSendToAgent, setAgentFlow, processResponse, } = useAgentFlow(dateFormat, chatDataRef, currentMode, setShowChatPlaceholder, setLoader, baseUrl, setCurrentSessionId, customChatConfig, chatDataInfoRef, {
2032
2036
  setChatDataState,
2033
2037
  activeConversationId,
@@ -2303,6 +2307,7 @@ const useChatFlow = (chatDataRef, setLoader, setFlowType, setScreenName, setUser
2303
2307
  else {
2304
2308
  body = {
2305
2309
  query: input,
2310
+ ...(navSessionIdRef.current && { session_id: navSessionIdRef.current }),
2306
2311
  };
2307
2312
  }
2308
2313
  let utitlityObject = {
@@ -2318,6 +2323,7 @@ const useChatFlow = (chatDataRef, setLoader, setFlowType, setScreenName, setUser
2318
2323
  functionsRef,
2319
2324
  functionsState,
2320
2325
  setFunctionsState,
2326
+ setNavSessionId,
2321
2327
  };
2322
2328
  let response;
2323
2329
  if (input.indexOf("@") > -1) {
@@ -4006,6 +4012,7 @@ const useChatState = () => {
4006
4012
  useState(null);
4007
4013
  const [additionalArgs, setAdditionalArgs] = useState({});
4008
4014
  const [showSavedFilters, setShowSavedFilters] = useState(false);
4015
+ const [navSessionId, setNavSessionId] = useState("");
4009
4016
  // Selectors
4010
4017
  const filterReducerState = useSelector((state) => state.filterReducer);
4011
4018
  const notificationData = useSelector((state) => state.notificationReducer.notificationData);
@@ -4158,6 +4165,8 @@ const useChatState = () => {
4158
4165
  setAdditionalArgs,
4159
4166
  showSavedFilters,
4160
4167
  setShowSavedFilters,
4168
+ navSessionId,
4169
+ setNavSessionId,
4161
4170
  // Refs
4162
4171
  grabPositionRef,
4163
4172
  chatDataRef,
@@ -5056,6 +5065,10 @@ const sseevent = (message, messageToStoreRef) => {
5056
5065
  : "";
5057
5066
  messageToStoreRef.current.sessionId = parsedData?.session_id;
5058
5067
  }
5068
+ if (messageToStoreRef.current.currentMode === "navigation" &&
5069
+ parsedData?.session_id) {
5070
+ messageToStoreRef.current.navSessionId = parsedData.session_id;
5071
+ }
5059
5072
  if (parsedData?.is_error) {
5060
5073
  messageToStoreRef.current.chatData.response =
5061
5074
  messageToStoreRef.current.chatData.response +
@@ -5347,10 +5360,14 @@ const ButtonContent = ({ bodyText, isFormDisabled = false, isStepFormSubmit = fa
5347
5360
  console.log("[ButtonContent] SSE chunk:", data);
5348
5361
  if (data?.status === "step" || data?.status === "step_form" || data?.status === "questions" || data?.status === "thinking" || data?.status === "widget") {
5349
5362
  chunksRef.push(data);
5363
+ // If this chunk also carries [DONE], dispatch collected chunks now
5364
+ if (data?.message === "[DONE]") {
5365
+ dispatch(setStepFormStreamData({ status: "done", chunks: [...chunksRef] }));
5366
+ }
5350
5367
  }
5351
5368
  else if (data?.status === "completed" || data?.message === "[DONE]") {
5352
5369
  // Stream ended — dispatch all collected chunks at once
5353
- dispatch(setStepFormStreamData({ status: "done", chunks: chunksRef }));
5370
+ dispatch(setStepFormStreamData({ status: "done", chunks: [...chunksRef] }));
5354
5371
  }
5355
5372
  else if (data?.message) {
5356
5373
  chunksRef.push({ status: "content", message: data.message });
@@ -5985,6 +6002,12 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false })
5985
6002
  setIsFormSubmitted(true);
5986
6003
  }
5987
6004
  }, [stepFormStreamData]);
6005
+ // Reset isFormSubmitted when parent signals the form should be enabled (new step_form from restream)
6006
+ useEffect(() => {
6007
+ if (!isFormDisabled) {
6008
+ setIsFormSubmitted(false);
6009
+ }
6010
+ }, [isFormDisabled]);
5988
6011
  const [isFilterSetOpen, setIsFilterSetOpen] = useState(false);
5989
6012
  const [selectedFilterSet, setSelectedFilterSet] = useState(() => {
5990
6013
  // Restore from chatbotContext if available (persists across tab switches)
@@ -6525,7 +6548,7 @@ const formatThinkingTime = (seconds) => {
6525
6548
  * @param {Function} botData.utilityObject.setChatDataState - Function to update chat data state
6526
6549
  */
6527
6550
  const StreamedContent = ({ botData }) => {
6528
- const { activeConversationId, currentMode, chatDataRef, chatBodyRef, setChatDataState, chatDataInfoRef, setLoader = (params) => { }, processResponse = (params) => { }, setThinkingContent, thinkingContent, isThinking: isThinkingFromParent, setIsThinking: setIsThinkingFromParent, chatId, setChatId, isStop, setIsStop, functionsRef, functionsState, setFunctionsState, thinkingHeaderMessage, setThinkingHeaderMessage, baseUrl } = botData.utilityObject || {};
6551
+ const { activeConversationId, currentMode, chatDataRef, chatBodyRef, setChatDataState, chatDataInfoRef, setLoader = (params) => { }, processResponse = (params) => { }, setThinkingContent, thinkingContent, isThinking: isThinkingFromParent, setIsThinking: setIsThinkingFromParent, chatId, setChatId, isStop, setIsStop, functionsRef, functionsState, setFunctionsState, thinkingHeaderMessage, setThinkingHeaderMessage, baseUrl, setNavSessionId } = botData.utilityObject || {};
6529
6552
  const classes = useStyles$4();
6530
6553
  useStyles$7();
6531
6554
  const dispatch = useDispatch();
@@ -6599,6 +6622,7 @@ const StreamedContent = ({ botData }) => {
6599
6622
  appendedDataFromLastChunk: {},
6600
6623
  initValue: false,
6601
6624
  sessionId: "",
6625
+ navSessionId: "",
6602
6626
  uniqueChatId: "",
6603
6627
  additionalArgs: {},
6604
6628
  });
@@ -7130,6 +7154,9 @@ const StreamedContent = ({ botData }) => {
7130
7154
  },
7131
7155
  },
7132
7156
  };
7157
+ if (messageToStoreRef.current.navSessionId && setNavSessionId) {
7158
+ setNavSessionId(messageToStoreRef.current.navSessionId);
7159
+ }
7133
7160
  processResponse(response, botData.inputBody, currentMode, botData.utilityObject.customChatConfig, {
7134
7161
  newChatData: chatDataInfoRef,
7135
7162
  isTabEnabled: true,
@@ -7572,6 +7599,7 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
7572
7599
  const [widgetContent, setWidgetContent] = useState([]);
7573
7600
  const [isRestreaming, setIsRestreaming] = useState(false);
7574
7601
  const [stepFormSubmitted, setStepFormSubmitted] = useState(false);
7602
+ const [hasNewStepFormFromRestream, setHasNewStepFormFromRestream] = useState(false);
7575
7603
  // Refs for accumulating state during streaming (avoids stale closures)
7576
7604
  const stepsRef = useRef(stepsState);
7577
7605
  const questionsRef = useRef(questionsState);
@@ -7613,6 +7641,7 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
7613
7641
  if (payload.status === "streaming_start") {
7614
7642
  setIsRestreaming(true);
7615
7643
  setStepFormSubmitted(true);
7644
+ setHasNewStepFormFromRestream(false);
7616
7645
  setTabValue("steps");
7617
7646
  return;
7618
7647
  }
@@ -7727,6 +7756,12 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
7727
7756
  if (newWidgets.length > 0) {
7728
7757
  setWidgetContent((prev) => [...prev, ...newWidgets]);
7729
7758
  }
7759
+ // If the response contains a new step_form, reset stepFormSubmitted and mark new form as active
7760
+ const hasNewStepForm = chunks.some((c) => c.status === "step_form");
7761
+ if (hasNewStepForm) {
7762
+ setStepFormSubmitted(false);
7763
+ setHasNewStepFormFromRestream(true);
7764
+ }
7730
7765
  setIsRestreaming(false);
7731
7766
  }, [stepFormStreamData]);
7732
7767
  // Render widget content from restream responses
@@ -7743,7 +7778,7 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
7743
7778
  icon: jsx(PsychologyOutlinedIcon, { fontSize: "large" }),
7744
7779
  },
7745
7780
  ], tabPanels: [
7746
- jsx(Steps, { steps: stepsState, questions: questionsState, questionsStepsMap: questionsStepsMapState, stepFormDataMap: stepFormDataMapState, isFormDisabled: (isFormDisabled && !isRestreaming) || stepFormSubmitted, isRestreaming: isRestreaming }),
7781
+ jsx(Steps, { steps: stepsState, questions: questionsState, questionsStepsMap: questionsStepsMapState, stepFormDataMap: stepFormDataMapState, isFormDisabled: hasNewStepFormFromRestream ? false : ((isFormDisabled && !isRestreaming) || stepFormSubmitted), isRestreaming: isRestreaming }),
7747
7782
  jsxs(AgentResponse, { children: [children, renderedWidgets.length > 0 && (jsx("div", { className: "restream-widget-content", children: renderedWidgets }))] }),
7748
7783
  ], value: tabValue }) }));
7749
7784
  };
@@ -11435,7 +11470,7 @@ var ChatbotSaveFilterComponent$1 = connect(mapStateToProps, mapDispatchToProps)(
11435
11470
 
11436
11471
  const SmartBot = (props) => {
11437
11472
  const { userName, partialClose, setPartialClose, forceOpen, customBaseUrl = "", displayQuestions, questions = [] } = props;
11438
- const { showModal, setShowModal, minimizedMode, setMinimizedMode, userInput, setUserInput, position, setPosition, flowType, setFlowType, screenName, setScreenName, questionIndex, setQuestionIndex, currentAppLink, setCurrentAppLink, loader, setLoader, enableRefreshAction, setEnableRefreshAction, refreshLoader, setRefreshLoader, chatDataState, setChatDataState, showExtendedContent, setShowExtendedContent, currentMode, setCurrentMode, selectedModule, setSelectedModule, isCardVisible, setIsCardVisible, templateData, setTemplateData, showAlert, setShowAlert, grabPositionRef, chatDataRef, chatBodyRef, minimizedBtnRef, chatDataScreenLinkRef, navigate, location, dispatch, globalClasses, classes, dateFormat, filterReducerState, activeConversationId, setActiveConversationId, isModuleChanged, setIsModuleChanged, showChatPlaceholder, setShowChatPlaceholder, currentAgentId, setCurrentAgentId, baseUrl = customBaseUrl, setBaseUrl, currentSessionId, setCurrentSessionId, notificationData, agentTaskCompleted, setAgentTaskCompleted, customChatConfig, setCustomChatConfig, setMiddleWareFunction, chatBotInfoRef, chatDataInfoRef, initValue, setInitValue, sessionId, setSessionId, thinkingContent, setThinkingContent, isThinking, setIsThinking, chatId, setChatId, isStop, setIsStop, functionsRef, functionsState, setFunctionsState, thinkingHeaderMessage, setThinkingHeaderMessage, legacyAgentScreen, setLegacyAgentScreen, uniqueChatId, setUniqueChatId, fieldNumber, setFieldNumber, thinkingContext, isModalOpen, setIsModalOpen, utilityList, setUtilityList, isUploadModalOpen, setIsUploadModalOpen, isRefreshTriggered, setIsRefreshTriggered, additionalArgs, setAdditionalArgs, showSavedFilters, setShowSavedFilters, } = useChatState();
11473
+ const { showModal, setShowModal, minimizedMode, setMinimizedMode, userInput, setUserInput, position, setPosition, flowType, setFlowType, screenName, setScreenName, questionIndex, setQuestionIndex, currentAppLink, setCurrentAppLink, loader, setLoader, enableRefreshAction, setEnableRefreshAction, refreshLoader, setRefreshLoader, chatDataState, setChatDataState, showExtendedContent, setShowExtendedContent, currentMode, setCurrentMode, selectedModule, setSelectedModule, isCardVisible, setIsCardVisible, templateData, setTemplateData, showAlert, setShowAlert, grabPositionRef, chatDataRef, chatBodyRef, minimizedBtnRef, chatDataScreenLinkRef, navigate, location, dispatch, globalClasses, classes, dateFormat, filterReducerState, activeConversationId, setActiveConversationId, isModuleChanged, setIsModuleChanged, showChatPlaceholder, setShowChatPlaceholder, currentAgentId, setCurrentAgentId, baseUrl = customBaseUrl, setBaseUrl, currentSessionId, setCurrentSessionId, notificationData, agentTaskCompleted, setAgentTaskCompleted, customChatConfig, setCustomChatConfig, setMiddleWareFunction, chatBotInfoRef, chatDataInfoRef, initValue, setInitValue, sessionId, setSessionId, thinkingContent, setThinkingContent, isThinking, setIsThinking, chatId, setChatId, isStop, setIsStop, functionsRef, functionsState, setFunctionsState, thinkingHeaderMessage, setThinkingHeaderMessage, legacyAgentScreen, setLegacyAgentScreen, uniqueChatId, setUniqueChatId, fieldNumber, setFieldNumber, thinkingContext, isModalOpen, setIsModalOpen, utilityList, setUtilityList, isUploadModalOpen, setIsUploadModalOpen, isRefreshTriggered, setIsRefreshTriggered, additionalArgs, setAdditionalArgs, showSavedFilters, setShowSavedFilters, navSessionId, setNavSessionId, } = useChatState();
11439
11474
  // Add state for confirmation dialogs
11440
11475
  useState(false);
11441
11476
  useState(null);
@@ -11466,7 +11501,7 @@ const SmartBot = (props) => {
11466
11501
  const [savedFilterSets, setSavedFilterSets$1] = useState([]);
11467
11502
  const [selectedFilterSet, setSelectedFilterSet] = useState(null);
11468
11503
  useRef(0);
11469
- const { setUserFlow, setUserScreenAndFlow, fetchUserResultsFromQuery, getCurrentDateTimeString, setLink, } = useChatFlow(chatDataRef, setLoader, setFlowType, setScreenName, setUserInput, setQuestionIndex, setCurrentAppLink, flowType, screenName, questionIndex, userInput, dateFormat, currentMode, activeConversationId, setIsModuleChanged, chatBodyRef, filterReducerState, dispatch, navigate, setShowChatPlaceholder, baseUrl, setChatDataState, setCurrentSessionId, customChatConfig, chatDataInfoRef, chatbotContext, setInitValue, setSessionId, thinkingContent, setThinkingContent, isThinking, setIsThinking, chatId, setChatId, isStop, setIsStop, functionsRef, functionsState, setFunctionsState, thinkingHeaderMessage, setThinkingHeaderMessage, uniqueChatId, initValue, sessionId, fieldNumber, setFieldNumber, additionalArgs, setActiveConversationId);
11504
+ const { setUserFlow, setUserScreenAndFlow, fetchUserResultsFromQuery, getCurrentDateTimeString, setLink, } = useChatFlow(chatDataRef, setLoader, setFlowType, setScreenName, setUserInput, setQuestionIndex, setCurrentAppLink, flowType, screenName, questionIndex, userInput, dateFormat, currentMode, activeConversationId, setIsModuleChanged, chatBodyRef, filterReducerState, dispatch, navigate, setShowChatPlaceholder, baseUrl, setChatDataState, setCurrentSessionId, customChatConfig, chatDataInfoRef, chatbotContext, setInitValue, setSessionId, thinkingContent, setThinkingContent, isThinking, setIsThinking, chatId, setChatId, isStop, setIsStop, functionsRef, functionsState, setFunctionsState, thinkingHeaderMessage, setThinkingHeaderMessage, uniqueChatId, initValue, sessionId, fieldNumber, setFieldNumber, additionalArgs, setActiveConversationId, navSessionId, setNavSessionId);
11470
11505
  const { parseSavedFlow, saveCurrentChanges, endCurrentSession, clearChatSession, initiateNewChat, hasUnsavedChanges, } = useChatSession(chatDataRef, setFlowType, setScreenName, setUserInput, setTemplateData, chatDataScreenLinkRef, setShowModal, setMinimizedMode, setSelectedModule, setChatDataState, currentMode, setUserFlow, getCurrentDateTimeString, setCurrentAppLink, selectedModule, fetchUserResultsFromQuery, props.closeBot, activeConversationId, setActiveConversationId, setShowChatPlaceholder);
11471
11506
  const { refreshAndUpdateUserManual, configureBotActions, displaySnackMessages, } = useBotConfiguration(setRefreshLoader, setEnableRefreshAction, dispatch);
11472
11507
  const { prepareDataAndSendToAgent, processResponse } = useAgentFlow(dateFormat, chatDataRef, currentMode, setShowChatPlaceholder, setLoader, baseUrl, setCurrentSessionId, customChatConfig, chatDataInfoRef, {
@@ -12120,6 +12155,7 @@ const SmartBot = (props) => {
12120
12155
  chatDataRef.current[currentMode] = {
12121
12156
  conversations: {},
12122
12157
  };
12158
+ setNavSessionId("");
12123
12159
  setNewChatScreen(true);
12124
12160
  return {
12125
12161
  tabName: currentMode,