impact-chatbot 2.3.61 → 2.3.62
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 +106 -7
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +106 -7
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -5203,9 +5203,28 @@ const sseevent = (message, messageToStoreRef) => {
|
|
|
5203
5203
|
messageToStoreRef.current.navSessionId = parsedData.session_id;
|
|
5204
5204
|
}
|
|
5205
5205
|
if (parsedData?.is_error) {
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5206
|
+
// Only append the error message once, even if multiple is_error chunks arrive.
|
|
5207
|
+
// Append as a widget item to appendedData so it renders AFTER any existing
|
|
5208
|
+
// widgets (tables, graphs, text widgets) rather than at the top of the response.
|
|
5209
|
+
if (!messageToStoreRef.current.hasErrorMessage) {
|
|
5210
|
+
messageToStoreRef.current.hasErrorMessage = true;
|
|
5211
|
+
const errorMsg = parsedData?.message && parsedData.message !== "[DONE]"
|
|
5212
|
+
? parsedData.message
|
|
5213
|
+
: "There is an error, please reach out to IA with this use case.";
|
|
5214
|
+
const errorWidget = { type: "text", response: errorMsg };
|
|
5215
|
+
const prevAppended = messageToStoreRef.current.appendedData;
|
|
5216
|
+
if (Array.isArray(prevAppended) && prevAppended.length > 0) {
|
|
5217
|
+
messageToStoreRef.current.appendedData = [...prevAppended, errorWidget];
|
|
5218
|
+
}
|
|
5219
|
+
else if (prevAppended && typeof prevAppended === "object" && Object.keys(prevAppended).length > 0) {
|
|
5220
|
+
messageToStoreRef.current.appendedData = [prevAppended, errorWidget];
|
|
5221
|
+
}
|
|
5222
|
+
else {
|
|
5223
|
+
// No existing widgets — put on chatData.response instead
|
|
5224
|
+
messageToStoreRef.current.chatData.response =
|
|
5225
|
+
messageToStoreRef.current.chatData.response + errorMsg;
|
|
5226
|
+
}
|
|
5227
|
+
}
|
|
5209
5228
|
// Still process completed/follow-up status even on error chunks
|
|
5210
5229
|
// so that initValue is set correctly and dummyButton is suppressed
|
|
5211
5230
|
if (parsedData?.status === "completed" ||
|
|
@@ -5690,6 +5709,28 @@ const ButtonContent = ({ bodyText, isFormDisabled = false, isStepFormSubmit = fa
|
|
|
5690
5709
|
window.dispatchEvent(new CustomEvent("stepFormStreamEnd"));
|
|
5691
5710
|
dispatch(setStepFormStreamData({ status: "error", chunks: chunksRef, sessionId }));
|
|
5692
5711
|
});
|
|
5712
|
+
// Handle stream closure — fires when the HTTP request completes successfully.
|
|
5713
|
+
// If [DONE] was received, the "message" handler already dispatched status:"done"
|
|
5714
|
+
// and set stepFormStreamControl.isStreaming = false.
|
|
5715
|
+
// If [DONE] was NOT received, the connection closed abruptly mid-processing.
|
|
5716
|
+
sourceRef.current.addEventListener("close", () => {
|
|
5717
|
+
if (stepFormStreamControl.isStreaming) {
|
|
5718
|
+
stepFormStreamControl.isStreaming = false;
|
|
5719
|
+
stepFormStreamControl.abort = null;
|
|
5720
|
+
window.dispatchEvent(new CustomEvent("stepFormStreamEnd"));
|
|
5721
|
+
// Append the abrupt close message as a content chunk so TabularContent
|
|
5722
|
+
// renders it at the bottom (after any already-received widgets/steps)
|
|
5723
|
+
chunksRef.push({
|
|
5724
|
+
status: "content",
|
|
5725
|
+
message: "The requested Task has ended unexpectedly, please retry again",
|
|
5726
|
+
});
|
|
5727
|
+
dispatch(setStepFormStreamData({
|
|
5728
|
+
status: "error",
|
|
5729
|
+
chunks: [...chunksRef],
|
|
5730
|
+
sessionId,
|
|
5731
|
+
}));
|
|
5732
|
+
}
|
|
5733
|
+
});
|
|
5693
5734
|
};
|
|
5694
5735
|
const renderButtons = () => {
|
|
5695
5736
|
if (!Array.isArray(bodyText.buttons)) {
|
|
@@ -8153,6 +8194,26 @@ const StreamedContent = ({ botData }) => {
|
|
|
8153
8194
|
}));
|
|
8154
8195
|
return;
|
|
8155
8196
|
}
|
|
8197
|
+
// Skip is_error chunks — already handled in AxiosEventSource sseevent()
|
|
8198
|
+
if (data?.is_error) {
|
|
8199
|
+
// Trigger completion if status is "completed"
|
|
8200
|
+
if (data?.status === "completed") {
|
|
8201
|
+
setStepsDone(true);
|
|
8202
|
+
setIsStreamingDone(true);
|
|
8203
|
+
const doneState = streamStateMap.get(streamKey);
|
|
8204
|
+
if (doneState)
|
|
8205
|
+
doneState.completed = true;
|
|
8206
|
+
dispatch(setMinimizedStreamData({
|
|
8207
|
+
isStreaming: false,
|
|
8208
|
+
stepHeader: questionsRef.current[questionsRef.current.length - 1] || "Completed",
|
|
8209
|
+
stepSubHeader: "Done",
|
|
8210
|
+
stepStatus: "completed",
|
|
8211
|
+
streamStartTime: streamStartTimeRef.current,
|
|
8212
|
+
actionCount: questionsRef.current.length || 1,
|
|
8213
|
+
}));
|
|
8214
|
+
}
|
|
8215
|
+
return;
|
|
8216
|
+
}
|
|
8156
8217
|
if (data?.message || data?.status === "step" || data?.status === "step_form" || data?.status === "thinking" || data?.status === "questions" || data?.status === "widget") {
|
|
8157
8218
|
if (data.status === "questions") {
|
|
8158
8219
|
const incomingQuestions = data.widget_data?.[0]?.questions || [];
|
|
@@ -8449,9 +8510,26 @@ const StreamedContent = ({ botData }) => {
|
|
|
8449
8510
|
stepRef.current = [...currentSteps];
|
|
8450
8511
|
setSteps([...currentSteps]);
|
|
8451
8512
|
}
|
|
8452
|
-
//
|
|
8513
|
+
// Show the abrupt close message at the bottom of any existing content.
|
|
8514
|
+
// If widgets already exist in appendedData, append the error as the last widget
|
|
8515
|
+
// so it renders AFTER the already-received content (not at the top).
|
|
8453
8516
|
const abruptCloseMessage = "The requested Task has ended unexpectedly, please retry again";
|
|
8454
|
-
messageToStoreRef.current.
|
|
8517
|
+
const hasExistingWidgetsOnErr = messageToStoreRef.current.appendedData &&
|
|
8518
|
+
(isArray(messageToStoreRef.current.appendedData)
|
|
8519
|
+
? messageToStoreRef.current.appendedData.length > 0
|
|
8520
|
+
: Object.keys(messageToStoreRef.current.appendedData).length > 0);
|
|
8521
|
+
if (hasExistingWidgetsOnErr) {
|
|
8522
|
+
const errorWidget = { type: "text", response: abruptCloseMessage };
|
|
8523
|
+
if (isArray(messageToStoreRef.current.appendedData)) {
|
|
8524
|
+
messageToStoreRef.current.appendedData.push(errorWidget);
|
|
8525
|
+
}
|
|
8526
|
+
else {
|
|
8527
|
+
messageToStoreRef.current.appendedData = [messageToStoreRef.current.appendedData, errorWidget];
|
|
8528
|
+
}
|
|
8529
|
+
}
|
|
8530
|
+
else {
|
|
8531
|
+
messageToStoreRef.current.chatData.response = abruptCloseMessage;
|
|
8532
|
+
}
|
|
8455
8533
|
setContent(abruptCloseMessage);
|
|
8456
8534
|
// Dispatch minimized widget data
|
|
8457
8535
|
dispatch(setMinimizedStreamData({
|
|
@@ -8489,9 +8567,30 @@ const StreamedContent = ({ botData }) => {
|
|
|
8489
8567
|
stepRef.current = [...currentSteps];
|
|
8490
8568
|
setSteps([...currentSteps]);
|
|
8491
8569
|
}
|
|
8492
|
-
//
|
|
8570
|
+
// Show the abrupt close message. The final response array is structured as:
|
|
8571
|
+
// [textResponseTobeParsed, ...appendedData] — so chatData.response renders FIRST,
|
|
8572
|
+
// then widget items from appendedData render below it.
|
|
8573
|
+
// To ensure the error message appears AFTER already-rendered widgets, we append it
|
|
8574
|
+
// as a text widget item to appendedData instead of setting it on chatData.response.
|
|
8493
8575
|
const abruptCloseMessage = "The requested Task has ended unexpectedly, please retry again";
|
|
8494
|
-
messageToStoreRef.current.
|
|
8576
|
+
const hasExistingWidgets = messageToStoreRef.current.appendedData &&
|
|
8577
|
+
(isArray(messageToStoreRef.current.appendedData)
|
|
8578
|
+
? messageToStoreRef.current.appendedData.length > 0
|
|
8579
|
+
: Object.keys(messageToStoreRef.current.appendedData).length > 0);
|
|
8580
|
+
if (hasExistingWidgets) {
|
|
8581
|
+
// Widgets already exist — append error as the last widget so it renders at the bottom
|
|
8582
|
+
const errorWidget = { type: "text", response: abruptCloseMessage };
|
|
8583
|
+
if (isArray(messageToStoreRef.current.appendedData)) {
|
|
8584
|
+
messageToStoreRef.current.appendedData.push(errorWidget);
|
|
8585
|
+
}
|
|
8586
|
+
else {
|
|
8587
|
+
messageToStoreRef.current.appendedData = [messageToStoreRef.current.appendedData, errorWidget];
|
|
8588
|
+
}
|
|
8589
|
+
}
|
|
8590
|
+
else {
|
|
8591
|
+
// No widgets — set on chatData.response (will be the only rendered text)
|
|
8592
|
+
messageToStoreRef.current.chatData.response = abruptCloseMessage;
|
|
8593
|
+
}
|
|
8495
8594
|
setContent(abruptCloseMessage);
|
|
8496
8595
|
// Stop thinking if in progress
|
|
8497
8596
|
if (isThinking) {
|