impact-chatbot 2.3.32 → 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
|
|
@@ -5119,6 +5120,13 @@ const sseevent = (message, messageToStoreRef) => {
|
|
|
5119
5120
|
? parsedData.additional_args
|
|
5120
5121
|
: {};
|
|
5121
5122
|
}
|
|
5123
|
+
if (parsedData?.status === "notification") {
|
|
5124
|
+
messageToStoreRef.current.notificationData = {
|
|
5125
|
+
message: parsedData?.message || "",
|
|
5126
|
+
chat_id: parsedData?.chat_id || "",
|
|
5127
|
+
session_id: parsedData?.session_id || "",
|
|
5128
|
+
};
|
|
5129
|
+
}
|
|
5122
5130
|
if (parsedData?.status === "completed" ||
|
|
5123
5131
|
parsedData?.status === "follow-up") {
|
|
5124
5132
|
messageToStoreRef.current.initValue = true;
|
|
@@ -5139,15 +5147,6 @@ const sseevent = (message, messageToStoreRef) => {
|
|
|
5139
5147
|
if (currentIntent) {
|
|
5140
5148
|
messageToStoreRef.current.stepFormData[currentIntent] = formWidgetData;
|
|
5141
5149
|
}
|
|
5142
|
-
let previousWidgetData = lodash.isArray(messageToStoreRef.current.appendedData)
|
|
5143
|
-
? messageToStoreRef.current.appendedData
|
|
5144
|
-
: lodash.isEmpty(messageToStoreRef.current.appendedData)
|
|
5145
|
-
? []
|
|
5146
|
-
: [messageToStoreRef.current.appendedData];
|
|
5147
|
-
messageToStoreRef.current.appendedData = [
|
|
5148
|
-
...previousWidgetData,
|
|
5149
|
-
...formWidgetData,
|
|
5150
|
-
];
|
|
5151
5150
|
messageToStoreRef.current.additionalArgs = parsedData?.additional_args
|
|
5152
5151
|
? parsedData.additional_args
|
|
5153
5152
|
: {};
|
|
@@ -5286,7 +5285,7 @@ const useStyles$4 = styles.makeStyles((theme) => ({
|
|
|
5286
5285
|
marginTop: pxToRem(16),
|
|
5287
5286
|
}
|
|
5288
5287
|
}));
|
|
5289
|
-
const ButtonContent = ({ bodyText, isFormDisabled = false, isStepFormSubmit = false }) => {
|
|
5288
|
+
const ButtonContent = ({ bodyText, isFormDisabled = false, isStepFormSubmit = false, isFormValid = true }) => {
|
|
5290
5289
|
const classes = useStyles$4();
|
|
5291
5290
|
const dispatch = reactRedux.useDispatch();
|
|
5292
5291
|
const sourceRef = React.useRef(null);
|
|
@@ -5392,7 +5391,7 @@ const ButtonContent = ({ bodyText, isFormDisabled = false, isStepFormSubmit = fa
|
|
|
5392
5391
|
if (!Array.isArray(bodyText.buttons)) {
|
|
5393
5392
|
return null;
|
|
5394
5393
|
}
|
|
5395
|
-
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)));
|
|
5396
5395
|
};
|
|
5397
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() })] }));
|
|
5398
5397
|
};
|
|
@@ -5773,6 +5772,12 @@ const SelectContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
|
|
|
5773
5772
|
console.error("Error in select handleChange", error);
|
|
5774
5773
|
}
|
|
5775
5774
|
};
|
|
5775
|
+
React.useEffect(() => {
|
|
5776
|
+
const persisted = persistedFormValues?.[formKey];
|
|
5777
|
+
if (!persisted || (Array.isArray(persisted) && persisted.length === 0)) {
|
|
5778
|
+
setCurrentSelectedOptions([]);
|
|
5779
|
+
}
|
|
5780
|
+
}, [persistedFormValues, formKey]);
|
|
5776
5781
|
React.useEffect(() => {
|
|
5777
5782
|
let formattedOptions = options.map((option) => {
|
|
5778
5783
|
return {
|
|
@@ -5995,6 +6000,13 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false })
|
|
|
5995
6000
|
const savedFilterSets = reactRedux.useSelector((state) => state.smartBotReducer.savedFilterSets);
|
|
5996
6001
|
const persistedFormValues = reactRedux.useSelector((state) => state.smartBotReducer.persistedFormValues);
|
|
5997
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]);
|
|
5998
6010
|
const [isFilterSetOpen, setIsFilterSetOpen] = React.useState(false);
|
|
5999
6011
|
const [selectedFilterSet, setSelectedFilterSet] = React.useState(() => {
|
|
6000
6012
|
// Restore from chatbotContext if available (persists across tab switches)
|
|
@@ -6015,6 +6027,7 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false })
|
|
|
6015
6027
|
const selectedValue = Array.isArray(selected) ? selected[0]?.value : selected?.value;
|
|
6016
6028
|
if (!selectedValue) {
|
|
6017
6029
|
dispatch(smartBotActions.setChatbotContext({}));
|
|
6030
|
+
dispatch(smartBotActions.clearPersistedFormValues());
|
|
6018
6031
|
return;
|
|
6019
6032
|
}
|
|
6020
6033
|
const fullFilterObj = (savedFilterSets || []).find((f) => (f.fuc_code || f.name || f.label) === selectedValue);
|
|
@@ -6062,8 +6075,32 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false })
|
|
|
6062
6075
|
return val && (Array.isArray(val) ? val.length > 0 : !!val);
|
|
6063
6076
|
});
|
|
6064
6077
|
}, [persistedFormValues, messageIndex]);
|
|
6065
|
-
const formFieldsDisabled = isFormDisabled || isFilterSelected;
|
|
6066
|
-
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]);
|
|
6067
6104
|
if (!formData || !Array.isArray(formData) || formData.length === 0) {
|
|
6068
6105
|
return null;
|
|
6069
6106
|
}
|
|
@@ -6091,7 +6128,7 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false })
|
|
|
6091
6128
|
case "radio":
|
|
6092
6129
|
return jsxRuntime.jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: formFieldsDisabled, messageIndex: messageIndex }, key);
|
|
6093
6130
|
case "button":
|
|
6094
|
-
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);
|
|
6095
6132
|
case "input":
|
|
6096
6133
|
return jsxRuntime.jsx(InputContent, { bodyText: parsedData.bodyText, isFormDisabled: formFieldsDisabled, messageIndex: messageIndex }, key);
|
|
6097
6134
|
case "image":
|
|
@@ -6152,12 +6189,10 @@ const useStyles$2 = makeStyles((theme) => ({
|
|
|
6152
6189
|
"@keyframes slideDown": {
|
|
6153
6190
|
"0%": {
|
|
6154
6191
|
opacity: 0,
|
|
6155
|
-
maxHeight: 0,
|
|
6156
6192
|
transform: "translateY(-12px)",
|
|
6157
6193
|
},
|
|
6158
6194
|
"100%": {
|
|
6159
6195
|
opacity: 1,
|
|
6160
|
-
maxHeight: "2000px",
|
|
6161
6196
|
transform: "translateY(0)",
|
|
6162
6197
|
},
|
|
6163
6198
|
},
|
|
@@ -6270,8 +6305,13 @@ const useStyles$2 = makeStyles((theme) => ({
|
|
|
6270
6305
|
padding: `${pxToRem(8)} ${pxToRem(14)}`,
|
|
6271
6306
|
background: colours.greys100,
|
|
6272
6307
|
borderRadius: pxToRem(8),
|
|
6273
|
-
|
|
6274
|
-
|
|
6308
|
+
transition: "opacity 0.3s ease",
|
|
6309
|
+
overflow: "auto",
|
|
6310
|
+
maxHeight: pxToRem(300),
|
|
6311
|
+
scrollbarWidth: "none",
|
|
6312
|
+
"&::-webkit-scrollbar": {
|
|
6313
|
+
display: "none",
|
|
6314
|
+
},
|
|
6275
6315
|
},
|
|
6276
6316
|
reasoningLabel: {
|
|
6277
6317
|
display: "flex",
|
|
@@ -6324,8 +6364,10 @@ const useStyles$2 = makeStyles((theme) => ({
|
|
|
6324
6364
|
* - "not-started": no steps or all pending
|
|
6325
6365
|
*/
|
|
6326
6366
|
const getQuestionStatus$1 = (questionSteps) => {
|
|
6327
|
-
if (!questionSteps
|
|
6367
|
+
if (!questionSteps)
|
|
6328
6368
|
return "not-started";
|
|
6369
|
+
if (questionSteps.length === 0)
|
|
6370
|
+
return "completed";
|
|
6329
6371
|
const hasError = questionSteps.some((s) => s.step_status === "error");
|
|
6330
6372
|
if (hasError)
|
|
6331
6373
|
return "error";
|
|
@@ -6366,8 +6408,11 @@ const ProgressBarItem$1 = ({ question, questionSteps, isLast, classes, formData,
|
|
|
6366
6408
|
if (status === "in-progress" || status === "error" || formData) {
|
|
6367
6409
|
setIsExpanded(true);
|
|
6368
6410
|
}
|
|
6411
|
+
else if (status === "completed" && !formData) {
|
|
6412
|
+
setIsExpanded(false);
|
|
6413
|
+
}
|
|
6369
6414
|
}, [status, formData]);
|
|
6370
|
-
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 }) }))] })] }));
|
|
6371
6416
|
};
|
|
6372
6417
|
const Steps$1 = ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, setFinalStepDone, stepChange, currentMode, questions = [], questionsStepsMap = {}, stepFormDataMap = {}, isFormDisabled = false, }) => {
|
|
6373
6418
|
const classes = useStyles$2();
|
|
@@ -6610,7 +6655,7 @@ const StreamedContent = ({ botData }) => {
|
|
|
6610
6655
|
// }
|
|
6611
6656
|
let endPoint = botData?.utilityObject?.endpoint
|
|
6612
6657
|
? `${api.BASE_API}${botData?.utilityObject?.endpoint}`
|
|
6613
|
-
: `${api.BASE_API}/core/chatbot/navigation-
|
|
6658
|
+
: `${api.BASE_API}/core/chatbot/navigation-v3`;
|
|
6614
6659
|
let method = botData?.utilityObject?.method
|
|
6615
6660
|
? botData?.utilityObject?.method
|
|
6616
6661
|
: "PUT";
|
|
@@ -6674,6 +6719,15 @@ const StreamedContent = ({ botData }) => {
|
|
|
6674
6719
|
thinkingStartTimeRef.current = Date.now();
|
|
6675
6720
|
}
|
|
6676
6721
|
const data = JSON.parse(event.data);
|
|
6722
|
+
if (data?.status === "notification") {
|
|
6723
|
+
window.dispatchEvent(new CustomEvent("agent-notification", {
|
|
6724
|
+
detail: {
|
|
6725
|
+
message: data?.message || "",
|
|
6726
|
+
chat_id: data?.chat_id || "",
|
|
6727
|
+
session_id: data?.session_id || "",
|
|
6728
|
+
},
|
|
6729
|
+
}));
|
|
6730
|
+
}
|
|
6677
6731
|
if (data?.message || data?.status === "step" || data?.status === "step_form" || data?.status === "thinking" || data?.status === "questions") {
|
|
6678
6732
|
if (data.status === "questions") {
|
|
6679
6733
|
const incomingQuestions = data.widget_data?.[0]?.questions || [];
|
|
@@ -6729,17 +6783,48 @@ const StreamedContent = ({ botData }) => {
|
|
|
6729
6783
|
}
|
|
6730
6784
|
stepRef.current = newSteps;
|
|
6731
6785
|
setSteps(newSteps);
|
|
6732
|
-
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
|
+
}
|
|
6733
6802
|
let intentSteps = lodash.cloneDeep(questionsStepsMapRef.current[currentIntent]);
|
|
6734
|
-
if (
|
|
6735
|
-
|
|
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
|
+
}
|
|
6736
6812
|
}
|
|
6737
|
-
|
|
6738
|
-
|
|
6739
|
-
|
|
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
|
+
}
|
|
6740
6822
|
}
|
|
6741
|
-
|
|
6742
|
-
|
|
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
|
+
});
|
|
6743
6828
|
}
|
|
6744
6829
|
questionsStepsMapRef.current[currentIntent] = intentSteps;
|
|
6745
6830
|
setQuestionsStepsMap(lodash.cloneDeep(questionsStepsMapRef.current));
|
|
@@ -6772,6 +6857,18 @@ const StreamedContent = ({ botData }) => {
|
|
|
6772
6857
|
setStepFormDataMap(lodash.cloneDeep(stepFormDataMapRef.current));
|
|
6773
6858
|
}
|
|
6774
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
|
+
}
|
|
6775
6872
|
}
|
|
6776
6873
|
else if (data.message !== "[DONE]") {
|
|
6777
6874
|
setStepsDone(true);
|
|
@@ -6934,7 +7031,9 @@ const StreamedContent = ({ botData }) => {
|
|
|
6934
7031
|
let sendButton = document.getElementById("chat-input-send-button");
|
|
6935
7032
|
// sendButton.disabled = false;
|
|
6936
7033
|
let dummyButton = {};
|
|
7034
|
+
const hasStepForm = !isEmpty(messageToStoreRef.current.stepFormData);
|
|
6937
7035
|
if (!wasStreamingAborted &&
|
|
7036
|
+
!hasStepForm &&
|
|
6938
7037
|
(!messageToStoreRef.current.initValue ||
|
|
6939
7038
|
messageToStoreRef.current.status === "follow-up")) {
|
|
6940
7039
|
dummyButton = {
|
|
@@ -7341,8 +7440,13 @@ const useStyles$1 = makeStyles((theme) => ({
|
|
|
7341
7440
|
padding: `${pxToRem(8)} ${pxToRem(14)}`,
|
|
7342
7441
|
background: colours.greys100,
|
|
7343
7442
|
borderRadius: pxToRem(8),
|
|
7344
|
-
overflow: "hidden",
|
|
7345
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
|
+
},
|
|
7346
7450
|
},
|
|
7347
7451
|
reasoningLabel: {
|
|
7348
7452
|
display: "flex",
|
|
@@ -7489,6 +7593,7 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
|
|
|
7489
7593
|
const [stepFormDataMapState, setStepFormDataMapState] = React.useState(lodash.cloneDeep(initialStepFormDataMap));
|
|
7490
7594
|
const [widgetContent, setWidgetContent] = React.useState([]);
|
|
7491
7595
|
const [isRestreaming, setIsRestreaming] = React.useState(false);
|
|
7596
|
+
const [stepFormSubmitted, setStepFormSubmitted] = React.useState(false);
|
|
7492
7597
|
// Refs for accumulating state during streaming (avoids stale closures)
|
|
7493
7598
|
const stepsRef = React.useRef(stepsState);
|
|
7494
7599
|
const questionsRef = React.useRef(questionsState);
|
|
@@ -7529,6 +7634,7 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
|
|
|
7529
7634
|
dispatch(smartBotActions.setStepFormStreamData(null));
|
|
7530
7635
|
if (payload.status === "streaming_start") {
|
|
7531
7636
|
setIsRestreaming(true);
|
|
7637
|
+
setStepFormSubmitted(true);
|
|
7532
7638
|
setTabValue("steps");
|
|
7533
7639
|
return;
|
|
7534
7640
|
}
|
|
@@ -7569,7 +7675,18 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
|
|
|
7569
7675
|
newSteps.push(newStep);
|
|
7570
7676
|
}
|
|
7571
7677
|
// Update per-question steps map
|
|
7572
|
-
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
|
+
}
|
|
7573
7690
|
const intentSteps = newQuestionsStepsMap[currentIntent];
|
|
7574
7691
|
if (intentSteps.length === 1 && intentSteps[0].header === "Processing Request") {
|
|
7575
7692
|
intentSteps[0].step_status = "completed";
|
|
@@ -7581,6 +7698,10 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
|
|
|
7581
7698
|
else {
|
|
7582
7699
|
intentSteps.push(newStep);
|
|
7583
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
|
+
}
|
|
7584
7705
|
newQuestionsStepsMap[currentIntent] = intentSteps;
|
|
7585
7706
|
}
|
|
7586
7707
|
}
|
|
@@ -7644,7 +7765,7 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
|
|
|
7644
7765
|
icon: jsxRuntime.jsx(PsychologyOutlinedIcon, { fontSize: "large" }),
|
|
7645
7766
|
},
|
|
7646
7767
|
], tabPanels: [
|
|
7647
|
-
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 }),
|
|
7648
7769
|
jsxRuntime.jsxs(AgentResponse, { children: [children, renderedWidgets.length > 0 && (jsxRuntime.jsx("div", { className: "restream-widget-content", children: renderedWidgets }))] }),
|
|
7649
7770
|
], value: tabValue }) }));
|
|
7650
7771
|
};
|