@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
|
@@ -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");
|
|
@@ -2048,7 +2097,6 @@ function DebugMenuButton({
|
|
|
2048
2097
|
}
|
|
2049
2098
|
|
|
2050
2099
|
// src/components/chat/Chat.tsx
|
|
2051
|
-
var import_react_core9 = require("@copilotkit/react-core");
|
|
2052
2100
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2053
2101
|
function CopilotChat({
|
|
2054
2102
|
instructions,
|
|
@@ -2056,8 +2104,6 @@ function CopilotChat({
|
|
|
2056
2104
|
makeSystemMessage,
|
|
2057
2105
|
showResponseButton = true,
|
|
2058
2106
|
onInProgress,
|
|
2059
|
-
onStopGeneration,
|
|
2060
|
-
onReloadMessages,
|
|
2061
2107
|
Messages: Messages2 = Messages,
|
|
2062
2108
|
RenderTextMessage: RenderTextMessage2 = RenderTextMessage,
|
|
2063
2109
|
RenderActionExecutionMessage: RenderActionExecutionMessage2 = RenderActionExecutionMessage,
|
|
@@ -2080,13 +2126,7 @@ function CopilotChat({
|
|
|
2080
2126
|
sendMessage,
|
|
2081
2127
|
stopGeneration,
|
|
2082
2128
|
reloadMessages
|
|
2083
|
-
} = useCopilotChatLogic(
|
|
2084
|
-
makeSystemMessage,
|
|
2085
|
-
onInProgress,
|
|
2086
|
-
onSubmitMessage,
|
|
2087
|
-
onStopGeneration,
|
|
2088
|
-
onReloadMessages
|
|
2089
|
-
);
|
|
2129
|
+
} = useCopilotChatLogic(makeSystemMessage, onInProgress, onSubmitMessage);
|
|
2090
2130
|
const chatContext = import_react11.default.useContext(ChatContext);
|
|
2091
2131
|
const isVisible = chatContext ? chatContext.open : true;
|
|
2092
2132
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
|
|
@@ -2142,15 +2182,8 @@ function WrappedCopilotChat({
|
|
|
2142
2182
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children });
|
|
2143
2183
|
}
|
|
2144
2184
|
var SUGGESTIONS_DEBOUNCE_TIMEOUT = 1e3;
|
|
2145
|
-
var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage
|
|
2146
|
-
|
|
2147
|
-
const {
|
|
2148
|
-
visibleMessages,
|
|
2149
|
-
appendMessage,
|
|
2150
|
-
reloadMessages: defaultReloadMessages,
|
|
2151
|
-
stopGeneration: defaultStopGeneration,
|
|
2152
|
-
isLoading
|
|
2153
|
-
} = (0, import_react_core8.useCopilotChat)({
|
|
2185
|
+
var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) => {
|
|
2186
|
+
const { visibleMessages, appendMessage, reloadMessages, stopGeneration, isLoading } = (0, import_react_core8.useCopilotChat)({
|
|
2154
2187
|
id: (0, import_shared3.randomId)(),
|
|
2155
2188
|
makeSystemMessage
|
|
2156
2189
|
});
|
|
@@ -2158,8 +2191,8 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onS
|
|
|
2158
2191
|
const suggestionsAbortControllerRef = (0, import_react11.useRef)(null);
|
|
2159
2192
|
const debounceTimerRef = (0, import_react11.useRef)();
|
|
2160
2193
|
const abortSuggestions = () => {
|
|
2161
|
-
var
|
|
2162
|
-
(
|
|
2194
|
+
var _a;
|
|
2195
|
+
(_a = suggestionsAbortControllerRef.current) == null ? void 0 : _a.abort();
|
|
2163
2196
|
suggestionsAbortControllerRef.current = null;
|
|
2164
2197
|
};
|
|
2165
2198
|
const generalContext = (0, import_react_core8.useCopilotContext)();
|
|
@@ -2185,13 +2218,7 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onS
|
|
|
2185
2218
|
return () => {
|
|
2186
2219
|
clearTimeout(debounceTimerRef.current);
|
|
2187
2220
|
};
|
|
2188
|
-
}, [
|
|
2189
|
-
isLoading,
|
|
2190
|
-
context.chatSuggestionConfiguration,
|
|
2191
|
-
// hackish way to trigger suggestions reload on reset, but better than moving suggestions to the
|
|
2192
|
-
// global context
|
|
2193
|
-
visibleMessages.length == 0
|
|
2194
|
-
]);
|
|
2221
|
+
}, [isLoading, context.chatSuggestionConfiguration]);
|
|
2195
2222
|
const sendMessage = (messageContent) => __async(void 0, null, function* () {
|
|
2196
2223
|
abortSuggestions();
|
|
2197
2224
|
setCurrentSuggestions([]);
|
|
@@ -2209,79 +2236,6 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onS
|
|
|
2209
2236
|
appendMessage(message);
|
|
2210
2237
|
return message;
|
|
2211
2238
|
});
|
|
2212
|
-
const messages = visibleMessages;
|
|
2213
|
-
const { setMessages } = messagesContext;
|
|
2214
|
-
const currentAgentName = (_a = generalContext.agentSession) == null ? void 0 : _a.agentName;
|
|
2215
|
-
const restartCurrentAgent = (hint) => __async(void 0, null, function* () {
|
|
2216
|
-
if (generalContext.agentSession) {
|
|
2217
|
-
generalContext.setAgentSession(__spreadProps(__spreadValues({}, generalContext.agentSession), {
|
|
2218
|
-
nodeName: void 0,
|
|
2219
|
-
threadId: void 0
|
|
2220
|
-
}));
|
|
2221
|
-
generalContext.setCoagentStates((prevAgentStates) => {
|
|
2222
|
-
return __spreadProps(__spreadValues({}, prevAgentStates), {
|
|
2223
|
-
[generalContext.agentSession.agentName]: __spreadProps(__spreadValues({}, prevAgentStates[generalContext.agentSession.agentName]), {
|
|
2224
|
-
threadId: void 0,
|
|
2225
|
-
nodeName: void 0,
|
|
2226
|
-
runId: void 0
|
|
2227
|
-
})
|
|
2228
|
-
});
|
|
2229
|
-
});
|
|
2230
|
-
}
|
|
2231
|
-
});
|
|
2232
|
-
const runCurrentAgent = (hint) => __async(void 0, null, function* () {
|
|
2233
|
-
if (generalContext.agentSession) {
|
|
2234
|
-
yield (0, import_react_core9.runAgent)(generalContext.agentSession.agentName, context, appendMessage, hint);
|
|
2235
|
-
}
|
|
2236
|
-
});
|
|
2237
|
-
const stopCurrentAgent = () => {
|
|
2238
|
-
if (generalContext.agentSession) {
|
|
2239
|
-
(0, import_react_core9.stopAgent)(generalContext.agentSession.agentName, context);
|
|
2240
|
-
}
|
|
2241
|
-
};
|
|
2242
|
-
const setCurrentAgentState = (state) => {
|
|
2243
|
-
if (generalContext.agentSession) {
|
|
2244
|
-
generalContext.setCoagentStates((prevAgentStates) => {
|
|
2245
|
-
return __spreadProps(__spreadValues({}, prevAgentStates), {
|
|
2246
|
-
[generalContext.agentSession.agentName]: {
|
|
2247
|
-
state
|
|
2248
|
-
}
|
|
2249
|
-
});
|
|
2250
|
-
});
|
|
2251
|
-
}
|
|
2252
|
-
};
|
|
2253
|
-
function stopGeneration() {
|
|
2254
|
-
if (onStopGeneration) {
|
|
2255
|
-
onStopGeneration({
|
|
2256
|
-
messages,
|
|
2257
|
-
setMessages,
|
|
2258
|
-
stopGeneration: defaultStopGeneration,
|
|
2259
|
-
currentAgentName,
|
|
2260
|
-
restartCurrentAgent,
|
|
2261
|
-
stopCurrentAgent,
|
|
2262
|
-
runCurrentAgent,
|
|
2263
|
-
setCurrentAgentState
|
|
2264
|
-
});
|
|
2265
|
-
} else {
|
|
2266
|
-
defaultStopGeneration();
|
|
2267
|
-
}
|
|
2268
|
-
}
|
|
2269
|
-
function reloadMessages() {
|
|
2270
|
-
if (onReloadMessages) {
|
|
2271
|
-
onReloadMessages({
|
|
2272
|
-
messages,
|
|
2273
|
-
setMessages,
|
|
2274
|
-
stopGeneration: defaultStopGeneration,
|
|
2275
|
-
currentAgentName,
|
|
2276
|
-
restartCurrentAgent,
|
|
2277
|
-
stopCurrentAgent,
|
|
2278
|
-
runCurrentAgent,
|
|
2279
|
-
setCurrentAgentState
|
|
2280
|
-
});
|
|
2281
|
-
} else {
|
|
2282
|
-
defaultReloadMessages();
|
|
2283
|
-
}
|
|
2284
|
-
}
|
|
2285
2239
|
return {
|
|
2286
2240
|
visibleMessages,
|
|
2287
2241
|
isLoading,
|
|
@@ -2301,8 +2255,6 @@ var CopilotModal = ({
|
|
|
2301
2255
|
hitEscapeToClose = true,
|
|
2302
2256
|
onSetOpen,
|
|
2303
2257
|
onSubmitMessage,
|
|
2304
|
-
onStopGeneration,
|
|
2305
|
-
onReloadMessages,
|
|
2306
2258
|
shortcut = "/",
|
|
2307
2259
|
icons,
|
|
2308
2260
|
labels,
|
|
@@ -2340,8 +2292,6 @@ var CopilotModal = ({
|
|
|
2340
2292
|
{
|
|
2341
2293
|
instructions,
|
|
2342
2294
|
onSubmitMessage,
|
|
2343
|
-
onStopGeneration,
|
|
2344
|
-
onReloadMessages,
|
|
2345
2295
|
makeSystemMessage,
|
|
2346
2296
|
showResponseButton,
|
|
2347
2297
|
onInProgress,
|
|
@@ -2386,7 +2336,7 @@ function CopilotSidebar(props) {
|
|
|
2386
2336
|
|
|
2387
2337
|
// src/hooks/use-copilot-chat-suggestions.tsx
|
|
2388
2338
|
var import_react14 = require("react");
|
|
2389
|
-
var
|
|
2339
|
+
var import_react_core9 = require("@copilotkit/react-core");
|
|
2390
2340
|
var import_shared4 = require("@copilotkit/shared");
|
|
2391
2341
|
function useCopilotChatSuggestions({
|
|
2392
2342
|
instructions,
|
|
@@ -2394,7 +2344,7 @@ function useCopilotChatSuggestions({
|
|
|
2394
2344
|
minSuggestions = 1,
|
|
2395
2345
|
maxSuggestions = 3
|
|
2396
2346
|
}, dependencies = []) {
|
|
2397
|
-
const context = (0,
|
|
2347
|
+
const context = (0, import_react_core9.useCopilotContext)();
|
|
2398
2348
|
(0, import_react14.useEffect)(() => {
|
|
2399
2349
|
const id = (0, import_shared4.randomId)();
|
|
2400
2350
|
context.addChatSuggestionConfiguration(id, {
|