@helpai/elements 0.52.4 → 0.52.6

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.52.4" : "0.0.0-dev";
32
+ var ELEMENTS_VERSION = true ? "0.52.6" : "0.0.0-dev";
33
33
  var ELEMENTS_VERSION_PARAM = "_ev";
34
34
 
35
35
  // src/i18n/strings.ts
@@ -6035,6 +6035,18 @@ function MessageList({
6035
6035
  const distanceFromBottom = el.scrollHeight - el.scrollTop - el.clientHeight;
6036
6036
  if (distanceFromBottom < STICK_THRESHOLD) pinBottom(el);
6037
6037
  }, [messages.value.length]);
6038
+ const prevLastIdRef = useRef5(null);
6039
+ useEffect7(() => {
6040
+ const el = ref.current;
6041
+ const last = messages.value.at(-1);
6042
+ const prevLastId = prevLastIdRef.current;
6043
+ prevLastIdRef.current = last?.id ?? null;
6044
+ if (!el) return;
6045
+ if (!hasHydratedRef.current) return;
6046
+ if (!last || last.id !== prevLastId || last.status !== "streaming") return;
6047
+ detachedRef.current = false;
6048
+ return pinBottomSoon(el, 3);
6049
+ }, [messages.value]);
6038
6050
  useEffect7(() => {
6039
6051
  const el = ref.current;
6040
6052
  if (!el) return;
@@ -6047,8 +6059,7 @@ function MessageList({
6047
6059
  if (distance < STICK_THRESHOLD * 2) pinBottom(el);
6048
6060
  };
6049
6061
  if (last.status !== "streaming") {
6050
- const rafId = requestAnimationFrame(pinIfNear);
6051
- return () => cancelAnimationFrame(rafId);
6062
+ return pinBottomThroughLayout(el, 300);
6052
6063
  }
6053
6064
  pinIfNear();
6054
6065
  const obs = new MutationObserver(pinIfNear);
@@ -8235,6 +8246,7 @@ function App({ options, hostElement, bus }) {
8235
8246
  last.partsSig.value = [...last.partsSig.value];
8236
8247
  if (!allToolPartsSettled(last)) return;
8237
8248
  last.status = "streaming";
8249
+ messagesSig.value = [...messagesSig.value];
8238
8250
  reducer.attach(last);
8239
8251
  void streamAssistant(last, { continueExisting: true });
8240
8252
  },
package/package.json CHANGED
@@ -80,5 +80,5 @@
80
80
  ],
81
81
  "type": "module",
82
82
  "types": "./index.d.ts",
83
- "version": "0.52.4"
83
+ "version": "0.52.6"
84
84
  }
package/web-component.mjs CHANGED
@@ -1790,7 +1790,7 @@ function createAuth(opts) {
1790
1790
  }
1791
1791
 
1792
1792
  // src/core/version.ts
1793
- var ELEMENTS_VERSION = true ? "0.52.4" : "0.0.0-dev";
1793
+ var ELEMENTS_VERSION = true ? "0.52.6" : "0.0.0-dev";
1794
1794
  var ELEMENTS_VERSION_PARAM = "_ev";
1795
1795
 
1796
1796
  // src/stream/types.ts
@@ -5994,6 +5994,18 @@ function MessageList({
5994
5994
  const distanceFromBottom = el.scrollHeight - el.scrollTop - el.clientHeight;
5995
5995
  if (distanceFromBottom < STICK_THRESHOLD) pinBottom(el);
5996
5996
  }, [messages.value.length]);
5997
+ const prevLastIdRef = useRef5(null);
5998
+ useEffect7(() => {
5999
+ const el = ref.current;
6000
+ const last = messages.value.at(-1);
6001
+ const prevLastId = prevLastIdRef.current;
6002
+ prevLastIdRef.current = last?.id ?? null;
6003
+ if (!el) return;
6004
+ if (!hasHydratedRef.current) return;
6005
+ if (!last || last.id !== prevLastId || last.status !== "streaming") return;
6006
+ detachedRef.current = false;
6007
+ return pinBottomSoon(el, 3);
6008
+ }, [messages.value]);
5997
6009
  useEffect7(() => {
5998
6010
  const el = ref.current;
5999
6011
  if (!el) return;
@@ -6006,8 +6018,7 @@ function MessageList({
6006
6018
  if (distance < STICK_THRESHOLD * 2) pinBottom(el);
6007
6019
  };
6008
6020
  if (last.status !== "streaming") {
6009
- const rafId = requestAnimationFrame(pinIfNear);
6010
- return () => cancelAnimationFrame(rafId);
6021
+ return pinBottomThroughLayout(el, 300);
6011
6022
  }
6012
6023
  pinIfNear();
6013
6024
  const obs = new MutationObserver(pinIfNear);
@@ -8194,6 +8205,7 @@ function App({ options, hostElement, bus }) {
8194
8205
  last.partsSig.value = [...last.partsSig.value];
8195
8206
  if (!allToolPartsSettled(last)) return;
8196
8207
  last.status = "streaming";
8208
+ messagesSig.value = [...messagesSig.value];
8197
8209
  reducer.attach(last);
8198
8210
  void streamAssistant(last, { continueExisting: true });
8199
8211
  },