@copilotkit/react-ui 1.8.5-next.0 → 1.8.5-next.2
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 +19 -0
- package/dist/{chunk-GOJ36LAI.mjs → chunk-62QMTKMJ.mjs} +2 -2
- package/dist/{chunk-GOJ36LAI.mjs.map → chunk-62QMTKMJ.mjs.map} +1 -1
- package/dist/{chunk-AENUXMIK.mjs → chunk-GOAED4H6.mjs} +3 -3
- package/dist/{chunk-P7S3E5UW.mjs → chunk-HIORSNVD.mjs} +35 -7
- package/dist/chunk-HIORSNVD.mjs.map +1 -0
- package/dist/chunk-JGMFJZMG.mjs +11 -0
- package/dist/chunk-JGMFJZMG.mjs.map +1 -0
- package/dist/{chunk-4LA24FID.mjs → chunk-SMJ3QQCE.mjs} +2 -2
- package/dist/{chunk-6YTN3554.mjs → chunk-X6EFGEBJ.mjs} +2 -2
- package/dist/{chunk-T2MTGCY3.mjs → chunk-ZLRUNNS7.mjs} +12 -11
- package/dist/chunk-ZLRUNNS7.mjs.map +1 -0
- package/dist/components/chat/Chat.d.ts +8 -3
- package/dist/components/chat/Chat.js +8 -7
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +4 -4
- package/dist/components/chat/Modal.js +74 -39
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +7 -6
- package/dist/components/chat/Popup.js +74 -39
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +8 -7
- package/dist/components/chat/Sidebar.js +74 -39
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +8 -7
- package/dist/components/chat/Window.js +39 -5
- package/dist/components/chat/Window.js.map +1 -1
- package/dist/components/chat/Window.mjs +2 -1
- package/dist/components/chat/index.js +74 -39
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +11 -10
- package/dist/components/chat/messages/AssistantMessage.mjs +1 -1
- package/dist/components/chat/messages/RenderActionExecutionMessage.mjs +1 -1
- package/dist/components/chat/messages/RenderAgentStateMessage.mjs +1 -1
- package/dist/components/chat/messages/RenderResultMessage.mjs +1 -1
- package/dist/components/chat/messages/RenderTextMessage.js +1 -1
- package/dist/components/chat/messages/RenderTextMessage.js.map +1 -1
- package/dist/components/chat/messages/RenderTextMessage.mjs +2 -2
- package/dist/components/chat/props.d.ts +2 -2
- package/dist/components/chat/props.js.map +1 -1
- package/dist/components/index.js +74 -39
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +11 -10
- package/dist/hooks/use-dark-mode.d.ts +3 -0
- package/dist/hooks/use-dark-mode.js +35 -0
- package/dist/hooks/use-dark-mode.js.map +1 -0
- package/dist/hooks/use-dark-mode.mjs +8 -0
- package/dist/hooks/use-dark-mode.mjs.map +1 -0
- package/dist/index.css +25 -1
- package/dist/index.css.map +1 -1
- package/dist/index.js +76 -41
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -10
- package/package.json +6 -6
- package/src/components/chat/Chat.tsx +13 -7
- package/src/components/chat/Window.tsx +26 -1
- package/src/components/chat/messages/RenderTextMessage.tsx +1 -1
- package/src/components/chat/props.ts +2 -2
- package/src/css/input.css +1 -1
- package/src/css/window.css +27 -0
- package/src/hooks/use-dark-mode.ts +10 -0
- package/dist/chunk-P7S3E5UW.mjs.map +0 -1
- package/dist/chunk-T2MTGCY3.mjs.map +0 -1
- /package/dist/{chunk-AENUXMIK.mjs.map → chunk-GOAED4H6.mjs.map} +0 -0
- /package/dist/{chunk-4LA24FID.mjs.map → chunk-SMJ3QQCE.mjs.map} +0 -0
- /package/dist/{chunk-6YTN3554.mjs.map → chunk-X6EFGEBJ.mjs.map} +0 -0
|
@@ -2,20 +2,20 @@ import {
|
|
|
2
2
|
CopilotChat,
|
|
3
3
|
WrappedCopilotChat,
|
|
4
4
|
useCopilotChatLogic
|
|
5
|
-
} from "../../chunk-
|
|
5
|
+
} from "../../chunk-ZLRUNNS7.mjs";
|
|
6
|
+
import "../../chunk-Q2YY2NX3.mjs";
|
|
6
7
|
import "../../chunk-WNC6OCIB.mjs";
|
|
7
|
-
import "../../chunk-
|
|
8
|
+
import "../../chunk-62QMTKMJ.mjs";
|
|
8
9
|
import "../../chunk-HEIDCT7I.mjs";
|
|
9
10
|
import "../../chunk-NMNC4ROZ.mjs";
|
|
10
|
-
import "../../chunk-Q2YY2NX3.mjs";
|
|
11
11
|
import "../../chunk-5M7ODWKH.mjs";
|
|
12
12
|
import "../../chunk-TOQ7P4DO.mjs";
|
|
13
13
|
import "../../chunk-QJKMOGWN.mjs";
|
|
14
14
|
import "../../chunk-YQFVRDNC.mjs";
|
|
15
15
|
import "../../chunk-XNQO5AZZ.mjs";
|
|
16
|
+
import "../../chunk-PCTCOQK2.mjs";
|
|
16
17
|
import "../../chunk-ZY25LVYR.mjs";
|
|
17
18
|
import "../../chunk-UN2E3HCK.mjs";
|
|
18
|
-
import "../../chunk-PCTCOQK2.mjs";
|
|
19
19
|
import "../../chunk-ORSMX3SE.mjs";
|
|
20
20
|
import "../../chunk-54JAUBUJ.mjs";
|
|
21
21
|
import "../../chunk-S5MBUNGN.mjs";
|
|
@@ -381,6 +381,16 @@ var ChatContextProvider = ({
|
|
|
381
381
|
|
|
382
382
|
// src/components/chat/Window.tsx
|
|
383
383
|
var import_react2 = __toESM(require("react"));
|
|
384
|
+
var import_react_core = require("@copilotkit/react-core");
|
|
385
|
+
|
|
386
|
+
// src/hooks/use-dark-mode.ts
|
|
387
|
+
var useDarkMode = () => {
|
|
388
|
+
if (typeof window === "undefined")
|
|
389
|
+
return false;
|
|
390
|
+
return document.documentElement.classList.contains("dark") || document.body.classList.contains("dark") || document.documentElement.getAttribute("data-theme") === "dark" || document.body.getAttribute("data-theme") === "dark" || window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
// src/components/chat/Window.tsx
|
|
384
394
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
385
395
|
var Window = ({
|
|
386
396
|
children,
|
|
@@ -388,15 +398,17 @@ var Window = ({
|
|
|
388
398
|
shortcut,
|
|
389
399
|
hitEscapeToClose
|
|
390
400
|
}) => {
|
|
401
|
+
var _a;
|
|
391
402
|
const windowRef = import_react2.default.useRef(null);
|
|
403
|
+
const context = (0, import_react_core.useCopilotContext)();
|
|
392
404
|
const { open, setOpen } = useChatContext();
|
|
393
405
|
const handleClickOutside = (0, import_react2.useCallback)(
|
|
394
406
|
(event) => {
|
|
395
|
-
var
|
|
407
|
+
var _a2;
|
|
396
408
|
if (!clickOutsideToClose) {
|
|
397
409
|
return;
|
|
398
410
|
}
|
|
399
|
-
const parentElement = (
|
|
411
|
+
const parentElement = (_a2 = windowRef.current) == null ? void 0 : _a2.parentElement;
|
|
400
412
|
let className = "";
|
|
401
413
|
if (event.target instanceof HTMLElement) {
|
|
402
414
|
className = event.target.className;
|
|
@@ -410,10 +422,10 @@ var Window = ({
|
|
|
410
422
|
);
|
|
411
423
|
const handleKeyDown = (0, import_react2.useCallback)(
|
|
412
424
|
(event) => {
|
|
413
|
-
var
|
|
425
|
+
var _a2;
|
|
414
426
|
const target = event.target;
|
|
415
427
|
const isInput = target.tagName === "INPUT" || target.tagName === "SELECT" || target.tagName === "TEXTAREA" || target.isContentEditable;
|
|
416
|
-
const isDescendantOfWrapper = (
|
|
428
|
+
const isDescendantOfWrapper = (_a2 = windowRef.current) == null ? void 0 : _a2.contains(target);
|
|
417
429
|
if (open && event.key === "Escape" && (!isInput || isDescendantOfWrapper) && hitEscapeToClose) {
|
|
418
430
|
setOpen(false);
|
|
419
431
|
} else if (event.key === shortcut && (isMacOS() && event.metaKey || !isMacOS() && event.ctrlKey) && (!isInput || isDescendantOfWrapper)) {
|
|
@@ -468,7 +480,29 @@ var Window = ({
|
|
|
468
480
|
}
|
|
469
481
|
};
|
|
470
482
|
}, [adjustForMobile, handleClickOutside, handleKeyDown]);
|
|
471
|
-
|
|
483
|
+
const isDark = useDarkMode();
|
|
484
|
+
const showPoweredBy = !((_a = context.copilotApiConfig) == null ? void 0 : _a.publicApiKey);
|
|
485
|
+
const poweredByStyle = {
|
|
486
|
+
visibility: "visible",
|
|
487
|
+
display: "block",
|
|
488
|
+
position: "static",
|
|
489
|
+
textAlign: "center",
|
|
490
|
+
fontSize: "12px",
|
|
491
|
+
padding: "3px 0",
|
|
492
|
+
color: isDark ? "rgb(69, 69, 69)" : "rgb(214, 214, 214)"
|
|
493
|
+
};
|
|
494
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
495
|
+
"div",
|
|
496
|
+
{
|
|
497
|
+
className: `copilotKitWindow ${showPoweredBy ? " poweredByContainer" : ""} ${open ? " open" : ""}`,
|
|
498
|
+
ref: windowRef,
|
|
499
|
+
children: [
|
|
500
|
+
children,
|
|
501
|
+
showPoweredBy && // @ts-expect-error -- expecting position not to be a string, but it can be.
|
|
502
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "poweredBy", style: poweredByStyle, children: "Powered by CopilotKit" })
|
|
503
|
+
]
|
|
504
|
+
}
|
|
505
|
+
);
|
|
472
506
|
};
|
|
473
507
|
var preventScroll = (event) => {
|
|
474
508
|
let targetElement = event.target;
|
|
@@ -507,7 +541,7 @@ var Button = ({}) => {
|
|
|
507
541
|
};
|
|
508
542
|
|
|
509
543
|
// src/components/dev-console/utils.ts
|
|
510
|
-
var
|
|
544
|
+
var import_react_core2 = require("@copilotkit/react-core");
|
|
511
545
|
function shouldShowDevConsole(showDevConsole) {
|
|
512
546
|
if (typeof showDevConsole === "boolean") {
|
|
513
547
|
return showDevConsole;
|
|
@@ -569,7 +603,7 @@ function getPublishedCopilotKitVersion(current, forceCheck = false) {
|
|
|
569
603
|
}
|
|
570
604
|
function logReadables(context) {
|
|
571
605
|
console.log("%cCurrent Readables:", "font-size: 16px; font-weight: bold;");
|
|
572
|
-
const readables = context.getContextString([],
|
|
606
|
+
const readables = context.getContextString([], import_react_core2.defaultCopilotContextCategories).trim();
|
|
573
607
|
if (readables.length === 0) {
|
|
574
608
|
console.log("No readables found");
|
|
575
609
|
return;
|
|
@@ -639,7 +673,7 @@ function logMessages(context) {
|
|
|
639
673
|
}
|
|
640
674
|
|
|
641
675
|
// src/components/dev-console/console.tsx
|
|
642
|
-
var
|
|
676
|
+
var import_react_core3 = require("@copilotkit/react-core");
|
|
643
677
|
var import_react4 = require("react");
|
|
644
678
|
|
|
645
679
|
// src/components/dev-console/icons.tsx
|
|
@@ -829,7 +863,7 @@ function CopilotKitHelpModal() {
|
|
|
829
863
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
830
864
|
function CopilotDevConsole() {
|
|
831
865
|
const currentVersion = import_shared.COPILOTKIT_VERSION;
|
|
832
|
-
const context = (0,
|
|
866
|
+
const context = (0, import_react_core3.useCopilotContext)();
|
|
833
867
|
const [showDevConsole, setShowDevConsole] = (0, import_react4.useState)(false);
|
|
834
868
|
(0, import_react4.useEffect)(() => {
|
|
835
869
|
setShowDevConsole(shouldShowDevConsole(context.showDevConsole));
|
|
@@ -960,8 +994,8 @@ function DebugMenuButton({
|
|
|
960
994
|
checkForUpdates,
|
|
961
995
|
mode
|
|
962
996
|
}) {
|
|
963
|
-
const context = (0,
|
|
964
|
-
const messagesContext = (0,
|
|
997
|
+
const context = (0, import_react_core3.useCopilotContext)();
|
|
998
|
+
const messagesContext = (0, import_react_core3.useCopilotMessagesContext)();
|
|
965
999
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react5.Menu, { children: [
|
|
966
1000
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
967
1001
|
import_react5.MenuButton,
|
|
@@ -1024,7 +1058,7 @@ var Header = ({}) => {
|
|
|
1024
1058
|
// src/components/chat/Messages.tsx
|
|
1025
1059
|
var import_react6 = require("react");
|
|
1026
1060
|
var import_runtime_client_gql = require("@copilotkit/runtime-client-gql");
|
|
1027
|
-
var
|
|
1061
|
+
var import_react_core4 = require("@copilotkit/react-core");
|
|
1028
1062
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1029
1063
|
var Messages = ({
|
|
1030
1064
|
messages,
|
|
@@ -1060,7 +1094,7 @@ var Messages = ({
|
|
|
1060
1094
|
}
|
|
1061
1095
|
}
|
|
1062
1096
|
const { messagesEndRef, messagesContainerRef } = useScrollToBottom(messages);
|
|
1063
|
-
const interrupt = (0,
|
|
1097
|
+
const interrupt = (0, import_react_core4.useLangGraphInterruptRender)();
|
|
1064
1098
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "copilotKitMessages", ref: messagesContainerRef, children: [
|
|
1065
1099
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "copilotKitMessagesContainer", children: [
|
|
1066
1100
|
messages.map((message, index) => {
|
|
@@ -1258,7 +1292,7 @@ var AutoResizingTextarea = (0, import_react7.forwardRef)(
|
|
|
1258
1292
|
var Textarea_default = AutoResizingTextarea;
|
|
1259
1293
|
|
|
1260
1294
|
// src/hooks/use-push-to-talk.tsx
|
|
1261
|
-
var
|
|
1295
|
+
var import_react_core5 = require("@copilotkit/react-core");
|
|
1262
1296
|
var import_react8 = require("react");
|
|
1263
1297
|
var startRecording = (mediaStreamRef, mediaRecorderRef, audioContextRef, recordedChunks, onStop) => __async(void 0, null, function* () {
|
|
1264
1298
|
if (!mediaStreamRef.current || !audioContextRef.current) {
|
|
@@ -1313,8 +1347,8 @@ var usePushToTalk = ({
|
|
|
1313
1347
|
const audioContextRef = (0, import_react8.useRef)(null);
|
|
1314
1348
|
const mediaRecorderRef = (0, import_react8.useRef)(null);
|
|
1315
1349
|
const recordedChunks = (0, import_react8.useRef)([]);
|
|
1316
|
-
const generalContext = (0,
|
|
1317
|
-
const messagesContext = (0,
|
|
1350
|
+
const generalContext = (0, import_react_core5.useCopilotContext)();
|
|
1351
|
+
const messagesContext = (0, import_react_core5.useCopilotMessagesContext)();
|
|
1318
1352
|
const context = __spreadValues(__spreadValues({}, generalContext), messagesContext);
|
|
1319
1353
|
const [startReadingFromMessageId, setStartReadingFromMessageId] = (0, import_react8.useState)(null);
|
|
1320
1354
|
(0, import_react8.useEffect)(() => {
|
|
@@ -1362,11 +1396,11 @@ var usePushToTalk = ({
|
|
|
1362
1396
|
};
|
|
1363
1397
|
|
|
1364
1398
|
// src/components/chat/Input.tsx
|
|
1365
|
-
var
|
|
1399
|
+
var import_react_core6 = require("@copilotkit/react-core");
|
|
1366
1400
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1367
1401
|
var Input = ({ inProgress, onSend, isVisible = false, onStop }) => {
|
|
1368
1402
|
const context = useChatContext();
|
|
1369
|
-
const copilotContext = (0,
|
|
1403
|
+
const copilotContext = (0, import_react_core6.useCopilotContext)();
|
|
1370
1404
|
const pushToTalkConfigured = copilotContext.copilotApiConfig.textToSpeechUrl !== void 0 && copilotContext.copilotApiConfig.transcribeAudioUrl !== void 0;
|
|
1371
1405
|
const textareaRef = (0, import_react9.useRef)(null);
|
|
1372
1406
|
const handleDivClick = (event) => {
|
|
@@ -2059,7 +2093,7 @@ function RenderTextMessage(_a) {
|
|
|
2059
2093
|
isLoading: inProgress && isCurrentMessage && !message.content,
|
|
2060
2094
|
isGenerating: inProgress && isCurrentMessage && !!message.content,
|
|
2061
2095
|
isCurrentMessage,
|
|
2062
|
-
onRegenerate,
|
|
2096
|
+
onRegenerate: () => onRegenerate == null ? void 0 : onRegenerate(message.id),
|
|
2063
2097
|
onCopy,
|
|
2064
2098
|
onThumbsUp,
|
|
2065
2099
|
onThumbsDown
|
|
@@ -2072,7 +2106,7 @@ function RenderTextMessage(_a) {
|
|
|
2072
2106
|
|
|
2073
2107
|
// src/components/chat/messages/RenderActionExecutionMessage.tsx
|
|
2074
2108
|
var import_runtime_client_gql2 = require("@copilotkit/runtime-client-gql");
|
|
2075
|
-
var
|
|
2109
|
+
var import_react_core7 = require("@copilotkit/react-core");
|
|
2076
2110
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2077
2111
|
function RenderActionExecutionMessage(_a) {
|
|
2078
2112
|
var _b = _a, {
|
|
@@ -2080,7 +2114,7 @@ function RenderActionExecutionMessage(_a) {
|
|
|
2080
2114
|
} = _b, props = __objRest(_b, [
|
|
2081
2115
|
"AssistantMessage"
|
|
2082
2116
|
]);
|
|
2083
|
-
const { chatComponentsCache } = (0,
|
|
2117
|
+
const { chatComponentsCache } = (0, import_react_core7.useCopilotContext)();
|
|
2084
2118
|
const { message, inProgress, index, isCurrentMessage, actionResult } = props;
|
|
2085
2119
|
if (message.isActionExecutionMessage()) {
|
|
2086
2120
|
if (chatComponentsCache.current !== null && (chatComponentsCache.current.actions[message.name] || chatComponentsCache.current.actions["*"])) {
|
|
@@ -2209,7 +2243,7 @@ function RenderResultMessage(_a) {
|
|
|
2209
2243
|
}
|
|
2210
2244
|
|
|
2211
2245
|
// src/components/chat/messages/RenderAgentStateMessage.tsx
|
|
2212
|
-
var
|
|
2246
|
+
var import_react_core8 = require("@copilotkit/react-core");
|
|
2213
2247
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2214
2248
|
function RenderAgentStateMessage(_a) {
|
|
2215
2249
|
var _b = _a, {
|
|
@@ -2217,7 +2251,7 @@ function RenderAgentStateMessage(_a) {
|
|
|
2217
2251
|
} = _b, props = __objRest(_b, [
|
|
2218
2252
|
"AssistantMessage"
|
|
2219
2253
|
]);
|
|
2220
|
-
const { chatComponentsCache } = (0,
|
|
2254
|
+
const { chatComponentsCache } = (0, import_react_core8.useCopilotContext)();
|
|
2221
2255
|
const { message, inProgress, index, isCurrentMessage } = props;
|
|
2222
2256
|
if (message.isAgentStateMessage()) {
|
|
2223
2257
|
let render;
|
|
@@ -2310,7 +2344,7 @@ function RenderAgentStateMessage(_a) {
|
|
|
2310
2344
|
}
|
|
2311
2345
|
|
|
2312
2346
|
// src/components/chat/Suggestion.tsx
|
|
2313
|
-
var
|
|
2347
|
+
var import_react_core9 = require("@copilotkit/react-core");
|
|
2314
2348
|
var import_shared2 = require("@copilotkit/shared");
|
|
2315
2349
|
var import_runtime_client_gql3 = require("@copilotkit/runtime-client-gql");
|
|
2316
2350
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
@@ -2342,7 +2376,7 @@ var reloadSuggestions = (context, chatSuggestionConfiguration, setCurrentSuggest
|
|
|
2342
2376
|
for (const config of Object.values(chatSuggestionConfiguration)) {
|
|
2343
2377
|
try {
|
|
2344
2378
|
const numOfSuggestionsInstructions = config.minSuggestions === 0 ? `Produce up to ${config.maxSuggestions} suggestions. If there are no highly relevant suggestions you can think of, provide an empty array.` : `Produce between ${config.minSuggestions} and ${config.maxSuggestions} suggestions.`;
|
|
2345
|
-
const result = yield (0,
|
|
2379
|
+
const result = yield (0, import_react_core9.extract)({
|
|
2346
2380
|
context,
|
|
2347
2381
|
instructions: "Suggest what the user could say next. Provide clear, highly relevant suggestions. Do not literally suggest function calls. ",
|
|
2348
2382
|
data: config.instructions + "\n\n" + numOfSuggestionsInstructions + "\n\nAvailable tools: " + tools + "\n\n",
|
|
@@ -2401,10 +2435,10 @@ var reloadSuggestions = (context, chatSuggestionConfiguration, setCurrentSuggest
|
|
|
2401
2435
|
|
|
2402
2436
|
// src/components/chat/Chat.tsx
|
|
2403
2437
|
var import_react13 = __toESM(require("react"));
|
|
2404
|
-
var
|
|
2438
|
+
var import_react_core10 = require("@copilotkit/react-core");
|
|
2405
2439
|
var import_runtime_client_gql4 = require("@copilotkit/runtime-client-gql");
|
|
2406
2440
|
var import_shared3 = require("@copilotkit/shared");
|
|
2407
|
-
var
|
|
2441
|
+
var import_react_core11 = require("@copilotkit/react-core");
|
|
2408
2442
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2409
2443
|
function CopilotChat({
|
|
2410
2444
|
instructions,
|
|
@@ -2429,7 +2463,7 @@ function CopilotChat({
|
|
|
2429
2463
|
AssistantMessage: AssistantMessage2 = AssistantMessage,
|
|
2430
2464
|
UserMessage: UserMessage2 = UserMessage
|
|
2431
2465
|
}) {
|
|
2432
|
-
const { additionalInstructions, setChatInstructions } = (0,
|
|
2466
|
+
const { additionalInstructions, setChatInstructions } = (0, import_react_core10.useCopilotContext)();
|
|
2433
2467
|
(0, import_react13.useEffect)(() => {
|
|
2434
2468
|
if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
|
|
2435
2469
|
setChatInstructions(instructions || "");
|
|
@@ -2459,11 +2493,11 @@ function CopilotChat({
|
|
|
2459
2493
|
);
|
|
2460
2494
|
const chatContext = import_react13.default.useContext(ChatContext);
|
|
2461
2495
|
const isVisible = chatContext ? chatContext.open : true;
|
|
2462
|
-
const handleRegenerate = () => {
|
|
2496
|
+
const handleRegenerate = (messageId) => {
|
|
2463
2497
|
if (onRegenerate) {
|
|
2464
|
-
onRegenerate();
|
|
2498
|
+
onRegenerate(messageId);
|
|
2465
2499
|
}
|
|
2466
|
-
reloadMessages();
|
|
2500
|
+
reloadMessages(messageId);
|
|
2467
2501
|
};
|
|
2468
2502
|
const handleCopy = (message) => {
|
|
2469
2503
|
if (onCopy) {
|
|
@@ -2533,7 +2567,7 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onS
|
|
|
2533
2567
|
stopGeneration: defaultStopGeneration,
|
|
2534
2568
|
runChatCompletion,
|
|
2535
2569
|
isLoading
|
|
2536
|
-
} = (0,
|
|
2570
|
+
} = (0, import_react_core10.useCopilotChat)({
|
|
2537
2571
|
id: (0, import_shared3.randomId)(),
|
|
2538
2572
|
makeSystemMessage
|
|
2539
2573
|
});
|
|
@@ -2545,8 +2579,8 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onS
|
|
|
2545
2579
|
(_a2 = suggestionsAbortControllerRef.current) == null ? void 0 : _a2.abort();
|
|
2546
2580
|
suggestionsAbortControllerRef.current = null;
|
|
2547
2581
|
};
|
|
2548
|
-
const generalContext = (0,
|
|
2549
|
-
const messagesContext = (0,
|
|
2582
|
+
const generalContext = (0, import_react_core10.useCopilotContext)();
|
|
2583
|
+
const messagesContext = (0, import_react_core10.useCopilotMessagesContext)();
|
|
2550
2584
|
const context = __spreadValues(__spreadValues({}, generalContext), messagesContext);
|
|
2551
2585
|
(0, import_react13.useEffect)(() => {
|
|
2552
2586
|
onInProgress == null ? void 0 : onInProgress(isLoading);
|
|
@@ -2614,7 +2648,7 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onS
|
|
|
2614
2648
|
});
|
|
2615
2649
|
const runCurrentAgent = (hint) => __async(void 0, null, function* () {
|
|
2616
2650
|
if (generalContext.agentSession) {
|
|
2617
|
-
yield (0,
|
|
2651
|
+
yield (0, import_react_core11.runAgent)(
|
|
2618
2652
|
generalContext.agentSession.agentName,
|
|
2619
2653
|
context,
|
|
2620
2654
|
appendMessage,
|
|
@@ -2625,7 +2659,7 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onS
|
|
|
2625
2659
|
});
|
|
2626
2660
|
const stopCurrentAgent = () => {
|
|
2627
2661
|
if (generalContext.agentSession) {
|
|
2628
|
-
(0,
|
|
2662
|
+
(0, import_react_core11.stopAgent)(generalContext.agentSession.agentName, context);
|
|
2629
2663
|
}
|
|
2630
2664
|
};
|
|
2631
2665
|
const setCurrentAgentState = (state) => {
|
|
@@ -2655,7 +2689,7 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onS
|
|
|
2655
2689
|
defaultStopGeneration();
|
|
2656
2690
|
}
|
|
2657
2691
|
}
|
|
2658
|
-
function reloadMessages() {
|
|
2692
|
+
function reloadMessages(messageId) {
|
|
2659
2693
|
if (onReloadMessages) {
|
|
2660
2694
|
onReloadMessages({
|
|
2661
2695
|
messages,
|
|
@@ -2665,10 +2699,11 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onS
|
|
|
2665
2699
|
restartCurrentAgent,
|
|
2666
2700
|
stopCurrentAgent,
|
|
2667
2701
|
runCurrentAgent,
|
|
2668
|
-
setCurrentAgentState
|
|
2702
|
+
setCurrentAgentState,
|
|
2703
|
+
messageId
|
|
2669
2704
|
});
|
|
2670
2705
|
} else {
|
|
2671
|
-
defaultReloadMessages();
|
|
2706
|
+
defaultReloadMessages(messageId);
|
|
2672
2707
|
}
|
|
2673
2708
|
}
|
|
2674
2709
|
return {
|