@helpai/elements 0.50.7 → 0.50.8

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/index.mjs CHANGED
@@ -29,7 +29,7 @@ var BRAND = {
29
29
  };
30
30
 
31
31
  // src/core/version.ts
32
- var ELEMENTS_VERSION = true ? "0.50.7" : "0.0.0-dev";
32
+ var ELEMENTS_VERSION = true ? "0.50.8" : "0.0.0-dev";
33
33
  var ELEMENTS_VERSION_PARAM = "_ev";
34
34
 
35
35
  // src/i18n/strings.ts
@@ -2829,11 +2829,13 @@ function assistantText(m) {
2829
2829
  }
2830
2830
  return out;
2831
2831
  }
2832
- function isEmptyAssistantReply(m) {
2833
- if (m.role !== "assistant" || m.status === "streaming") return false;
2832
+ function hasNoVisibleAnswer(m) {
2834
2833
  if (assistantText(m).trim() !== "") return false;
2835
2834
  return !m.partsSig.value.some((p36) => p36.kind === "tool" || p36.kind === "file" || p36.kind === "source");
2836
2835
  }
2836
+ function isEmptyAssistantReply(m) {
2837
+ return m.role === "assistant" && m.status !== "streaming" && hasNoVisibleAnswer(m);
2838
+ }
2837
2839
  function partToReactive(p36) {
2838
2840
  if (p36.kind === "text" || p36.kind === "reasoning") {
2839
2841
  return { kind: p36.kind, id: p36.id, textSig: signal(p36.text), doneSig: signal(p36.done) };
@@ -6057,6 +6059,7 @@ function MessageList({
6057
6059
  }
6058
6060
  };
6059
6061
  for (const m of messages.value) {
6062
+ if (m.role === "assistant" && m.id !== lastId && isEmptyAssistantReply(m)) continue;
6060
6063
  flushMarkersBefore(m.createdAt);
6061
6064
  const day = dayKey(m.createdAt);
6062
6065
  if (day && day !== prevDay) {
@@ -7514,6 +7517,9 @@ function allToolPartsSettled(msg) {
7514
7517
  return s === "output-available" || s === "output-error" || s === "output-denied" || s === "approval-responded";
7515
7518
  });
7516
7519
  }
7520
+ function isAbortError(error) {
7521
+ return error instanceof DOMException ? error.name === "AbortError" : error?.name === "AbortError";
7522
+ }
7517
7523
  function App({ options, hostElement, bus }) {
7518
7524
  const [persistence] = useState14(
7519
7525
  () => createPersistence(options.widgetId, options.storage, options.aiAgentDeploymentId)
@@ -8029,11 +8035,19 @@ function App({ options, hostElement, bus }) {
8029
8035
  emitMessage(bus, options, "assistant", assistantText(assistantMsg));
8030
8036
  }
8031
8037
  } catch (error) {
8032
- assistantMsg.status = "error";
8033
- assistantMsg.errorText = errorMessageFor(error, options.strings);
8034
- feedback.play("error");
8035
- bus.emit("error", error);
8036
- options.onError?.(error);
8038
+ if (isAbortError(error)) {
8039
+ if (hasNoVisibleAnswer(assistantMsg)) {
8040
+ messagesSig.value = messagesSig.value.filter((m) => m !== assistantMsg);
8041
+ } else {
8042
+ assistantMsg.status = "complete";
8043
+ }
8044
+ } else {
8045
+ assistantMsg.status = "error";
8046
+ assistantMsg.errorText = errorMessageFor(error, options.strings);
8047
+ feedback.play("error");
8048
+ bus.emit("error", error);
8049
+ options.onError?.(error);
8050
+ }
8037
8051
  } finally {
8038
8052
  reducer.detach();
8039
8053
  setStreaming(false);
package/package.json CHANGED
@@ -80,5 +80,5 @@
80
80
  ],
81
81
  "type": "module",
82
82
  "types": "./index.d.ts",
83
- "version": "0.50.7"
83
+ "version": "0.50.8"
84
84
  }
package/web-component.mjs CHANGED
@@ -1794,7 +1794,7 @@ function createAuth(opts) {
1794
1794
  }
1795
1795
 
1796
1796
  // src/core/version.ts
1797
- var ELEMENTS_VERSION = true ? "0.50.7" : "0.0.0-dev";
1797
+ var ELEMENTS_VERSION = true ? "0.50.8" : "0.0.0-dev";
1798
1798
  var ELEMENTS_VERSION_PARAM = "_ev";
1799
1799
 
1800
1800
  // src/stream/types.ts
@@ -2788,11 +2788,13 @@ function assistantText(m) {
2788
2788
  }
2789
2789
  return out;
2790
2790
  }
2791
- function isEmptyAssistantReply(m) {
2792
- if (m.role !== "assistant" || m.status === "streaming") return false;
2791
+ function hasNoVisibleAnswer(m) {
2793
2792
  if (assistantText(m).trim() !== "") return false;
2794
2793
  return !m.partsSig.value.some((p36) => p36.kind === "tool" || p36.kind === "file" || p36.kind === "source");
2795
2794
  }
2795
+ function isEmptyAssistantReply(m) {
2796
+ return m.role === "assistant" && m.status !== "streaming" && hasNoVisibleAnswer(m);
2797
+ }
2796
2798
  function partToReactive(p36) {
2797
2799
  if (p36.kind === "text" || p36.kind === "reasoning") {
2798
2800
  return { kind: p36.kind, id: p36.id, textSig: signal(p36.text), doneSig: signal(p36.done) };
@@ -6016,6 +6018,7 @@ function MessageList({
6016
6018
  }
6017
6019
  };
6018
6020
  for (const m of messages.value) {
6021
+ if (m.role === "assistant" && m.id !== lastId && isEmptyAssistantReply(m)) continue;
6019
6022
  flushMarkersBefore(m.createdAt);
6020
6023
  const day = dayKey(m.createdAt);
6021
6024
  if (day && day !== prevDay) {
@@ -7473,6 +7476,9 @@ function allToolPartsSettled(msg) {
7473
7476
  return s === "output-available" || s === "output-error" || s === "output-denied" || s === "approval-responded";
7474
7477
  });
7475
7478
  }
7479
+ function isAbortError(error) {
7480
+ return error instanceof DOMException ? error.name === "AbortError" : error?.name === "AbortError";
7481
+ }
7476
7482
  function App({ options, hostElement, bus }) {
7477
7483
  const [persistence] = useState14(
7478
7484
  () => createPersistence(options.widgetId, options.storage, options.aiAgentDeploymentId)
@@ -7988,11 +7994,19 @@ function App({ options, hostElement, bus }) {
7988
7994
  emitMessage(bus, options, "assistant", assistantText(assistantMsg));
7989
7995
  }
7990
7996
  } catch (error) {
7991
- assistantMsg.status = "error";
7992
- assistantMsg.errorText = errorMessageFor(error, options.strings);
7993
- feedback.play("error");
7994
- bus.emit("error", error);
7995
- options.onError?.(error);
7997
+ if (isAbortError(error)) {
7998
+ if (hasNoVisibleAnswer(assistantMsg)) {
7999
+ messagesSig.value = messagesSig.value.filter((m) => m !== assistantMsg);
8000
+ } else {
8001
+ assistantMsg.status = "complete";
8002
+ }
8003
+ } else {
8004
+ assistantMsg.status = "error";
8005
+ assistantMsg.errorText = errorMessageFor(error, options.strings);
8006
+ feedback.play("error");
8007
+ bus.emit("error", error);
8008
+ options.onError?.(error);
8009
+ }
7996
8010
  } finally {
7997
8011
  reducer.detach();
7998
8012
  setStreaming(false);