impact-chatbot 2.3.43 → 2.3.48

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
@@ -5095,6 +5095,26 @@ const sseevent = (message, messageToStoreRef) => {
5095
5095
  messageToStoreRef.current.chatData.response =
5096
5096
  messageToStoreRef.current.chatData.response +
5097
5097
  "There is an error, please reach out to IA with this use case.";
5098
+ // Still process completed/follow-up status even on error chunks
5099
+ // so that initValue is set correctly and dummyButton is suppressed
5100
+ if (parsedData?.status === "completed" ||
5101
+ parsedData?.status === "follow-up") {
5102
+ messageToStoreRef.current.initValue = true;
5103
+ messageToStoreRef.current.sessionId = "";
5104
+ messageToStoreRef.current.uniqueChatId = parsedData?.chat_id
5105
+ ? parsedData.chat_id
5106
+ : "";
5107
+ messageToStoreRef.current.status = parsedData?.status;
5108
+ }
5109
+ return new MessageEvent(type, { data: data });
5110
+ }
5111
+ if (parsedData?.status === "notification") {
5112
+ messageToStoreRef.current.notificationData = {
5113
+ message: parsedData?.message || "",
5114
+ chat_id: parsedData?.chat_id || "",
5115
+ session_id: parsedData?.session_id || "",
5116
+ };
5117
+ // Do NOT append notification messages to chatData.response — return early
5098
5118
  return new MessageEvent(type, { data: data });
5099
5119
  }
5100
5120
  if (parsedData?.status === "thinking") {
@@ -5133,13 +5153,6 @@ const sseevent = (message, messageToStoreRef) => {
5133
5153
  ? parsedData.additional_args
5134
5154
  : {};
5135
5155
  }
5136
- if (parsedData?.status === "notification") {
5137
- messageToStoreRef.current.notificationData = {
5138
- message: parsedData?.message || "",
5139
- chat_id: parsedData?.chat_id || "",
5140
- session_id: parsedData?.session_id || "",
5141
- };
5142
- }
5143
5156
  if (parsedData?.status === "completed" ||
5144
5157
  parsedData?.status === "follow-up") {
5145
5158
  messageToStoreRef.current.initValue = true;
@@ -5295,6 +5308,9 @@ const stepFormStreamControl = {
5295
5308
  chatId: "",
5296
5309
  agentId: "",
5297
5310
  baseUrl: "",
5311
+ // Completed/follow-up state — persists across ButtonContent remounts
5312
+ initValue: false,
5313
+ uniqueChatId: "",
5298
5314
  };
5299
5315
  const useStyles$5 = styles.makeStyles((theme) => ({
5300
5316
  buttonContainer: {
@@ -5357,8 +5373,15 @@ const ButtonContent = ({ bodyText, isFormDisabled = false, isStepFormSubmit = fa
5357
5373
  };
5358
5374
  const callInitApiStream = (userInput) => {
5359
5375
  // Prefer module-level values (set synchronously by StreamedContent), fall back to sessionStorage
5360
- const sessionId = stepFormStreamControl.sessionId || sessionStorage.getItem("stepForm_sessionId") || "";
5361
- const chatId = stepFormStreamControl.chatId || sessionStorage.getItem("stepForm_chatId") || "";
5376
+ // If a previous completed/follow-up response updated the state, use those values.
5377
+ // Read from module-level stepFormStreamControl (survives remounts) instead of local messageStoreRef.
5378
+ const hasCompletedState = stepFormStreamControl.initValue === true;
5379
+ const sessionId = hasCompletedState
5380
+ ? (stepFormStreamControl.sessionId ?? "")
5381
+ : (stepFormStreamControl.sessionId || sessionStorage.getItem("stepForm_sessionId") || "");
5382
+ const chatId = hasCompletedState
5383
+ ? (stepFormStreamControl.uniqueChatId ?? "")
5384
+ : (stepFormStreamControl.chatId || sessionStorage.getItem("stepForm_chatId") || "");
5362
5385
  const agentId = stepFormStreamControl.agentId || sessionStorage.getItem("stepForm_agentId") || "";
5363
5386
  const baseUrl = stepFormStreamControl.baseUrl || sessionStorage.getItem("stepForm_baseUrl") || "";
5364
5387
  const payload = {
@@ -5366,9 +5389,14 @@ const ButtonContent = ({ bodyText, isFormDisabled = false, isStepFormSubmit = fa
5366
5389
  session_id: sessionId,
5367
5390
  chat_id: chatId,
5368
5391
  user_input: userInput,
5369
- init: false,
5392
+ init: hasCompletedState ? true : false,
5370
5393
  delay: 0.3,
5371
5394
  };
5395
+ // Reset the flag so subsequent calls don't re-use stale completed state
5396
+ if (hasCompletedState) {
5397
+ messageStoreRef.current.initValue = false;
5398
+ stepFormStreamControl.initValue = false;
5399
+ }
5372
5400
  const endPoint = baseUrl
5373
5401
  ? `${api.BASE_API}${baseUrl}/chatbot/agent/init`
5374
5402
  : `${api.BASE_API}/core/chatbot/agent/init`;
@@ -5387,10 +5415,10 @@ const ButtonContent = ({ bodyText, isFormDisabled = false, isStepFormSubmit = fa
5387
5415
  if (sessionId) {
5388
5416
  chatbotServices.stopAgentFlow({ session_id: sessionId }, baseUrl);
5389
5417
  }
5390
- dispatch(smartBotActions.setStepFormStreamData({ status: "error", chunks: [...chunksRef] }));
5418
+ dispatch(smartBotActions.setStepFormStreamData({ status: "error", chunks: [...chunksRef], sessionId }));
5391
5419
  };
5392
5420
  // Signal that streaming has started (after setting stepFormStreamControl so useEffect sees the flag)
5393
- dispatch(smartBotActions.setStepFormStreamData({ status: "streaming_start", chunks: [] }));
5421
+ dispatch(smartBotActions.setStepFormStreamData({ status: "streaming_start", chunks: [], sessionId }));
5394
5422
  // Fire DOM event so SmartBot can show stop icon (Redux gets cleared by TabularContent before parent effects run)
5395
5423
  window.dispatchEvent(new CustomEvent("stepFormStreamStart"));
5396
5424
  sourceRef.current = AxiosSource(endPoint, {
@@ -5410,24 +5438,40 @@ const ButtonContent = ({ bodyText, isFormDisabled = false, isStepFormSubmit = fa
5410
5438
  console.log("[ButtonContent] SSE chunk:", data);
5411
5439
  if (data?.status === "step" || data?.status === "step_form" || data?.status === "questions" || data?.status === "thinking" || data?.status === "widget") {
5412
5440
  chunksRef.push(data);
5441
+ // Dispatch widget chunks immediately for real-time rendering
5442
+ if (data?.status === "widget") {
5443
+ dispatch(smartBotActions.setStepFormStreamData({ status: "widget_chunk", chunks: [data], sessionId }));
5444
+ }
5413
5445
  // If this chunk also carries [DONE], dispatch collected chunks now
5414
5446
  if (data?.message === "[DONE]") {
5415
5447
  stepFormStreamControl.isStreaming = false;
5416
5448
  stepFormStreamControl.abort = null;
5417
5449
  window.dispatchEvent(new CustomEvent("stepFormStreamEnd"));
5418
- dispatch(smartBotActions.setStepFormStreamData({ status: "done", chunks: [...chunksRef] }));
5450
+ dispatch(smartBotActions.setStepFormStreamData({ status: "done", chunks: [...chunksRef], sessionId }));
5419
5451
  }
5420
5452
  }
5421
- else if (data?.status === "completed" || data?.message === "[DONE]") {
5453
+ else if (data?.status === "completed" || data?.status === "follow-up" || data?.message === "[DONE]") {
5454
+ // Update messageStoreRef the same way AxiosEventSource does for completed/follow-up
5455
+ if (data?.status === "completed" || data?.status === "follow-up") {
5456
+ messageStoreRef.current.initValue = true;
5457
+ messageStoreRef.current.sessionId = "";
5458
+ messageStoreRef.current.uniqueChatId = data?.chat_id ? data.chat_id : "";
5459
+ // Also persist on module-level object so it survives ButtonContent remounts
5460
+ stepFormStreamControl.initValue = true;
5461
+ stepFormStreamControl.sessionId = "";
5462
+ stepFormStreamControl.uniqueChatId = data?.chat_id ? data.chat_id : "";
5463
+ }
5422
5464
  // Stream ended — dispatch all collected chunks at once
5423
5465
  stepFormStreamControl.isStreaming = false;
5424
5466
  stepFormStreamControl.abort = null;
5425
5467
  window.dispatchEvent(new CustomEvent("stepFormStreamEnd"));
5426
- // Signal tab switch to agent_response when status is "completed"
5427
- if (data?.status === "completed") {
5468
+ // Signal tab switch to agent_response when status is "completed",
5469
+ // but only if the response doesn't contain a new step_form that needs user interaction
5470
+ const hasStepForm = chunksRef.some((c) => c.status === "step_form");
5471
+ if (data?.status === "completed" && !hasStepForm) {
5428
5472
  window.dispatchEvent(new CustomEvent("stepFormStreamCompleted"));
5429
5473
  }
5430
- dispatch(smartBotActions.setStepFormStreamData({ status: "done", chunks: [...chunksRef] }));
5474
+ dispatch(smartBotActions.setStepFormStreamData({ status: "done", chunks: [...chunksRef], sessionId }));
5431
5475
  }
5432
5476
  else if (data?.message) {
5433
5477
  chunksRef.push({ status: "content", message: data.message });
@@ -5442,7 +5486,7 @@ const ButtonContent = ({ bodyText, isFormDisabled = false, isStepFormSubmit = fa
5442
5486
  stepFormStreamControl.isStreaming = false;
5443
5487
  stepFormStreamControl.abort = null;
5444
5488
  window.dispatchEvent(new CustomEvent("stepFormStreamEnd"));
5445
- dispatch(smartBotActions.setStepFormStreamData({ status: "error", chunks: chunksRef }));
5489
+ dispatch(smartBotActions.setStepFormStreamData({ status: "error", chunks: chunksRef, sessionId }));
5446
5490
  });
5447
5491
  };
5448
5492
  const renderButtons = () => {
@@ -6534,10 +6578,8 @@ const getQuestionStatus$1 = (questionSteps) => {
6534
6578
  /**
6535
6579
  * Renders a single progress bar item (main point + sub-items)
6536
6580
  */
6537
- const ProgressBarItem$1 = ({ question, questionSteps, isLast, classes, formData, showSavedFilters = true, isFormDisabled, isRestreaming = false, onAllSubItemsAnimated = undefined }) => {
6538
- const baseStatus = getQuestionStatus$1(questionSteps);
6539
- // When restreaming and this is the last item, show as in-progress
6540
- const status = (isRestreaming && isLast) ? "in-progress" : baseStatus;
6581
+ const ProgressBarItem$1 = ({ question, questionSteps, isLast, classes, formData, showSavedFilters = true, isFormDisabled, onAllSubItemsAnimated = undefined }) => {
6582
+ const status = getQuestionStatus$1(questionSteps);
6541
6583
  const animatedCountRef = React.useRef(0);
6542
6584
  const [isExpanded, setIsExpanded] = React.useState(true);
6543
6585
  const dotClass = status === "completed"
@@ -6581,8 +6623,14 @@ const Steps$1 = ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, s
6581
6623
  const lastQuestionCompleted = lastQuestionSteps &&
6582
6624
  lastQuestionSteps.length > 0 &&
6583
6625
  lastQuestionSteps.every((s) => s.step_status === "completed");
6626
+ const hasStepFormData = Object.keys(stepFormDataMap).length > 0;
6584
6627
  React.useEffect(() => {
6585
6628
  if (done) {
6629
+ // Don't auto-switch to agent_response tab when there's a step form pending user interaction
6630
+ if (hasStepFormData) {
6631
+ setFinalStepDone(true);
6632
+ return;
6633
+ }
6586
6634
  if (!finalStepDone) {
6587
6635
  if (currentMode === "navigation") {
6588
6636
  let updatedSteps = steps.map((step) => ({
@@ -6632,7 +6680,7 @@ const Steps$1 = ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, s
6632
6680
  step_status: "not-completed",
6633
6681
  },
6634
6682
  ];
6635
- return (jsxRuntime.jsx("div", { className: classes.progressBarContainer, children: jsxRuntime.jsx(ProgressBarItem$1, { question: fallbackQuestion, questionSteps: fallbackSteps, isLast: true, classes: classes, formData: null, isFormDisabled: isFormDisabled, showSavedFilters: true }) }));
6683
+ return (jsxRuntime.jsx("div", { className: classes.progressBarContainer, children: jsxRuntime.jsx(ProgressBarItem$1, { question: fallbackQuestion, questionSteps: fallbackSteps, isLast: true, classes: classes, formData: null, isFormDisabled: isFormDisabled }) }));
6636
6684
  }
6637
6685
  return (jsxRuntime.jsxs("div", { className: classes.progressBarContainer, children: [questions.map((question, index) => {
6638
6686
  const questionData = questionsStepsMap[question];
@@ -6655,17 +6703,40 @@ const Steps$1 = ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, s
6655
6703
  }, children: jsxRuntime.jsx(ProgressBarItem$1, { question: "Thinking", questionSteps: [{ header: "", sub_header: "", step_status: "not-completed" }], isLast: true, classes: classes, formData: null, isFormDisabled: isFormDisabled }) }))] }));
6656
6704
  };
6657
6705
 
6706
+ const renderWidgetItem = (item, index) => {
6707
+ try {
6708
+ const parsedData = parseResponse(item, item.type, "", "", true);
6709
+ if (!parsedData)
6710
+ return null;
6711
+ const key = `streaming-widget-${index}`;
6712
+ switch (parsedData.bodyType) {
6713
+ case "text":
6714
+ return jsxRuntime.jsx(TextContent, { bodyText: parsedData.bodyText, botData: parsedData }, key);
6715
+ case "table":
6716
+ return jsxRuntime.jsx(TableContent, { bodyText: parsedData.bodyText }, key);
6717
+ case "graph":
6718
+ return jsxRuntime.jsx(GraphContent, { bodyText: parsedData.bodyText }, key);
6719
+ default:
6720
+ return null;
6721
+ }
6722
+ }
6723
+ catch (e) {
6724
+ console.error("[AgentResponse] renderWidgetItem error:", e);
6725
+ return null;
6726
+ }
6727
+ };
6658
6728
  const AgentResponse$1 = (props) => {
6659
- const { content, isStreaming } = props;
6729
+ const { content, isStreaming, streamingWidgetData = [] } = props;
6660
6730
  const classes = useStyles$4();
6661
6731
  const chatClasses = useStyles$7();
6662
- return (jsxRuntime.jsx("div", { className: chatClasses.agentResponseContainer, children: content ? (jsxRuntime.jsxs(material.Typography, { className: chatClasses.bodyTextStyling, children: [jsxRuntime.jsx(TextRenderer, { text: content }), isStreaming && jsxRuntime.jsx("span", { className: classes.cursor })] })) : (
6663
- // Show cursor even when no content yet
6664
- isStreaming && jsxRuntime.jsx("span", { className: classes.cursor })) }));
6732
+ const renderedWidgets = streamingWidgetData
6733
+ .map((item, index) => renderWidgetItem(item, index))
6734
+ .filter(Boolean);
6735
+ return (jsxRuntime.jsxs("div", { className: chatClasses.agentResponseContainer, children: [content ? (jsxRuntime.jsxs(material.Typography, { className: chatClasses.bodyTextStyling, children: [jsxRuntime.jsx(TextRenderer, { text: content }), isStreaming && renderedWidgets.length === 0 && jsxRuntime.jsx("span", { className: classes.cursor })] })) : null, renderedWidgets.length > 0 && (jsxRuntime.jsx("div", { className: "streaming-widget-content", children: renderedWidgets })), isStreaming && (renderedWidgets.length > 0 || !content) && (jsxRuntime.jsx("span", { className: classes.cursor }))] }));
6665
6736
  };
6666
6737
 
6667
6738
  const StepsResponseTab = (props) => {
6668
- const { steps, setSteps, stepsDone, setStepsDone, finalStepDone, setFinalStepDone, content, isStreaming, stepChange, currentMode, questions, questionsStepsMap, stepFormDataMap, isFormDisabled, } = props;
6739
+ const { steps, setSteps, stepsDone, setStepsDone, finalStepDone, setFinalStepDone, content, isStreaming, stepChange, currentMode, questions, questionsStepsMap, stepFormDataMap, isFormDisabled, streamingWidgetData, } = props;
6669
6740
  const [tabValue, setTabValue] = React.useState("steps");
6670
6741
  const handleChangeTabValue = (_event, newValue) => {
6671
6742
  setTabValue(newValue);
@@ -6683,7 +6754,7 @@ const StepsResponseTab = (props) => {
6683
6754
  },
6684
6755
  ], tabPanels: [
6685
6756
  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 }),
6686
- jsxRuntime.jsx(AgentResponse$1, { content: content, isStreaming: isStreaming }),
6757
+ jsxRuntime.jsx(AgentResponse$1, { content: content, isStreaming: isStreaming, streamingWidgetData: streamingWidgetData }),
6687
6758
  ], value: tabValue }) }));
6688
6759
  };
6689
6760
 
@@ -6733,6 +6804,7 @@ const StreamedContent = ({ botData }) => {
6733
6804
  // const [thinkingContent, setThinkingContent] = useState("");
6734
6805
  const [thinkDone, setThinkDone] = React.useState(false);
6735
6806
  const [isStreaming, setIsStreaming] = React.useState(true);
6807
+ const [streamingWidgetData, setStreamingWidgetData] = React.useState([]);
6736
6808
  const [thinkingStarted, setThinkingStarted] = React.useState(false);
6737
6809
  const [isStreamingDone, setIsStreamingDone] = React.useState(false);
6738
6810
  const [isThinking, setIsThinking] = React.useState(false);
@@ -6907,7 +6979,7 @@ const StreamedContent = ({ botData }) => {
6907
6979
  }));
6908
6980
  return;
6909
6981
  }
6910
- if (data?.message || data?.status === "step" || data?.status === "step_form" || data?.status === "thinking" || data?.status === "questions") {
6982
+ if (data?.message || data?.status === "step" || data?.status === "step_form" || data?.status === "thinking" || data?.status === "questions" || data?.status === "widget") {
6911
6983
  if (data.status === "questions") {
6912
6984
  const incomingQuestions = data.widget_data?.[0]?.questions || [];
6913
6985
  questionsRef.current = incomingQuestions;
@@ -7020,6 +7092,15 @@ const StreamedContent = ({ botData }) => {
7020
7092
  : [data.widget_data];
7021
7093
  const currentIntent = data.current_intent || formWidgetData?.[0]?.current_intent;
7022
7094
  if (currentIntent) {
7095
+ // Auto-create question/intent entry if no prior step chunk created it
7096
+ if (!questionsStepsMapRef.current[currentIntent]) {
7097
+ questionsStepsMapRef.current[currentIntent] = [];
7098
+ if (!questionsRef.current.includes(currentIntent)) {
7099
+ questionsRef.current = [...questionsRef.current, currentIntent];
7100
+ setQuestions([...questionsRef.current]);
7101
+ }
7102
+ setQuestionsStepsMap(lodash.cloneDeep(questionsStepsMapRef.current));
7103
+ }
7023
7104
  const sendButton = document.getElementById("chat-input-send-button");
7024
7105
  const stepFormSubmitButton = {
7025
7106
  type: "button",
@@ -7059,12 +7140,20 @@ const StreamedContent = ({ botData }) => {
7059
7140
  stepFormStreamControl.baseUrl = _burl;
7060
7141
  // If this is the [DONE] chunk, mark streaming as complete
7061
7142
  if (data.message === "[DONE]") {
7143
+ setStepsDone(true);
7062
7144
  setIsStreamingDone(true);
7063
7145
  const doneState = streamStateMap.get(streamKey);
7064
7146
  if (doneState)
7065
7147
  doneState.completed = true;
7066
7148
  }
7067
7149
  }
7150
+ else if (data.status === "widget") {
7151
+ // Render widget data immediately as it arrives during streaming
7152
+ const widgetItems = isArray(data.widget_data)
7153
+ ? data.widget_data
7154
+ : [data.widget_data];
7155
+ setStreamingWidgetData((prev) => [...prev, ...widgetItems]);
7156
+ }
7068
7157
  else if (data.message !== "[DONE]") {
7069
7158
  if (!thinkingDoneRef?.current && currentMode === "agent") {
7070
7159
  thinkingDoneRef.current = true;
@@ -7147,6 +7236,13 @@ const StreamedContent = ({ botData }) => {
7147
7236
  const store = messageToStoreRef.current;
7148
7237
  // Restore accumulated content
7149
7238
  setContent(store.chatData?.response || "");
7239
+ // Restore widget data received so far
7240
+ if (isArray(store.appendedData) && store.appendedData.length > 0) {
7241
+ setStreamingWidgetData(store.appendedData);
7242
+ }
7243
+ else if (store.appendedData && !isArray(store.appendedData) && Object.keys(store.appendedData).length > 0) {
7244
+ setStreamingWidgetData([store.appendedData]);
7245
+ }
7150
7246
  // Restore thinking state
7151
7247
  if (store.chatData?.thinkingResponse?.thinkingStream) {
7152
7248
  thinkingContentRef.current = store.chatData.thinkingResponse.thinkingStream;
@@ -7213,15 +7309,21 @@ const StreamedContent = ({ botData }) => {
7213
7309
  dispatch(smartBotActions.setCurrentAgentChatId(messageToStoreRef.current.uniqueChatId));
7214
7310
  }
7215
7311
  // Persist IDs for step form restream (ButtonContent reads these)
7216
- sessionStorage.setItem("stepForm_sessionId", messageToStoreRef.current.sessionId || "");
7217
- sessionStorage.setItem("stepForm_chatId", messageToStoreRef.current.uniqueChatId || "");
7218
- sessionStorage.setItem("stepForm_agentId", botData.inputBody?.agent_id || "");
7219
- sessionStorage.setItem("stepForm_baseUrl", baseUrl || "");
7220
- // Also sync module-level control object
7221
- stepFormStreamControl.sessionId = messageToStoreRef.current.sessionId || "";
7222
- stepFormStreamControl.chatId = messageToStoreRef.current.uniqueChatId || "";
7223
- stepFormStreamControl.agentId = botData.inputBody?.agent_id || "";
7224
- stepFormStreamControl.baseUrl = baseUrl || "";
7312
+ const _sid2 = messageToStoreRef.current.sessionId || "";
7313
+ const _cid2 = messageToStoreRef.current.uniqueChatId || "";
7314
+ const _aid2 = botData.inputBody?.agent_id || "";
7315
+ const _burl2 = baseUrl || "";
7316
+ sessionStorage.setItem("stepForm_sessionId", _sid2);
7317
+ sessionStorage.setItem("stepForm_chatId", _cid2);
7318
+ sessionStorage.setItem("stepForm_agentId", _aid2);
7319
+ sessionStorage.setItem("stepForm_baseUrl", _burl2);
7320
+ stepFormStreamControl.sessionId = _sid2;
7321
+ stepFormStreamControl.chatId = _cid2;
7322
+ stepFormStreamControl.agentId = _aid2;
7323
+ stepFormStreamControl.baseUrl = _burl2;
7324
+ // Persist completed/follow-up state so ButtonContent can read it after remount
7325
+ stepFormStreamControl.initValue = messageToStoreRef.current.initValue;
7326
+ stepFormStreamControl.uniqueChatId = _cid2;
7225
7327
  let appendedDataLength = 0;
7226
7328
  // Use appendedDataFromLastChunk for field number calculation like host app
7227
7329
  if (isArray(messageToStoreRef.current.appendedDataFromLastChunk)) {
@@ -7269,14 +7371,16 @@ const StreamedContent = ({ botData }) => {
7269
7371
  data: isEmpty(dummyButton)
7270
7372
  ? [textResponseTobeParsed, ...finalData]
7271
7373
  : [textResponseTobeParsed, ...finalData, dummyButton],
7374
+ session_id: messageToStoreRef.current.sessionId || "",
7272
7375
  },
7273
7376
  },
7274
7377
  };
7378
+ const hasStepFormWidgets = !isEmpty(stepFormDataMapRef.current);
7275
7379
  processResponse(response, botData.inputBody, currentMode, botData.utilityObject.customChatConfig, {
7276
7380
  newChatData: chatDataInfoRef,
7277
7381
  isTabEnabled: true,
7278
7382
  steps: lodash.cloneDeep(stepRef.current),
7279
- currentTabValue: stepsDone ? "agent_response" : undefined,
7383
+ currentTabValue: (stepsDone && !hasStepFormWidgets) ? "agent_response" : "steps",
7280
7384
  questions: lodash.cloneDeep(questionsRef.current),
7281
7385
  questionsStepsMap: lodash.cloneDeep(questionsStepsMapRef.current),
7282
7386
  stepFormDataMap: { ...stepFormDataMapRef.current },
@@ -7352,6 +7456,7 @@ const StreamedContent = ({ botData }) => {
7352
7456
  data: {
7353
7457
  data: {
7354
7458
  data: [textResponseTobeParsed, ...finalData],
7459
+ session_id: messageToStoreRef.current.sessionId || "",
7355
7460
  },
7356
7461
  },
7357
7462
  };
@@ -7362,7 +7467,7 @@ const StreamedContent = ({ botData }) => {
7362
7467
  newChatData: chatDataInfoRef,
7363
7468
  isTabEnabled: true,
7364
7469
  steps: lodash.cloneDeep(stepRef.current),
7365
- currentTabValue: stepsDone ? "agent_response" : undefined,
7470
+ currentTabValue: stepsDone ? "agent_response" : "steps",
7366
7471
  questions: lodash.cloneDeep(questionsRef.current),
7367
7472
  questionsStepsMap: lodash.cloneDeep(questionsStepsMapRef.current),
7368
7473
  stepFormDataMap: { ...stepFormDataMapRef.current },
@@ -7509,7 +7614,7 @@ const StreamedContent = ({ botData }) => {
7509
7614
  * @returns {JSX.Element} Rendered content with optional blinking cursor
7510
7615
  */
7511
7616
  const renderContent = () => {
7512
- return (jsxRuntime.jsx("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 }) }));
7617
+ return (jsxRuntime.jsx("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 }) }));
7513
7618
  };
7514
7619
  if (currentMode === "agent") {
7515
7620
  return renderContent();
@@ -7772,7 +7877,11 @@ const AgentResponse = ({ children }) => {
7772
7877
  return (jsxRuntime.jsx("div", { className: classes.agentResponseContainer, children: children }));
7773
7878
  };
7774
7879
 
7775
- const TabularContent = ({ steps: initialSteps, currentTabValue, children, questions: initialQuestions = [], questionsStepsMap: initialQuestionsStepsMap = {}, stepFormDataMap: initialStepFormDataMap = {}, isFormDisabled = false }) => {
7880
+ // Module-level counter and active instance tracker.
7881
+ // Only the active instance should process stepFormStreamData from Redux.
7882
+ let instanceCounter = 0;
7883
+ let activeTabularInstanceId = null;
7884
+ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questions: initialQuestions = [], questionsStepsMap: initialQuestionsStepsMap = {}, stepFormDataMap: initialStepFormDataMap = {}, isFormDisabled = false, sessionId: propSessionId = "" }) => {
7776
7885
  const dispatch = reactRedux.useDispatch();
7777
7886
  const stepFormStreamData = reactRedux.useSelector((state) => state.smartBotReducer.stepFormStreamData);
7778
7887
  const [tabValue, setTabValue] = React.useState(currentTabValue);
@@ -7796,6 +7905,12 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
7796
7905
  const [stepFormSubmitted, setStepFormSubmitted] = React.useState(false);
7797
7906
  const [hasNewStepFormFromRestream, setHasNewStepFormFromRestream] = React.useState(false);
7798
7907
  const [activeFormIntent, setActiveFormIntent] = React.useState(null);
7908
+ // Stable unique instance ID for this TabularContent mount
7909
+ const instanceIdRef = React.useRef(null);
7910
+ if (instanceIdRef.current === null) {
7911
+ instanceCounter += 1;
7912
+ instanceIdRef.current = instanceCounter;
7913
+ }
7799
7914
  // Refs for accumulating state during streaming (avoids stale closures)
7800
7915
  const stepsRef = React.useRef(stepsState);
7801
7916
  const questionsRef = React.useRef(questionsState);
@@ -7837,10 +7952,21 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
7837
7952
  return null;
7838
7953
  }
7839
7954
  };
7955
+ // Register as active instance when this TabularContent has an active step form
7956
+ React.useEffect(() => {
7957
+ const hasActiveForm = Object.keys(initialStepFormDataMap).length > 0;
7958
+ if (hasActiveForm) {
7959
+ activeTabularInstanceId = instanceIdRef.current;
7960
+ }
7961
+ }, [initialStepFormDataMap]);
7840
7962
  // Watch Redux for batched SSE chunks dispatched by ButtonContent
7841
7963
  React.useEffect(() => {
7842
7964
  if (!stepFormStreamData)
7843
7965
  return;
7966
+ // Only the active instance should process stepFormStreamData
7967
+ if (activeTabularInstanceId !== null && activeTabularInstanceId !== instanceIdRef.current) {
7968
+ return;
7969
+ }
7844
7970
  const payload = stepFormStreamData;
7845
7971
  // Clear Redux immediately
7846
7972
  dispatch(smartBotActions.setStepFormStreamData(null));
@@ -7851,6 +7977,24 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
7851
7977
  setTabValue("steps");
7852
7978
  return;
7853
7979
  }
7980
+ // Handle real-time widget chunks dispatched immediately by ButtonContent
7981
+ if (payload.status === "widget_chunk") {
7982
+ const chunks = payload.chunks || [];
7983
+ const newWidgets = [];
7984
+ chunks.forEach((data) => {
7985
+ if (data.status === "widget") {
7986
+ const widgetItems = isArray$1(data.widget_data) ? data.widget_data : [data.widget_data];
7987
+ widgetItems.forEach((item) => {
7988
+ if (item)
7989
+ newWidgets.push(item);
7990
+ });
7991
+ }
7992
+ });
7993
+ if (newWidgets.length > 0) {
7994
+ setWidgetContent((prev) => [...prev, ...newWidgets]);
7995
+ }
7996
+ return;
7997
+ }
7854
7998
  // Process all collected chunks at once (done or error)
7855
7999
  const chunks = payload.chunks || [];
7856
8000
  let newSteps = lodash.cloneDeep(stepsRef.current);
@@ -7924,6 +8068,13 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
7924
8068
  const formWidgetData = isArray$1(data.widget_data) ? data.widget_data : [data.widget_data];
7925
8069
  const currentIntent = data.current_intent || formWidgetData?.[0]?.current_intent;
7926
8070
  if (currentIntent) {
8071
+ // Auto-create question/intent entry if no prior step chunk created it
8072
+ if (!newQuestionsStepsMap[currentIntent]) {
8073
+ newQuestionsStepsMap[currentIntent] = [];
8074
+ if (!newQuestions.includes(currentIntent)) {
8075
+ newQuestions.push(currentIntent);
8076
+ }
8077
+ }
7927
8078
  const submitButton = {
7928
8079
  type: "button",
7929
8080
  data: {
@@ -7944,13 +8095,7 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
7944
8095
  };
7945
8096
  }
7946
8097
  }
7947
- if (data.status === "widget") {
7948
- const widgetItems = isArray$1(data.widget_data) ? data.widget_data : [data.widget_data];
7949
- widgetItems.forEach((item) => {
7950
- if (item)
7951
- newWidgets.push(item);
7952
- });
7953
- }
8098
+ if (data.status === "widget") ;
7954
8099
  if (data.status === "content" && data.message) {
7955
8100
  newWidgets.push({ type: "text", response: data.message });
7956
8101
  }
@@ -7975,6 +8120,8 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
7975
8120
  setStepFormSubmitted(false);
7976
8121
  setHasNewStepFormFromRestream(true);
7977
8122
  setActiveFormIntent(latestIntent || null);
8123
+ // Re-register as active instance since this TabularContent now owns the new form
8124
+ activeTabularInstanceId = instanceIdRef.current;
7978
8125
  // Clear stale persisted form values and context so the new form starts fresh
7979
8126
  dispatch(smartBotActions.clearPersistedFormValues());
7980
8127
  dispatch(smartBotActions.setChatbotContext({}));
@@ -7999,6 +8146,10 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
7999
8146
  jsxRuntime.jsxs(AgentResponse, { children: [children, renderedWidgets.length > 0 && (jsxRuntime.jsx("div", { className: "restream-widget-content", children: renderedWidgets }))] }),
8000
8147
  ], value: tabValue }) }));
8001
8148
  };
8149
+ /** Reset the active instance tracker (call when a new conversation starts from the input field) */
8150
+ const resetActiveTabularInstance = () => {
8151
+ activeTabularInstanceId = null;
8152
+ };
8002
8153
 
8003
8154
  const CombinedContent = ({ botData, props }) => {
8004
8155
  const isFormDisabled = botData?.isFormDisabled || false;
@@ -8067,7 +8218,7 @@ const CombinedContent = ({ botData, props }) => {
8067
8218
  const validContent = renderedContent.filter(content => content !== null);
8068
8219
  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" })) }));
8069
8220
  if (isTabEnabled) {
8070
- 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, children: renderCombinedContent() }));
8221
+ 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() }));
8071
8222
  }
8072
8223
  return renderCombinedContent();
8073
8224
  };
@@ -10574,7 +10725,21 @@ const ChatbotInput = (props) => {
10574
10725
  if (newChatScreen) {
10575
10726
  clearFilterValuesCache();
10576
10727
  }
10728
+ // Auto-focus editor on mount
10729
+ setTimeout(() => {
10730
+ if (editorRef.current) {
10731
+ editorRef.current.focus();
10732
+ }
10733
+ }, 100);
10577
10734
  }, []);
10735
+ // Effect: Re-focus editor when filter set changes (e.g. chip cleared)
10736
+ React.useEffect(() => {
10737
+ setTimeout(() => {
10738
+ if (editorRef.current) {
10739
+ editorRef.current.focus();
10740
+ }
10741
+ }, 50);
10742
+ }, [selectedFilterSet]);
10578
10743
  // Effect: Cleanup tooltips on unmount
10579
10744
  React.useEffect(() => {
10580
10745
  return () => {
@@ -10784,7 +10949,8 @@ const ChatbotInput = (props) => {
10784
10949
  !target.closest("button") &&
10785
10950
  !target.closest(".chat-actions") &&
10786
10951
  !target.closest(".filter-set-trigger-wrapper") &&
10787
- !target.closest(".filter-set-chip-clear")) {
10952
+ !target.closest(".filter-set-chip-clear") &&
10953
+ !target.closest(".mention-select-wrapper")) {
10788
10954
  editorRef.current.focus();
10789
10955
  }
10790
10956
  }, children: jsxRuntime.jsxs("div", { className: `chat-input-wrapper ${isFixed ? "stacked" : ""} ${selectedFilterSet ? "has-filter-selected" : ""} ${(!isFixed || inputValue === "") && !newChatScreen && !selectedFilterSet ? "empty" : ""} ${!newChatScreen && !isFixed && !selectedFilterSet ? "single-line-textarea" : ""}`, style: { height }, children: [jsxRuntime.jsxs("div", { className: "chat-input-left-actions", children: [jsxRuntime.jsxs("div", { className: "filter-set-trigger-wrapper", ref: filterSetSelectRef, children: [jsxRuntime.jsx(impactUiV3.Tooltip, { title: hasMentionsInEditor || showMentionSelect ? "Cannot use filter set while @ mentions are active" : "Add filter set", children: jsxRuntime.jsx("button", { type: "button", className: `filter-set-plus-btn${hasMentionsInEditor || showMentionSelect ? " disabled" : ""}`, onClick: () => {
@@ -11573,10 +11739,13 @@ const useStyles = styles.makeStyles({
11573
11739
  buttonWrapper: {
11574
11740
  marginTop: "16px",
11575
11741
  },
11742
+ hidden: {
11743
+ display: "none",
11744
+ },
11576
11745
  });
11577
11746
  const ChatbotSaveFilterComponent = (props) => {
11578
11747
  const classes = useStyles();
11579
- const { savedFilterSets } = props;
11748
+ const { savedFilterSets, partialClose, chatBotWidth } = props;
11580
11749
  const [showFilter, setShowFilter] = React.useState(!lodash.isEmpty(savedFilterSets));
11581
11750
  /**
11582
11751
  * onFilterDashboardClick function is called when we click the apply filter
@@ -11610,6 +11779,12 @@ const ChatbotSaveFilterComponent = (props) => {
11610
11779
  setShowFilter(true);
11611
11780
  }
11612
11781
  }, [savedFilterSets]);
11782
+ React.useEffect(() => {
11783
+ const drawer = document.querySelector(".MuiModal-root.MuiDrawer-root");
11784
+ if (drawer) {
11785
+ drawer.style.display = partialClose ? "none" : "";
11786
+ }
11787
+ }, [partialClose]);
11613
11788
  React.useEffect(() => {
11614
11789
  if (!showFilter)
11615
11790
  return;
@@ -11643,11 +11818,13 @@ const ChatbotSaveFilterComponent = (props) => {
11643
11818
  }
11644
11819
  const filterContainer = document.querySelector(".impact_drawer_filter_container.impact_drawer_filter_container_large");
11645
11820
  if (filterContainer) {
11646
- filterContainer.style.setProperty("width", "616px");
11821
+ const computedWidth = chatBotWidth ? `${chatBotWidth - 86}px` : "616px";
11822
+ filterContainer.style.setProperty("width", computedWidth);
11647
11823
  }
11648
11824
  const rightPanel = document.querySelector(".impact_drawer_filter_container .impact_drawer_filter_container_right_panel");
11649
11825
  if (rightPanel) {
11650
11826
  rightPanel.style.setProperty("height", "600px");
11827
+ rightPanel.style.setProperty("width", "100%");
11651
11828
  }
11652
11829
  const backdrop = document.querySelector(".MuiBackdrop-root.MuiModal-backdrop");
11653
11830
  if (backdrop) {
@@ -11681,8 +11858,8 @@ const ChatbotSaveFilterComponent = (props) => {
11681
11858
  const observer = new MutationObserver(patchDrawer);
11682
11859
  observer.observe(document.body, { childList: true, subtree: true });
11683
11860
  return () => observer.disconnect();
11684
- }, [showFilter]);
11685
- return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: !showFilter ?
11861
+ }, [showFilter, chatBotWidth]);
11862
+ return (jsxRuntime.jsx("div", { className: partialClose ? classes.hidden : undefined, children: !showFilter ?
11686
11863
  jsxRuntime.jsxs("div", { className: classes.container, children: [jsxRuntime.jsx(NoFilterSetSavedIcon, { width: "189px", height: "126px", className: classes.icon }), jsxRuntime.jsx("p", { className: classes.title, children: "No filter set saved!" }), jsxRuntime.jsx("p", { className: classes.subtitle, children: "Create and save a filter set to use as your default scope or apply it anytime during a conversation" }), jsxRuntime.jsx("div", { className: classes.buttonWrapper, children: jsxRuntime.jsx(impactUiV3.Button, { variant: "primary", onClick: () => setShowFilter(true), children: "Create A Filter Set" }) })] }) :
11687
11864
  jsxRuntime.jsx("div", { children: jsxRuntime.jsx(CoreComponentScreen, { showPageHeader: false,
11688
11865
  // Filter dashboard props
@@ -11715,6 +11892,7 @@ const SmartBot = (props) => {
11715
11892
  // Per-mode conversation ID tracking — prevents cross-mode contamination when
11716
11893
  // switching tabs while streams are pending.
11717
11894
  React.useRef({});
11895
+ const activeConversationIdRef = React.useRef(activeConversationId);
11718
11896
  const activeTab = React.useRef({
11719
11897
  activeTab: "dashboard",
11720
11898
  });
@@ -11733,6 +11911,7 @@ const SmartBot = (props) => {
11733
11911
  const [filterOptions, setFilterOptions] = React.useState([]);
11734
11912
  const [savedFilterSets, setSavedFilterSets] = React.useState([]);
11735
11913
  const [selectedFilterSet, setSelectedFilterSet] = React.useState(null);
11914
+ const [chatBotWidth, setChatBotWidth] = React.useState(null);
11736
11915
  React.useRef(0);
11737
11916
  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);
11738
11917
  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);
@@ -11765,6 +11944,10 @@ const SmartBot = (props) => {
11765
11944
  setFieldNumber,
11766
11945
  setAdditionalArgs,
11767
11946
  });
11947
+ // Keep activeConversationIdRef in sync so event handlers with [] deps can access the latest value
11948
+ React.useEffect(() => {
11949
+ activeConversationIdRef.current = activeConversationId;
11950
+ }, [activeConversationId]);
11768
11951
  // Show/hide stop icon when step-form restream (second init API from ButtonContent) starts/ends.
11769
11952
  // Must live here (SmartBot) because StreamedContent unmounts after the first stream completes.
11770
11953
  React.useEffect(() => {
@@ -11786,6 +11969,23 @@ const SmartBot = (props) => {
11786
11969
  };
11787
11970
  const handleStepFormStreamEnd = () => {
11788
11971
  setIsStop(false);
11972
+ // Update the timestamp on the last bot message to reflect when the restream completed
11973
+ try {
11974
+ const mode = localStorage.getItem("currentModeData") || "agent";
11975
+ const convId = activeConversationIdRef.current;
11976
+ const messages = chatDataInfoRef?.current?.[mode]?.conversations?.[convId]?.messages;
11977
+ if (messages && messages.length > 0) {
11978
+ const lastBotIdx = messages.reduce((lastIdx, msg, idx) => msg.userType === "bot" ? idx : lastIdx, -1);
11979
+ if (lastBotIdx !== -1) {
11980
+ messages[lastBotIdx].timeStamp = moment().format(dateFormat);
11981
+ // Trigger re-render so the UI reflects the updated timestamp
11982
+ setChatDataState((prev) => ({ ...prev }));
11983
+ }
11984
+ }
11985
+ }
11986
+ catch (e) {
11987
+ console.error("Error updating timestamp after step form stream:", e);
11988
+ }
11789
11989
  };
11790
11990
  window.addEventListener("stepFormStreamStart", handleStepFormStreamStart);
11791
11991
  window.addEventListener("stepFormStreamEnd", handleStepFormStreamEnd);
@@ -12091,7 +12291,6 @@ const SmartBot = (props) => {
12091
12291
  newMessage.utilityObject = originalUtilityObject;
12092
12292
  }
12093
12293
  message.jsx = (jsxRuntime.jsx(BotMessage, { botData: newMessage, state: loadingState, handleLikeDislike: handleLikeDislike, props: properties }));
12094
- message.firstMessage = true;
12095
12294
  let actualProps = {
12096
12295
  botData: newMessage,
12097
12296
  state: loadingState,
@@ -12099,6 +12298,7 @@ const SmartBot = (props) => {
12099
12298
  props: properties,
12100
12299
  };
12101
12300
  message.actualProps = actualProps;
12301
+ message.firstMessage = true;
12102
12302
  // message.enableLikes = true;
12103
12303
  }
12104
12304
  });
@@ -12222,6 +12422,9 @@ const SmartBot = (props) => {
12222
12422
  };
12223
12423
  const onSendIconClick = (params, params2) => {
12224
12424
  try {
12425
+ // Reset step form stream state so old TabularContent instances don't process new data
12426
+ dispatch(smartBotActions.setStepFormStreamData(null));
12427
+ resetActiveTabularInstance();
12225
12428
  // dispatch(setChatbotContext({}));
12226
12429
  setUserInput(params?.text);
12227
12430
  handleSendMessage(params?.text, params?.userExplicitInput, params?.textWithColumnNames);
@@ -12388,6 +12591,8 @@ const SmartBot = (props) => {
12388
12591
  localStorage.setItem("isStreaming", "false");
12389
12592
  dispatch(smartBotActions.setChatbotContext({}));
12390
12593
  dispatch(smartBotActions.clearPersistedFormValues());
12594
+ dispatch(smartBotActions.setStepFormStreamData(null));
12595
+ resetActiveTabularInstance();
12391
12596
  setConversation([]);
12392
12597
  chatDataInfoRef.current[currentMode] = {
12393
12598
  conversations: {},
@@ -12537,18 +12742,50 @@ const SmartBot = (props) => {
12537
12742
  // isActive: activeTab.current.activeTab === "agent",
12538
12743
  // initialClick: true,
12539
12744
  onClick: (params) => {
12745
+ // if (localStorage.getItem("isStreaming") === "true") {
12746
+ // displaySnackMessages(
12747
+ // "Please wait till the current request is completed",
12748
+ // "warning"
12749
+ // );
12750
+ // return;
12751
+ // } else {
12752
+ // const agentConversations = chatDataInfoRef?.current[params?.name?.toLowerCase()]?.conversations;
12753
+ // const firstConversationId = agentConversations ? Object.keys(agentConversations)[0] : undefined;
12540
12754
  if (params?.name?.toLowerCase() === "saved filters") {
12541
12755
  setNewChatScreen(false);
12542
12756
  setShowChatPlaceholder(false);
12543
12757
  setShowSavedFilters(true);
12758
+ // if (
12759
+ // !isEmpty(
12760
+ // agentConversations?.[firstConversationId]?.messages
12761
+ // )
12762
+ // ) {
12763
+ // setShowChatPlaceholder(false);
12764
+ // } else {
12765
+ // setShowChatPlaceholder(true);
12766
+ // }
12544
12767
  }
12768
+ // setCurrentMode(params?.name?.toLowerCase());
12769
+ // if (firstConversationId) {
12770
+ // setActiveConversationId(firstConversationId);
12771
+ // }
12772
+ // localStorage.setItem(
12773
+ // "currentModeData",
12774
+ // params?.name?.toLowerCase()
12775
+ // );
12776
+ // setNewChatScreen(false);
12777
+ // activeTab.current.activeTab = "agent";
12778
+ // setIsStop(false);
12779
+ // }
12780
+ // setConversation([]);
12781
+ // chatDataInfoRef.current[currentMode] = [];
12545
12782
  },
12546
12783
  icon: jsxRuntime.jsx(SvgSaveFilterTab, {}),
12547
12784
  },
12548
12785
  ], utilityList: utilityList, isAssistantThinking: false, isCustomScreen: showChatPlaceholder ? showChatPlaceholder : showSavedFilters, customScreenJsx: showChatPlaceholder ?
12549
12786
  jsxRuntime.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 })
12550
12787
  :
12551
- jsxRuntime.jsx(ChatbotSaveFilterComponent$1, { savedFilterSets: savedFilterSets }), inputText: userInput, threadList: ["Home"], hideMenuArrow: hideMenu, newChatScreen: newChatScreen, isModuleListLoading: modulesLoading, suggestionBanner: {
12788
+ jsxRuntime.jsx(ChatbotSaveFilterComponent$1, { savedFilterSets: savedFilterSets, partialClose: partialClose, chatBotWidth: chatBotWidth }), inputText: userInput, threadList: ["Home"], hideMenuArrow: hideMenu, newChatScreen: newChatScreen, isModuleListLoading: modulesLoading, suggestionBanner: {
12552
12789
  freeTextHeading: "Try adding more details :",
12553
12790
  freeTextContent: "Alan works better when you provide more context and pointed questions",
12554
12791
  }, isStopIcon: isStop, onStopIconClick: onStopIconClick, footerText: "AI-generated responses may contain errors\u2014please verify important information", showSuggestionBanner: showSavedFilters ? false : showSuggestionBanner, onCloseSuggestionBanner: () => {
@@ -12568,7 +12805,9 @@ const SmartBot = (props) => {
12568
12805
  }, handleSaveChat: () => {
12569
12806
  // Handle save chat logic here
12570
12807
  saveCurrentChat();
12571
- } })] }));
12808
+ }, onChatBotResize: (params) => {
12809
+ setChatBotWidth(params);
12810
+ }, onMinimiseChatBot: null })] }));
12572
12811
  };
12573
12812
 
12574
12813
  exports.default = SmartBot;