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 +20 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +20 -2
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -5347,10 +5347,14 @@ const ButtonContent = ({ bodyText, isFormDisabled = false, isStepFormSubmit = fa
|
|
|
5347
5347
|
console.log("[ButtonContent] SSE chunk:", data);
|
|
5348
5348
|
if (data?.status === "step" || data?.status === "step_form" || data?.status === "questions" || data?.status === "thinking" || data?.status === "widget") {
|
|
5349
5349
|
chunksRef.push(data);
|
|
5350
|
+
// If this chunk also carries [DONE], dispatch collected chunks now
|
|
5351
|
+
if (data?.message === "[DONE]") {
|
|
5352
|
+
dispatch(setStepFormStreamData({ status: "done", chunks: [...chunksRef] }));
|
|
5353
|
+
}
|
|
5350
5354
|
}
|
|
5351
5355
|
else if (data?.status === "completed" || data?.message === "[DONE]") {
|
|
5352
5356
|
// Stream ended — dispatch all collected chunks at once
|
|
5353
|
-
dispatch(setStepFormStreamData({ status: "done", chunks: chunksRef }));
|
|
5357
|
+
dispatch(setStepFormStreamData({ status: "done", chunks: [...chunksRef] }));
|
|
5354
5358
|
}
|
|
5355
5359
|
else if (data?.message) {
|
|
5356
5360
|
chunksRef.push({ status: "content", message: data.message });
|
|
@@ -5985,6 +5989,12 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false })
|
|
|
5985
5989
|
setIsFormSubmitted(true);
|
|
5986
5990
|
}
|
|
5987
5991
|
}, [stepFormStreamData]);
|
|
5992
|
+
// Reset isFormSubmitted when parent signals the form should be enabled (new step_form from restream)
|
|
5993
|
+
useEffect(() => {
|
|
5994
|
+
if (!isFormDisabled) {
|
|
5995
|
+
setIsFormSubmitted(false);
|
|
5996
|
+
}
|
|
5997
|
+
}, [isFormDisabled]);
|
|
5988
5998
|
const [isFilterSetOpen, setIsFilterSetOpen] = useState(false);
|
|
5989
5999
|
const [selectedFilterSet, setSelectedFilterSet] = useState(() => {
|
|
5990
6000
|
// Restore from chatbotContext if available (persists across tab switches)
|
|
@@ -7572,6 +7582,7 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
|
|
|
7572
7582
|
const [widgetContent, setWidgetContent] = useState([]);
|
|
7573
7583
|
const [isRestreaming, setIsRestreaming] = useState(false);
|
|
7574
7584
|
const [stepFormSubmitted, setStepFormSubmitted] = useState(false);
|
|
7585
|
+
const [hasNewStepFormFromRestream, setHasNewStepFormFromRestream] = useState(false);
|
|
7575
7586
|
// Refs for accumulating state during streaming (avoids stale closures)
|
|
7576
7587
|
const stepsRef = useRef(stepsState);
|
|
7577
7588
|
const questionsRef = useRef(questionsState);
|
|
@@ -7613,6 +7624,7 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
|
|
|
7613
7624
|
if (payload.status === "streaming_start") {
|
|
7614
7625
|
setIsRestreaming(true);
|
|
7615
7626
|
setStepFormSubmitted(true);
|
|
7627
|
+
setHasNewStepFormFromRestream(false);
|
|
7616
7628
|
setTabValue("steps");
|
|
7617
7629
|
return;
|
|
7618
7630
|
}
|
|
@@ -7727,6 +7739,12 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
|
|
|
7727
7739
|
if (newWidgets.length > 0) {
|
|
7728
7740
|
setWidgetContent((prev) => [...prev, ...newWidgets]);
|
|
7729
7741
|
}
|
|
7742
|
+
// If the response contains a new step_form, reset stepFormSubmitted and mark new form as active
|
|
7743
|
+
const hasNewStepForm = chunks.some((c) => c.status === "step_form");
|
|
7744
|
+
if (hasNewStepForm) {
|
|
7745
|
+
setStepFormSubmitted(false);
|
|
7746
|
+
setHasNewStepFormFromRestream(true);
|
|
7747
|
+
}
|
|
7730
7748
|
setIsRestreaming(false);
|
|
7731
7749
|
}, [stepFormStreamData]);
|
|
7732
7750
|
// Render widget content from restream responses
|
|
@@ -7743,7 +7761,7 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
|
|
|
7743
7761
|
icon: jsx(PsychologyOutlinedIcon, { fontSize: "large" }),
|
|
7744
7762
|
},
|
|
7745
7763
|
], tabPanels: [
|
|
7746
|
-
jsx(Steps, { steps: stepsState, questions: questionsState, questionsStepsMap: questionsStepsMapState, stepFormDataMap: stepFormDataMapState, isFormDisabled: (isFormDisabled && !isRestreaming) || stepFormSubmitted, isRestreaming: isRestreaming }),
|
|
7764
|
+
jsx(Steps, { steps: stepsState, questions: questionsState, questionsStepsMap: questionsStepsMapState, stepFormDataMap: stepFormDataMapState, isFormDisabled: hasNewStepFormFromRestream ? false : ((isFormDisabled && !isRestreaming) || stepFormSubmitted), isRestreaming: isRestreaming }),
|
|
7747
7765
|
jsxs(AgentResponse, { children: [children, renderedWidgets.length > 0 && (jsx("div", { className: "restream-widget-content", children: renderedWidgets }))] }),
|
|
7748
7766
|
], value: tabValue }) }));
|
|
7749
7767
|
};
|