@zero-library/chat-copilot 3.1.24 → 3.1.26

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.esm.js CHANGED
@@ -1379,6 +1379,7 @@ function createChatStore() {
1379
1379
  }
1380
1380
  };
1381
1381
  const conversation = proxy({
1382
+ loading: false,
1382
1383
  /** 当前激活的会话信息 */
1383
1384
  active: {
1384
1385
  id: "",
@@ -1450,6 +1451,7 @@ function createChatStore() {
1450
1451
  if (canProceed === false) {
1451
1452
  throw new Error("\u64CD\u4F5C\u88AB\u963B\u6B62");
1452
1453
  }
1454
+ conversation.loading = true;
1453
1455
  if (!conversation.messages[conversationId]) {
1454
1456
  setInitMessage(conversationId);
1455
1457
  }
@@ -1472,6 +1474,7 @@ function createChatStore() {
1472
1474
  normalizeMessagesByExecutionAndRole(conversation.messages[conversationId].message);
1473
1475
  }
1474
1476
  }
1477
+ conversation.loading = false;
1475
1478
  config.hooks?.onAfterInitMessages?.(conversation.messages[conversationId].message);
1476
1479
  config.hooks?.onAfterInit?.();
1477
1480
  };
@@ -5686,44 +5689,16 @@ var BubbleListItems_default = ({
5686
5689
  return [...welcomeMessageRecord];
5687
5690
  }, [chatRecords, welcomeMessageRecord, firstMessagesRecord]);
5688
5691
  const listRef = useRef(null);
5689
- const autoScrollRef = useRef(true);
5690
- const handleScroll = (el) => {
5691
- const target = el.target;
5692
- const distanceToBottom = target.scrollHeight - target.scrollTop - target.clientHeight;
5693
- autoScrollRef.current = distanceToBottom < 90;
5694
- };
5695
- useEffect(() => {
5696
- const latestMessage = conversationMessages[conversationMessages?.length - 1];
5697
- if (!latestMessage) return;
5698
- if (latestMessage.generating) {
5699
- autoScrollRef.current = true;
5700
- }
5701
- }, [conversationMessages?.length]);
5702
- useEffect(() => {
5703
- const el = listRef.current?.nativeElement;
5704
- if (!el || !bubbleListItems.length) return;
5705
- if (autoScrollRef.current) {
5706
- setTimeout(() => {
5707
- if (autoScrollRef.current) {
5708
- listRef.current?.scrollTo({
5709
- top: "bottom",
5710
- behavior: "instant"
5711
- });
5712
- }
5713
- }, 300);
5714
- }
5715
- }, [bubbleListItems]);
5716
- return /* @__PURE__ */ jsx(A2uiRenderer, { messages: conversationMessages, children: /* @__PURE__ */ jsx(
5692
+ return /* @__PURE__ */ jsx(A2uiRenderer, { messages: conversationMessages, children: /* @__PURE__ */ jsx(Spin, { spinning: conversationState.loading, classNames: { root: "full-spin" }, children: /* @__PURE__ */ jsx(
5717
5693
  Bubble.List,
5718
5694
  {
5719
- autoScroll: false,
5695
+ autoScroll: true,
5720
5696
  ref: listRef,
5721
5697
  items: bubbleListItems,
5722
- className: classNames2(styles_module_default2.bubbleList, "height-full", "scroll-fade-in"),
5723
- onScroll: handleScroll
5698
+ className: classNames2(styles_module_default2.bubbleList, "height-full", "scroll-fade-in")
5724
5699
  },
5725
5700
  conversationState.active.id
5726
- ) });
5701
+ ) }) });
5727
5702
  };
5728
5703
  var { Sider, Content } = Layout;
5729
5704
  var { Title: Title2, Text: Text4 } = Typography;