impact-chatbot 2.3.35 → 2.3.36

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
@@ -5369,10 +5369,14 @@ const ButtonContent = ({ bodyText, isFormDisabled = false, isStepFormSubmit = fa
5369
5369
  console.log("[ButtonContent] SSE chunk:", data);
5370
5370
  if (data?.status === "step" || data?.status === "step_form" || data?.status === "questions" || data?.status === "thinking" || data?.status === "widget") {
5371
5371
  chunksRef.push(data);
5372
+ // If this chunk also carries [DONE], dispatch collected chunks now
5373
+ if (data?.message === "[DONE]") {
5374
+ dispatch(smartBotActions.setStepFormStreamData({ status: "done", chunks: [...chunksRef] }));
5375
+ }
5372
5376
  }
5373
5377
  else if (data?.status === "completed" || data?.message === "[DONE]") {
5374
5378
  // Stream ended — dispatch all collected chunks at once
5375
- dispatch(smartBotActions.setStepFormStreamData({ status: "done", chunks: chunksRef }));
5379
+ dispatch(smartBotActions.setStepFormStreamData({ status: "done", chunks: [...chunksRef] }));
5376
5380
  }
5377
5381
  else if (data?.message) {
5378
5382
  chunksRef.push({ status: "content", message: data.message });
@@ -6007,6 +6011,12 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false })
6007
6011
  setIsFormSubmitted(true);
6008
6012
  }
6009
6013
  }, [stepFormStreamData]);
6014
+ // Reset isFormSubmitted when parent signals the form should be enabled (new step_form from restream)
6015
+ React.useEffect(() => {
6016
+ if (!isFormDisabled) {
6017
+ setIsFormSubmitted(false);
6018
+ }
6019
+ }, [isFormDisabled]);
6010
6020
  const [isFilterSetOpen, setIsFilterSetOpen] = React.useState(false);
6011
6021
  const [selectedFilterSet, setSelectedFilterSet] = React.useState(() => {
6012
6022
  // Restore from chatbotContext if available (persists across tab switches)
@@ -7594,6 +7604,7 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
7594
7604
  const [widgetContent, setWidgetContent] = React.useState([]);
7595
7605
  const [isRestreaming, setIsRestreaming] = React.useState(false);
7596
7606
  const [stepFormSubmitted, setStepFormSubmitted] = React.useState(false);
7607
+ const [hasNewStepFormFromRestream, setHasNewStepFormFromRestream] = React.useState(false);
7597
7608
  // Refs for accumulating state during streaming (avoids stale closures)
7598
7609
  const stepsRef = React.useRef(stepsState);
7599
7610
  const questionsRef = React.useRef(questionsState);
@@ -7635,6 +7646,7 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
7635
7646
  if (payload.status === "streaming_start") {
7636
7647
  setIsRestreaming(true);
7637
7648
  setStepFormSubmitted(true);
7649
+ setHasNewStepFormFromRestream(false);
7638
7650
  setTabValue("steps");
7639
7651
  return;
7640
7652
  }
@@ -7749,6 +7761,12 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
7749
7761
  if (newWidgets.length > 0) {
7750
7762
  setWidgetContent((prev) => [...prev, ...newWidgets]);
7751
7763
  }
7764
+ // If the response contains a new step_form, reset stepFormSubmitted and mark new form as active
7765
+ const hasNewStepForm = chunks.some((c) => c.status === "step_form");
7766
+ if (hasNewStepForm) {
7767
+ setStepFormSubmitted(false);
7768
+ setHasNewStepFormFromRestream(true);
7769
+ }
7752
7770
  setIsRestreaming(false);
7753
7771
  }, [stepFormStreamData]);
7754
7772
  // Render widget content from restream responses
@@ -7765,7 +7783,7 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
7765
7783
  icon: jsxRuntime.jsx(PsychologyOutlinedIcon, { fontSize: "large" }),
7766
7784
  },
7767
7785
  ], tabPanels: [
7768
- jsxRuntime.jsx(Steps, { steps: stepsState, questions: questionsState, questionsStepsMap: questionsStepsMapState, stepFormDataMap: stepFormDataMapState, isFormDisabled: (isFormDisabled && !isRestreaming) || stepFormSubmitted, isRestreaming: isRestreaming }),
7786
+ jsxRuntime.jsx(Steps, { steps: stepsState, questions: questionsState, questionsStepsMap: questionsStepsMapState, stepFormDataMap: stepFormDataMapState, isFormDisabled: hasNewStepFormFromRestream ? false : ((isFormDisabled && !isRestreaming) || stepFormSubmitted), isRestreaming: isRestreaming }),
7769
7787
  jsxRuntime.jsxs(AgentResponse, { children: [children, renderedWidgets.length > 0 && (jsxRuntime.jsx("div", { className: "restream-widget-content", children: renderedWidgets }))] }),
7770
7788
  ], value: tabValue }) }));
7771
7789
  };