impact-chatbot 2.3.33 → 2.3.34
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.
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
declare const ButtonContent: ({ bodyText, isFormDisabled, isStepFormSubmit }: {
|
|
1
|
+
declare const ButtonContent: ({ bodyText, isFormDisabled, isStepFormSubmit, isFormValid }: {
|
|
2
2
|
bodyText: any;
|
|
3
3
|
isFormDisabled?: boolean;
|
|
4
4
|
isStepFormSubmit?: boolean;
|
|
5
|
+
isFormValid?: boolean;
|
|
5
6
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
6
7
|
export default ButtonContent;
|
package/dist/index.cjs.js
CHANGED
|
@@ -5098,7 +5098,8 @@ const sseevent = (message, messageToStoreRef) => {
|
|
|
5098
5098
|
parsedData?.response_heading || "";
|
|
5099
5099
|
}
|
|
5100
5100
|
else if (parsedData?.message === "[DONE]" &&
|
|
5101
|
-
!lodash.isEmpty(parsedData?.widget_data)
|
|
5101
|
+
!lodash.isEmpty(parsedData?.widget_data) &&
|
|
5102
|
+
parsedData?.status !== "step_form") {
|
|
5102
5103
|
// Accumulate widget_data chunks like host app
|
|
5103
5104
|
let finalWidgetData = lodash.isArray(parsedData.widget_data)
|
|
5104
5105
|
? parsedData.widget_data
|
|
@@ -5146,15 +5147,6 @@ const sseevent = (message, messageToStoreRef) => {
|
|
|
5146
5147
|
if (currentIntent) {
|
|
5147
5148
|
messageToStoreRef.current.stepFormData[currentIntent] = formWidgetData;
|
|
5148
5149
|
}
|
|
5149
|
-
let previousWidgetData = lodash.isArray(messageToStoreRef.current.appendedData)
|
|
5150
|
-
? messageToStoreRef.current.appendedData
|
|
5151
|
-
: lodash.isEmpty(messageToStoreRef.current.appendedData)
|
|
5152
|
-
? []
|
|
5153
|
-
: [messageToStoreRef.current.appendedData];
|
|
5154
|
-
messageToStoreRef.current.appendedData = [
|
|
5155
|
-
...previousWidgetData,
|
|
5156
|
-
...formWidgetData,
|
|
5157
|
-
];
|
|
5158
5150
|
messageToStoreRef.current.additionalArgs = parsedData?.additional_args
|
|
5159
5151
|
? parsedData.additional_args
|
|
5160
5152
|
: {};
|
|
@@ -5293,7 +5285,7 @@ const useStyles$4 = styles.makeStyles((theme) => ({
|
|
|
5293
5285
|
marginTop: pxToRem(16),
|
|
5294
5286
|
}
|
|
5295
5287
|
}));
|
|
5296
|
-
const ButtonContent = ({ bodyText, isFormDisabled = false, isStepFormSubmit = false }) => {
|
|
5288
|
+
const ButtonContent = ({ bodyText, isFormDisabled = false, isStepFormSubmit = false, isFormValid = true }) => {
|
|
5297
5289
|
const classes = useStyles$4();
|
|
5298
5290
|
const dispatch = reactRedux.useDispatch();
|
|
5299
5291
|
const sourceRef = React.useRef(null);
|
|
@@ -5399,7 +5391,7 @@ const ButtonContent = ({ bodyText, isFormDisabled = false, isStepFormSubmit = fa
|
|
|
5399
5391
|
if (!Array.isArray(bodyText.buttons)) {
|
|
5400
5392
|
return null;
|
|
5401
5393
|
}
|
|
5402
|
-
return bodyText.buttons.map((button, index) => (jsxRuntime.jsx("div", { children: jsxRuntime.jsx(impactUiV3.Button, { variant: button.variant || "primary", size: button.size || "medium", onClick: () => handleButtonClick(), disabled: button.disabled || isFormDisabled, className: button.className, icon: button.icon, iconPlacement: button.iconPlacement || "left", children: button.label }) }, index)));
|
|
5394
|
+
return bodyText.buttons.map((button, index) => (jsxRuntime.jsx("div", { children: jsxRuntime.jsx(impactUiV3.Button, { variant: button.variant || "primary", size: button.size || "medium", onClick: () => handleButtonClick(), disabled: button.disabled || isFormDisabled || (isStepFormSubmit && !isFormValid), className: button.className, icon: button.icon, iconPlacement: button.iconPlacement || "left", children: button.label }) }, index)));
|
|
5403
5395
|
};
|
|
5404
5396
|
return (jsxRuntime.jsxs("div", { className: classes.buttonContainer, children: [bodyText.message && (jsxRuntime.jsx("div", { className: classes.message, children: bodyText.message })), jsxRuntime.jsx("div", { className: classes.buttonRow, children: renderButtons() })] }));
|
|
5405
5397
|
};
|
|
@@ -5780,6 +5772,12 @@ const SelectContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
|
|
|
5780
5772
|
console.error("Error in select handleChange", error);
|
|
5781
5773
|
}
|
|
5782
5774
|
};
|
|
5775
|
+
React.useEffect(() => {
|
|
5776
|
+
const persisted = persistedFormValues?.[formKey];
|
|
5777
|
+
if (!persisted || (Array.isArray(persisted) && persisted.length === 0)) {
|
|
5778
|
+
setCurrentSelectedOptions([]);
|
|
5779
|
+
}
|
|
5780
|
+
}, [persistedFormValues, formKey]);
|
|
5783
5781
|
React.useEffect(() => {
|
|
5784
5782
|
let formattedOptions = options.map((option) => {
|
|
5785
5783
|
return {
|
|
@@ -6002,6 +6000,13 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false })
|
|
|
6002
6000
|
const savedFilterSets = reactRedux.useSelector((state) => state.smartBotReducer.savedFilterSets);
|
|
6003
6001
|
const persistedFormValues = reactRedux.useSelector((state) => state.smartBotReducer.persistedFormValues);
|
|
6004
6002
|
const chatbotContext = reactRedux.useSelector((state) => state.smartBotReducer.chatbotContext);
|
|
6003
|
+
const stepFormStreamData = reactRedux.useSelector((state) => state.smartBotReducer.stepFormStreamData);
|
|
6004
|
+
const [isFormSubmitted, setIsFormSubmitted] = React.useState(false);
|
|
6005
|
+
React.useEffect(() => {
|
|
6006
|
+
if (stepFormStreamData?.status === "streaming_start") {
|
|
6007
|
+
setIsFormSubmitted(true);
|
|
6008
|
+
}
|
|
6009
|
+
}, [stepFormStreamData]);
|
|
6005
6010
|
const [isFilterSetOpen, setIsFilterSetOpen] = React.useState(false);
|
|
6006
6011
|
const [selectedFilterSet, setSelectedFilterSet] = React.useState(() => {
|
|
6007
6012
|
// Restore from chatbotContext if available (persists across tab switches)
|
|
@@ -6022,6 +6027,7 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false })
|
|
|
6022
6027
|
const selectedValue = Array.isArray(selected) ? selected[0]?.value : selected?.value;
|
|
6023
6028
|
if (!selectedValue) {
|
|
6024
6029
|
dispatch(smartBotActions.setChatbotContext({}));
|
|
6030
|
+
dispatch(smartBotActions.clearPersistedFormValues());
|
|
6025
6031
|
return;
|
|
6026
6032
|
}
|
|
6027
6033
|
const fullFilterObj = (savedFilterSets || []).find((f) => (f.fuc_code || f.name || f.label) === selectedValue);
|
|
@@ -6069,8 +6075,32 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false })
|
|
|
6069
6075
|
return val && (Array.isArray(val) ? val.length > 0 : !!val);
|
|
6070
6076
|
});
|
|
6071
6077
|
}, [persistedFormValues, messageIndex]);
|
|
6072
|
-
const formFieldsDisabled = isFormDisabled || isFilterSelected;
|
|
6073
|
-
const savedFilterDisabled = isFormDisabled || isFormFieldUsed;
|
|
6078
|
+
const formFieldsDisabled = isFormDisabled || isFilterSelected || isFormSubmitted;
|
|
6079
|
+
const savedFilterDisabled = isFormDisabled || isFormFieldUsed || isFormSubmitted;
|
|
6080
|
+
const requiredFieldsFilled = React.useMemo(() => {
|
|
6081
|
+
if (!formData || !Array.isArray(formData))
|
|
6082
|
+
return false;
|
|
6083
|
+
const requiredParams = formData
|
|
6084
|
+
.filter((item) => item?.data?.isRequired)
|
|
6085
|
+
.map((item) => item.data.param_name);
|
|
6086
|
+
if (requiredParams.length === 0)
|
|
6087
|
+
return true;
|
|
6088
|
+
return requiredParams.every((param) => {
|
|
6089
|
+
// Check chatbotContext (populated by saved filters)
|
|
6090
|
+
const ctx = chatbotContext?.[param];
|
|
6091
|
+
if (ctx && ctx.updated) {
|
|
6092
|
+
const val = ctx[param];
|
|
6093
|
+
if (val && (Array.isArray(val) ? val.length > 0 : !!val))
|
|
6094
|
+
return true;
|
|
6095
|
+
}
|
|
6096
|
+
// Check persistedFormValues (populated by manual form field selection)
|
|
6097
|
+
const persistedKey = `${messageIndex}_${param}`;
|
|
6098
|
+
const persistedVal = persistedFormValues?.[persistedKey];
|
|
6099
|
+
if (persistedVal && (Array.isArray(persistedVal) ? persistedVal.length > 0 : !!persistedVal))
|
|
6100
|
+
return true;
|
|
6101
|
+
return false;
|
|
6102
|
+
});
|
|
6103
|
+
}, [formData, chatbotContext, persistedFormValues, messageIndex]);
|
|
6074
6104
|
if (!formData || !Array.isArray(formData) || formData.length === 0) {
|
|
6075
6105
|
return null;
|
|
6076
6106
|
}
|
|
@@ -6098,7 +6128,7 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false })
|
|
|
6098
6128
|
case "radio":
|
|
6099
6129
|
return jsxRuntime.jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: formFieldsDisabled, messageIndex: messageIndex }, key);
|
|
6100
6130
|
case "button":
|
|
6101
|
-
return jsxRuntime.jsx(ButtonContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled, isStepFormSubmit: true }, key);
|
|
6131
|
+
return jsxRuntime.jsx(ButtonContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled || isFormSubmitted, isStepFormSubmit: true, isFormValid: requiredFieldsFilled }, key);
|
|
6102
6132
|
case "input":
|
|
6103
6133
|
return jsxRuntime.jsx(InputContent, { bodyText: parsedData.bodyText, isFormDisabled: formFieldsDisabled, messageIndex: messageIndex }, key);
|
|
6104
6134
|
case "image":
|
|
@@ -6159,12 +6189,10 @@ const useStyles$2 = makeStyles((theme) => ({
|
|
|
6159
6189
|
"@keyframes slideDown": {
|
|
6160
6190
|
"0%": {
|
|
6161
6191
|
opacity: 0,
|
|
6162
|
-
maxHeight: 0,
|
|
6163
6192
|
transform: "translateY(-12px)",
|
|
6164
6193
|
},
|
|
6165
6194
|
"100%": {
|
|
6166
6195
|
opacity: 1,
|
|
6167
|
-
maxHeight: "2000px",
|
|
6168
6196
|
transform: "translateY(0)",
|
|
6169
6197
|
},
|
|
6170
6198
|
},
|
|
@@ -6277,8 +6305,13 @@ const useStyles$2 = makeStyles((theme) => ({
|
|
|
6277
6305
|
padding: `${pxToRem(8)} ${pxToRem(14)}`,
|
|
6278
6306
|
background: colours.greys100,
|
|
6279
6307
|
borderRadius: pxToRem(8),
|
|
6280
|
-
|
|
6281
|
-
|
|
6308
|
+
transition: "opacity 0.3s ease",
|
|
6309
|
+
overflow: "auto",
|
|
6310
|
+
maxHeight: pxToRem(300),
|
|
6311
|
+
scrollbarWidth: "none",
|
|
6312
|
+
"&::-webkit-scrollbar": {
|
|
6313
|
+
display: "none",
|
|
6314
|
+
},
|
|
6282
6315
|
},
|
|
6283
6316
|
reasoningLabel: {
|
|
6284
6317
|
display: "flex",
|
|
@@ -6331,8 +6364,10 @@ const useStyles$2 = makeStyles((theme) => ({
|
|
|
6331
6364
|
* - "not-started": no steps or all pending
|
|
6332
6365
|
*/
|
|
6333
6366
|
const getQuestionStatus$1 = (questionSteps) => {
|
|
6334
|
-
if (!questionSteps
|
|
6367
|
+
if (!questionSteps)
|
|
6335
6368
|
return "not-started";
|
|
6369
|
+
if (questionSteps.length === 0)
|
|
6370
|
+
return "completed";
|
|
6336
6371
|
const hasError = questionSteps.some((s) => s.step_status === "error");
|
|
6337
6372
|
if (hasError)
|
|
6338
6373
|
return "error";
|
|
@@ -6373,8 +6408,11 @@ const ProgressBarItem$1 = ({ question, questionSteps, isLast, classes, formData,
|
|
|
6373
6408
|
if (status === "in-progress" || status === "error" || formData) {
|
|
6374
6409
|
setIsExpanded(true);
|
|
6375
6410
|
}
|
|
6411
|
+
else if (status === "completed" && !formData) {
|
|
6412
|
+
setIsExpanded(false);
|
|
6413
|
+
}
|
|
6376
6414
|
}, [status, formData]);
|
|
6377
|
-
return (jsxRuntime.jsxs("div", { className: classes.progressItem, children: [jsxRuntime.jsxs("div", { className: classes.progressTrack, children: [jsxRuntime.jsx("div", { className: `${classes.progressDot} ${dotClass}` }), !isLast && jsxRuntime.jsx("div", { className: `${classes.progressLine} ${lineClass}` })] }), jsxRuntime.jsxs("div", { className: classes.progressContent, children: [jsxRuntime.jsxs("div", { className: classes.progressHeader, onClick: handleToggle, children: [jsxRuntime.jsx("span", { className: `${classes.progressHeaderText} ${textClass}`, children: question }), hasSubItems && (jsxRuntime.jsx(ChevronRightIcon$1, { className: `${classes.progressChevron} ${textClass} ${isExpanded ? "expanded" : ""}` }))] }), hasSubItems && isExpanded && status === "in-progress" && (jsxRuntime.jsxs("div", { className: classes.reasoningLabel, children: [jsxRuntime.jsx(SvgReasoningIcon, {}), "Reasoning..."] })), hasSubItems && isExpanded && (jsxRuntime.jsx("div", { className: classes.progressSubItems, style: {
|
|
6415
|
+
return (jsxRuntime.jsxs("div", { className: classes.progressItem, children: [jsxRuntime.jsxs("div", { className: classes.progressTrack, children: [jsxRuntime.jsx("div", { className: `${classes.progressDot} ${dotClass}` }), !isLast && jsxRuntime.jsx("div", { className: `${classes.progressLine} ${lineClass}` })] }), jsxRuntime.jsxs("div", { className: classes.progressContent, children: [jsxRuntime.jsxs("div", { className: classes.progressHeader, onClick: handleToggle, children: [jsxRuntime.jsx("span", { className: `${classes.progressHeaderText} ${textClass}`, children: question }), hasSubItems && (jsxRuntime.jsx(ChevronRightIcon$1, { className: `${classes.progressChevron} ${textClass} ${isExpanded ? "expanded" : ""}` }))] }), hasSubItems && isExpanded && status === "in-progress" && (jsxRuntime.jsxs("div", { className: classes.reasoningLabel, children: [jsxRuntime.jsx(SvgReasoningIcon, {}), "Reasoning..."] })), hasSubItems && isExpanded && (jsxRuntime.jsx("div", { className: classes.progressSubItems, style: { opacity: isExpanded ? 1 : 0 }, children: questionSteps.map((step, idx) => (jsxRuntime.jsxs("div", { className: classes.progressSubItem, children: [step.header, step.sub_header ? ` - ${step.sub_header}` : ""] }, idx))) })), formData && isExpanded && (jsxRuntime.jsx("div", { className: classes.stepFormContainer, children: jsxRuntime.jsx(StepFormContent, { formData: formData, isFormDisabled: isFormDisabled }) }))] })] }));
|
|
6378
6416
|
};
|
|
6379
6417
|
const Steps$1 = ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, setFinalStepDone, stepChange, currentMode, questions = [], questionsStepsMap = {}, stepFormDataMap = {}, isFormDisabled = false, }) => {
|
|
6380
6418
|
const classes = useStyles$2();
|
|
@@ -6617,7 +6655,7 @@ const StreamedContent = ({ botData }) => {
|
|
|
6617
6655
|
// }
|
|
6618
6656
|
let endPoint = botData?.utilityObject?.endpoint
|
|
6619
6657
|
? `${api.BASE_API}${botData?.utilityObject?.endpoint}`
|
|
6620
|
-
: `${api.BASE_API}/core/chatbot/navigation-
|
|
6658
|
+
: `${api.BASE_API}/core/chatbot/navigation-v3`;
|
|
6621
6659
|
let method = botData?.utilityObject?.method
|
|
6622
6660
|
? botData?.utilityObject?.method
|
|
6623
6661
|
: "PUT";
|
|
@@ -6745,17 +6783,48 @@ const StreamedContent = ({ botData }) => {
|
|
|
6745
6783
|
}
|
|
6746
6784
|
stepRef.current = newSteps;
|
|
6747
6785
|
setSteps(newSteps);
|
|
6748
|
-
if (currentIntent
|
|
6786
|
+
if (currentIntent) {
|
|
6787
|
+
// Auto-create entry if no questions chunk was received
|
|
6788
|
+
if (!questionsStepsMapRef.current[currentIntent]) {
|
|
6789
|
+
questionsStepsMapRef.current[currentIntent] = [
|
|
6790
|
+
{
|
|
6791
|
+
header: "Processing Request",
|
|
6792
|
+
sub_header: "Analyzing the current request",
|
|
6793
|
+
step_status: "not-completed",
|
|
6794
|
+
},
|
|
6795
|
+
];
|
|
6796
|
+
// Add intent to questions list if not already present
|
|
6797
|
+
if (!questionsRef.current.includes(currentIntent)) {
|
|
6798
|
+
questionsRef.current = [...questionsRef.current, currentIntent];
|
|
6799
|
+
setQuestions([...questionsRef.current]);
|
|
6800
|
+
}
|
|
6801
|
+
}
|
|
6749
6802
|
let intentSteps = lodash.cloneDeep(questionsStepsMapRef.current[currentIntent]);
|
|
6750
|
-
if (
|
|
6751
|
-
|
|
6803
|
+
if (newStep.header) {
|
|
6804
|
+
// Only add/update sub-steps that have a non-empty header
|
|
6805
|
+
const existingIdx = intentSteps.findIndex((s) => s.header === newStep.header);
|
|
6806
|
+
if (existingIdx !== -1) {
|
|
6807
|
+
intentSteps[existingIdx] = newStep;
|
|
6808
|
+
}
|
|
6809
|
+
else {
|
|
6810
|
+
intentSteps.push(newStep);
|
|
6811
|
+
}
|
|
6752
6812
|
}
|
|
6753
|
-
|
|
6754
|
-
|
|
6755
|
-
|
|
6813
|
+
else if (newStep.step_status === "completed") {
|
|
6814
|
+
// Empty header + completed: remove the placeholder so no bullet shows
|
|
6815
|
+
const placeholderIdx = intentSteps.findIndex((s) => s.header === "Processing Request");
|
|
6816
|
+
if (placeholderIdx !== -1 && intentSteps.length === 1) {
|
|
6817
|
+
intentSteps.splice(placeholderIdx, 1);
|
|
6818
|
+
}
|
|
6819
|
+
else if (placeholderIdx !== -1) {
|
|
6820
|
+
intentSteps[placeholderIdx].step_status = "completed";
|
|
6821
|
+
}
|
|
6756
6822
|
}
|
|
6757
|
-
|
|
6758
|
-
|
|
6823
|
+
// If the latest step for this intent is completed, mark all sub-steps as completed
|
|
6824
|
+
if (newStep.step_status === "completed") {
|
|
6825
|
+
intentSteps.forEach((s) => {
|
|
6826
|
+
s.step_status = "completed";
|
|
6827
|
+
});
|
|
6759
6828
|
}
|
|
6760
6829
|
questionsStepsMapRef.current[currentIntent] = intentSteps;
|
|
6761
6830
|
setQuestionsStepsMap(lodash.cloneDeep(questionsStepsMapRef.current));
|
|
@@ -6788,6 +6857,18 @@ const StreamedContent = ({ botData }) => {
|
|
|
6788
6857
|
setStepFormDataMap(lodash.cloneDeep(stepFormDataMapRef.current));
|
|
6789
6858
|
}
|
|
6790
6859
|
setStepChange((prev) => !prev);
|
|
6860
|
+
// Persist IDs immediately when step_form arrives (AxiosEventSource already set them)
|
|
6861
|
+
localStorage.setItem("stepForm_sessionId", messageToStoreRef.current.sessionId || "");
|
|
6862
|
+
localStorage.setItem("stepForm_chatId", messageToStoreRef.current.uniqueChatId || "");
|
|
6863
|
+
localStorage.setItem("stepForm_agentId", botData.inputBody?.agent_id || "");
|
|
6864
|
+
localStorage.setItem("stepForm_baseUrl", baseUrl || "");
|
|
6865
|
+
// If this is the [DONE] chunk, mark streaming as complete
|
|
6866
|
+
if (data.message === "[DONE]") {
|
|
6867
|
+
setIsStreamingDone(true);
|
|
6868
|
+
const doneState = streamStateMap.get(streamKey);
|
|
6869
|
+
if (doneState)
|
|
6870
|
+
doneState.completed = true;
|
|
6871
|
+
}
|
|
6791
6872
|
}
|
|
6792
6873
|
else if (data.message !== "[DONE]") {
|
|
6793
6874
|
setStepsDone(true);
|
|
@@ -6950,7 +7031,9 @@ const StreamedContent = ({ botData }) => {
|
|
|
6950
7031
|
let sendButton = document.getElementById("chat-input-send-button");
|
|
6951
7032
|
// sendButton.disabled = false;
|
|
6952
7033
|
let dummyButton = {};
|
|
7034
|
+
const hasStepForm = !isEmpty(messageToStoreRef.current.stepFormData);
|
|
6953
7035
|
if (!wasStreamingAborted &&
|
|
7036
|
+
!hasStepForm &&
|
|
6954
7037
|
(!messageToStoreRef.current.initValue ||
|
|
6955
7038
|
messageToStoreRef.current.status === "follow-up")) {
|
|
6956
7039
|
dummyButton = {
|
|
@@ -7357,8 +7440,13 @@ const useStyles$1 = makeStyles((theme) => ({
|
|
|
7357
7440
|
padding: `${pxToRem(8)} ${pxToRem(14)}`,
|
|
7358
7441
|
background: colours.greys100,
|
|
7359
7442
|
borderRadius: pxToRem(8),
|
|
7360
|
-
overflow: "hidden",
|
|
7361
7443
|
transition: "max-height 0.3s ease, opacity 0.3s ease",
|
|
7444
|
+
overflow: "auto",
|
|
7445
|
+
maxHeight: pxToRem(300),
|
|
7446
|
+
scrollbarWidth: "none",
|
|
7447
|
+
"&::-webkit-scrollbar": {
|
|
7448
|
+
display: "none",
|
|
7449
|
+
},
|
|
7362
7450
|
},
|
|
7363
7451
|
reasoningLabel: {
|
|
7364
7452
|
display: "flex",
|
|
@@ -7505,6 +7593,7 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
|
|
|
7505
7593
|
const [stepFormDataMapState, setStepFormDataMapState] = React.useState(lodash.cloneDeep(initialStepFormDataMap));
|
|
7506
7594
|
const [widgetContent, setWidgetContent] = React.useState([]);
|
|
7507
7595
|
const [isRestreaming, setIsRestreaming] = React.useState(false);
|
|
7596
|
+
const [stepFormSubmitted, setStepFormSubmitted] = React.useState(false);
|
|
7508
7597
|
// Refs for accumulating state during streaming (avoids stale closures)
|
|
7509
7598
|
const stepsRef = React.useRef(stepsState);
|
|
7510
7599
|
const questionsRef = React.useRef(questionsState);
|
|
@@ -7545,6 +7634,7 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
|
|
|
7545
7634
|
dispatch(smartBotActions.setStepFormStreamData(null));
|
|
7546
7635
|
if (payload.status === "streaming_start") {
|
|
7547
7636
|
setIsRestreaming(true);
|
|
7637
|
+
setStepFormSubmitted(true);
|
|
7548
7638
|
setTabValue("steps");
|
|
7549
7639
|
return;
|
|
7550
7640
|
}
|
|
@@ -7585,7 +7675,18 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
|
|
|
7585
7675
|
newSteps.push(newStep);
|
|
7586
7676
|
}
|
|
7587
7677
|
// Update per-question steps map
|
|
7588
|
-
if (currentIntent
|
|
7678
|
+
if (currentIntent) {
|
|
7679
|
+
// If this is a new intent we haven't seen, add it to questions and map
|
|
7680
|
+
if (!newQuestionsStepsMap[currentIntent]) {
|
|
7681
|
+
newQuestions.push(currentIntent);
|
|
7682
|
+
newQuestionsStepsMap[currentIntent] = [
|
|
7683
|
+
{
|
|
7684
|
+
header: "Processing Request",
|
|
7685
|
+
sub_header: "Analyzing the current request",
|
|
7686
|
+
step_status: "not-completed",
|
|
7687
|
+
},
|
|
7688
|
+
];
|
|
7689
|
+
}
|
|
7589
7690
|
const intentSteps = newQuestionsStepsMap[currentIntent];
|
|
7590
7691
|
if (intentSteps.length === 1 && intentSteps[0].header === "Processing Request") {
|
|
7591
7692
|
intentSteps[0].step_status = "completed";
|
|
@@ -7597,6 +7698,10 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
|
|
|
7597
7698
|
else {
|
|
7598
7699
|
intentSteps.push(newStep);
|
|
7599
7700
|
}
|
|
7701
|
+
// Mark all sub-steps completed when the latest step is completed
|
|
7702
|
+
if (newStep.step_status === "completed") {
|
|
7703
|
+
intentSteps.forEach((s) => { s.step_status = "completed"; });
|
|
7704
|
+
}
|
|
7600
7705
|
newQuestionsStepsMap[currentIntent] = intentSteps;
|
|
7601
7706
|
}
|
|
7602
7707
|
}
|
|
@@ -7660,7 +7765,7 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
|
|
|
7660
7765
|
icon: jsxRuntime.jsx(PsychologyOutlinedIcon, { fontSize: "large" }),
|
|
7661
7766
|
},
|
|
7662
7767
|
], tabPanels: [
|
|
7663
|
-
jsxRuntime.jsx(Steps, { steps: stepsState, questions: questionsState, questionsStepsMap: questionsStepsMapState, stepFormDataMap: stepFormDataMapState, isFormDisabled: isFormDisabled && !isRestreaming, isRestreaming: isRestreaming }),
|
|
7768
|
+
jsxRuntime.jsx(Steps, { steps: stepsState, questions: questionsState, questionsStepsMap: questionsStepsMapState, stepFormDataMap: stepFormDataMapState, isFormDisabled: (isFormDisabled && !isRestreaming) || stepFormSubmitted, isRestreaming: isRestreaming }),
|
|
7664
7769
|
jsxRuntime.jsxs(AgentResponse, { children: [children, renderedWidgets.length > 0 && (jsxRuntime.jsx("div", { className: "restream-widget-content", children: renderedWidgets }))] }),
|
|
7665
7770
|
], value: tabValue }) }));
|
|
7666
7771
|
};
|