impact-chatbot 2.3.82 → 2.3.83

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.
@@ -7,12 +7,16 @@
7
7
  * @param {Array} props.formData - Array of raw widget_data items from step_form chunk
8
8
  * @param {number} props.messageIndex - Index for form state persistence keys
9
9
  */
10
- declare const StepFormContent: ({ formData, messageIndex, isFormDisabled, showSavedFilters, preSelectedFilters }: {
10
+ declare const StepFormContent: ({ formData, messageIndex, isFormDisabled, showSavedFilters, preSelectedFilters, botProps, currentMode, agentId, sessionId, }: {
11
11
  formData: any;
12
12
  messageIndex?: number;
13
13
  isFormDisabled?: boolean;
14
14
  showSavedFilters?: boolean;
15
15
  preSelectedFilters?: any;
16
+ botProps?: any;
17
+ currentMode?: string;
18
+ agentId?: string;
19
+ sessionId?: string;
16
20
  }) => import("react/jsx-runtime").JSX.Element;
17
21
  /** Reset the timeout flag (call when a new conversation/message starts) */
18
22
  export declare const resetStepFormTimeoutFlag: () => void;
@@ -1,4 +1,4 @@
1
- declare const TabularContent: ({ steps: initialSteps, currentTabValue, children, questions: initialQuestions, questionsStepsMap: initialQuestionsStepsMap, stepFormDataMap: initialStepFormDataMap, isFormDisabled, sessionId: propSessionId }: {
1
+ declare const TabularContent: ({ steps: initialSteps, currentTabValue, children, questions: initialQuestions, questionsStepsMap: initialQuestionsStepsMap, stepFormDataMap: initialStepFormDataMap, isFormDisabled, sessionId: propSessionId, botProps, currentMode, agentId }: {
2
2
  steps: any;
3
3
  currentTabValue: any;
4
4
  children: any;
@@ -7,6 +7,9 @@ declare const TabularContent: ({ steps: initialSteps, currentTabValue, children,
7
7
  stepFormDataMap?: {};
8
8
  isFormDisabled?: boolean;
9
9
  sessionId?: string;
10
+ botProps?: any;
11
+ currentMode?: string;
12
+ agentId?: string;
10
13
  }) => import("react/jsx-runtime").JSX.Element;
11
14
  /** Reset the active instance tracker (call when a new conversation starts from the input field) */
12
15
  export declare const resetActiveTabularInstance: () => void;
@@ -10,7 +10,8 @@
10
10
  * @param {React.RefObject} botData.utilityObject.chatBodyRef - Ref to chat body element
11
11
  * @param {Function} botData.utilityObject.setChatDataState - Function to update chat data state
12
12
  */
13
- declare const StreamedContent: ({ botData }: {
13
+ declare const StreamedContent: ({ botData, botProps }: {
14
14
  botData: any;
15
+ botProps: any;
15
16
  }) => import("react/jsx-runtime").JSX.Element;
16
17
  export default StreamedContent;
@@ -1,4 +1,4 @@
1
- declare const Steps: ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, setFinalStepDone, stepChange, currentMode, questions, questionsStepsMap, stepFormDataMap, isFormDisabled, }: {
1
+ declare const Steps: ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, setFinalStepDone, stepChange, currentMode, questions, questionsStepsMap, stepFormDataMap, isFormDisabled, botProps, agentId, sessionId, }: {
2
2
  steps: any;
3
3
  setSteps: any;
4
4
  done: any;
@@ -12,5 +12,8 @@ declare const Steps: ({ steps, setSteps, done, setTabValue, setDone, finalStepDo
12
12
  questionsStepsMap?: {};
13
13
  stepFormDataMap?: {};
14
14
  isFormDisabled?: boolean;
15
+ botProps?: any;
16
+ agentId?: string;
17
+ sessionId?: string;
15
18
  }) => import("react/jsx-runtime").JSX.Element;
16
19
  export default Steps;
package/dist/index.cjs.js CHANGED
@@ -348,9 +348,9 @@ const parseResponse = (data, type, agentId = "", currentMode = "", disableTimeAn
348
348
  userType: "bot",
349
349
  userName: userName,
350
350
  bodyText: data?.response,
351
- headerTitle: data?.response_heading,
351
+ headerTitle: "",
352
352
  thinkingResponse: data?.thinkingResponse,
353
- noShowHeaderTitle: false,
353
+ noShowHeaderTitle: true,
354
354
  bodyType: "text",
355
355
  };
356
356
  case "stream":
@@ -614,7 +614,8 @@ const parseResponse = (data, type, agentId = "", currentMode = "", disableTimeAn
614
614
  timeStamp: timeString,
615
615
  userType: "bot",
616
616
  userName: userName,
617
- headerTitle: data?.response_heading || "",
617
+ headerTitle: "",
618
+ noShowHeaderTitle: true,
618
619
  bodyType: "image",
619
620
  bodyText: data?.image || data,
620
621
  };
@@ -5031,7 +5032,7 @@ const ChipsContent = ({ bodyText, props }) => {
5031
5032
  const classes = useStyles$a();
5032
5033
  const globalClasses = globalStyles();
5033
5034
  return (jsxRuntime.jsx("div", { className: `${globalClasses.flexRow} ${globalClasses.flexWrap} ${globalClasses.gap} ${globalClasses.verticalAlignCenter}`, children: bodyText.map((data, index) => {
5034
- const callBack = data.interactable
5035
+ const callBack = data.interactable && props
5035
5036
  ? Object.entries(props).filter((entry) => entry[0] === data.actionName)?.[0]?.[1]
5036
5037
  : null;
5037
5038
  return (jsxRuntime.jsx(material.Typography, { component: "span", variant: "body1", className: `${classes.gptChips} ${data.interactable ? globalClasses.cursorPointer : ""}`, onClick: () => {
@@ -5098,7 +5099,7 @@ const QuestionsContent = ({ bodyText, props }) => {
5098
5099
  };
5099
5100
  };
5100
5101
  return (jsxRuntime.jsx("div", { className: `${globalClasses.flexRow} ${globalClasses.flexColumn} ${classes.gptQuestionContainer}`, children: bodyText.map((data, index) => {
5101
- const callBack = data.interactable
5102
+ const callBack = data.interactable && props
5102
5103
  ? Object.entries(props).filter((entry) => entry[0] === data.actionName)?.[0]?.[1]
5103
5104
  : null;
5104
5105
  return (jsxRuntime.jsxs("div", { className: `${globalClasses.layoutAlignStart} ${classes.gptQuestionBlock}`, style: {
@@ -6849,6 +6850,36 @@ const fetchCrossFilterOptions = async (filterConfig, existingSelections = [], al
6849
6850
  }
6850
6851
  };
6851
6852
 
6853
+ const useStyles$6 = styles.makeStyles(() => ({
6854
+ htmlContentContainer: {
6855
+ width: "100%",
6856
+ "& *": {
6857
+ boxSizing: "border-box",
6858
+ },
6859
+ },
6860
+ }));
6861
+ const HtmlContent = ({ bodyText }) => {
6862
+ const classes = useStyles$6();
6863
+ const containerRef = React.useRef(null);
6864
+ const content = bodyText?.content || "";
6865
+ React.useEffect(() => {
6866
+ if (containerRef.current && content) {
6867
+ const sanitizedHtml = DOMPurify.sanitize(content, {
6868
+ ADD_TAGS: ["style", "details", "summary"],
6869
+ ADD_ATTR: ["open", "target", "rel", "class", "style"],
6870
+ ALLOW_DATA_ATTR: true,
6871
+ FORCE_BODY: true,
6872
+ WHOLE_DOCUMENT: false,
6873
+ });
6874
+ containerRef.current.innerHTML = sanitizedHtml;
6875
+ }
6876
+ }, [content]);
6877
+ if (!content) {
6878
+ return null;
6879
+ }
6880
+ return (jsxRuntime.jsx("div", { ref: containerRef, className: classes.htmlContentContainer }));
6881
+ };
6882
+
6852
6883
  const SliderContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6853
6884
  const formKey = `${messageIndex}_${bodyText?.paramName}`;
6854
6885
  const { header, headerOrentiation, inputPosition, label, max, min, required, disabled, } = bodyText;
@@ -7394,8 +7425,9 @@ const STEP_FORM_TIMEOUT_KEY = "__stepFormTimedOut";
7394
7425
  * @param {Array} props.formData - Array of raw widget_data items from step_form chunk
7395
7426
  * @param {number} props.messageIndex - Index for form state persistence keys
7396
7427
  */
7397
- const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false, showSavedFilters = true, preSelectedFilters = null }) => {
7428
+ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false, showSavedFilters = true, preSelectedFilters = null, botProps = null, currentMode = "", agentId = "", sessionId = "", }) => {
7398
7429
  const dispatch = reactRedux.useDispatch();
7430
+ const classes = useStyles$a();
7399
7431
  const savedFilterSets = reactRedux.useSelector((state) => state.smartBotReducer.savedFilterSets);
7400
7432
  const persistedFormValues = reactRedux.useSelector((state) => state.smartBotReducer.persistedFormValues);
7401
7433
  const chatbotContext = reactRedux.useSelector((state) => state.smartBotReducer.chatbotContext);
@@ -7668,7 +7700,11 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false, s
7668
7700
  case "text":
7669
7701
  return jsxRuntime.jsx(TextContent, { bodyText: parsedData.bodyText, botData: parsedData }, key);
7670
7702
  case "chips":
7671
- return jsxRuntime.jsx(ChipsContent, { bodyText: parsedData.bodyText, props: {} }, key);
7703
+ return parsedData.isMultiSelect ? (jsxRuntime.jsx(SelectableChips, { bodyText: parsedData.bodyText, chipType: "selectable", utilityData: parsedData.utilityData, props: botProps }, key)) : (jsxRuntime.jsx(ChipsContent, { bodyText: parsedData.bodyText, props: botProps }, key));
7704
+ case "questions":
7705
+ return jsxRuntime.jsx(QuestionsContent, { bodyText: parsedData.bodyText, props: botProps }, key);
7706
+ case "html":
7707
+ return jsxRuntime.jsx(HtmlContent, { bodyText: parsedData.bodyText }, key);
7672
7708
  case "table":
7673
7709
  return jsxRuntime.jsx(TableContent, { bodyText: parsedData.bodyText }, key);
7674
7710
  case "graph":
@@ -7699,12 +7735,18 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false, s
7699
7735
  const buttonItems = [];
7700
7736
  formData.forEach((item, index) => {
7701
7737
  try {
7702
- const parsedData = parseResponse(item, item.type, "", "", true);
7738
+ const parsedData = parseResponse(item, item.type, agentId, currentMode, true, sessionId);
7703
7739
  if (!parsedData)
7704
7740
  return;
7705
- const rendered = renderItem(parsedData, index);
7706
- if (!rendered)
7741
+ const body = renderItem(parsedData, index);
7742
+ if (!body)
7707
7743
  return;
7744
+ // Skip the block header when it is just a repeat of the label the widget
7745
+ // renders itself (parseResponse derives headerTitle from label for inputs).
7746
+ const showHeaderTitle = !parsedData?.noShowHeaderTitle &&
7747
+ Boolean(parsedData?.headerTitle?.length) &&
7748
+ parsedData.headerTitle !== parsedData?.bodyText?.label;
7749
+ const rendered = showHeaderTitle ? (jsxRuntime.jsxs(React.Fragment, { children: [jsxRuntime.jsx("div", { className: `${classes.chatbotText} ${classes.boldText} ${classes.combinedBlockHeaderTitle}`, children: parsedData.headerTitle }), body] }, `step-form-block-${index}`)) : (body);
7708
7750
  if (parsedData.bodyType === "button") {
7709
7751
  buttonItems.push(rendered);
7710
7752
  }
@@ -7727,7 +7769,7 @@ const resetStepFormTimeoutFlag = () => {
7727
7769
  sessionStorage.removeItem(STEP_FORM_TIMEOUT_KEY);
7728
7770
  };
7729
7771
 
7730
- const useStyles$6 = styles.makeStyles(() => ({
7772
+ const useStyles$5 = styles.makeStyles(() => ({
7731
7773
  subStepMarkdown: {
7732
7774
  // Inherit font styles from parent (.progressSubItem)
7733
7775
  fontFamily: 'inherit',
@@ -7801,14 +7843,14 @@ const preprocessSubStepMarkdown = (content) => {
7801
7843
  .trim();
7802
7844
  };
7803
7845
  const SubStepRenderer = ({ text }) => {
7804
- const classes = useStyles$6();
7846
+ const classes = useStyles$5();
7805
7847
  if (!text)
7806
7848
  return null;
7807
7849
  const processed = preprocessSubStepMarkdown(text);
7808
7850
  return (jsxRuntime.jsx("div", { className: classes.subStepMarkdown, children: jsxRuntime.jsx(ReactMarkdown, { remarkPlugins: [remarkGfm, remarkBreaks], children: processed }) }));
7809
7851
  };
7810
7852
 
7811
- const useStyles$5 = makeStyles((theme) => ({
7853
+ const useStyles$4 = makeStyles((theme) => ({
7812
7854
  "@global": {
7813
7855
  "@keyframes progressDotPulse": {
7814
7856
  "0%": {
@@ -8082,7 +8124,7 @@ const getQuestionStatus$1 = (questionSteps) => {
8082
8124
  /**
8083
8125
  * Renders a single progress bar item (main point + sub-items)
8084
8126
  */
8085
- const ProgressBarItem$1 = ({ question, questionSteps, isLast, classes, formData, showSavedFilters = true, preSelectedFilters = null, isFormDisabled, onAllSubItemsAnimated = undefined }) => {
8127
+ const ProgressBarItem$1 = ({ question, questionSteps, isLast, classes, formData, showSavedFilters = true, preSelectedFilters = null, isFormDisabled, onAllSubItemsAnimated = undefined, botProps = null, currentMode = "", agentId = "", sessionId = "" }) => {
8086
8128
  const status = getQuestionStatus$1(questionSteps);
8087
8129
  const animatedCountRef = React.useRef(0);
8088
8130
  const [isExpanded, setIsExpanded] = React.useState(true);
@@ -8116,10 +8158,10 @@ const ProgressBarItem$1 = ({ question, questionSteps, isLast, classes, formData,
8116
8158
  if (animatedCountRef.current >= arr.length && onAllSubItemsAnimated) {
8117
8159
  onAllSubItemsAnimated();
8118
8160
  }
8119
- } }) }, idx))) })), formData && isExpanded && (jsxRuntime.jsx("div", { className: classes.stepFormContainer, children: jsxRuntime.jsx(StepFormContent, { formData: formData, isFormDisabled: isFormDisabled, showSavedFilters: showSavedFilters, preSelectedFilters: preSelectedFilters }) }))] })] }));
8161
+ } }) }, idx))) })), formData && isExpanded && (jsxRuntime.jsx("div", { className: classes.stepFormContainer, children: jsxRuntime.jsx(StepFormContent, { formData: formData, isFormDisabled: isFormDisabled, showSavedFilters: showSavedFilters, preSelectedFilters: preSelectedFilters, botProps: botProps, currentMode: currentMode, agentId: agentId, sessionId: sessionId }) }))] })] }));
8120
8162
  };
8121
- const Steps$1 = ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, setFinalStepDone, stepChange, currentMode, questions = [], questionsStepsMap = {}, stepFormDataMap = {}, isFormDisabled = false, }) => {
8122
- const classes = useStyles$5();
8163
+ const Steps$1 = ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, setFinalStepDone, stepChange, currentMode, questions = [], questionsStepsMap = {}, stepFormDataMap = {}, isFormDisabled = false, botProps = null, agentId = "", sessionId = "", }) => {
8164
+ const classes = useStyles$4();
8123
8165
  React.useState(false);
8124
8166
  const [showThinking, setShowThinking] = React.useState(false);
8125
8167
  // Determine if last question is fully completed (all sub-steps done)
@@ -8201,7 +8243,7 @@ const Steps$1 = ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, s
8201
8243
  const showSavedFilters = formEntry && !Array.isArray(formEntry) ? formEntry.showSavedFilters : true;
8202
8244
  const preSelectedFilters = formEntry && !Array.isArray(formEntry) ? formEntry.preSelectedFilters : null;
8203
8245
  const isLast = index === questions.length - 1;
8204
- return (jsxRuntime.jsx(ProgressBarItem$1, { question: question, questionSteps: questionSteps, isLast: isLast && !showThinking, classes: classes, formData: formData, isFormDisabled: isFormDisabled, showSavedFilters: showSavedFilters, preSelectedFilters: preSelectedFilters, onAllSubItemsAnimated: isLast && lastQuestionCompleted && !done
8246
+ return (jsxRuntime.jsx(ProgressBarItem$1, { question: question, questionSteps: questionSteps, isLast: isLast && !showThinking, classes: classes, formData: formData, isFormDisabled: isFormDisabled, showSavedFilters: showSavedFilters, preSelectedFilters: preSelectedFilters, botProps: botProps, currentMode: currentMode, agentId: agentId, sessionId: sessionId, onAllSubItemsAnimated: isLast && lastQuestionCompleted && !done
8205
8247
  ? () => setShowThinking(true)
8206
8248
  : undefined }, index));
8207
8249
  }), showThinking && !done && (jsxRuntime.jsx("div", { style: {
@@ -8209,36 +8251,6 @@ const Steps$1 = ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, s
8209
8251
  }, children: jsxRuntime.jsx(ProgressBarItem$1, { question: "Thinking", questionSteps: [{ header: "", sub_header: "", step_status: "not-completed" }], isLast: true, classes: classes, formData: null, isFormDisabled: isFormDisabled }) }))] }));
8210
8252
  };
8211
8253
 
8212
- const useStyles$4 = styles.makeStyles(() => ({
8213
- htmlContentContainer: {
8214
- width: "100%",
8215
- "& *": {
8216
- boxSizing: "border-box",
8217
- },
8218
- },
8219
- }));
8220
- const HtmlContent = ({ bodyText }) => {
8221
- const classes = useStyles$4();
8222
- const containerRef = React.useRef(null);
8223
- const content = bodyText?.content || "";
8224
- React.useEffect(() => {
8225
- if (containerRef.current && content) {
8226
- const sanitizedHtml = DOMPurify.sanitize(content, {
8227
- ADD_TAGS: ["style", "details", "summary"],
8228
- ADD_ATTR: ["open", "target", "rel", "class", "style"],
8229
- ALLOW_DATA_ATTR: true,
8230
- FORCE_BODY: true,
8231
- WHOLE_DOCUMENT: false,
8232
- });
8233
- containerRef.current.innerHTML = sanitizedHtml;
8234
- }
8235
- }, [content]);
8236
- if (!content) {
8237
- return null;
8238
- }
8239
- return (jsxRuntime.jsx("div", { ref: containerRef, className: classes.htmlContentContainer }));
8240
- };
8241
-
8242
8254
  const renderWidgetItem = (item, index, isFormDisabled) => {
8243
8255
  try {
8244
8256
  const parsedData = parseResponse(item, item.type, "", "", true);
@@ -8290,7 +8302,7 @@ const AgentResponse$1 = (props) => {
8290
8302
  };
8291
8303
 
8292
8304
  const StepsResponseTab = (props) => {
8293
- const { steps, setSteps, stepsDone, setStepsDone, finalStepDone, setFinalStepDone, content, isStreaming, stepChange, currentMode, questions, questionsStepsMap, stepFormDataMap, isFormDisabled, streamingWidgetData, isRetrying, } = props;
8305
+ const { steps, setSteps, stepsDone, setStepsDone, finalStepDone, setFinalStepDone, content, isStreaming, stepChange, currentMode, questions, questionsStepsMap, stepFormDataMap, isFormDisabled, streamingWidgetData, isRetrying, botProps, agentId, sessionId, } = props;
8294
8306
  const dispatch = reactRedux.useDispatch();
8295
8307
  const thinkingContext = reactRedux.useSelector((state) => state.smartBotReducer.thinkingContext);
8296
8308
  const streamStartTimeRef = React.useRef(thinkingContext?.streamStartTime);
@@ -8354,7 +8366,7 @@ const StepsResponseTab = (props) => {
8354
8366
  icon: jsxRuntime.jsx(PsychologyOutlinedIcon, { fontSize: "large" }),
8355
8367
  },
8356
8368
  ], tabPanels: [
8357
- jsxRuntime.jsx(Steps$1, { steps: steps, setSteps: setSteps, done: stepsDone, setDone: setStepsDone, setTabValue: setTabValue, finalStepDone: finalStepDone, setFinalStepDone: setFinalStepDone, stepChange: stepChange, currentMode: currentMode, questions: questions, questionsStepsMap: questionsStepsMap, stepFormDataMap: stepFormDataMap, isFormDisabled: isFormDisabled || isTimedOut }),
8369
+ jsxRuntime.jsx(Steps$1, { steps: steps, setSteps: setSteps, done: stepsDone, setDone: setStepsDone, setTabValue: setTabValue, finalStepDone: finalStepDone, setFinalStepDone: setFinalStepDone, stepChange: stepChange, currentMode: currentMode, questions: questions, questionsStepsMap: questionsStepsMap, stepFormDataMap: stepFormDataMap, isFormDisabled: isFormDisabled || isTimedOut, botProps: botProps, agentId: agentId, sessionId: sessionId }),
8358
8370
  jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(AgentResponse$1, { content: content, isStreaming: isStreaming, streamingWidgetData: streamingWidgetData, isFormDisabled: isFormDisabled || isTimedOut }), timeoutMessage && (jsxRuntime.jsx("div", { style: { marginTop: "8px", padding: "0 8px" }, children: jsxRuntime.jsx(TextRenderer, { text: timeoutMessage, thinking: "" }) }))] }),
8359
8371
  ], value: tabValue }) }));
8360
8372
  };
@@ -8536,7 +8548,7 @@ const streamStateMap = new Map();
8536
8548
  * @param {React.RefObject} botData.utilityObject.chatBodyRef - Ref to chat body element
8537
8549
  * @param {Function} botData.utilityObject.setChatDataState - Function to update chat data state
8538
8550
  */
8539
- const StreamedContent = ({ botData }) => {
8551
+ const StreamedContent = ({ botData, botProps }) => {
8540
8552
  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 || {};
8541
8553
  const classes = useStyles$7();
8542
8554
  useStyles$a();
@@ -9715,8 +9727,13 @@ const StreamedContent = ({ botData }) => {
9715
9727
  }, 1000);
9716
9728
  }
9717
9729
  }, [isStreamingDone, thinkingTime, activeConversationId]);
9730
+ // Show/hide the stop (cancel execution) icon while the stream is active.
9731
+ // Gate on state only - sourceRef is a ref, so mutating it never re-runs this
9732
+ // effect. Relying on it meant that if the source wasn't assigned yet on the
9733
+ // first run, isStop was set to false and never re-evaluated for the rest of
9734
+ // the stream, leaving the cancel button hidden.
9718
9735
  React.useEffect(() => {
9719
- if (sourceRef.current && isStreaming) {
9736
+ if (isStreaming && !isStreamingDone) {
9720
9737
  setIsStop(true);
9721
9738
  setFunctionsState({
9722
9739
  ...functionsState,
@@ -9727,7 +9744,7 @@ const StreamedContent = ({ botData }) => {
9727
9744
  else {
9728
9745
  setIsStop(false);
9729
9746
  }
9730
- }, [isStreaming]);
9747
+ }, [isStreaming, isStreamingDone]);
9731
9748
  /**
9732
9749
  * Aborts the current streaming connection
9733
9750
  */
@@ -9740,10 +9757,12 @@ const StreamedContent = ({ botData }) => {
9740
9757
  setRetryCountdown(0);
9741
9758
  }
9742
9759
  retryCountRef.current = MAX_RETRY_COUNT; // Exhaust retries so no further auto-retries happen
9743
- if (sourceRef.current && isStreaming) {
9760
+ if (isStreaming) {
9744
9761
  setWasStreamingAborted(true);
9745
9762
  wasStreamingAbortedRef.current = true;
9746
- sourceRef.current.close();
9763
+ if (sourceRef.current) {
9764
+ sourceRef.current.close();
9765
+ }
9747
9766
  setIsStreaming(false);
9748
9767
  setIsStreamingDone(true);
9749
9768
  // Mark as completed+aborted so tab-switch remounts don't restart the stream.
@@ -9903,7 +9922,7 @@ const StreamedContent = ({ botData }) => {
9903
9922
  * @returns {JSX.Element} Rendered content with optional blinking cursor
9904
9923
  */
9905
9924
  const renderContent = () => {
9906
- return (jsxRuntime.jsxs("div", { className: classes.streamContainer, children: [jsxRuntime.jsx(StepsResponseTab, { steps: steps, stepChange: stepChange, setSteps: setSteps, stepsDone: stepsDone, setStepsDone: setStepsDone, finalStepDone: finalStepDone, setFinalStepDone: setFinalStepDone, content: content, isStreaming: isStreaming, currentMode: currentMode, questions: questions, questionsStepsMap: questionsStepsMap, stepFormDataMap: stepFormDataMap, isFormDisabled: botData?.isFormDisabled || false, streamingWidgetData: streamingWidgetData, isRetrying: isRetrying }), isRetrying && (jsxRuntime.jsx("div", { className: classes.retryContainer, children: jsxRuntime.jsx(TextRenderer, { text: `Auto re-trying in ${retryCountdown}s`, thinking: "" }) }))] }));
9925
+ return (jsxRuntime.jsxs("div", { className: classes.streamContainer, children: [jsxRuntime.jsx(StepsResponseTab, { steps: steps, stepChange: stepChange, setSteps: setSteps, stepsDone: stepsDone, setStepsDone: setStepsDone, finalStepDone: finalStepDone, setFinalStepDone: setFinalStepDone, content: content, isStreaming: isStreaming, currentMode: currentMode, questions: questions, questionsStepsMap: questionsStepsMap, stepFormDataMap: stepFormDataMap, isFormDisabled: botData?.isFormDisabled || false, streamingWidgetData: streamingWidgetData, isRetrying: isRetrying, botProps: botProps, agentId: botData?.inputBody?.agent_id || "", sessionId: messageToStoreRef.current?.sessionId || "" }), isRetrying && (jsxRuntime.jsx("div", { className: classes.retryContainer, children: jsxRuntime.jsx(TextRenderer, { text: `Auto re-trying in ${retryCountdown}s`, thinking: "" }) }))] }));
9907
9926
  };
9908
9927
  if (currentMode === "agent") {
9909
9928
  return renderContent();
@@ -10173,8 +10192,9 @@ const AgentResponse = ({ children }) => {
10173
10192
  // Only the active instance should process stepFormStreamData from Redux.
10174
10193
  let instanceCounter = 0;
10175
10194
  let activeTabularInstanceId = null;
10176
- const TabularContent = ({ steps: initialSteps, currentTabValue, children, questions: initialQuestions = [], questionsStepsMap: initialQuestionsStepsMap = {}, stepFormDataMap: initialStepFormDataMap = {}, isFormDisabled = false, sessionId: propSessionId = "" }) => {
10195
+ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questions: initialQuestions = [], questionsStepsMap: initialQuestionsStepsMap = {}, stepFormDataMap: initialStepFormDataMap = {}, isFormDisabled = false, sessionId: propSessionId = "", botProps = null, currentMode = "", agentId = "" }) => {
10177
10196
  const dispatch = reactRedux.useDispatch();
10197
+ const chatClasses = useStyles$a();
10178
10198
  const stepFormStreamData = reactRedux.useSelector((state) => state.smartBotReducer.stepFormStreamData);
10179
10199
  const thinkingContext = reactRedux.useSelector((state) => state.smartBotReducer.thinkingContext);
10180
10200
  const streamStartTimeRef = React.useRef(thinkingContext?.streamStartTime);
@@ -10258,40 +10278,55 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
10258
10278
  };
10259
10279
  }, []);
10260
10280
  // Render a widget item from SSE data
10281
+ const renderWidgetBody = (parsedData, key) => {
10282
+ switch (parsedData.bodyType) {
10283
+ case "text":
10284
+ return jsxRuntime.jsx(TextContent, { bodyText: parsedData.bodyText, botData: parsedData }, key);
10285
+ case "chips":
10286
+ return parsedData.isMultiSelect ? (jsxRuntime.jsx(SelectableChips, { bodyText: parsedData.bodyText, chipType: "selectable", utilityData: parsedData.utilityData, props: botProps }, key)) : (jsxRuntime.jsx(ChipsContent, { bodyText: parsedData.bodyText, props: botProps }, key));
10287
+ case "questions":
10288
+ return jsxRuntime.jsx(QuestionsContent, { bodyText: parsedData.bodyText, props: botProps }, key);
10289
+ case "image":
10290
+ return jsxRuntime.jsx(ImageContent, { bodyText: parsedData.bodyText }, key);
10291
+ case "table":
10292
+ return jsxRuntime.jsx(TableContent, { bodyText: parsedData.bodyText }, key);
10293
+ case "graph":
10294
+ return jsxRuntime.jsx(GraphContent, { bodyText: parsedData.bodyText }, key);
10295
+ case "radio":
10296
+ return jsxRuntime.jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10297
+ case "checkbox":
10298
+ return jsxRuntime.jsx(CheckboxContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10299
+ case "select":
10300
+ return jsxRuntime.jsx(SelectContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10301
+ case "slider":
10302
+ return jsxRuntime.jsx(SliderContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10303
+ case "button":
10304
+ return jsxRuntime.jsx(ButtonContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10305
+ case "input":
10306
+ return jsxRuntime.jsx(InputContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10307
+ case "datePicker":
10308
+ return jsxRuntime.jsx(DatePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10309
+ case "dateRangePicker":
10310
+ return jsxRuntime.jsx(DateRangePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10311
+ case "html":
10312
+ return jsxRuntime.jsx(HtmlContent, { bodyText: parsedData.bodyText }, key);
10313
+ default:
10314
+ return null;
10315
+ }
10316
+ };
10261
10317
  const renderWidget = (item, index) => {
10262
10318
  try {
10263
- const parsedData = parseResponse(item, item.type, "", "", true);
10319
+ const parsedData = parseResponse(item, item.type, agentId, currentMode, true, propSessionId);
10264
10320
  if (!parsedData)
10265
10321
  return null;
10266
10322
  const key = `restream-widget-${index}`;
10267
- switch (parsedData.bodyType) {
10268
- case "text":
10269
- return jsxRuntime.jsx(TextContent, { bodyText: parsedData.bodyText, botData: parsedData }, key);
10270
- case "table":
10271
- return jsxRuntime.jsx(TableContent, { bodyText: parsedData.bodyText }, key);
10272
- case "graph":
10273
- return jsxRuntime.jsx(GraphContent, { bodyText: parsedData.bodyText }, key);
10274
- case "radio":
10275
- return jsxRuntime.jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10276
- case "checkbox":
10277
- return jsxRuntime.jsx(CheckboxContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10278
- case "select":
10279
- return jsxRuntime.jsx(SelectContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10280
- case "slider":
10281
- return jsxRuntime.jsx(SliderContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10282
- case "button":
10283
- return jsxRuntime.jsx(ButtonContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10284
- case "input":
10285
- return jsxRuntime.jsx(InputContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10286
- case "datePicker":
10287
- return jsxRuntime.jsx(DatePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10288
- case "dateRangePicker":
10289
- return jsxRuntime.jsx(DateRangePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
10290
- case "html":
10291
- return jsxRuntime.jsx(HtmlContent, { bodyText: parsedData.bodyText }, key);
10292
- default:
10293
- return null;
10294
- }
10323
+ const body = renderWidgetBody(parsedData, key);
10324
+ if (!body)
10325
+ return null;
10326
+ const showHeaderTitle = !parsedData?.noShowHeaderTitle && Boolean(parsedData?.headerTitle?.length);
10327
+ if (!showHeaderTitle)
10328
+ return body;
10329
+ return (jsxRuntime.jsxs(React.Fragment, { children: [jsxRuntime.jsx("div", { className: `${chatClasses.chatbotText} ${chatClasses.boldText} ${chatClasses.combinedBlockHeaderTitle}`, children: parsedData.headerTitle }), body] }, `restream-widget-block-${index}`));
10295
10330
  }
10296
10331
  catch (e) {
10297
10332
  console.error("[TabularContent] renderWidget error:", e);
@@ -10661,11 +10696,8 @@ const CombinedContent = ({ botData, props }) => {
10661
10696
  // Get the array of content items from bodyText
10662
10697
  const contentItems = Array.isArray(botData.bodyText) ? botData.bodyText : [];
10663
10698
  // Renders the optional block-level header title above a content item.
10664
- // Text blocks are skipped because their heading is the echoed user query
10665
- // (response_heading), which we don't want to duplicate in the response.
10666
10699
  const renderHeaderTitle = (parsedData) => {
10667
- const showHeaderTitle = parsedData?.bodyType !== "text" &&
10668
- !parsedData?.noShowHeaderTitle &&
10700
+ const showHeaderTitle = !parsedData?.noShowHeaderTitle &&
10669
10701
  Boolean(parsedData?.headerTitle?.length);
10670
10702
  if (!showHeaderTitle)
10671
10703
  return null;
@@ -10735,7 +10767,7 @@ const CombinedContent = ({ botData, props }) => {
10735
10767
  const validContent = renderedContent.filter(content => content !== null);
10736
10768
  const renderCombinedContent = () => (jsxRuntime.jsx("div", { className: "combined-content-container", children: validContent.length > 0 ? (validContent.map((content, index) => (jsxRuntime.jsx("div", { className: "combined-content-item", children: content }, `wrapper-${index}`)))) : (jsxRuntime.jsx("div", { children: "No valid content to display" })) }));
10737
10769
  if (isTabEnabled) {
10738
- return (jsxRuntime.jsx(TabularContent, { steps: botData?.utilityData?.steps || [], currentTabValue: botData?.utilityData?.currentTabValue || "steps", questions: botData?.utilityData?.questions || [], questionsStepsMap: botData?.utilityData?.questionsStepsMap || {}, stepFormDataMap: botData?.utilityData?.stepFormDataMap || {}, isFormDisabled: isFormDisabled, sessionId: botData?.sessionId || "", children: renderCombinedContent() }));
10770
+ return (jsxRuntime.jsx(TabularContent, { steps: botData?.utilityData?.steps || [], currentTabValue: botData?.utilityData?.currentTabValue || "steps", questions: botData?.utilityData?.questions || [], questionsStepsMap: botData?.utilityData?.questionsStepsMap || {}, stepFormDataMap: botData?.utilityData?.stepFormDataMap || {}, isFormDisabled: isFormDisabled, sessionId: botData?.sessionId || "", botProps: props, currentMode: botData?.currentMode || "", agentId: botData?.agentId || "", children: renderCombinedContent() }));
10739
10771
  }
10740
10772
  return renderCombinedContent();
10741
10773
  };
@@ -10774,7 +10806,7 @@ const BotMessage = ({ botData, state, handleLikeDislike, props }) => {
10774
10806
  case "text":
10775
10807
  return jsxRuntime.jsx(TextContent, { bodyText: botData.bodyText, botData: botData });
10776
10808
  case "stream":
10777
- return jsxRuntime.jsx(StreamedContent, { botData: botData });
10809
+ return jsxRuntime.jsx(StreamedContent, { botData: botData, botProps: props });
10778
10810
  case "chips":
10779
10811
  if (botData.isMultiSelect) {
10780
10812
  return (jsxRuntime.jsx(SelectableChips, { bodyText: botData.bodyText, utilityData: botData.utilityData, props: props }));
@@ -15163,6 +15195,13 @@ const SmartBot = (props) => {
15163
15195
  // );
15164
15196
  // return;
15165
15197
  // } else {
15198
+ // The library re-fires the `initialClick` tab's onClick from an
15199
+ // effect whose deps (tabList/menuItems/onChatBotResize) are
15200
+ // recreated on every render. Track the previous tab so we only
15201
+ // reset transient state on a real tab change - otherwise these
15202
+ // spurious re-invocations wipe isStop mid-stream and hide the
15203
+ // cancel execution button.
15204
+ const previousActiveTab = activeTab.current.activeTab;
15166
15205
  setShowSavedFilters(false);
15167
15206
  const agentConversations = chatDataInfoRef?.current[params?.name?.toLowerCase()]?.conversations;
15168
15207
  const firstConversationId = agentConversations ? Object.keys(agentConversations)[0] : undefined;
@@ -15181,7 +15220,9 @@ const SmartBot = (props) => {
15181
15220
  localStorage.setItem("currentModeData", params?.name?.toLowerCase());
15182
15221
  setNewChatScreen(false);
15183
15222
  activeTab.current.activeTab = "agent";
15184
- setIsStop(false);
15223
+ if (previousActiveTab !== "agent") {
15224
+ setIsStop(false);
15225
+ }
15185
15226
  // }
15186
15227
  // setConversation([]);
15187
15228
  // chatDataInfoRef.current[currentMode] = [];
@@ -15200,6 +15241,8 @@ const SmartBot = (props) => {
15200
15241
  // );
15201
15242
  // return;
15202
15243
  // } else {
15244
+ // Only reset transient state on a real tab change.
15245
+ const previousActiveTab = activeTab.current.activeTab;
15203
15246
  setShowSavedFilters(false);
15204
15247
  let currentModeValue = params?.name?.toLowerCase();
15205
15248
  const modeConversations = chatDataInfoRef?.current[currentModeValue]?.conversations;
@@ -15223,7 +15266,9 @@ const SmartBot = (props) => {
15223
15266
  chatDataInfoRef.current = lodash.cloneDeep(parsedData);
15224
15267
  }
15225
15268
  // setNewChatScreen(true);
15226
- setIsStop(false);
15269
+ if (previousActiveTab !== "navigation") {
15270
+ setIsStop(false);
15271
+ }
15227
15272
  setCurrentMode(params?.name?.toLowerCase());
15228
15273
  if (firstConversationId) {
15229
15274
  setActiveConversationId(firstConversationId);
@@ -15292,6 +15337,9 @@ const SmartBot = (props) => {
15292
15337
  // );
15293
15338
  // return;
15294
15339
  // } else {
15340
+ // Only reset transient state on a real tab change - the library
15341
+ // re-fires this initialClick handler on every render.
15342
+ const previousActiveTab = activeTab.current.activeTab;
15295
15343
  setShowSavedFilters(false);
15296
15344
  let currentModeValue = params?.name?.toLowerCase();
15297
15345
  const modeConversations = chatDataInfoRef?.current[currentModeValue]?.conversations;
@@ -15315,7 +15363,9 @@ const SmartBot = (props) => {
15315
15363
  chatDataInfoRef.current = lodash.cloneDeep(parsedData);
15316
15364
  }
15317
15365
  // setNewChatScreen(true);
15318
- setIsStop(false);
15366
+ if (previousActiveTab !== "navigation") {
15367
+ setIsStop(false);
15368
+ }
15319
15369
  setCurrentMode(params?.name?.toLowerCase());
15320
15370
  if (firstConversationId) {
15321
15371
  setActiveConversationId(firstConversationId);
@@ -15346,6 +15396,9 @@ const SmartBot = (props) => {
15346
15396
  // );
15347
15397
  // return;
15348
15398
  // } else {
15399
+ // Only reset transient state on a real tab change - the library
15400
+ // re-fires this initialClick handler on every render.
15401
+ const previousActiveTab = activeTab.current.activeTab;
15349
15402
  setShowSavedFilters(false);
15350
15403
  let currentModeValue = params?.name?.toLowerCase();
15351
15404
  const modeConversations = chatDataInfoRef?.current[currentModeValue]?.conversations;
@@ -15369,7 +15422,9 @@ const SmartBot = (props) => {
15369
15422
  chatDataInfoRef.current = lodash.cloneDeep(parsedData);
15370
15423
  }
15371
15424
  // setNewChatScreen(true);
15372
- setIsStop(false);
15425
+ if (previousActiveTab !== "navigation") {
15426
+ setIsStop(false);
15427
+ }
15373
15428
  setCurrentMode(params?.name?.toLowerCase());
15374
15429
  if (firstConversationId) {
15375
15430
  setActiveConversationId(firstConversationId);