@copilotkit/react-ui 1.4.0-pre-1-4-0.12 → 1.4.0-pre-1-4-0.13
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/CHANGELOG.md +13 -0
- package/dist/{chunk-QK6XA3PL.mjs → chunk-H5CXJBR5.mjs} +3 -3
- package/dist/{chunk-TEZWY2BL.mjs → chunk-M2NVAJQA.mjs} +2 -2
- package/dist/{chunk-C5KOJ3IH.mjs → chunk-ORHE7FYT.mjs} +2 -2
- package/dist/{chunk-OJ5NVSTU.mjs → chunk-PY7YBFPA.mjs} +2 -2
- package/dist/{chunk-CPMIEVKK.mjs → chunk-RKPANT3F.mjs} +65 -15
- package/dist/chunk-RKPANT3F.mjs.map +1 -0
- package/dist/components/chat/Chat.js +62 -13
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +2 -2
- package/dist/components/chat/Messages.d.ts +6 -1
- package/dist/components/chat/Messages.js +66 -15
- package/dist/components/chat/Messages.js.map +1 -1
- package/dist/components/chat/Messages.mjs +5 -3
- package/dist/components/chat/Modal.js +62 -13
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +3 -3
- package/dist/components/chat/Popup.js +62 -13
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +4 -4
- package/dist/components/chat/Sidebar.js +62 -13
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +4 -4
- package/dist/components/chat/index.js +62 -13
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +5 -5
- package/dist/components/index.js +62 -13
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +5 -5
- package/dist/index.js +62 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -5
- package/package.json +7 -7
- package/src/components/chat/Messages.tsx +72 -15
- package/dist/chunk-CPMIEVKK.mjs.map +0 -1
- /package/dist/{chunk-QK6XA3PL.mjs.map → chunk-H5CXJBR5.mjs.map} +0 -0
- /package/dist/{chunk-TEZWY2BL.mjs.map → chunk-M2NVAJQA.mjs.map} +0 -0
- /package/dist/{chunk-C5KOJ3IH.mjs.map → chunk-ORHE7FYT.mjs.map} +0 -0
- /package/dist/{chunk-OJ5NVSTU.mjs.map → chunk-PY7YBFPA.mjs.map} +0 -0
|
@@ -2,18 +2,18 @@ import "../chunk-JD7BAH7U.mjs";
|
|
|
2
2
|
import "../chunk-MRFF7GSQ.mjs";
|
|
3
3
|
import {
|
|
4
4
|
CopilotSidebar
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-M2NVAJQA.mjs";
|
|
6
6
|
import "../chunk-WB3YULQ4.mjs";
|
|
7
7
|
import {
|
|
8
8
|
CopilotPopup
|
|
9
|
-
} from "../chunk-
|
|
10
|
-
import "../chunk-
|
|
9
|
+
} from "../chunk-PY7YBFPA.mjs";
|
|
10
|
+
import "../chunk-H5CXJBR5.mjs";
|
|
11
11
|
import "../chunk-YAGE7RCE.mjs";
|
|
12
12
|
import "../chunk-VEC45H6Q.mjs";
|
|
13
13
|
import "../chunk-RQNJNK2W.mjs";
|
|
14
14
|
import {
|
|
15
15
|
CopilotChat
|
|
16
|
-
} from "../chunk-
|
|
16
|
+
} from "../chunk-ORHE7FYT.mjs";
|
|
17
17
|
import "../chunk-V7W6IM2V.mjs";
|
|
18
18
|
import "../chunk-OMTPWC7T.mjs";
|
|
19
19
|
import "../chunk-ZABXREBH.mjs";
|
|
@@ -26,7 +26,7 @@ import "../chunk-OTPAZXVR.mjs";
|
|
|
26
26
|
import "../chunk-4LUMV4YO.mjs";
|
|
27
27
|
import "../chunk-YQFVRDNC.mjs";
|
|
28
28
|
import "../chunk-YQ3D5IQV.mjs";
|
|
29
|
-
import "../chunk-
|
|
29
|
+
import "../chunk-RKPANT3F.mjs";
|
|
30
30
|
import "../chunk-3XAXY2Z3.mjs";
|
|
31
31
|
import {
|
|
32
32
|
useChatContext
|
package/dist/index.js
CHANGED
|
@@ -531,7 +531,7 @@ var Header = ({}) => {
|
|
|
531
531
|
};
|
|
532
532
|
|
|
533
533
|
// src/components/chat/Messages.tsx
|
|
534
|
-
var import_react3 =
|
|
534
|
+
var import_react3 = require("react");
|
|
535
535
|
var import_runtime_client_gql = require("@copilotkit/runtime-client-gql");
|
|
536
536
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
537
537
|
var Messages = ({
|
|
@@ -561,18 +561,8 @@ var Messages = ({
|
|
|
561
561
|
}
|
|
562
562
|
}
|
|
563
563
|
}
|
|
564
|
-
const messagesEndRef =
|
|
565
|
-
|
|
566
|
-
if (messagesEndRef.current) {
|
|
567
|
-
messagesEndRef.current.scrollIntoView({
|
|
568
|
-
behavior: "auto"
|
|
569
|
-
});
|
|
570
|
-
}
|
|
571
|
-
};
|
|
572
|
-
(0, import_react3.useEffect)(() => {
|
|
573
|
-
scrollToBottom();
|
|
574
|
-
}, [messages]);
|
|
575
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "copilotKitMessages", children: [
|
|
564
|
+
const { messagesEndRef, messagesContainerRef } = useScrollToBottom(messages);
|
|
565
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "copilotKitMessages", ref: messagesContainerRef, children: [
|
|
576
566
|
messages.map((message, index) => {
|
|
577
567
|
const isCurrentMessage = index === messages.length - 1;
|
|
578
568
|
if (message.isTextMessage()) {
|
|
@@ -641,6 +631,65 @@ function makeInitialMessages(initial) {
|
|
|
641
631
|
})
|
|
642
632
|
);
|
|
643
633
|
}
|
|
634
|
+
function useScrollToBottom(messages) {
|
|
635
|
+
const messagesEndRef = (0, import_react3.useRef)(null);
|
|
636
|
+
const messagesContainerRef = (0, import_react3.useRef)(null);
|
|
637
|
+
const isProgrammaticScrollRef = (0, import_react3.useRef)(false);
|
|
638
|
+
const isUserScrollUpRef = (0, import_react3.useRef)(false);
|
|
639
|
+
const scrollToBottom = () => {
|
|
640
|
+
if (messagesEndRef.current) {
|
|
641
|
+
isProgrammaticScrollRef.current = true;
|
|
642
|
+
messagesEndRef.current.scrollIntoView({
|
|
643
|
+
behavior: "auto"
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
};
|
|
647
|
+
const handleScroll = () => {
|
|
648
|
+
if (isProgrammaticScrollRef.current) {
|
|
649
|
+
isProgrammaticScrollRef.current = false;
|
|
650
|
+
return;
|
|
651
|
+
}
|
|
652
|
+
if (messagesContainerRef.current) {
|
|
653
|
+
const { scrollTop, scrollHeight, clientHeight } = messagesContainerRef.current;
|
|
654
|
+
isUserScrollUpRef.current = scrollTop + clientHeight < scrollHeight;
|
|
655
|
+
}
|
|
656
|
+
};
|
|
657
|
+
(0, import_react3.useEffect)(() => {
|
|
658
|
+
const container = messagesContainerRef.current;
|
|
659
|
+
if (container) {
|
|
660
|
+
container.addEventListener("scroll", handleScroll);
|
|
661
|
+
}
|
|
662
|
+
return () => {
|
|
663
|
+
if (container) {
|
|
664
|
+
container.removeEventListener("scroll", handleScroll);
|
|
665
|
+
}
|
|
666
|
+
};
|
|
667
|
+
}, []);
|
|
668
|
+
(0, import_react3.useEffect)(() => {
|
|
669
|
+
const container = messagesContainerRef.current;
|
|
670
|
+
if (!container) {
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
const mutationObserver = new MutationObserver(() => {
|
|
674
|
+
if (!isUserScrollUpRef.current) {
|
|
675
|
+
scrollToBottom();
|
|
676
|
+
}
|
|
677
|
+
});
|
|
678
|
+
mutationObserver.observe(container, {
|
|
679
|
+
childList: true,
|
|
680
|
+
subtree: true,
|
|
681
|
+
characterData: true
|
|
682
|
+
});
|
|
683
|
+
return () => {
|
|
684
|
+
mutationObserver.disconnect();
|
|
685
|
+
};
|
|
686
|
+
}, []);
|
|
687
|
+
(0, import_react3.useEffect)(() => {
|
|
688
|
+
isUserScrollUpRef.current = false;
|
|
689
|
+
scrollToBottom();
|
|
690
|
+
}, [messages.filter((m) => m.isTextMessage() && m.role === import_runtime_client_gql.Role.User).length]);
|
|
691
|
+
return { messagesEndRef, messagesContainerRef };
|
|
692
|
+
}
|
|
644
693
|
|
|
645
694
|
// src/components/chat/Input.tsx
|
|
646
695
|
var import_react6 = require("react");
|