impact-chatbot 2.3.99 → 2.3.101

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
@@ -761,6 +761,7 @@ const parseResponse = (data, type, agentId = "", currentMode = "", disableTimeAn
761
761
  isDisabled: data?.data?.isDisabled,
762
762
  orientation: data?.data?.orientation,
763
763
  options: data?.data?.options,
764
+ defaultSelected: data?.data?.defaultSelected,
764
765
  paramName: data?.data?.param_name
765
766
  }
766
767
  };
@@ -2793,9 +2794,16 @@ const useChatFlow = (chatDataRef, setLoader, setFlowType, setScreenName, setUser
2793
2794
  else if (data.actionType === "indirect") {
2794
2795
  setUserInput(data.displayText);
2795
2796
  }
2796
- else {
2797
+ else if (data.screen_name) {
2797
2798
  fetchUserResultsFromQuery(data, true, "", activeConversationId);
2798
2799
  }
2800
+ else {
2801
+ // No screen_name (e.g. suggested follow-up chips from navigation-v2):
2802
+ // treat the chip's displayText as a regular user query so it flows
2803
+ // through the navigation streaming endpoint instead of the
2804
+ // fetchRelatedQuestions screen-based endpoint.
2805
+ fetchUserResultsFromQuery(data, false, data.displayText, activeConversationId);
2806
+ }
2799
2807
  }, [activeConversationId, baseUrl]);
2800
2808
  const fetchUserResultsFromQuery = useCallback(async (refObject, fetchQuestions = false, inputValue = userInput, conversationId = activeConversationId) => {
2801
2809
  let flowType = refObject?.flow_type ? refObject?.flow_type : currentMode;
@@ -7875,13 +7883,36 @@ const CheckboxGroupContent = ({ bodyText, isFormDisabled = false, messageIndex }
7875
7883
  const RadioContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
7876
7884
  const formKey = `${messageIndex}_${bodyText?.paramName}`;
7877
7885
  const classes = useStyles$b();
7878
- const { label, isDisabled, orientation, options } = bodyText;
7886
+ const { label, isDisabled, orientation, options, defaultSelected } = bodyText;
7879
7887
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
7880
7888
  const chatbotContextRef = useRef(chatbotContext);
7881
7889
  chatbotContextRef.current = chatbotContext;
7882
7890
  const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
7883
7891
  const dispatch = useDispatch();
7884
- const [selectedOption, setSelectedOption] = useState(persistedFormValues[formKey] ?? null);
7892
+ const [selectedOption, setSelectedOption] = useState(persistedFormValues[formKey] ?? defaultSelected ?? null);
7893
+ // When a defaultSelected value is provided and nothing was previously persisted,
7894
+ // seed Redux state so submit-validation and context are aware of the pre-selection.
7895
+ // Uses getState inside a thunk to read the latest chatbotContext at dispatch time,
7896
+ // avoiding stale-ref overwrites when multiple radio widgets mount in the same flush.
7897
+ useEffect(() => {
7898
+ if (defaultSelected && !persistedFormValues[formKey]) {
7899
+ dispatch((dispatchAction, getState) => {
7900
+ const currentContext = getState().smartBotReducer.chatbotContext;
7901
+ dispatchAction({
7902
+ type: "SET_CHATBOT_CONTEXT",
7903
+ payload: {
7904
+ ...currentContext,
7905
+ [bodyText?.paramName]: {
7906
+ ...currentContext?.[bodyText?.paramName],
7907
+ [bodyText?.paramName]: defaultSelected,
7908
+ updated: true,
7909
+ },
7910
+ },
7911
+ });
7912
+ });
7913
+ dispatch(setPersistedFormValues({ [formKey]: defaultSelected }));
7914
+ }
7915
+ }, []);
7885
7916
  if (isEmpty$1(bodyText))
7886
7917
  return null;
7887
7918
  const handleChange = (selectedOption) => {
@@ -16687,7 +16718,7 @@ const SmartBot = (props) => {
16687
16718
  }
16688
16719
  }, [forceOpen]);
16689
16720
  const [historyPanelData, setHistoryPanelData] = useState([]);
16690
- const { fetchConversations, saveCurrentChat, renameConversation, deleteConversation, fetchConversationChats, fetchChatHistory, renameChat, pinChat, deleteChatById, } = useConversationManagement(chatDataRef, currentMode, activeConversationId, setActiveConversationId, setChatDataState, selectedModule, setSelectedModule, isModuleChanged, setIsModuleChanged, undefined, undefined, chatDataInfoRef, setHistoryPanelData, processResponse);
16721
+ const { loading: conversationLoading, fetchConversations, saveCurrentChat, renameConversation, deleteConversation, fetchConversationChats, fetchChatHistory, renameChat, pinChat, deleteChatById, } = useConversationManagement(chatDataRef, currentMode, activeConversationId, setActiveConversationId, setChatDataState, selectedModule, setSelectedModule, isModuleChanged, setIsModuleChanged, undefined, undefined, chatDataInfoRef, setHistoryPanelData, processResponse);
16691
16722
  const handleHistoryMenuAction = useCallback(async (action, conversationData) => {
16692
16723
  const conversationId = conversationData?.conversation_id;
16693
16724
  if (!conversationId)
@@ -16834,7 +16865,7 @@ const SmartBot = (props) => {
16834
16865
  return (jsxs(Fragment, { children: [partialClose && (minimizedStreamData?.isStreaming || minimizedStreamData?.stepStatus === "step_form") && (jsx(MinimizedChatWidget, { onExpand: () => {
16835
16866
  setShowModal(true);
16836
16867
  setPartialClose(false);
16837
- } })), jsxs("div", { ref: smartBotWrapperRef, className: `${classes.agentStyleOverride} ${partialClose || !(showModal || forceOpen) ? classes.hideBotStyle : ""} `, children: [jsx(RenameModal, { open: renameOpen, renameValue: renameValue, setRenameValue: setRenameValue, onConfirm: handleRenameConfirm, onCancel: handleRenameCancel }), jsx(DeleteConfirmModal, { open: deleteOpen, onConfirm: handleDeleteConfirm, onCancel: handleDeleteCancel }), jsx(MemoryModal, { isModalOpen: isModalOpen, setIsModalOpen: setIsModalOpen, displaySnackMessages: displaySnackMessages }), jsx(UploadModal, { isUploadModalOpen: isUploadModalOpen, setIsUploadModalOpen: setIsUploadModalOpen, displaySnackMessages: displaySnackMessages }), jsx(ChatBotComponent, { isFullWidth: forceOpen, userName: userName, showHistoryPanel: enableMultiChat, customInputComponent: currentMode === "agent" && !showSavedFilters ? (jsx(ChatbotInput, { newChatScreen: newChatScreen, inputValue: userInput, setInputValue: setUserInput, isStopIcon: isStop, onSendIconClick: onSendIconClick, onStopIconClick: onStopIconClick, currentMode: currentMode, filterOptions: filterOptions,
16868
+ } })), jsxs("div", { ref: smartBotWrapperRef, className: `${classes.agentStyleOverride} ${partialClose || !(showModal || forceOpen) ? classes.hideBotStyle : ""} `, children: [jsx(RenameModal, { open: renameOpen, renameValue: renameValue, setRenameValue: setRenameValue, onConfirm: handleRenameConfirm, onCancel: handleRenameCancel }), jsx(DeleteConfirmModal, { open: deleteOpen, onConfirm: handleDeleteConfirm, onCancel: handleDeleteCancel }), jsx(MemoryModal, { isModalOpen: isModalOpen, setIsModalOpen: setIsModalOpen, displaySnackMessages: displaySnackMessages }), jsx(UploadModal, { isUploadModalOpen: isUploadModalOpen, setIsUploadModalOpen: setIsUploadModalOpen, displaySnackMessages: displaySnackMessages }), jsx(ChatBotComponent, { isFullWidth: forceOpen, userName: userName, showHistoryPanel: enableMultiChat, isConversationLoading: conversationLoading, customInputComponent: currentMode === "agent" && !showSavedFilters ? (jsx(ChatbotInput, { newChatScreen: newChatScreen, inputValue: userInput, setInputValue: setUserInput, isStopIcon: isStop, onSendIconClick: onSendIconClick, onStopIconClick: onStopIconClick, currentMode: currentMode, filterOptions: filterOptions,
16838
16869
  // onSaveClick={saveCurrentChat}
16839
16870
  savedFilterSets: savedFilterSets, selectedFilterSet: selectedFilterSet, onFilterSetSelect: (filterSet) => setSelectedFilterSet(filterSet), onClearFilterSet: () => setSelectedFilterSet(null), onTriggerRefresh: triggerRefreshAction, answerMode: answerMode, setAnswerMode: setAnswerMode })) : showSavedFilters ? jsx(Fragment, {}) : null, isChatBotOpen: showModal || forceOpen, historyPanelData: historyPanelData, onHistorySearchChange: (params) => { console.log("History Search Change", params); }, onHistorySelectConversation: (params) => {
16840
16871
  const convId = params?.conversation_id;
@@ -16949,7 +16980,7 @@ const SmartBot = (props) => {
16949
16980
  }, moduleList: modules, tabList: tabList, utilityList: utilityList, isAssistantThinking: false, isCustomScreen: showChatPlaceholder ? showChatPlaceholder : showSavedFilters, customScreenJsx: showChatPlaceholder ?
16950
16981
  jsx(ChatPlaceholder, { dateFormat: dateFormat, chatDataRef: chatDataRef, currentMode: currentMode, setShowChatPlaceholder: setShowChatPlaceholder, setLoader: setLoader, setCurrentAgentId: setCurrentAgentId, baseUrl: baseUrl, setBaseUrl: setBaseUrl, setCurrentSessionId: setCurrentSessionId, customChatConfig: customChatConfig, chatDataInfoRef: chatDataInfoRef, setChatDataState: setChatDataState, userInput: userInput, legacyAgentScreen: legacyAgentScreen, activeConversationId: activeConversationId, chatBodyRef: chatBodyRef, chatbotContext: chatbotContext, setInitValue: setInitValue, setSessionId: setSessionId, thinkingContent: thinkingContext?.thinkingContent, setThinkingContent: setThinkingContent, isThinking: isThinking, setIsThinking: setIsThinking, chatId: chatId, setChatId: setChatId, isStop: isStop, setIsStop: setIsStop, functionsRef: functionsRef, functionsState: functionsState, setFunctionsState: setFunctionsState, thinkingHeaderMessage: thinkingContext?.thinkingHeaderMessage, setThinkingHeaderMessage: setThinkingHeaderMessage, uniqueChatId: uniqueChatId, setUniqueChatId: setUniqueChatId, fieldNumber: fieldNumber, setFieldNumber: setFieldNumber, setAdditionalArgs: setAdditionalArgs, displayQuestions: displayQuestions, questions: questions, setActiveConversationId: setActiveConversationId, selectedFilterSet: selectedFilterSet, answerMode: answerMode })
16951
16982
  :
16952
- jsx(ChatbotSaveFilterComponent$1, { savedFilterSets: savedFilterSets, partialClose: partialClose, chatBotWidth: chatBotWidth }), inputText: userInput, threadList: ["Home"], hideMenuArrow: hideMenu, newChatScreen: newChatScreen, isModuleListLoading: modulesLoading, suggestionBanner: {
16983
+ jsx(ChatbotSaveFilterComponent$1, { savedFilterSets: savedFilterSets, partialClose: partialClose, chatBotWidth: chatBotWidth }), inputText: userInput, threadList: ["Home"], hideMenuArrow: true, newChatScreen: newChatScreen, isModuleListLoading: modulesLoading, suggestionBanner: {
16953
16984
  freeTextHeading: "Try adding more details :",
16954
16985
  freeTextContent: "Iris works better when you provide more context and pointed questions",
16955
16986
  }, isStopIcon: isStop, onStopIconClick: onStopIconClick, footerText: "AI-generated responses may contain errors\u2014please verify important information", showSuggestionBanner: showSavedFilters ? false : showSuggestionBanner, onCloseSuggestionBanner: () => {