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.
@@ -1,4 +1,4 @@
1
- export declare const useChatFlow: (chatDataRef: any, setLoader: any, setFlowType: any, setScreenName: any, setUserInput: any, setQuestionIndex: any, setCurrentAppLink: any, flowType: any, screenName: any, questionIndex: any, userInput: any, dateFormat: any, currentMode: any, activeConversationId: any, setIsModuleChanged: any, chatBodyRef: any, filterReducerState: any, dispatch: any, navigate: any, setShowChatPlaceholder: any, baseUrl: any, setChatDataState: any, setCurrentSessionId: any, customChatConfig: any, chatDataInfoRef: any, chatbotContext: any, setInitValue: any, setSessionId: any, thinkingContent: any, setThinkingContent: any, isThinking: any, setIsThinking: any, chatId: any, setChatId: any, isStop: any, setIsStop: any, functionsRef: any, functionsState: any, setFunctionsState: any, thinkingHeaderMessage: any, setThinkingHeaderMessage: any, uniqueChatId: any, initValue: any, sessionId: any, fieldNumber: any, setFieldNumber: any, additionalArgs: any, setActiveConversationId: any) => {
1
+ export declare const useChatFlow: (chatDataRef: any, setLoader: any, setFlowType: any, setScreenName: any, setUserInput: any, setQuestionIndex: any, setCurrentAppLink: any, flowType: any, screenName: any, questionIndex: any, userInput: any, dateFormat: any, currentMode: any, activeConversationId: any, setIsModuleChanged: any, chatBodyRef: any, filterReducerState: any, dispatch: any, navigate: any, setShowChatPlaceholder: any, baseUrl: any, setChatDataState: any, setCurrentSessionId: any, customChatConfig: any, chatDataInfoRef: any, chatbotContext: any, setInitValue: any, setSessionId: any, thinkingContent: any, setThinkingContent: any, isThinking: any, setIsThinking: any, chatId: any, setChatId: any, isStop: any, setIsStop: any, functionsRef: any, functionsState: any, setFunctionsState: any, thinkingHeaderMessage: any, setThinkingHeaderMessage: any, uniqueChatId: any, initValue: any, sessionId: any, fieldNumber: any, setFieldNumber: any, additionalArgs: any, setActiveConversationId: any, navSessionId: any, setNavSessionId: any) => {
2
2
  setUserFlow: (data: any) => Promise<void>;
3
3
  setUserScreenAndFlow: (data: any) => void;
4
4
  fetchUserResultsFromQuery: (refObject: any, fetchQuestions?: boolean, inputValue?: any, conversationId?: any) => Promise<void>;
@@ -96,6 +96,8 @@ export declare const useChatState: () => {
96
96
  setAdditionalArgs: import("react").Dispatch<import("react").SetStateAction<{}>>;
97
97
  showSavedFilters: boolean;
98
98
  setShowSavedFilters: import("react").Dispatch<import("react").SetStateAction<boolean>>;
99
+ navSessionId: string;
100
+ setNavSessionId: import("react").Dispatch<import("react").SetStateAction<string>>;
99
101
  grabPositionRef: import("react").MutableRefObject<any>;
100
102
  chatDataRef: import("react").MutableRefObject<{
101
103
  insights: {
package/dist/index.cjs.js CHANGED
@@ -2049,7 +2049,11 @@ const useAgentFlow = (dateFormat, chatDataRef, currentMode, setShowChatPlacehold
2049
2049
  };
2050
2050
  };
2051
2051
 
2052
- 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) => {
2052
+ 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) => {
2053
+ const navSessionIdRef = React.useRef(navSessionId);
2054
+ React.useEffect(() => {
2055
+ navSessionIdRef.current = navSessionId;
2056
+ }, [navSessionId]);
2053
2057
  const { prepareDataAndSendToAgent, setAgentFlow, processResponse, } = useAgentFlow(dateFormat, chatDataRef, currentMode, setShowChatPlaceholder, setLoader, baseUrl, setCurrentSessionId, customChatConfig, chatDataInfoRef, {
2054
2058
  setChatDataState,
2055
2059
  activeConversationId,
@@ -2325,6 +2329,7 @@ const useChatFlow = (chatDataRef, setLoader, setFlowType, setScreenName, setUser
2325
2329
  else {
2326
2330
  body = {
2327
2331
  query: input,
2332
+ ...(navSessionIdRef.current && { session_id: navSessionIdRef.current }),
2328
2333
  };
2329
2334
  }
2330
2335
  let utitlityObject = {
@@ -2340,6 +2345,7 @@ const useChatFlow = (chatDataRef, setLoader, setFlowType, setScreenName, setUser
2340
2345
  functionsRef,
2341
2346
  functionsState,
2342
2347
  setFunctionsState,
2348
+ setNavSessionId,
2343
2349
  };
2344
2350
  let response;
2345
2351
  if (input.indexOf("@") > -1) {
@@ -4028,6 +4034,7 @@ const useChatState = () => {
4028
4034
  React.useState(null);
4029
4035
  const [additionalArgs, setAdditionalArgs] = React.useState({});
4030
4036
  const [showSavedFilters, setShowSavedFilters] = React.useState(false);
4037
+ const [navSessionId, setNavSessionId] = React.useState("");
4031
4038
  // Selectors
4032
4039
  const filterReducerState = reactRedux.useSelector((state) => state.filterReducer);
4033
4040
  const notificationData = reactRedux.useSelector((state) => state.notificationReducer.notificationData);
@@ -4180,6 +4187,8 @@ const useChatState = () => {
4180
4187
  setAdditionalArgs,
4181
4188
  showSavedFilters,
4182
4189
  setShowSavedFilters,
4190
+ navSessionId,
4191
+ setNavSessionId,
4183
4192
  // Refs
4184
4193
  grabPositionRef,
4185
4194
  chatDataRef,
@@ -5078,6 +5087,10 @@ const sseevent = (message, messageToStoreRef) => {
5078
5087
  : "";
5079
5088
  messageToStoreRef.current.sessionId = parsedData?.session_id;
5080
5089
  }
5090
+ if (messageToStoreRef.current.currentMode === "navigation" &&
5091
+ parsedData?.session_id) {
5092
+ messageToStoreRef.current.navSessionId = parsedData.session_id;
5093
+ }
5081
5094
  if (parsedData?.is_error) {
5082
5095
  messageToStoreRef.current.chatData.response =
5083
5096
  messageToStoreRef.current.chatData.response +
@@ -5369,10 +5382,14 @@ const ButtonContent = ({ bodyText, isFormDisabled = false, isStepFormSubmit = fa
5369
5382
  console.log("[ButtonContent] SSE chunk:", data);
5370
5383
  if (data?.status === "step" || data?.status === "step_form" || data?.status === "questions" || data?.status === "thinking" || data?.status === "widget") {
5371
5384
  chunksRef.push(data);
5385
+ // If this chunk also carries [DONE], dispatch collected chunks now
5386
+ if (data?.message === "[DONE]") {
5387
+ dispatch(smartBotActions.setStepFormStreamData({ status: "done", chunks: [...chunksRef] }));
5388
+ }
5372
5389
  }
5373
5390
  else if (data?.status === "completed" || data?.message === "[DONE]") {
5374
5391
  // Stream ended — dispatch all collected chunks at once
5375
- dispatch(smartBotActions.setStepFormStreamData({ status: "done", chunks: chunksRef }));
5392
+ dispatch(smartBotActions.setStepFormStreamData({ status: "done", chunks: [...chunksRef] }));
5376
5393
  }
5377
5394
  else if (data?.message) {
5378
5395
  chunksRef.push({ status: "content", message: data.message });
@@ -6007,6 +6024,12 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false })
6007
6024
  setIsFormSubmitted(true);
6008
6025
  }
6009
6026
  }, [stepFormStreamData]);
6027
+ // Reset isFormSubmitted when parent signals the form should be enabled (new step_form from restream)
6028
+ React.useEffect(() => {
6029
+ if (!isFormDisabled) {
6030
+ setIsFormSubmitted(false);
6031
+ }
6032
+ }, [isFormDisabled]);
6010
6033
  const [isFilterSetOpen, setIsFilterSetOpen] = React.useState(false);
6011
6034
  const [selectedFilterSet, setSelectedFilterSet] = React.useState(() => {
6012
6035
  // Restore from chatbotContext if available (persists across tab switches)
@@ -6547,7 +6570,7 @@ const formatThinkingTime = (seconds) => {
6547
6570
  * @param {Function} botData.utilityObject.setChatDataState - Function to update chat data state
6548
6571
  */
6549
6572
  const StreamedContent = ({ botData }) => {
6550
- 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 || {};
6573
+ 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 || {};
6551
6574
  const classes = useStyles$4();
6552
6575
  useStyles$7();
6553
6576
  const dispatch = reactRedux.useDispatch();
@@ -6621,6 +6644,7 @@ const StreamedContent = ({ botData }) => {
6621
6644
  appendedDataFromLastChunk: {},
6622
6645
  initValue: false,
6623
6646
  sessionId: "",
6647
+ navSessionId: "",
6624
6648
  uniqueChatId: "",
6625
6649
  additionalArgs: {},
6626
6650
  });
@@ -7152,6 +7176,9 @@ const StreamedContent = ({ botData }) => {
7152
7176
  },
7153
7177
  },
7154
7178
  };
7179
+ if (messageToStoreRef.current.navSessionId && setNavSessionId) {
7180
+ setNavSessionId(messageToStoreRef.current.navSessionId);
7181
+ }
7155
7182
  processResponse(response, botData.inputBody, currentMode, botData.utilityObject.customChatConfig, {
7156
7183
  newChatData: chatDataInfoRef,
7157
7184
  isTabEnabled: true,
@@ -7594,6 +7621,7 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
7594
7621
  const [widgetContent, setWidgetContent] = React.useState([]);
7595
7622
  const [isRestreaming, setIsRestreaming] = React.useState(false);
7596
7623
  const [stepFormSubmitted, setStepFormSubmitted] = React.useState(false);
7624
+ const [hasNewStepFormFromRestream, setHasNewStepFormFromRestream] = React.useState(false);
7597
7625
  // Refs for accumulating state during streaming (avoids stale closures)
7598
7626
  const stepsRef = React.useRef(stepsState);
7599
7627
  const questionsRef = React.useRef(questionsState);
@@ -7635,6 +7663,7 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
7635
7663
  if (payload.status === "streaming_start") {
7636
7664
  setIsRestreaming(true);
7637
7665
  setStepFormSubmitted(true);
7666
+ setHasNewStepFormFromRestream(false);
7638
7667
  setTabValue("steps");
7639
7668
  return;
7640
7669
  }
@@ -7749,6 +7778,12 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
7749
7778
  if (newWidgets.length > 0) {
7750
7779
  setWidgetContent((prev) => [...prev, ...newWidgets]);
7751
7780
  }
7781
+ // If the response contains a new step_form, reset stepFormSubmitted and mark new form as active
7782
+ const hasNewStepForm = chunks.some((c) => c.status === "step_form");
7783
+ if (hasNewStepForm) {
7784
+ setStepFormSubmitted(false);
7785
+ setHasNewStepFormFromRestream(true);
7786
+ }
7752
7787
  setIsRestreaming(false);
7753
7788
  }, [stepFormStreamData]);
7754
7789
  // Render widget content from restream responses
@@ -7765,7 +7800,7 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
7765
7800
  icon: jsxRuntime.jsx(PsychologyOutlinedIcon, { fontSize: "large" }),
7766
7801
  },
7767
7802
  ], tabPanels: [
7768
- jsxRuntime.jsx(Steps, { steps: stepsState, questions: questionsState, questionsStepsMap: questionsStepsMapState, stepFormDataMap: stepFormDataMapState, isFormDisabled: (isFormDisabled && !isRestreaming) || stepFormSubmitted, isRestreaming: isRestreaming }),
7803
+ jsxRuntime.jsx(Steps, { steps: stepsState, questions: questionsState, questionsStepsMap: questionsStepsMapState, stepFormDataMap: stepFormDataMapState, isFormDisabled: hasNewStepFormFromRestream ? false : ((isFormDisabled && !isRestreaming) || stepFormSubmitted), isRestreaming: isRestreaming }),
7769
7804
  jsxRuntime.jsxs(AgentResponse, { children: [children, renderedWidgets.length > 0 && (jsxRuntime.jsx("div", { className: "restream-widget-content", children: renderedWidgets }))] }),
7770
7805
  ], value: tabValue }) }));
7771
7806
  };
@@ -11457,7 +11492,7 @@ var ChatbotSaveFilterComponent$1 = reactRedux.connect(mapStateToProps, mapDispat
11457
11492
 
11458
11493
  const SmartBot = (props) => {
11459
11494
  const { userName, partialClose, setPartialClose, forceOpen, customBaseUrl = "", displayQuestions, questions = [] } = props;
11460
- 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();
11495
+ 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();
11461
11496
  // Add state for confirmation dialogs
11462
11497
  React.useState(false);
11463
11498
  React.useState(null);
@@ -11488,7 +11523,7 @@ const SmartBot = (props) => {
11488
11523
  const [savedFilterSets, setSavedFilterSets] = React.useState([]);
11489
11524
  const [selectedFilterSet, setSelectedFilterSet] = React.useState(null);
11490
11525
  React.useRef(0);
11491
- 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);
11526
+ 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);
11492
11527
  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);
11493
11528
  const { refreshAndUpdateUserManual, configureBotActions, displaySnackMessages, } = useBotConfiguration(setRefreshLoader, setEnableRefreshAction, dispatch);
11494
11529
  const { prepareDataAndSendToAgent, processResponse } = useAgentFlow(dateFormat, chatDataRef, currentMode, setShowChatPlaceholder, setLoader, baseUrl, setCurrentSessionId, customChatConfig, chatDataInfoRef, {
@@ -12142,6 +12177,7 @@ const SmartBot = (props) => {
12142
12177
  chatDataRef.current[currentMode] = {
12143
12178
  conversations: {},
12144
12179
  };
12180
+ setNavSessionId("");
12145
12181
  setNewChatScreen(true);
12146
12182
  return {
12147
12183
  tabName: currentMode,