@helpai/elements 0.51.7 → 0.51.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.51.7" : "0.0.0-dev";
32
+ var ELEMENTS_VERSION = true ? "0.51.8" : "0.0.0-dev";
33
33
  var ELEMENTS_VERSION_PARAM = "_ev";
34
34
 
35
35
  // src/i18n/strings.ts
@@ -5956,13 +5956,16 @@ function MessageList({
5956
5956
  autoPinAtRef.current = performance.now();
5957
5957
  el.scrollTop = el.scrollHeight;
5958
5958
  };
5959
- const firstMessageId = messages.value[0]?.id;
5960
- useLayoutEffect2(() => {
5961
- const el = ref.current;
5962
- if (!el) return;
5963
- if (messages.value.length === 0) return;
5964
- hasHydratedRef.current = true;
5965
- if (!messages.value.some((m) => m.role === "user")) return;
5959
+ const pinBottomSoon = (el, frames) => {
5960
+ pinBottom(el);
5961
+ let left = frames;
5962
+ const tick = () => {
5963
+ pinBottom(el);
5964
+ if (--left > 0) requestAnimationFrame(tick);
5965
+ };
5966
+ if (frames > 0) requestAnimationFrame(tick);
5967
+ };
5968
+ const pinBottomThroughLayout = (el, ms) => {
5966
5969
  const pinNow = () => pinBottom(el);
5967
5970
  pinNow();
5968
5971
  const resizeObs = new ResizeObserver(pinNow);
@@ -5972,12 +5975,21 @@ function MessageList({
5972
5975
  const timerId = setTimeout(() => {
5973
5976
  resizeObs.disconnect();
5974
5977
  mutationObs.disconnect();
5975
- }, 300);
5978
+ }, ms);
5976
5979
  return () => {
5977
5980
  resizeObs.disconnect();
5978
5981
  mutationObs.disconnect();
5979
5982
  clearTimeout(timerId);
5980
5983
  };
5984
+ };
5985
+ const firstMessageId = messages.value[0]?.id;
5986
+ useLayoutEffect2(() => {
5987
+ const el = ref.current;
5988
+ if (!el) return;
5989
+ if (messages.value.length === 0) return;
5990
+ hasHydratedRef.current = true;
5991
+ if (!messages.value.some((m) => m.role === "user")) return;
5992
+ return pinBottomThroughLayout(el, 300);
5981
5993
  }, [firstMessageId]);
5982
5994
  const prevLengthRef = useRef5(0);
5983
5995
  useEffect7(() => {
@@ -5989,7 +6001,7 @@ function MessageList({
5989
6001
  if (!hasHydratedRef.current) return;
5990
6002
  if (list.slice(prevLength).some((m) => m.role === "user")) {
5991
6003
  detachedRef.current = false;
5992
- pinBottom(el);
6004
+ pinBottomSoon(el, 3);
5993
6005
  return;
5994
6006
  }
5995
6007
  if (!list.some((m) => m.role === "user")) return;
package/package.json CHANGED
@@ -80,5 +80,5 @@
80
80
  ],
81
81
  "type": "module",
82
82
  "types": "./index.d.ts",
83
- "version": "0.51.7"
83
+ "version": "0.51.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.51.7" : "0.0.0-dev";
1797
+ var ELEMENTS_VERSION = true ? "0.51.8" : "0.0.0-dev";
1798
1798
  var ELEMENTS_VERSION_PARAM = "_ev";
1799
1799
 
1800
1800
  // src/stream/types.ts
@@ -5915,13 +5915,16 @@ function MessageList({
5915
5915
  autoPinAtRef.current = performance.now();
5916
5916
  el.scrollTop = el.scrollHeight;
5917
5917
  };
5918
- const firstMessageId = messages.value[0]?.id;
5919
- useLayoutEffect2(() => {
5920
- const el = ref.current;
5921
- if (!el) return;
5922
- if (messages.value.length === 0) return;
5923
- hasHydratedRef.current = true;
5924
- if (!messages.value.some((m) => m.role === "user")) return;
5918
+ const pinBottomSoon = (el, frames) => {
5919
+ pinBottom(el);
5920
+ let left = frames;
5921
+ const tick = () => {
5922
+ pinBottom(el);
5923
+ if (--left > 0) requestAnimationFrame(tick);
5924
+ };
5925
+ if (frames > 0) requestAnimationFrame(tick);
5926
+ };
5927
+ const pinBottomThroughLayout = (el, ms) => {
5925
5928
  const pinNow = () => pinBottom(el);
5926
5929
  pinNow();
5927
5930
  const resizeObs = new ResizeObserver(pinNow);
@@ -5931,12 +5934,21 @@ function MessageList({
5931
5934
  const timerId = setTimeout(() => {
5932
5935
  resizeObs.disconnect();
5933
5936
  mutationObs.disconnect();
5934
- }, 300);
5937
+ }, ms);
5935
5938
  return () => {
5936
5939
  resizeObs.disconnect();
5937
5940
  mutationObs.disconnect();
5938
5941
  clearTimeout(timerId);
5939
5942
  };
5943
+ };
5944
+ const firstMessageId = messages.value[0]?.id;
5945
+ useLayoutEffect2(() => {
5946
+ const el = ref.current;
5947
+ if (!el) return;
5948
+ if (messages.value.length === 0) return;
5949
+ hasHydratedRef.current = true;
5950
+ if (!messages.value.some((m) => m.role === "user")) return;
5951
+ return pinBottomThroughLayout(el, 300);
5940
5952
  }, [firstMessageId]);
5941
5953
  const prevLengthRef = useRef5(0);
5942
5954
  useEffect7(() => {
@@ -5948,7 +5960,7 @@ function MessageList({
5948
5960
  if (!hasHydratedRef.current) return;
5949
5961
  if (list.slice(prevLength).some((m) => m.role === "user")) {
5950
5962
  detachedRef.current = false;
5951
- pinBottom(el);
5963
+ pinBottomSoon(el, 3);
5952
5964
  return;
5953
5965
  }
5954
5966
  if (!list.some((m) => m.role === "user")) return;