@xapp/chat-widget 1.105.0 → 1.105.2

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.js CHANGED
@@ -4155,6 +4155,28 @@ function newMessage() {
4155
4155
 
4156
4156
  } (cjs));
4157
4157
 
4158
+ /**
4159
+ * Did this request fail because it never reached the server?
4160
+ *
4161
+ * The widget used to answer "the server is offline" to every failure, and on 2026-09-25 a retired
4162
+ * Bedrock model made every new chat fail with a 500 — so every visitor was told the server was
4163
+ * offline while it was up and serving. The message sent the investigation at DNS, CORS and CDNs for
4164
+ * 110 minutes and told customers something untrue.
4165
+ *
4166
+ * A status code is the discriminator: it only exists because the server answered. Present means
4167
+ * reachable-but-failing, which is a different message to a visitor and a different thing for us to
4168
+ * go and look at.
4169
+ *
4170
+ * An unrecognised failure counts as transport. It is the safer claim — "cannot reach the server"
4171
+ * when the truth is unknown is wrong in a way the visitor can act on, where leaving the widget
4172
+ * looking hung is not.
4173
+ */
4174
+ function isTransportFailure(error) {
4175
+ var status = Number(error === null || error === void 0 ? void 0 : error.statusCode);
4176
+ // A real HTTP status, so the server answered.
4177
+ return !(Number.isFinite(status) && status >= 100 && status <= 599);
4178
+ }
4179
+
4158
4180
  /**
4159
4181
  * Default configuration messages
4160
4182
  * @returns
@@ -4590,7 +4612,7 @@ var MCPChat = /** @class */ (function () {
4590
4612
  */
4591
4613
  MCPChat.prototype.initializeNewSession = function () {
4592
4614
  return __awaiter$1(this, void 0, void 0, function () {
4593
- var endpoint, error_2;
4615
+ var endpoint, error_2, statusCode;
4594
4616
  var _this = this;
4595
4617
  var _a;
4596
4618
  return __generator$1(this, function (_b) {
@@ -4620,11 +4642,18 @@ var MCPChat = /** @class */ (function () {
4620
4642
  return [3 /*break*/, 5];
4621
4643
  case 3:
4622
4644
  error_2 = _b.sent();
4623
- err("Failed to initialize new session: ".concat(error_2));
4645
+ statusCode = error_2 === null || error_2 === void 0 ? void 0 : error_2.statusCode;
4646
+ err("Failed to initialize new session: ".concat(error_2, ", statusCode: ").concat(statusCode));
4624
4647
  this.stopTyping();
4625
- this.setConnectionStatus("offline");
4648
+ // Only "offline" when the request never reached the server. A status code means it
4649
+ // answered, so the server is up and something behind it is broken -- and on 2026-09-25
4650
+ // a 500 from a retired model put "Server is offline" in front of every visitor, which
4651
+ // was untrue and sent the investigation at DNS, CORS and CDNs for 110 minutes.
4652
+ if (isTransportFailure(error_2)) {
4653
+ this.setConnectionStatus("offline");
4654
+ }
4626
4655
  // Show a failure message but don't block - user can still try sending messages
4627
- this.sendFailureMessage(0, 0, this.getErrorMessage(error_2));
4656
+ this.sendFailureMessage(0, 0, this.getErrorMessage(error_2, statusCode));
4628
4657
  return [3 /*break*/, 5];
4629
4658
  case 4:
4630
4659
  this.isInitializingSession = false;
@@ -5156,8 +5185,11 @@ var MCPChat = /** @class */ (function () {
5156
5185
  this.sendFailureMessage(0, 0, errorMessage);
5157
5186
  return [2 /*return*/];
5158
5187
  }
5159
- // Set offline status
5160
- this.setConnectionStatus("offline");
5188
+ // Same rule: a 5xx is the server answering, so it is not offline. Left as a
5189
+ // retryable failure, which is what the loop below treats it as anyway.
5190
+ if (isTransportFailure(error_4)) {
5191
+ this.setConnectionStatus("offline");
5192
+ }
5161
5193
  if (!isLastAttempt) return [3 /*break*/, 7];
5162
5194
  statusCode_1 = error_4 === null || error_4 === void 0 ? void 0 : error_4.statusCode;
5163
5195
  errorMessage = config.text || this.getErrorMessage(error_4, statusCode_1);
@@ -5719,7 +5751,7 @@ var MCPChat = /** @class */ (function () {
5719
5751
  };
5720
5752
  MCPChat.prototype.requestReplay = function () {
5721
5753
  return __awaiter$1(this, void 0, void 0, function () {
5722
- var error_5;
5754
+ var error_5, statusCode;
5723
5755
  return __generator$1(this, function (_a) {
5724
5756
  switch (_a.label) {
5725
5757
  case 0:
@@ -5741,8 +5773,12 @@ var MCPChat = /** @class */ (function () {
5741
5773
  return [3 /*break*/, 5];
5742
5774
  case 3:
5743
5775
  error_5 = _a.sent();
5744
- err("[MCPChat] Replay request failed: ".concat(error_5));
5745
- this.setConnectionStatus("offline");
5776
+ statusCode = error_5 === null || error_5 === void 0 ? void 0 : error_5.statusCode;
5777
+ err("[MCPChat] Replay request failed: ".concat(error_5, ", statusCode: ").concat(statusCode));
5778
+ // Same rule as session init: a status code means the server answered.
5779
+ if (isTransportFailure(error_5)) {
5780
+ this.setConnectionStatus("offline");
5781
+ }
5746
5782
  return [3 /*break*/, 5];
5747
5783
  case 4:
5748
5784
  this.stopTyping();
@@ -35930,8 +35966,17 @@ var MessageList = function (_a) {
35930
35966
  return (require$$0.jsxs("div", { className: "message-list-container", ref: containerRef, children: [require$$0.jsxs("div", { className: "message-list-container__msgs", children: [renderAll(), require$$0.jsx("div", { ref: messagesEndRef, style: { float: "left", clear: "both" } }), require$$0.jsx(QueuePosition, { position: queuePosition }), require$$0.jsx(TypingStatus, { agents: agents, textTypingStatusEnabled: textTypingStatusEnabled })] }), require$$0.jsx(ChatChipsContainer, {})] }));
35931
35967
  };
35932
35968
 
35969
+ /**
35970
+ * Shown when a chat request never reached the server -- see `isTransportFailure`.
35971
+ *
35972
+ * This overlay covers the conversation, so its two lines are the only thing the visitor sees. It
35973
+ * used to appear for every failure and say "Server is offline", which on 2026-09-25 was put in
35974
+ * front of every visitor by a 500 from a server that was up and serving. The copy is now limited to
35975
+ * what a failed request actually proves -- we could not reach it -- and names the one thing a
35976
+ * visitor can do about it.
35977
+ */
35933
35978
  var ServerOffline = function () {
35934
- return (require$$0.jsxs("div", { className: "server-offline", children: [require$$0.jsx("h2", { children: "Chat is currently unavailable" }), require$$0.jsx("h3", { children: "Server is offline" })] }));
35979
+ return (require$$0.jsxs("div", { className: "server-offline", children: [require$$0.jsx("h2", { children: "We can't reach the chat right now" }), require$$0.jsx("h3", { children: "Check your connection and try again in a moment." })] }));
35935
35980
  };
35936
35981
 
35937
35982
  /**