@frankieai/react 0.2.6 → 0.2.7

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
@@ -1183,14 +1183,23 @@ function ChatPanel({
1183
1183
  const theme = useFrankieTheme();
1184
1184
  const { messages, busy, restoring, error, send, stop, reset } = useFrankieChat();
1185
1185
  const scrollRef = useRef4(null);
1186
+ const atBottomRef = useRef4(true);
1186
1187
  const features = config?.features;
1187
1188
  const pickerModels = features?.modelPicker.enabled ? features.modelPicker.models : [];
1188
1189
  const [model, setModel] = useState5(void 0);
1189
1190
  useEffect4(() => {
1190
1191
  const node = scrollRef.current;
1191
1192
  if (!node) return;
1192
- const distanceFromBottom = node.scrollHeight - node.scrollTop - node.clientHeight;
1193
- if (distanceFromBottom < 160) node.scrollTop = node.scrollHeight;
1193
+ const onScroll = () => {
1194
+ atBottomRef.current = node.scrollHeight - node.scrollTop - node.clientHeight < 160;
1195
+ };
1196
+ node.addEventListener("scroll", onScroll, { passive: true });
1197
+ return () => node.removeEventListener("scroll", onScroll);
1198
+ }, []);
1199
+ useEffect4(() => {
1200
+ const node = scrollRef.current;
1201
+ if (!node || !atBottomRef.current) return;
1202
+ node.scrollTop = node.scrollHeight;
1194
1203
  }, [messages]);
1195
1204
  const name = config?.branding.name ?? "Assistant";
1196
1205
  const mode = resolveMode(theme?.mode);