@copilotkit/react-ui 1.3.16-mme-reset-chat.10 → 1.3.16-mme-revert-rxjs-changes.10
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 +9 -53
- package/dist/{chunk-H7LLXN6X.mjs → chunk-H5CXJBR5.mjs} +3 -7
- package/dist/chunk-H5CXJBR5.mjs.map +1 -0
- package/dist/{chunk-P54DK2TL.mjs → chunk-M2NVAJQA.mjs} +2 -2
- package/dist/{chunk-3QOICFXX.mjs → chunk-ORHE7FYT.mjs} +8 -104
- package/dist/chunk-ORHE7FYT.mjs.map +1 -0
- package/dist/{chunk-SEY3XSCD.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.d.ts +5 -50
- package/dist/components/chat/Chat.js +68 -114
- 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.d.ts +1 -1
- package/dist/components/chat/Modal.js +68 -118
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +3 -3
- package/dist/components/chat/Popup.js +68 -118
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +4 -4
- package/dist/components/chat/Sidebar.js +68 -118
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +4 -4
- package/dist/components/chat/index.js +68 -118
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +5 -5
- package/dist/components/index.js +68 -118
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +5 -5
- package/dist/index.js +70 -120
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -5
- package/package.json +7 -7
- package/src/components/chat/Chat.tsx +7 -166
- package/src/components/chat/Messages.tsx +72 -15
- package/src/components/chat/Modal.tsx +0 -4
- package/dist/chunk-3QOICFXX.mjs.map +0 -1
- package/dist/chunk-CPMIEVKK.mjs.map +0 -1
- package/dist/chunk-H7LLXN6X.mjs.map +0 -1
- /package/dist/{chunk-P54DK2TL.mjs.map → chunk-M2NVAJQA.mjs.map} +0 -0
- /package/dist/{chunk-SEY3XSCD.mjs.map → chunk-PY7YBFPA.mjs.map} +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotPopup
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-PY7YBFPA.mjs";
|
|
4
|
+
import "../../chunk-H5CXJBR5.mjs";
|
|
5
5
|
import "../../chunk-YAGE7RCE.mjs";
|
|
6
6
|
import "../../chunk-VEC45H6Q.mjs";
|
|
7
7
|
import "../../chunk-RQNJNK2W.mjs";
|
|
8
|
-
import "../../chunk-
|
|
8
|
+
import "../../chunk-ORHE7FYT.mjs";
|
|
9
9
|
import "../../chunk-V7W6IM2V.mjs";
|
|
10
10
|
import "../../chunk-OMTPWC7T.mjs";
|
|
11
11
|
import "../../chunk-ZABXREBH.mjs";
|
|
@@ -18,7 +18,7 @@ import "../../chunk-OTPAZXVR.mjs";
|
|
|
18
18
|
import "../../chunk-4LUMV4YO.mjs";
|
|
19
19
|
import "../../chunk-YQFVRDNC.mjs";
|
|
20
20
|
import "../../chunk-YQ3D5IQV.mjs";
|
|
21
|
-
import "../../chunk-
|
|
21
|
+
import "../../chunk-RKPANT3F.mjs";
|
|
22
22
|
import "../../chunk-3XAXY2Z3.mjs";
|
|
23
23
|
import "../../chunk-CBBFRI3Q.mjs";
|
|
24
24
|
import "../../chunk-UPTB2MVO.mjs";
|
|
@@ -527,7 +527,7 @@ var Header = ({}) => {
|
|
|
527
527
|
};
|
|
528
528
|
|
|
529
529
|
// src/components/chat/Messages.tsx
|
|
530
|
-
var import_react3 =
|
|
530
|
+
var import_react3 = require("react");
|
|
531
531
|
var import_runtime_client_gql = require("@copilotkit/runtime-client-gql");
|
|
532
532
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
533
533
|
var Messages = ({
|
|
@@ -557,18 +557,8 @@ var Messages = ({
|
|
|
557
557
|
}
|
|
558
558
|
}
|
|
559
559
|
}
|
|
560
|
-
const messagesEndRef =
|
|
561
|
-
|
|
562
|
-
if (messagesEndRef.current) {
|
|
563
|
-
messagesEndRef.current.scrollIntoView({
|
|
564
|
-
behavior: "auto"
|
|
565
|
-
});
|
|
566
|
-
}
|
|
567
|
-
};
|
|
568
|
-
(0, import_react3.useEffect)(() => {
|
|
569
|
-
scrollToBottom();
|
|
570
|
-
}, [messages]);
|
|
571
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "copilotKitMessages", children: [
|
|
560
|
+
const { messagesEndRef, messagesContainerRef } = useScrollToBottom(messages);
|
|
561
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "copilotKitMessages", ref: messagesContainerRef, children: [
|
|
572
562
|
messages.map((message, index) => {
|
|
573
563
|
const isCurrentMessage = index === messages.length - 1;
|
|
574
564
|
if (message.isTextMessage()) {
|
|
@@ -637,6 +627,65 @@ function makeInitialMessages(initial) {
|
|
|
637
627
|
})
|
|
638
628
|
);
|
|
639
629
|
}
|
|
630
|
+
function useScrollToBottom(messages) {
|
|
631
|
+
const messagesEndRef = (0, import_react3.useRef)(null);
|
|
632
|
+
const messagesContainerRef = (0, import_react3.useRef)(null);
|
|
633
|
+
const isProgrammaticScrollRef = (0, import_react3.useRef)(false);
|
|
634
|
+
const isUserScrollUpRef = (0, import_react3.useRef)(false);
|
|
635
|
+
const scrollToBottom = () => {
|
|
636
|
+
if (messagesEndRef.current) {
|
|
637
|
+
isProgrammaticScrollRef.current = true;
|
|
638
|
+
messagesEndRef.current.scrollIntoView({
|
|
639
|
+
behavior: "auto"
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
};
|
|
643
|
+
const handleScroll = () => {
|
|
644
|
+
if (isProgrammaticScrollRef.current) {
|
|
645
|
+
isProgrammaticScrollRef.current = false;
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
if (messagesContainerRef.current) {
|
|
649
|
+
const { scrollTop, scrollHeight, clientHeight } = messagesContainerRef.current;
|
|
650
|
+
isUserScrollUpRef.current = scrollTop + clientHeight < scrollHeight;
|
|
651
|
+
}
|
|
652
|
+
};
|
|
653
|
+
(0, import_react3.useEffect)(() => {
|
|
654
|
+
const container = messagesContainerRef.current;
|
|
655
|
+
if (container) {
|
|
656
|
+
container.addEventListener("scroll", handleScroll);
|
|
657
|
+
}
|
|
658
|
+
return () => {
|
|
659
|
+
if (container) {
|
|
660
|
+
container.removeEventListener("scroll", handleScroll);
|
|
661
|
+
}
|
|
662
|
+
};
|
|
663
|
+
}, []);
|
|
664
|
+
(0, import_react3.useEffect)(() => {
|
|
665
|
+
const container = messagesContainerRef.current;
|
|
666
|
+
if (!container) {
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
const mutationObserver = new MutationObserver(() => {
|
|
670
|
+
if (!isUserScrollUpRef.current) {
|
|
671
|
+
scrollToBottom();
|
|
672
|
+
}
|
|
673
|
+
});
|
|
674
|
+
mutationObserver.observe(container, {
|
|
675
|
+
childList: true,
|
|
676
|
+
subtree: true,
|
|
677
|
+
characterData: true
|
|
678
|
+
});
|
|
679
|
+
return () => {
|
|
680
|
+
mutationObserver.disconnect();
|
|
681
|
+
};
|
|
682
|
+
}, []);
|
|
683
|
+
(0, import_react3.useEffect)(() => {
|
|
684
|
+
isUserScrollUpRef.current = false;
|
|
685
|
+
scrollToBottom();
|
|
686
|
+
}, [messages.filter((m) => m.isTextMessage() && m.role === import_runtime_client_gql.Role.User).length]);
|
|
687
|
+
return { messagesEndRef, messagesContainerRef };
|
|
688
|
+
}
|
|
640
689
|
|
|
641
690
|
// src/components/chat/Input.tsx
|
|
642
691
|
var import_react6 = require("react");
|
|
@@ -2044,7 +2093,6 @@ function DebugMenuButton({
|
|
|
2044
2093
|
}
|
|
2045
2094
|
|
|
2046
2095
|
// src/components/chat/Chat.tsx
|
|
2047
|
-
var import_react_core9 = require("@copilotkit/react-core");
|
|
2048
2096
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2049
2097
|
function CopilotChat({
|
|
2050
2098
|
instructions,
|
|
@@ -2052,8 +2100,6 @@ function CopilotChat({
|
|
|
2052
2100
|
makeSystemMessage,
|
|
2053
2101
|
showResponseButton = true,
|
|
2054
2102
|
onInProgress,
|
|
2055
|
-
onStopGeneration,
|
|
2056
|
-
onReloadMessages,
|
|
2057
2103
|
Messages: Messages2 = Messages,
|
|
2058
2104
|
RenderTextMessage: RenderTextMessage2 = RenderTextMessage,
|
|
2059
2105
|
RenderActionExecutionMessage: RenderActionExecutionMessage2 = RenderActionExecutionMessage,
|
|
@@ -2076,13 +2122,7 @@ function CopilotChat({
|
|
|
2076
2122
|
sendMessage,
|
|
2077
2123
|
stopGeneration,
|
|
2078
2124
|
reloadMessages
|
|
2079
|
-
} = useCopilotChatLogic(
|
|
2080
|
-
makeSystemMessage,
|
|
2081
|
-
onInProgress,
|
|
2082
|
-
onSubmitMessage,
|
|
2083
|
-
onStopGeneration,
|
|
2084
|
-
onReloadMessages
|
|
2085
|
-
);
|
|
2125
|
+
} = useCopilotChatLogic(makeSystemMessage, onInProgress, onSubmitMessage);
|
|
2086
2126
|
const chatContext = import_react11.default.useContext(ChatContext);
|
|
2087
2127
|
const isVisible = chatContext ? chatContext.open : true;
|
|
2088
2128
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
|
|
@@ -2138,15 +2178,8 @@ function WrappedCopilotChat({
|
|
|
2138
2178
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children });
|
|
2139
2179
|
}
|
|
2140
2180
|
var SUGGESTIONS_DEBOUNCE_TIMEOUT = 1e3;
|
|
2141
|
-
var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage
|
|
2142
|
-
|
|
2143
|
-
const {
|
|
2144
|
-
visibleMessages,
|
|
2145
|
-
appendMessage,
|
|
2146
|
-
reloadMessages: defaultReloadMessages,
|
|
2147
|
-
stopGeneration: defaultStopGeneration,
|
|
2148
|
-
isLoading
|
|
2149
|
-
} = (0, import_react_core8.useCopilotChat)({
|
|
2181
|
+
var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) => {
|
|
2182
|
+
const { visibleMessages, appendMessage, reloadMessages, stopGeneration, isLoading } = (0, import_react_core8.useCopilotChat)({
|
|
2150
2183
|
id: (0, import_shared3.randomId)(),
|
|
2151
2184
|
makeSystemMessage
|
|
2152
2185
|
});
|
|
@@ -2154,8 +2187,8 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onS
|
|
|
2154
2187
|
const suggestionsAbortControllerRef = (0, import_react11.useRef)(null);
|
|
2155
2188
|
const debounceTimerRef = (0, import_react11.useRef)();
|
|
2156
2189
|
const abortSuggestions = () => {
|
|
2157
|
-
var
|
|
2158
|
-
(
|
|
2190
|
+
var _a;
|
|
2191
|
+
(_a = suggestionsAbortControllerRef.current) == null ? void 0 : _a.abort();
|
|
2159
2192
|
suggestionsAbortControllerRef.current = null;
|
|
2160
2193
|
};
|
|
2161
2194
|
const generalContext = (0, import_react_core8.useCopilotContext)();
|
|
@@ -2181,13 +2214,7 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onS
|
|
|
2181
2214
|
return () => {
|
|
2182
2215
|
clearTimeout(debounceTimerRef.current);
|
|
2183
2216
|
};
|
|
2184
|
-
}, [
|
|
2185
|
-
isLoading,
|
|
2186
|
-
context.chatSuggestionConfiguration,
|
|
2187
|
-
// hackish way to trigger suggestions reload on reset, but better than moving suggestions to the
|
|
2188
|
-
// global context
|
|
2189
|
-
visibleMessages.length == 0
|
|
2190
|
-
]);
|
|
2217
|
+
}, [isLoading, context.chatSuggestionConfiguration]);
|
|
2191
2218
|
const sendMessage = (messageContent) => __async(void 0, null, function* () {
|
|
2192
2219
|
abortSuggestions();
|
|
2193
2220
|
setCurrentSuggestions([]);
|
|
@@ -2205,79 +2232,6 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onS
|
|
|
2205
2232
|
appendMessage(message);
|
|
2206
2233
|
return message;
|
|
2207
2234
|
});
|
|
2208
|
-
const messages = visibleMessages;
|
|
2209
|
-
const { setMessages } = messagesContext;
|
|
2210
|
-
const currentAgentName = (_a = generalContext.agentSession) == null ? void 0 : _a.agentName;
|
|
2211
|
-
const restartCurrentAgent = (hint) => __async(void 0, null, function* () {
|
|
2212
|
-
if (generalContext.agentSession) {
|
|
2213
|
-
generalContext.setAgentSession(__spreadProps(__spreadValues({}, generalContext.agentSession), {
|
|
2214
|
-
nodeName: void 0,
|
|
2215
|
-
threadId: void 0
|
|
2216
|
-
}));
|
|
2217
|
-
generalContext.setCoagentStates((prevAgentStates) => {
|
|
2218
|
-
return __spreadProps(__spreadValues({}, prevAgentStates), {
|
|
2219
|
-
[generalContext.agentSession.agentName]: __spreadProps(__spreadValues({}, prevAgentStates[generalContext.agentSession.agentName]), {
|
|
2220
|
-
threadId: void 0,
|
|
2221
|
-
nodeName: void 0,
|
|
2222
|
-
runId: void 0
|
|
2223
|
-
})
|
|
2224
|
-
});
|
|
2225
|
-
});
|
|
2226
|
-
}
|
|
2227
|
-
});
|
|
2228
|
-
const runCurrentAgent = (hint) => __async(void 0, null, function* () {
|
|
2229
|
-
if (generalContext.agentSession) {
|
|
2230
|
-
yield (0, import_react_core9.runAgent)(generalContext.agentSession.agentName, context, appendMessage, hint);
|
|
2231
|
-
}
|
|
2232
|
-
});
|
|
2233
|
-
const stopCurrentAgent = () => {
|
|
2234
|
-
if (generalContext.agentSession) {
|
|
2235
|
-
(0, import_react_core9.stopAgent)(generalContext.agentSession.agentName, context);
|
|
2236
|
-
}
|
|
2237
|
-
};
|
|
2238
|
-
const setCurrentAgentState = (state) => {
|
|
2239
|
-
if (generalContext.agentSession) {
|
|
2240
|
-
generalContext.setCoagentStates((prevAgentStates) => {
|
|
2241
|
-
return __spreadProps(__spreadValues({}, prevAgentStates), {
|
|
2242
|
-
[generalContext.agentSession.agentName]: {
|
|
2243
|
-
state
|
|
2244
|
-
}
|
|
2245
|
-
});
|
|
2246
|
-
});
|
|
2247
|
-
}
|
|
2248
|
-
};
|
|
2249
|
-
function stopGeneration() {
|
|
2250
|
-
if (onStopGeneration) {
|
|
2251
|
-
onStopGeneration({
|
|
2252
|
-
messages,
|
|
2253
|
-
setMessages,
|
|
2254
|
-
stopGeneration: defaultStopGeneration,
|
|
2255
|
-
currentAgentName,
|
|
2256
|
-
restartCurrentAgent,
|
|
2257
|
-
stopCurrentAgent,
|
|
2258
|
-
runCurrentAgent,
|
|
2259
|
-
setCurrentAgentState
|
|
2260
|
-
});
|
|
2261
|
-
} else {
|
|
2262
|
-
defaultStopGeneration();
|
|
2263
|
-
}
|
|
2264
|
-
}
|
|
2265
|
-
function reloadMessages() {
|
|
2266
|
-
if (onReloadMessages) {
|
|
2267
|
-
onReloadMessages({
|
|
2268
|
-
messages,
|
|
2269
|
-
setMessages,
|
|
2270
|
-
stopGeneration: defaultStopGeneration,
|
|
2271
|
-
currentAgentName,
|
|
2272
|
-
restartCurrentAgent,
|
|
2273
|
-
stopCurrentAgent,
|
|
2274
|
-
runCurrentAgent,
|
|
2275
|
-
setCurrentAgentState
|
|
2276
|
-
});
|
|
2277
|
-
} else {
|
|
2278
|
-
defaultReloadMessages();
|
|
2279
|
-
}
|
|
2280
|
-
}
|
|
2281
2235
|
return {
|
|
2282
2236
|
visibleMessages,
|
|
2283
2237
|
isLoading,
|
|
@@ -2297,8 +2251,6 @@ var CopilotModal = ({
|
|
|
2297
2251
|
hitEscapeToClose = true,
|
|
2298
2252
|
onSetOpen,
|
|
2299
2253
|
onSubmitMessage,
|
|
2300
|
-
onStopGeneration,
|
|
2301
|
-
onReloadMessages,
|
|
2302
2254
|
shortcut = "/",
|
|
2303
2255
|
icons,
|
|
2304
2256
|
labels,
|
|
@@ -2336,8 +2288,6 @@ var CopilotModal = ({
|
|
|
2336
2288
|
{
|
|
2337
2289
|
instructions,
|
|
2338
2290
|
onSubmitMessage,
|
|
2339
|
-
onStopGeneration,
|
|
2340
|
-
onReloadMessages,
|
|
2341
2291
|
makeSystemMessage,
|
|
2342
2292
|
showResponseButton,
|
|
2343
2293
|
onInProgress,
|