@crestapps/ai-chat-ui 1.3.0 → 2.0.0-preview.154
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/ai-chat.js +29 -0
- package/dist/ai-chat.js.map +1 -1
- package/dist/ai-chat.min.js +1 -1
- package/dist/ai-chat.min.js.map +1 -1
- package/package.json +1 -1
package/dist/ai-chat.js
CHANGED
|
@@ -1199,8 +1199,29 @@ window.coreAIChatManager = function () {
|
|
|
1199
1199
|
if (_this3.isRecording) {
|
|
1200
1200
|
_this3.stopRecording();
|
|
1201
1201
|
}
|
|
1202
|
+
|
|
1203
|
+
// A server-side error (for example a session-start rate-limit rejection) ends the
|
|
1204
|
+
// in-flight request. Reject any pending new-session promise so the UI stops waiting
|
|
1205
|
+
// until it times out, and clear the typing indicator that a send may have shown.
|
|
1206
|
+
_this3.rejectPendingSessionRequest(error);
|
|
1207
|
+
_this3.hideTypingIndicator();
|
|
1202
1208
|
if (widgetBehavior && typeof widgetBehavior.handleReceiveError === 'function') {
|
|
1203
1209
|
widgetBehavior.handleReceiveError(_this3, error, config);
|
|
1210
|
+
} else if (!_this3.isNavigatingAway) {
|
|
1211
|
+
// Surface the message to the user instead of failing silently.
|
|
1212
|
+
_this3.addMessage(_this3.getErrorMessage(error));
|
|
1213
|
+
}
|
|
1214
|
+
});
|
|
1215
|
+
_this3.connection.on("ReceiveSessionStartRejected", function (reason) {
|
|
1216
|
+
// A rate-limit rejection is a definitive "wait and retry", not a recoverable
|
|
1217
|
+
// session/connection error. Unblock any pending new-session request, clear the
|
|
1218
|
+
// typing indicator, and show the message for every host (main app and widget)
|
|
1219
|
+
// without triggering the widget's clear-and-retry recovery, which would wipe the
|
|
1220
|
+
// visitor's state and fire another throttled StartSession.
|
|
1221
|
+
_this3.rejectPendingSessionRequest(reason);
|
|
1222
|
+
_this3.hideTypingIndicator();
|
|
1223
|
+
if (!_this3.isNavigatingAway) {
|
|
1224
|
+
_this3.addMessage(_this3.getErrorMessage(reason));
|
|
1204
1225
|
}
|
|
1205
1226
|
});
|
|
1206
1227
|
_this3.connection.on("MessageRated", function (messageId, userRating) {
|
|
@@ -1715,6 +1736,14 @@ window.coreAIChatManager = function () {
|
|
|
1715
1736
|
};
|
|
1716
1737
|
return newMessage;
|
|
1717
1738
|
},
|
|
1739
|
+
getErrorMessage: function getErrorMessage(error) {
|
|
1740
|
+
var content = typeof error === 'string' && error.trim() ? error : "Something went wrong. Please try again.";
|
|
1741
|
+
return {
|
|
1742
|
+
role: "assistant",
|
|
1743
|
+
content: content,
|
|
1744
|
+
htmlContent: ""
|
|
1745
|
+
};
|
|
1746
|
+
},
|
|
1718
1747
|
processReferences: function processReferences(references, messageIndex) {
|
|
1719
1748
|
var _this9 = this;
|
|
1720
1749
|
references = normalizeReferences(references);
|