@copilotkit/react-ui 1.10.5 → 1.10.6-next.0
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 +12 -0
- package/dist/{chunk-QPONDGDJ.mjs → chunk-5HQD6ZPA.mjs} +2 -2
- package/dist/{chunk-DSNTTAJX.mjs → chunk-7HAFY2YK.mjs} +3 -3
- package/dist/{chunk-CGEAG65D.mjs → chunk-ELGRNEAO.mjs} +7 -2
- package/dist/chunk-ELGRNEAO.mjs.map +1 -0
- package/dist/{chunk-K2FLPUR5.mjs → chunk-G7VB7A4O.mjs} +2 -2
- package/dist/{chunk-SDQTGCT2.mjs → chunk-SNGWNZNH.mjs} +2 -2
- package/dist/{chunk-DTRPPNSA.mjs → chunk-ZJCHKHE4.mjs} +2 -2
- package/dist/components/chat/Chat.js +36 -29
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +3 -3
- package/dist/components/chat/Input.js +14 -7
- package/dist/components/chat/Input.js.map +1 -1
- package/dist/components/chat/Input.mjs +2 -2
- package/dist/components/chat/Modal.js +43 -36
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +4 -4
- package/dist/components/chat/Popup.js +43 -36
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +5 -5
- package/dist/components/chat/PoweredByTag.js +6 -1
- package/dist/components/chat/PoweredByTag.js.map +1 -1
- package/dist/components/chat/PoweredByTag.mjs +1 -1
- package/dist/components/chat/Sidebar.js +45 -38
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +5 -5
- package/dist/components/chat/index.js +45 -38
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +6 -6
- package/dist/components/index.js +45 -38
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +6 -6
- package/dist/index.js +47 -40
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -11
- package/package.json +4 -4
- package/src/components/chat/PoweredByTag.tsx +15 -2
- package/dist/chunk-CGEAG65D.mjs.map +0 -1
- /package/dist/{chunk-QPONDGDJ.mjs.map → chunk-5HQD6ZPA.mjs.map} +0 -0
- /package/dist/{chunk-DSNTTAJX.mjs.map → chunk-7HAFY2YK.mjs.map} +0 -0
- /package/dist/{chunk-K2FLPUR5.mjs.map → chunk-G7VB7A4O.mjs.map} +0 -0
- /package/dist/{chunk-SDQTGCT2.mjs.map → chunk-SNGWNZNH.mjs.map} +0 -0
- /package/dist/{chunk-DTRPPNSA.mjs.map → chunk-ZJCHKHE4.mjs.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotPopup
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-5HQD6ZPA.mjs";
|
|
4
|
+
import "../../chunk-7HAFY2YK.mjs";
|
|
5
5
|
import "../../chunk-C3GSYRC3.mjs";
|
|
6
6
|
import "../../chunk-GDSZGYCE.mjs";
|
|
7
7
|
import "../../chunk-V7W6IM2V.mjs";
|
|
@@ -12,12 +12,12 @@ import "../../chunk-KXE2JCUH.mjs";
|
|
|
12
12
|
import "../../chunk-NRA3CFEE.mjs";
|
|
13
13
|
import "../../chunk-BH6PCAAL.mjs";
|
|
14
14
|
import "../../chunk-UFN2VWSR.mjs";
|
|
15
|
-
import "../../chunk-
|
|
15
|
+
import "../../chunk-G7VB7A4O.mjs";
|
|
16
16
|
import "../../chunk-226ZMOE3.mjs";
|
|
17
17
|
import "../../chunk-W26XFBEG.mjs";
|
|
18
18
|
import "../../chunk-PLHTVHUW.mjs";
|
|
19
|
-
import "../../chunk-
|
|
20
|
-
import "../../chunk-
|
|
19
|
+
import "../../chunk-ZJCHKHE4.mjs";
|
|
20
|
+
import "../../chunk-ELGRNEAO.mjs";
|
|
21
21
|
import "../../chunk-QIOJXTIQ.mjs";
|
|
22
22
|
import "../../chunk-W7ONZTSW.mjs";
|
|
23
23
|
import "../../chunk-2LIO4Z3E.mjs";
|
|
@@ -23,6 +23,7 @@ __export(PoweredByTag_exports, {
|
|
|
23
23
|
PoweredByTag: () => PoweredByTag
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(PoweredByTag_exports);
|
|
26
|
+
var import_react = require("react");
|
|
26
27
|
|
|
27
28
|
// src/hooks/use-dark-mode.ts
|
|
28
29
|
var useDarkMode = () => {
|
|
@@ -34,7 +35,11 @@ var useDarkMode = () => {
|
|
|
34
35
|
// src/components/chat/PoweredByTag.tsx
|
|
35
36
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
37
|
function PoweredByTag({ showPoweredBy = true }) {
|
|
38
|
+
const [mounted, setMounted] = (0, import_react.useState)(false);
|
|
37
39
|
const isDark = useDarkMode();
|
|
40
|
+
(0, import_react.useEffect)(() => {
|
|
41
|
+
setMounted(true);
|
|
42
|
+
}, []);
|
|
38
43
|
if (!showPoweredBy) {
|
|
39
44
|
return null;
|
|
40
45
|
}
|
|
@@ -45,7 +50,7 @@ function PoweredByTag({ showPoweredBy = true }) {
|
|
|
45
50
|
textAlign: "center",
|
|
46
51
|
fontSize: "12px",
|
|
47
52
|
padding: "3px 0",
|
|
48
|
-
color: isDark ? "rgb(69, 69, 69)" : "rgb(214, 214, 214)"
|
|
53
|
+
color: mounted && isDark ? "rgb(69, 69, 69)" : "rgb(214, 214, 214)"
|
|
49
54
|
};
|
|
50
55
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "poweredBy", style: poweredByStyle, children: "Powered by CopilotKit" }) });
|
|
51
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/chat/PoweredByTag.tsx","../../../src/hooks/use-dark-mode.ts"],"sourcesContent":["import React from \"react\";\nimport { useDarkMode } from \"../../hooks/use-dark-mode\";\n\nexport function PoweredByTag({ showPoweredBy = true }: { showPoweredBy?: boolean }) {\n const isDark = useDarkMode();\n\n if (!showPoweredBy) {\n return null;\n }\n\n const poweredByStyle = {\n visibility: \"visible\",\n display: \"block\",\n position: \"static\",\n textAlign: \"center\",\n fontSize: \"12px\",\n padding: \"3px 0\",\n color: isDark ? \"rgb(69, 69, 69)\" : \"rgb(214, 214, 214)\",\n };\n\n return (\n <div>\n {/*@ts-expect-error -- expecting position not to be a string, but it can be.*/}\n <p className=\"poweredBy\" style={poweredByStyle}>\n Powered by CopilotKit\n </p>\n </div>\n );\n}\n","export const useDarkMode = () => {\n if (typeof window === \"undefined\") return false;\n return (\n document.documentElement.classList.contains(\"dark\") ||\n document.body.classList.contains(\"dark\") ||\n document.documentElement.getAttribute(\"data-theme\") === \"dark\" ||\n document.body.getAttribute(\"data-theme\") === \"dark\" ||\n window.matchMedia(\"(prefers-color-scheme: dark)\").matches\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;
|
|
1
|
+
{"version":3,"sources":["../../../src/components/chat/PoweredByTag.tsx","../../../src/hooks/use-dark-mode.ts"],"sourcesContent":["import React, { useState, useEffect } from \"react\";\nimport { useDarkMode } from \"../../hooks/use-dark-mode\";\n\nexport function PoweredByTag({ showPoweredBy = true }: { showPoweredBy?: boolean }) {\n const [mounted, setMounted] = useState(false);\n const isDark = useDarkMode();\n\n /*\n note(tylerslaton):\n\n Ensure we only use the isDark computed value after client-side mount.\n This prevents hydration mismatches by using a default color on the\n server and initial client render, then updating to the correct\n dark mode color after hydration is complete.\n */\n useEffect(() => {\n setMounted(true);\n }, []);\n\n if (!showPoweredBy) {\n return null;\n }\n\n const poweredByStyle = {\n visibility: \"visible\",\n display: \"block\",\n position: \"static\",\n textAlign: \"center\",\n fontSize: \"12px\",\n padding: \"3px 0\",\n color: mounted && isDark ? \"rgb(69, 69, 69)\" : \"rgb(214, 214, 214)\",\n };\n\n return (\n <div>\n {/*@ts-expect-error -- expecting position not to be a string, but it can be.*/}\n <p className=\"poweredBy\" style={poweredByStyle}>\n Powered by CopilotKit\n </p>\n </div>\n );\n}\n","export const useDarkMode = () => {\n if (typeof window === \"undefined\") return false;\n return (\n document.documentElement.classList.contains(\"dark\") ||\n document.body.classList.contains(\"dark\") ||\n document.documentElement.getAttribute(\"data-theme\") === \"dark\" ||\n document.body.getAttribute(\"data-theme\") === \"dark\" ||\n window.matchMedia(\"(prefers-color-scheme: dark)\").matches\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA2C;;;ACApC,IAAM,cAAc,MAAM;AAC/B,MAAI,OAAO,WAAW;AAAa,WAAO;AAC1C,SACE,SAAS,gBAAgB,UAAU,SAAS,MAAM,KAClD,SAAS,KAAK,UAAU,SAAS,MAAM,KACvC,SAAS,gBAAgB,aAAa,YAAY,MAAM,UACxD,SAAS,KAAK,aAAa,YAAY,MAAM,UAC7C,OAAO,WAAW,8BAA8B,EAAE;AAEtD;;;AD2BM;AAjCC,SAAS,aAAa,EAAE,gBAAgB,KAAK,GAAgC;AAClF,QAAM,CAAC,SAAS,UAAU,QAAI,uBAAS,KAAK;AAC5C,QAAM,SAAS,YAAY;AAU3B,8BAAU,MAAM;AACd,eAAW,IAAI;AAAA,EACjB,GAAG,CAAC,CAAC;AAEL,MAAI,CAAC,eAAe;AAClB,WAAO;AAAA,EACT;AAEA,QAAM,iBAAiB;AAAA,IACrB,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,UAAU;AAAA,IACV,WAAW;AAAA,IACX,UAAU;AAAA,IACV,SAAS;AAAA,IACT,OAAO,WAAW,SAAS,oBAAoB;AAAA,EACjD;AAEA,SACE,4CAAC,SAEC,sDAAC,OAAE,WAAU,aAAY,OAAO,gBAAgB,mCAEhD,GACF;AAEJ;","names":[]}
|
|
@@ -82,10 +82,10 @@ __export(Sidebar_exports, {
|
|
|
82
82
|
CopilotSidebar: () => CopilotSidebar
|
|
83
83
|
});
|
|
84
84
|
module.exports = __toCommonJS(Sidebar_exports);
|
|
85
|
-
var
|
|
85
|
+
var import_react17 = require("react");
|
|
86
86
|
|
|
87
87
|
// src/components/chat/Modal.tsx
|
|
88
|
-
var
|
|
88
|
+
var import_react16 = __toESM(require("react"));
|
|
89
89
|
|
|
90
90
|
// src/components/chat/ChatContext.tsx
|
|
91
91
|
var import_react = __toESM(require("react"));
|
|
@@ -2037,7 +2037,7 @@ function useScrollToBottom(messages) {
|
|
|
2037
2037
|
}
|
|
2038
2038
|
|
|
2039
2039
|
// src/components/chat/Input.tsx
|
|
2040
|
-
var
|
|
2040
|
+
var import_react14 = require("react");
|
|
2041
2041
|
|
|
2042
2042
|
// src/components/chat/Textarea.tsx
|
|
2043
2043
|
var import_react11 = require("react");
|
|
@@ -2206,6 +2206,9 @@ var usePushToTalk = ({
|
|
|
2206
2206
|
// src/components/chat/Input.tsx
|
|
2207
2207
|
var import_react_core7 = require("@copilotkit/react-core");
|
|
2208
2208
|
|
|
2209
|
+
// src/components/chat/PoweredByTag.tsx
|
|
2210
|
+
var import_react13 = require("react");
|
|
2211
|
+
|
|
2209
2212
|
// src/hooks/use-dark-mode.ts
|
|
2210
2213
|
var useDarkMode = () => {
|
|
2211
2214
|
if (typeof window === "undefined")
|
|
@@ -2216,7 +2219,11 @@ var useDarkMode = () => {
|
|
|
2216
2219
|
// src/components/chat/PoweredByTag.tsx
|
|
2217
2220
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2218
2221
|
function PoweredByTag({ showPoweredBy = true }) {
|
|
2222
|
+
const [mounted, setMounted] = (0, import_react13.useState)(false);
|
|
2219
2223
|
const isDark = useDarkMode();
|
|
2224
|
+
(0, import_react13.useEffect)(() => {
|
|
2225
|
+
setMounted(true);
|
|
2226
|
+
}, []);
|
|
2220
2227
|
if (!showPoweredBy) {
|
|
2221
2228
|
return null;
|
|
2222
2229
|
}
|
|
@@ -2227,7 +2234,7 @@ function PoweredByTag({ showPoweredBy = true }) {
|
|
|
2227
2234
|
textAlign: "center",
|
|
2228
2235
|
fontSize: "12px",
|
|
2229
2236
|
padding: "3px 0",
|
|
2230
|
-
color: isDark ? "rgb(69, 69, 69)" : "rgb(214, 214, 214)"
|
|
2237
|
+
color: mounted && isDark ? "rgb(69, 69, 69)" : "rgb(214, 214, 214)"
|
|
2231
2238
|
};
|
|
2232
2239
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "poweredBy", style: poweredByStyle, children: "Powered by CopilotKit" }) });
|
|
2233
2240
|
}
|
|
@@ -2248,8 +2255,8 @@ var Input = ({
|
|
|
2248
2255
|
const copilotContext = (0, import_react_core7.useCopilotContext)();
|
|
2249
2256
|
const showPoweredBy = !((_a = copilotContext.copilotApiConfig) == null ? void 0 : _a.publicApiKey);
|
|
2250
2257
|
const pushToTalkConfigured = copilotContext.copilotApiConfig.textToSpeechUrl !== void 0 && copilotContext.copilotApiConfig.transcribeAudioUrl !== void 0;
|
|
2251
|
-
const textareaRef = (0,
|
|
2252
|
-
const [isComposing, setIsComposing] = (0,
|
|
2258
|
+
const textareaRef = (0, import_react14.useRef)(null);
|
|
2259
|
+
const [isComposing, setIsComposing] = (0, import_react14.useState)(false);
|
|
2253
2260
|
const handleDivClick = (event) => {
|
|
2254
2261
|
var _a2;
|
|
2255
2262
|
const target = event.target;
|
|
@@ -2259,7 +2266,7 @@ var Input = ({
|
|
|
2259
2266
|
return;
|
|
2260
2267
|
(_a2 = textareaRef.current) == null ? void 0 : _a2.focus();
|
|
2261
2268
|
};
|
|
2262
|
-
const [text, setText] = (0,
|
|
2269
|
+
const [text, setText] = (0, import_react14.useState)("");
|
|
2263
2270
|
const send = () => {
|
|
2264
2271
|
var _a2;
|
|
2265
2272
|
if (inProgress)
|
|
@@ -2275,13 +2282,13 @@ var Input = ({
|
|
|
2275
2282
|
const isInProgress = inProgress || pushToTalkState === "transcribing";
|
|
2276
2283
|
const buttonIcon = isInProgress && !hideStopButton ? context.icons.stopIcon : context.icons.sendIcon;
|
|
2277
2284
|
const showPushToTalk = pushToTalkConfigured && (pushToTalkState === "idle" || pushToTalkState === "recording") && !inProgress;
|
|
2278
|
-
const canSend = (0,
|
|
2285
|
+
const canSend = (0, import_react14.useMemo)(() => {
|
|
2279
2286
|
var _a2;
|
|
2280
2287
|
const interruptEvent = (_a2 = copilotContext.langGraphInterruptAction) == null ? void 0 : _a2.event;
|
|
2281
2288
|
const interruptInProgress = (interruptEvent == null ? void 0 : interruptEvent.name) === "LangGraphInterruptEvent" && !(interruptEvent == null ? void 0 : interruptEvent.response);
|
|
2282
2289
|
return !isInProgress && text.trim().length > 0 && pushToTalkState === "idle" && !interruptInProgress;
|
|
2283
2290
|
}, [(_b = copilotContext.langGraphInterruptAction) == null ? void 0 : _b.event, isInProgress, text, pushToTalkState]);
|
|
2284
|
-
const canStop = (0,
|
|
2291
|
+
const canStop = (0, import_react14.useMemo)(() => {
|
|
2285
2292
|
return isInProgress && !hideStopButton;
|
|
2286
2293
|
}, [isInProgress, hideStopButton]);
|
|
2287
2294
|
const sendDisabled = !canSend && !canStop;
|
|
@@ -2337,7 +2344,7 @@ var Input = ({
|
|
|
2337
2344
|
};
|
|
2338
2345
|
|
|
2339
2346
|
// src/components/chat/Chat.tsx
|
|
2340
|
-
var
|
|
2347
|
+
var import_react15 = __toESM(require("react"));
|
|
2341
2348
|
var import_react_core9 = require("@copilotkit/react-core");
|
|
2342
2349
|
var import_shared3 = require("@copilotkit/shared");
|
|
2343
2350
|
var import_shared4 = require("@copilotkit/shared");
|
|
@@ -2508,10 +2515,10 @@ function CopilotChat({
|
|
|
2508
2515
|
removeInternalErrorHandler
|
|
2509
2516
|
} = (0, import_react_core9.useCopilotContext)();
|
|
2510
2517
|
const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
|
|
2511
|
-
const [selectedImages, setSelectedImages] = (0,
|
|
2512
|
-
const [chatError, setChatError] = (0,
|
|
2513
|
-
const fileInputRef = (0,
|
|
2514
|
-
const triggerObservabilityHook = (0,
|
|
2518
|
+
const [selectedImages, setSelectedImages] = (0, import_react15.useState)([]);
|
|
2519
|
+
const [chatError, setChatError] = (0, import_react15.useState)(null);
|
|
2520
|
+
const fileInputRef = (0, import_react15.useRef)(null);
|
|
2521
|
+
const triggerObservabilityHook = (0, import_react15.useCallback)(
|
|
2515
2522
|
(hookName, ...args) => {
|
|
2516
2523
|
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
2517
2524
|
observabilityHooks[hookName](...args);
|
|
@@ -2530,7 +2537,7 @@ function CopilotChat({
|
|
|
2530
2537
|
},
|
|
2531
2538
|
[publicApiKey, observabilityHooks, setBannerError]
|
|
2532
2539
|
);
|
|
2533
|
-
const triggerChatError = (0,
|
|
2540
|
+
const triggerChatError = (0, import_react15.useCallback)(
|
|
2534
2541
|
(error, operation, originalError) => {
|
|
2535
2542
|
const errorMessage = (error == null ? void 0 : error.message) || (error == null ? void 0 : error.toString()) || "An error occurred";
|
|
2536
2543
|
setChatError({
|
|
@@ -2576,7 +2583,7 @@ function CopilotChat({
|
|
|
2576
2583
|
},
|
|
2577
2584
|
[publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError]
|
|
2578
2585
|
);
|
|
2579
|
-
(0,
|
|
2586
|
+
(0, import_react15.useEffect)(() => {
|
|
2580
2587
|
const id = "chat-component";
|
|
2581
2588
|
setInternalErrorHandler({
|
|
2582
2589
|
[id]: (error) => {
|
|
@@ -2589,7 +2596,7 @@ function CopilotChat({
|
|
|
2589
2596
|
removeInternalErrorHandler == null ? void 0 : removeInternalErrorHandler(id);
|
|
2590
2597
|
};
|
|
2591
2598
|
}, [triggerChatError, setInternalErrorHandler, removeInternalErrorHandler]);
|
|
2592
|
-
(0,
|
|
2599
|
+
(0, import_react15.useEffect)(() => {
|
|
2593
2600
|
if (!imageUploadsEnabled)
|
|
2594
2601
|
return;
|
|
2595
2602
|
const handlePaste = (e) => __async(this, null, function* () {
|
|
@@ -2635,7 +2642,7 @@ function CopilotChat({
|
|
|
2635
2642
|
document.addEventListener("paste", handlePaste);
|
|
2636
2643
|
return () => document.removeEventListener("paste", handlePaste);
|
|
2637
2644
|
}, [imageUploadsEnabled, triggerChatError]);
|
|
2638
|
-
(0,
|
|
2645
|
+
(0, import_react15.useEffect)(() => {
|
|
2639
2646
|
if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
|
|
2640
2647
|
setChatInstructions(instructions || "");
|
|
2641
2648
|
return;
|
|
@@ -2663,8 +2670,8 @@ function CopilotChat({
|
|
|
2663
2670
|
onStopGeneration,
|
|
2664
2671
|
onReloadMessages
|
|
2665
2672
|
);
|
|
2666
|
-
const prevIsLoading = (0,
|
|
2667
|
-
(0,
|
|
2673
|
+
const prevIsLoading = (0, import_react15.useRef)(isLoading);
|
|
2674
|
+
(0, import_react15.useEffect)(() => {
|
|
2668
2675
|
if (prevIsLoading.current !== isLoading) {
|
|
2669
2676
|
if (isLoading) {
|
|
2670
2677
|
triggerObservabilityHook("onChatStarted");
|
|
@@ -2683,7 +2690,7 @@ function CopilotChat({
|
|
|
2683
2690
|
triggerObservabilityHook("onMessageSent", text);
|
|
2684
2691
|
return sendMessage(text, images);
|
|
2685
2692
|
};
|
|
2686
|
-
const chatContext =
|
|
2693
|
+
const chatContext = import_react15.default.useContext(ChatContext);
|
|
2687
2694
|
const isVisible = chatContext ? chatContext.open : true;
|
|
2688
2695
|
const handleRegenerate = (messageId) => {
|
|
2689
2696
|
if (onRegenerate) {
|
|
@@ -2818,7 +2825,7 @@ function WrappedCopilotChat({
|
|
|
2818
2825
|
labels,
|
|
2819
2826
|
className
|
|
2820
2827
|
}) {
|
|
2821
|
-
const chatContext =
|
|
2828
|
+
const chatContext = import_react15.default.useContext(ChatContext);
|
|
2822
2829
|
if (!chatContext) {
|
|
2823
2830
|
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
|
|
2824
2831
|
}, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: `copilotKitChat ${className != null ? className : ""}`, children }) });
|
|
@@ -2847,15 +2854,15 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
2847
2854
|
const generalContext = (0, import_react_core9.useCopilotContext)();
|
|
2848
2855
|
const messagesContext = (0, import_react_core9.useCopilotMessagesContext)();
|
|
2849
2856
|
const { actions } = generalContext;
|
|
2850
|
-
const [suggestionsFailed, setSuggestionsFailed] = (0,
|
|
2851
|
-
const hasGeneratedInitialSuggestions = (0,
|
|
2852
|
-
(0,
|
|
2857
|
+
const [suggestionsFailed, setSuggestionsFailed] = (0, import_react15.useState)(false);
|
|
2858
|
+
const hasGeneratedInitialSuggestions = (0, import_react15.useRef)(false);
|
|
2859
|
+
(0, import_react15.useEffect)(() => {
|
|
2853
2860
|
if (Array.isArray(chatSuggestions)) {
|
|
2854
2861
|
setSuggestions(chatSuggestions);
|
|
2855
2862
|
hasGeneratedInitialSuggestions.current = true;
|
|
2856
2863
|
}
|
|
2857
2864
|
}, [JSON.stringify(chatSuggestions), setSuggestions]);
|
|
2858
|
-
const generateSuggestionsWithErrorHandling = (0,
|
|
2865
|
+
const generateSuggestionsWithErrorHandling = (0, import_react15.useCallback)(
|
|
2859
2866
|
(context) => __async(void 0, null, function* () {
|
|
2860
2867
|
try {
|
|
2861
2868
|
yield generateSuggestions();
|
|
@@ -2866,7 +2873,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
2866
2873
|
}),
|
|
2867
2874
|
[generateSuggestions]
|
|
2868
2875
|
);
|
|
2869
|
-
(0,
|
|
2876
|
+
(0, import_react15.useEffect)(() => {
|
|
2870
2877
|
if (chatSuggestions !== "auto" || isLoadingSuggestions || suggestionsFailed) {
|
|
2871
2878
|
return;
|
|
2872
2879
|
}
|
|
@@ -2896,13 +2903,13 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
2896
2903
|
// Use stable string instead of object reference
|
|
2897
2904
|
generateSuggestionsWithErrorHandling
|
|
2898
2905
|
]);
|
|
2899
|
-
(0,
|
|
2906
|
+
(0, import_react15.useEffect)(() => {
|
|
2900
2907
|
if (chatSuggestions !== "auto") {
|
|
2901
2908
|
hasGeneratedInitialSuggestions.current = false;
|
|
2902
2909
|
setSuggestionsFailed(false);
|
|
2903
2910
|
}
|
|
2904
2911
|
}, [chatSuggestions]);
|
|
2905
|
-
const stableContext = (0,
|
|
2912
|
+
const stableContext = (0, import_react15.useMemo)(
|
|
2906
2913
|
() => __spreadValues(__spreadValues({}, generalContext), messagesContext),
|
|
2907
2914
|
[
|
|
2908
2915
|
// Only include stable dependencies
|
|
@@ -2911,12 +2918,12 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
2911
2918
|
generalContext.isLoading
|
|
2912
2919
|
]
|
|
2913
2920
|
);
|
|
2914
|
-
const resetSuggestions = (0,
|
|
2921
|
+
const resetSuggestions = (0, import_react15.useCallback)(() => {
|
|
2915
2922
|
resetSuggestionsFromHook();
|
|
2916
2923
|
setSuggestionsFailed(false);
|
|
2917
2924
|
hasGeneratedInitialSuggestions.current = false;
|
|
2918
2925
|
}, [resetSuggestionsFromHook]);
|
|
2919
|
-
(0,
|
|
2926
|
+
(0, import_react15.useEffect)(() => {
|
|
2920
2927
|
onInProgress == null ? void 0 : onInProgress(isLoading);
|
|
2921
2928
|
}, [onInProgress, isLoading]);
|
|
2922
2929
|
const safelySendMessage = (messageContent, imagesToUse) => __async(void 0, null, function* () {
|
|
@@ -3089,7 +3096,7 @@ var CopilotModalInner = (_a) => {
|
|
|
3089
3096
|
]);
|
|
3090
3097
|
const { copilotApiConfig, setBannerError } = (0, import_react_core11.useCopilotContext)();
|
|
3091
3098
|
const { publicApiKey } = copilotApiConfig;
|
|
3092
|
-
const triggerObservabilityHook = (0,
|
|
3099
|
+
const triggerObservabilityHook = (0, import_react16.useCallback)(
|
|
3093
3100
|
(hookName, ...args) => {
|
|
3094
3101
|
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
3095
3102
|
observabilityHooks[hookName](...args);
|
|
@@ -3109,8 +3116,8 @@ var CopilotModalInner = (_a) => {
|
|
|
3109
3116
|
[publicApiKey, observabilityHooks, setBannerError]
|
|
3110
3117
|
);
|
|
3111
3118
|
const { open } = useChatContext();
|
|
3112
|
-
const prevOpen = (0,
|
|
3113
|
-
(0,
|
|
3119
|
+
const prevOpen = (0, import_react16.useRef)(open);
|
|
3120
|
+
(0, import_react16.useEffect)(() => {
|
|
3114
3121
|
if (prevOpen.current !== open) {
|
|
3115
3122
|
onSetOpen == null ? void 0 : onSetOpen(open);
|
|
3116
3123
|
if (open) {
|
|
@@ -3121,8 +3128,8 @@ var CopilotModalInner = (_a) => {
|
|
|
3121
3128
|
prevOpen.current = open;
|
|
3122
3129
|
}
|
|
3123
3130
|
}, [open, onSetOpen, triggerObservabilityHook]);
|
|
3124
|
-
const memoizedHeader = (0,
|
|
3125
|
-
const memoizedChildren = (0,
|
|
3131
|
+
const memoizedHeader = (0, import_react16.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Header2, {}), [Header2]);
|
|
3132
|
+
const memoizedChildren = (0, import_react16.useMemo)(() => children, [children]);
|
|
3126
3133
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
|
|
3127
3134
|
memoizedChildren,
|
|
3128
3135
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className, children: [
|
|
@@ -3202,7 +3209,7 @@ var CopilotModal = (_a) => {
|
|
|
3202
3209
|
"children",
|
|
3203
3210
|
"observabilityHooks"
|
|
3204
3211
|
]);
|
|
3205
|
-
const [openState, setOpenState] =
|
|
3212
|
+
const [openState, setOpenState] = import_react16.default.useState(defaultOpen);
|
|
3206
3213
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChatContextProvider, { icons, labels, open: openState, setOpen: setOpenState, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3207
3214
|
CopilotModalInner,
|
|
3208
3215
|
__spreadProps(__spreadValues({
|
|
@@ -3242,7 +3249,7 @@ function CopilotSidebar(props) {
|
|
|
3242
3249
|
props = __spreadProps(__spreadValues({}, props), {
|
|
3243
3250
|
className: props.className ? props.className + " copilotKitSidebar" : "copilotKitSidebar"
|
|
3244
3251
|
});
|
|
3245
|
-
const [expandedClassName, setExpandedClassName] = (0,
|
|
3252
|
+
const [expandedClassName, setExpandedClassName] = (0, import_react17.useState)(
|
|
3246
3253
|
props.defaultOpen ? "sidebarExpanded" : ""
|
|
3247
3254
|
);
|
|
3248
3255
|
const onSetOpen = (open) => {
|