@zero-library/chat-copilot 3.1.26 → 3.1.27

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.cjs.js CHANGED
@@ -2369,7 +2369,7 @@ var ConversationTabPane = ({ items, activeKey, emptyDescription, scrollableTarge
2369
2369
  console2__default.default.log("next");
2370
2370
  },
2371
2371
  loader: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-center", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { indicator: /* @__PURE__ */ jsxRuntime.jsx(icons.RedoOutlined, { spin: true }), size: "small" }) }),
2372
- style: { overflow: "hidden" },
2372
+ style: { overflow: "hidden", padding: "0 10px" },
2373
2373
  scrollableTarget,
2374
2374
  children: /* @__PURE__ */ jsxRuntime.jsx(
2375
2375
  xV2.Conversations,
@@ -5719,13 +5719,41 @@ var BubbleListItems_default = ({
5719
5719
  return [...welcomeMessageRecord];
5720
5720
  }, [chatRecords, welcomeMessageRecord, firstMessagesRecord]);
5721
5721
  const listRef = React10.useRef(null);
5722
+ const autoScrollRef = React10.useRef(true);
5723
+ const handleScroll = (el) => {
5724
+ const target = el.target;
5725
+ const distanceToBottom = target.scrollHeight - target.scrollTop - target.clientHeight;
5726
+ autoScrollRef.current = distanceToBottom < 90;
5727
+ };
5728
+ React10.useEffect(() => {
5729
+ const latestMessage = conversationMessages[conversationMessages?.length - 1];
5730
+ if (!latestMessage) return;
5731
+ if (latestMessage.generating) {
5732
+ autoScrollRef.current = true;
5733
+ }
5734
+ }, [conversationMessages?.length]);
5735
+ React10.useEffect(() => {
5736
+ const el = listRef.current?.nativeElement;
5737
+ if (!el || !bubbleListItems.length) return;
5738
+ if (autoScrollRef.current) {
5739
+ setTimeout(() => {
5740
+ if (autoScrollRef.current) {
5741
+ listRef.current?.scrollTo({
5742
+ top: "bottom",
5743
+ behavior: "instant"
5744
+ });
5745
+ }
5746
+ }, 300);
5747
+ }
5748
+ }, [bubbleListItems]);
5722
5749
  return /* @__PURE__ */ jsxRuntime.jsx(A2uiRenderer, { messages: conversationMessages, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { spinning: conversationState.loading, classNames: { root: "full-spin" }, children: /* @__PURE__ */ jsxRuntime.jsx(
5723
5750
  xV2.Bubble.List,
5724
5751
  {
5725
- autoScroll: true,
5752
+ autoScroll: false,
5726
5753
  ref: listRef,
5727
5754
  items: bubbleListItems,
5728
- className: classNames2__default.default(styles_module_default2.bubbleList, "height-full", "scroll-fade-in")
5755
+ className: classNames2__default.default(styles_module_default2.bubbleList, "height-full", "scroll-fade-in"),
5756
+ onScroll: handleScroll
5729
5757
  },
5730
5758
  conversationState.active.id
5731
5759
  ) }) });