@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
|
CopilotSidebar
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-M2NVAJQA.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";
|
|
@@ -529,7 +529,7 @@ var Header = ({}) => {
|
|
|
529
529
|
};
|
|
530
530
|
|
|
531
531
|
// src/components/chat/Messages.tsx
|
|
532
|
-
var import_react3 =
|
|
532
|
+
var import_react3 = require("react");
|
|
533
533
|
var import_runtime_client_gql = require("@copilotkit/runtime-client-gql");
|
|
534
534
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
535
535
|
var Messages = ({
|
|
@@ -559,18 +559,8 @@ var Messages = ({
|
|
|
559
559
|
}
|
|
560
560
|
}
|
|
561
561
|
}
|
|
562
|
-
const messagesEndRef =
|
|
563
|
-
|
|
564
|
-
if (messagesEndRef.current) {
|
|
565
|
-
messagesEndRef.current.scrollIntoView({
|
|
566
|
-
behavior: "auto"
|
|
567
|
-
});
|
|
568
|
-
}
|
|
569
|
-
};
|
|
570
|
-
(0, import_react3.useEffect)(() => {
|
|
571
|
-
scrollToBottom();
|
|
572
|
-
}, [messages]);
|
|
573
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "copilotKitMessages", children: [
|
|
562
|
+
const { messagesEndRef, messagesContainerRef } = useScrollToBottom(messages);
|
|
563
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "copilotKitMessages", ref: messagesContainerRef, children: [
|
|
574
564
|
messages.map((message, index) => {
|
|
575
565
|
const isCurrentMessage = index === messages.length - 1;
|
|
576
566
|
if (message.isTextMessage()) {
|
|
@@ -639,6 +629,65 @@ function makeInitialMessages(initial) {
|
|
|
639
629
|
})
|
|
640
630
|
);
|
|
641
631
|
}
|
|
632
|
+
function useScrollToBottom(messages) {
|
|
633
|
+
const messagesEndRef = (0, import_react3.useRef)(null);
|
|
634
|
+
const messagesContainerRef = (0, import_react3.useRef)(null);
|
|
635
|
+
const isProgrammaticScrollRef = (0, import_react3.useRef)(false);
|
|
636
|
+
const isUserScrollUpRef = (0, import_react3.useRef)(false);
|
|
637
|
+
const scrollToBottom = () => {
|
|
638
|
+
if (messagesEndRef.current) {
|
|
639
|
+
isProgrammaticScrollRef.current = true;
|
|
640
|
+
messagesEndRef.current.scrollIntoView({
|
|
641
|
+
behavior: "auto"
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
};
|
|
645
|
+
const handleScroll = () => {
|
|
646
|
+
if (isProgrammaticScrollRef.current) {
|
|
647
|
+
isProgrammaticScrollRef.current = false;
|
|
648
|
+
return;
|
|
649
|
+
}
|
|
650
|
+
if (messagesContainerRef.current) {
|
|
651
|
+
const { scrollTop, scrollHeight, clientHeight } = messagesContainerRef.current;
|
|
652
|
+
isUserScrollUpRef.current = scrollTop + clientHeight < scrollHeight;
|
|
653
|
+
}
|
|
654
|
+
};
|
|
655
|
+
(0, import_react3.useEffect)(() => {
|
|
656
|
+
const container = messagesContainerRef.current;
|
|
657
|
+
if (container) {
|
|
658
|
+
container.addEventListener("scroll", handleScroll);
|
|
659
|
+
}
|
|
660
|
+
return () => {
|
|
661
|
+
if (container) {
|
|
662
|
+
container.removeEventListener("scroll", handleScroll);
|
|
663
|
+
}
|
|
664
|
+
};
|
|
665
|
+
}, []);
|
|
666
|
+
(0, import_react3.useEffect)(() => {
|
|
667
|
+
const container = messagesContainerRef.current;
|
|
668
|
+
if (!container) {
|
|
669
|
+
return;
|
|
670
|
+
}
|
|
671
|
+
const mutationObserver = new MutationObserver(() => {
|
|
672
|
+
if (!isUserScrollUpRef.current) {
|
|
673
|
+
scrollToBottom();
|
|
674
|
+
}
|
|
675
|
+
});
|
|
676
|
+
mutationObserver.observe(container, {
|
|
677
|
+
childList: true,
|
|
678
|
+
subtree: true,
|
|
679
|
+
characterData: true
|
|
680
|
+
});
|
|
681
|
+
return () => {
|
|
682
|
+
mutationObserver.disconnect();
|
|
683
|
+
};
|
|
684
|
+
}, []);
|
|
685
|
+
(0, import_react3.useEffect)(() => {
|
|
686
|
+
isUserScrollUpRef.current = false;
|
|
687
|
+
scrollToBottom();
|
|
688
|
+
}, [messages.filter((m) => m.isTextMessage() && m.role === import_runtime_client_gql.Role.User).length]);
|
|
689
|
+
return { messagesEndRef, messagesContainerRef };
|
|
690
|
+
}
|
|
642
691
|
|
|
643
692
|
// src/components/chat/Input.tsx
|
|
644
693
|
var import_react6 = require("react");
|
|
@@ -2046,7 +2095,6 @@ function DebugMenuButton({
|
|
|
2046
2095
|
}
|
|
2047
2096
|
|
|
2048
2097
|
// src/components/chat/Chat.tsx
|
|
2049
|
-
var import_react_core9 = require("@copilotkit/react-core");
|
|
2050
2098
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2051
2099
|
function CopilotChat({
|
|
2052
2100
|
instructions,
|
|
@@ -2054,8 +2102,6 @@ function CopilotChat({
|
|
|
2054
2102
|
makeSystemMessage,
|
|
2055
2103
|
showResponseButton = true,
|
|
2056
2104
|
onInProgress,
|
|
2057
|
-
onStopGeneration,
|
|
2058
|
-
onReloadMessages,
|
|
2059
2105
|
Messages: Messages2 = Messages,
|
|
2060
2106
|
RenderTextMessage: RenderTextMessage2 = RenderTextMessage,
|
|
2061
2107
|
RenderActionExecutionMessage: RenderActionExecutionMessage2 = RenderActionExecutionMessage,
|
|
@@ -2078,13 +2124,7 @@ function CopilotChat({
|
|
|
2078
2124
|
sendMessage,
|
|
2079
2125
|
stopGeneration,
|
|
2080
2126
|
reloadMessages
|
|
2081
|
-
} = useCopilotChatLogic(
|
|
2082
|
-
makeSystemMessage,
|
|
2083
|
-
onInProgress,
|
|
2084
|
-
onSubmitMessage,
|
|
2085
|
-
onStopGeneration,
|
|
2086
|
-
onReloadMessages
|
|
2087
|
-
);
|
|
2127
|
+
} = useCopilotChatLogic(makeSystemMessage, onInProgress, onSubmitMessage);
|
|
2088
2128
|
const chatContext = import_react11.default.useContext(ChatContext);
|
|
2089
2129
|
const isVisible = chatContext ? chatContext.open : true;
|
|
2090
2130
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
|
|
@@ -2140,15 +2180,8 @@ function WrappedCopilotChat({
|
|
|
2140
2180
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children });
|
|
2141
2181
|
}
|
|
2142
2182
|
var SUGGESTIONS_DEBOUNCE_TIMEOUT = 1e3;
|
|
2143
|
-
var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage
|
|
2144
|
-
|
|
2145
|
-
const {
|
|
2146
|
-
visibleMessages,
|
|
2147
|
-
appendMessage,
|
|
2148
|
-
reloadMessages: defaultReloadMessages,
|
|
2149
|
-
stopGeneration: defaultStopGeneration,
|
|
2150
|
-
isLoading
|
|
2151
|
-
} = (0, import_react_core8.useCopilotChat)({
|
|
2183
|
+
var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) => {
|
|
2184
|
+
const { visibleMessages, appendMessage, reloadMessages, stopGeneration, isLoading } = (0, import_react_core8.useCopilotChat)({
|
|
2152
2185
|
id: (0, import_shared3.randomId)(),
|
|
2153
2186
|
makeSystemMessage
|
|
2154
2187
|
});
|
|
@@ -2156,8 +2189,8 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onS
|
|
|
2156
2189
|
const suggestionsAbortControllerRef = (0, import_react11.useRef)(null);
|
|
2157
2190
|
const debounceTimerRef = (0, import_react11.useRef)();
|
|
2158
2191
|
const abortSuggestions = () => {
|
|
2159
|
-
var
|
|
2160
|
-
(
|
|
2192
|
+
var _a;
|
|
2193
|
+
(_a = suggestionsAbortControllerRef.current) == null ? void 0 : _a.abort();
|
|
2161
2194
|
suggestionsAbortControllerRef.current = null;
|
|
2162
2195
|
};
|
|
2163
2196
|
const generalContext = (0, import_react_core8.useCopilotContext)();
|
|
@@ -2183,13 +2216,7 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onS
|
|
|
2183
2216
|
return () => {
|
|
2184
2217
|
clearTimeout(debounceTimerRef.current);
|
|
2185
2218
|
};
|
|
2186
|
-
}, [
|
|
2187
|
-
isLoading,
|
|
2188
|
-
context.chatSuggestionConfiguration,
|
|
2189
|
-
// hackish way to trigger suggestions reload on reset, but better than moving suggestions to the
|
|
2190
|
-
// global context
|
|
2191
|
-
visibleMessages.length == 0
|
|
2192
|
-
]);
|
|
2219
|
+
}, [isLoading, context.chatSuggestionConfiguration]);
|
|
2193
2220
|
const sendMessage = (messageContent) => __async(void 0, null, function* () {
|
|
2194
2221
|
abortSuggestions();
|
|
2195
2222
|
setCurrentSuggestions([]);
|
|
@@ -2207,79 +2234,6 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onS
|
|
|
2207
2234
|
appendMessage(message);
|
|
2208
2235
|
return message;
|
|
2209
2236
|
});
|
|
2210
|
-
const messages = visibleMessages;
|
|
2211
|
-
const { setMessages } = messagesContext;
|
|
2212
|
-
const currentAgentName = (_a = generalContext.agentSession) == null ? void 0 : _a.agentName;
|
|
2213
|
-
const restartCurrentAgent = (hint) => __async(void 0, null, function* () {
|
|
2214
|
-
if (generalContext.agentSession) {
|
|
2215
|
-
generalContext.setAgentSession(__spreadProps(__spreadValues({}, generalContext.agentSession), {
|
|
2216
|
-
nodeName: void 0,
|
|
2217
|
-
threadId: void 0
|
|
2218
|
-
}));
|
|
2219
|
-
generalContext.setCoagentStates((prevAgentStates) => {
|
|
2220
|
-
return __spreadProps(__spreadValues({}, prevAgentStates), {
|
|
2221
|
-
[generalContext.agentSession.agentName]: __spreadProps(__spreadValues({}, prevAgentStates[generalContext.agentSession.agentName]), {
|
|
2222
|
-
threadId: void 0,
|
|
2223
|
-
nodeName: void 0,
|
|
2224
|
-
runId: void 0
|
|
2225
|
-
})
|
|
2226
|
-
});
|
|
2227
|
-
});
|
|
2228
|
-
}
|
|
2229
|
-
});
|
|
2230
|
-
const runCurrentAgent = (hint) => __async(void 0, null, function* () {
|
|
2231
|
-
if (generalContext.agentSession) {
|
|
2232
|
-
yield (0, import_react_core9.runAgent)(generalContext.agentSession.agentName, context, appendMessage, hint);
|
|
2233
|
-
}
|
|
2234
|
-
});
|
|
2235
|
-
const stopCurrentAgent = () => {
|
|
2236
|
-
if (generalContext.agentSession) {
|
|
2237
|
-
(0, import_react_core9.stopAgent)(generalContext.agentSession.agentName, context);
|
|
2238
|
-
}
|
|
2239
|
-
};
|
|
2240
|
-
const setCurrentAgentState = (state) => {
|
|
2241
|
-
if (generalContext.agentSession) {
|
|
2242
|
-
generalContext.setCoagentStates((prevAgentStates) => {
|
|
2243
|
-
return __spreadProps(__spreadValues({}, prevAgentStates), {
|
|
2244
|
-
[generalContext.agentSession.agentName]: {
|
|
2245
|
-
state
|
|
2246
|
-
}
|
|
2247
|
-
});
|
|
2248
|
-
});
|
|
2249
|
-
}
|
|
2250
|
-
};
|
|
2251
|
-
function stopGeneration() {
|
|
2252
|
-
if (onStopGeneration) {
|
|
2253
|
-
onStopGeneration({
|
|
2254
|
-
messages,
|
|
2255
|
-
setMessages,
|
|
2256
|
-
stopGeneration: defaultStopGeneration,
|
|
2257
|
-
currentAgentName,
|
|
2258
|
-
restartCurrentAgent,
|
|
2259
|
-
stopCurrentAgent,
|
|
2260
|
-
runCurrentAgent,
|
|
2261
|
-
setCurrentAgentState
|
|
2262
|
-
});
|
|
2263
|
-
} else {
|
|
2264
|
-
defaultStopGeneration();
|
|
2265
|
-
}
|
|
2266
|
-
}
|
|
2267
|
-
function reloadMessages() {
|
|
2268
|
-
if (onReloadMessages) {
|
|
2269
|
-
onReloadMessages({
|
|
2270
|
-
messages,
|
|
2271
|
-
setMessages,
|
|
2272
|
-
stopGeneration: defaultStopGeneration,
|
|
2273
|
-
currentAgentName,
|
|
2274
|
-
restartCurrentAgent,
|
|
2275
|
-
stopCurrentAgent,
|
|
2276
|
-
runCurrentAgent,
|
|
2277
|
-
setCurrentAgentState
|
|
2278
|
-
});
|
|
2279
|
-
} else {
|
|
2280
|
-
defaultReloadMessages();
|
|
2281
|
-
}
|
|
2282
|
-
}
|
|
2283
2237
|
return {
|
|
2284
2238
|
visibleMessages,
|
|
2285
2239
|
isLoading,
|
|
@@ -2299,8 +2253,6 @@ var CopilotModal = ({
|
|
|
2299
2253
|
hitEscapeToClose = true,
|
|
2300
2254
|
onSetOpen,
|
|
2301
2255
|
onSubmitMessage,
|
|
2302
|
-
onStopGeneration,
|
|
2303
|
-
onReloadMessages,
|
|
2304
2256
|
shortcut = "/",
|
|
2305
2257
|
icons,
|
|
2306
2258
|
labels,
|
|
@@ -2338,8 +2290,6 @@ var CopilotModal = ({
|
|
|
2338
2290
|
{
|
|
2339
2291
|
instructions,
|
|
2340
2292
|
onSubmitMessage,
|
|
2341
|
-
onStopGeneration,
|
|
2342
|
-
onReloadMessages,
|
|
2343
2293
|
makeSystemMessage,
|
|
2344
2294
|
showResponseButton,
|
|
2345
2295
|
onInProgress,
|