@copilotkit/react-ui 1.10.4-next.2 → 1.10.4
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 +23 -0
- package/dist/{chunk-KCRWXHWT.mjs → chunk-DII7M2HW.mjs} +2 -2
- package/dist/{chunk-FJFWH5AF.mjs → chunk-GKIR7J5D.mjs} +7 -7
- package/dist/{chunk-PHH6DYUW.mjs → chunk-NGA4T3VT.mjs} +3 -3
- package/dist/chunk-NGA4T3VT.mjs.map +1 -0
- package/dist/{chunk-Z66Y3KRE.mjs → chunk-NJY6RHHQ.mjs} +8 -11
- package/dist/chunk-NJY6RHHQ.mjs.map +1 -0
- package/dist/{chunk-YO63WHVQ.mjs → chunk-SP2PFXCH.mjs} +2 -2
- package/dist/{chunk-QQDCZRPA.mjs → chunk-TNN2ZGO6.mjs} +2 -2
- package/dist/{chunk-GDSZGYCE.mjs → chunk-V6DDX4LH.mjs} +2 -2
- package/dist/{chunk-FFJHOZX6.mjs → chunk-WBPBTTQD.mjs} +4 -4
- package/dist/{chunk-LJAYSRCB.mjs → chunk-WRQST6DJ.mjs} +4 -4
- package/dist/components/chat/Chat.js +47 -99
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +5 -6
- package/dist/components/chat/Header.mjs +4 -4
- package/dist/components/chat/Messages.js +1 -1
- package/dist/components/chat/Messages.js.map +1 -1
- package/dist/components/chat/Messages.mjs +4 -4
- package/dist/components/chat/Modal.js +61 -113
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +10 -11
- package/dist/components/chat/Popup.js +63 -115
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +11 -12
- package/dist/components/chat/Sidebar.js +65 -117
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +11 -12
- package/dist/components/chat/index.js +67 -119
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +14 -15
- package/dist/components/chat/messages/ErrorMessage.mjs +57 -4
- package/dist/components/chat/messages/ErrorMessage.mjs.map +1 -1
- package/dist/components/chat/messages/LegacyRenderMessage.mjs +3 -3
- package/dist/components/chat/messages/RenderMessage.mjs +2 -2
- package/dist/components/chat/props.d.ts +1 -1
- package/dist/components/chat/props.js.map +1 -1
- package/dist/components/dev-console/console.mjs +3 -3
- package/dist/components/dev-console/index.mjs +4 -4
- package/dist/components/index.js +67 -119
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +15 -16
- package/dist/index.js +69 -121
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -16
- package/package.json +4 -4
- package/src/components/chat/Chat.tsx +1 -2
- package/src/components/chat/Messages.tsx +1 -1
- package/src/components/chat/props.ts +1 -1
- package/dist/chunk-PHH6DYUW.mjs.map +0 -1
- package/dist/chunk-SRY5COHG.mjs +0 -63
- package/dist/chunk-SRY5COHG.mjs.map +0 -1
- package/dist/chunk-Z66Y3KRE.mjs.map +0 -1
- /package/dist/{chunk-KCRWXHWT.mjs.map → chunk-DII7M2HW.mjs.map} +0 -0
- /package/dist/{chunk-FJFWH5AF.mjs.map → chunk-GKIR7J5D.mjs.map} +0 -0
- /package/dist/{chunk-YO63WHVQ.mjs.map → chunk-SP2PFXCH.mjs.map} +0 -0
- /package/dist/{chunk-QQDCZRPA.mjs.map → chunk-TNN2ZGO6.mjs.map} +0 -0
- /package/dist/{chunk-GDSZGYCE.mjs.map → chunk-V6DDX4LH.mjs.map} +0 -0
- /package/dist/{chunk-FFJHOZX6.mjs.map → chunk-WBPBTTQD.mjs.map} +0 -0
- /package/dist/{chunk-LJAYSRCB.mjs.map → chunk-WRQST6DJ.mjs.map} +0 -0
|
@@ -2,30 +2,29 @@ import "../chunk-MMVDU6DF.mjs";
|
|
|
2
2
|
import "../chunk-SC6JRFAJ.mjs";
|
|
3
3
|
import {
|
|
4
4
|
CopilotSidebar
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-DII7M2HW.mjs";
|
|
6
6
|
import "../chunk-WB3YULQ4.mjs";
|
|
7
7
|
import {
|
|
8
8
|
CopilotPopup
|
|
9
|
-
} from "../chunk-
|
|
10
|
-
import "../chunk-
|
|
9
|
+
} from "../chunk-TNN2ZGO6.mjs";
|
|
10
|
+
import "../chunk-GKIR7J5D.mjs";
|
|
11
11
|
import "../chunk-C3GSYRC3.mjs";
|
|
12
|
-
import "../chunk-
|
|
12
|
+
import "../chunk-V6DDX4LH.mjs";
|
|
13
13
|
import "../chunk-V7W6IM2V.mjs";
|
|
14
14
|
import {
|
|
15
15
|
CopilotDevConsole
|
|
16
|
-
} from "../chunk-
|
|
16
|
+
} from "../chunk-WBPBTTQD.mjs";
|
|
17
|
+
import "../chunk-KXE2JCUH.mjs";
|
|
18
|
+
import "../chunk-NRA3CFEE.mjs";
|
|
19
|
+
import "../chunk-BH6PCAAL.mjs";
|
|
17
20
|
import "../chunk-Q5V6S67N.mjs";
|
|
18
21
|
import {
|
|
19
22
|
shouldShowDevConsole
|
|
20
23
|
} from "../chunk-JY2CSDKN.mjs";
|
|
21
|
-
import "../chunk-KXE2JCUH.mjs";
|
|
22
|
-
import "../chunk-NRA3CFEE.mjs";
|
|
23
|
-
import "../chunk-BH6PCAAL.mjs";
|
|
24
24
|
import "../chunk-UFN2VWSR.mjs";
|
|
25
25
|
import {
|
|
26
26
|
CopilotChat
|
|
27
|
-
} from "../chunk-
|
|
28
|
-
import "../chunk-SRY5COHG.mjs";
|
|
27
|
+
} from "../chunk-NJY6RHHQ.mjs";
|
|
29
28
|
import {
|
|
30
29
|
Suggestions
|
|
31
30
|
} from "../chunk-226ZMOE3.mjs";
|
|
@@ -36,18 +35,18 @@ import "../chunk-PLHTVHUW.mjs";
|
|
|
36
35
|
import "../chunk-DTRPPNSA.mjs";
|
|
37
36
|
import "../chunk-CGEAG65D.mjs";
|
|
38
37
|
import "../chunk-QIOJXTIQ.mjs";
|
|
39
|
-
import "../chunk-
|
|
40
|
-
import "../chunk-
|
|
41
|
-
import "../chunk-
|
|
38
|
+
import "../chunk-NGA4T3VT.mjs";
|
|
39
|
+
import "../chunk-SP2PFXCH.mjs";
|
|
40
|
+
import "../chunk-WRQST6DJ.mjs";
|
|
41
|
+
import {
|
|
42
|
+
UserMessage
|
|
43
|
+
} from "../chunk-VVL6JFCJ.mjs";
|
|
42
44
|
import {
|
|
43
45
|
AssistantMessage
|
|
44
46
|
} from "../chunk-X477GDGZ.mjs";
|
|
45
47
|
import {
|
|
46
48
|
ImageRenderer
|
|
47
49
|
} from "../chunk-DBKRAOH7.mjs";
|
|
48
|
-
import {
|
|
49
|
-
UserMessage
|
|
50
|
-
} from "../chunk-VVL6JFCJ.mjs";
|
|
51
50
|
import {
|
|
52
51
|
Markdown
|
|
53
52
|
} from "../chunk-SNFHUE5S.mjs";
|
package/dist/index.js
CHANGED
|
@@ -97,7 +97,7 @@ __export(src_exports, {
|
|
|
97
97
|
module.exports = __toCommonJS(src_exports);
|
|
98
98
|
|
|
99
99
|
// src/components/chat/Modal.tsx
|
|
100
|
-
var
|
|
100
|
+
var import_react15 = __toESM(require("react"));
|
|
101
101
|
|
|
102
102
|
// src/components/chat/ChatContext.tsx
|
|
103
103
|
var import_react = __toESM(require("react"));
|
|
@@ -1885,7 +1885,7 @@ var Messages = ({
|
|
|
1885
1885
|
RenderMessage: RenderMessage2,
|
|
1886
1886
|
AssistantMessage: AssistantMessage2,
|
|
1887
1887
|
UserMessage: UserMessage2,
|
|
1888
|
-
ErrorMessage
|
|
1888
|
+
ErrorMessage,
|
|
1889
1889
|
ImageRenderer: ImageRenderer2,
|
|
1890
1890
|
onRegenerate,
|
|
1891
1891
|
onCopy,
|
|
@@ -1954,7 +1954,7 @@ var Messages = ({
|
|
|
1954
1954
|
);
|
|
1955
1955
|
}),
|
|
1956
1956
|
interrupt,
|
|
1957
|
-
chatError && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1957
|
+
chatError && ErrorMessage && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ErrorMessage, { error: chatError, isCurrentMessage: true })
|
|
1958
1958
|
] }),
|
|
1959
1959
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("footer", { className: "copilotKitMessagesFooter", ref: messagesEndRef, children })
|
|
1960
1960
|
] });
|
|
@@ -2337,67 +2337,15 @@ var Input = ({
|
|
|
2337
2337
|
] });
|
|
2338
2338
|
};
|
|
2339
2339
|
|
|
2340
|
-
// src/components/chat/messages/ErrorMessage.tsx
|
|
2341
|
-
var import_react14 = require("react");
|
|
2342
|
-
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2343
|
-
var ErrorMessage = (props) => {
|
|
2344
|
-
const { icons, labels } = useChatContext();
|
|
2345
|
-
const { error, onRegenerate, onCopy, isCurrentMessage } = props;
|
|
2346
|
-
const [copied, setCopied] = (0, import_react14.useState)(false);
|
|
2347
|
-
const handleCopy = () => {
|
|
2348
|
-
const content = error.message;
|
|
2349
|
-
if (content && onCopy) {
|
|
2350
|
-
navigator.clipboard.writeText(content);
|
|
2351
|
-
setCopied(true);
|
|
2352
|
-
onCopy(content);
|
|
2353
|
-
setTimeout(() => setCopied(false), 2e3);
|
|
2354
|
-
} else if (content) {
|
|
2355
|
-
navigator.clipboard.writeText(content);
|
|
2356
|
-
setCopied(true);
|
|
2357
|
-
setTimeout(() => setCopied(false), 2e3);
|
|
2358
|
-
}
|
|
2359
|
-
};
|
|
2360
|
-
const handleRegenerate = () => {
|
|
2361
|
-
if (onRegenerate)
|
|
2362
|
-
onRegenerate();
|
|
2363
|
-
};
|
|
2364
|
-
console.log(error);
|
|
2365
|
-
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "copilotKitMessage copilotKitAssistantMessage", children: [
|
|
2366
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Markdown, { content: error.message }),
|
|
2367
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: `copilotKitMessageControls ${isCurrentMessage ? "currentMessage" : ""}`, children: [
|
|
2368
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2369
|
-
"button",
|
|
2370
|
-
{
|
|
2371
|
-
className: "copilotKitMessageControlButton",
|
|
2372
|
-
onClick: handleRegenerate,
|
|
2373
|
-
"aria-label": labels.regenerateResponse,
|
|
2374
|
-
title: labels.regenerateResponse,
|
|
2375
|
-
children: icons.regenerateIcon
|
|
2376
|
-
}
|
|
2377
|
-
),
|
|
2378
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2379
|
-
"button",
|
|
2380
|
-
{
|
|
2381
|
-
className: "copilotKitMessageControlButton",
|
|
2382
|
-
onClick: handleCopy,
|
|
2383
|
-
"aria-label": labels.copyToClipboard,
|
|
2384
|
-
title: labels.copyToClipboard,
|
|
2385
|
-
children: copied ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { style: { fontSize: "10px", fontWeight: "bold" }, children: "\u2713" }) : icons.copyIcon
|
|
2386
|
-
}
|
|
2387
|
-
)
|
|
2388
|
-
] })
|
|
2389
|
-
] });
|
|
2390
|
-
};
|
|
2391
|
-
|
|
2392
2340
|
// src/components/chat/Chat.tsx
|
|
2393
|
-
var
|
|
2341
|
+
var import_react14 = __toESM(require("react"));
|
|
2394
2342
|
var import_react_core9 = require("@copilotkit/react-core");
|
|
2395
2343
|
var import_shared3 = require("@copilotkit/shared");
|
|
2396
2344
|
var import_shared4 = require("@copilotkit/shared");
|
|
2397
2345
|
var import_react_core10 = require("@copilotkit/react-core");
|
|
2398
2346
|
|
|
2399
2347
|
// src/components/chat/ImageUploadQueue.tsx
|
|
2400
|
-
var
|
|
2348
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2401
2349
|
var ImageUploadQueue = ({
|
|
2402
2350
|
images,
|
|
2403
2351
|
onRemoveImage,
|
|
@@ -2405,7 +2353,7 @@ var ImageUploadQueue = ({
|
|
|
2405
2353
|
}) => {
|
|
2406
2354
|
if (images.length === 0)
|
|
2407
2355
|
return null;
|
|
2408
|
-
return /* @__PURE__ */ (0,
|
|
2356
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2409
2357
|
"div",
|
|
2410
2358
|
{
|
|
2411
2359
|
className: `copilotKitImageUploadQueue ${className}`,
|
|
@@ -2416,7 +2364,7 @@ var ImageUploadQueue = ({
|
|
|
2416
2364
|
margin: "8px",
|
|
2417
2365
|
padding: "8px"
|
|
2418
2366
|
},
|
|
2419
|
-
children: images.map((image, index) => /* @__PURE__ */ (0,
|
|
2367
|
+
children: images.map((image, index) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
2420
2368
|
"div",
|
|
2421
2369
|
{
|
|
2422
2370
|
className: "copilotKitImageUploadQueueItem",
|
|
@@ -2429,7 +2377,7 @@ var ImageUploadQueue = ({
|
|
|
2429
2377
|
overflow: "hidden"
|
|
2430
2378
|
},
|
|
2431
2379
|
children: [
|
|
2432
|
-
/* @__PURE__ */ (0,
|
|
2380
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2433
2381
|
"img",
|
|
2434
2382
|
{
|
|
2435
2383
|
src: `data:${image.contentType};base64,${image.bytes}`,
|
|
@@ -2441,7 +2389,7 @@ var ImageUploadQueue = ({
|
|
|
2441
2389
|
}
|
|
2442
2390
|
}
|
|
2443
2391
|
),
|
|
2444
|
-
/* @__PURE__ */ (0,
|
|
2392
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2445
2393
|
"button",
|
|
2446
2394
|
{
|
|
2447
2395
|
onClick: () => onRemoveImage(index),
|
|
@@ -2476,12 +2424,12 @@ var ImageUploadQueue = ({
|
|
|
2476
2424
|
|
|
2477
2425
|
// src/components/chat/Suggestion.tsx
|
|
2478
2426
|
var import_react_core8 = require("@copilotkit/react-core");
|
|
2479
|
-
var
|
|
2427
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2480
2428
|
function Suggestion({ title, onClick, partial, className }) {
|
|
2481
2429
|
if (!title)
|
|
2482
2430
|
return null;
|
|
2483
2431
|
const { isLoading } = (0, import_react_core8.useCopilotChatInternal)();
|
|
2484
|
-
return /* @__PURE__ */ (0,
|
|
2432
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2485
2433
|
"button",
|
|
2486
2434
|
{
|
|
2487
2435
|
disabled: partial || isLoading,
|
|
@@ -2491,15 +2439,15 @@ function Suggestion({ title, onClick, partial, className }) {
|
|
|
2491
2439
|
},
|
|
2492
2440
|
className: className || (partial ? "suggestion loading" : "suggestion"),
|
|
2493
2441
|
"data-test-id": "suggestion",
|
|
2494
|
-
children: partial ? SmallSpinnerIcon : /* @__PURE__ */ (0,
|
|
2442
|
+
children: partial ? SmallSpinnerIcon : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { children: title })
|
|
2495
2443
|
}
|
|
2496
2444
|
);
|
|
2497
2445
|
}
|
|
2498
2446
|
|
|
2499
2447
|
// src/components/chat/Suggestions.tsx
|
|
2500
|
-
var
|
|
2448
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
2501
2449
|
function Suggestions({ suggestions, onSuggestionClick }) {
|
|
2502
|
-
return /* @__PURE__ */ (0,
|
|
2450
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "suggestions", children: suggestions.map((suggestion, index) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2503
2451
|
Suggestion,
|
|
2504
2452
|
{
|
|
2505
2453
|
title: suggestion.title,
|
|
@@ -2513,7 +2461,7 @@ function Suggestions({ suggestions, onSuggestionClick }) {
|
|
|
2513
2461
|
}
|
|
2514
2462
|
|
|
2515
2463
|
// src/components/chat/Chat.tsx
|
|
2516
|
-
var
|
|
2464
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2517
2465
|
function CopilotChat({
|
|
2518
2466
|
instructions,
|
|
2519
2467
|
suggestions = "auto",
|
|
@@ -2538,7 +2486,7 @@ function CopilotChat({
|
|
|
2538
2486
|
AssistantMessage: AssistantMessage2 = AssistantMessage,
|
|
2539
2487
|
UserMessage: UserMessage2 = UserMessage,
|
|
2540
2488
|
ImageRenderer: ImageRenderer2 = ImageRenderer,
|
|
2541
|
-
ErrorMessage
|
|
2489
|
+
ErrorMessage,
|
|
2542
2490
|
imageUploadsEnabled,
|
|
2543
2491
|
inputFileAccept = "image/*",
|
|
2544
2492
|
hideStopButton,
|
|
@@ -2561,10 +2509,10 @@ function CopilotChat({
|
|
|
2561
2509
|
removeInternalErrorHandler
|
|
2562
2510
|
} = (0, import_react_core9.useCopilotContext)();
|
|
2563
2511
|
const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
|
|
2564
|
-
const [selectedImages, setSelectedImages] = (0,
|
|
2565
|
-
const [chatError, setChatError] = (0,
|
|
2566
|
-
const fileInputRef = (0,
|
|
2567
|
-
const triggerObservabilityHook = (0,
|
|
2512
|
+
const [selectedImages, setSelectedImages] = (0, import_react14.useState)([]);
|
|
2513
|
+
const [chatError, setChatError] = (0, import_react14.useState)(null);
|
|
2514
|
+
const fileInputRef = (0, import_react14.useRef)(null);
|
|
2515
|
+
const triggerObservabilityHook = (0, import_react14.useCallback)(
|
|
2568
2516
|
(hookName, ...args) => {
|
|
2569
2517
|
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
2570
2518
|
observabilityHooks[hookName](...args);
|
|
@@ -2583,7 +2531,7 @@ function CopilotChat({
|
|
|
2583
2531
|
},
|
|
2584
2532
|
[publicApiKey, observabilityHooks, setBannerError]
|
|
2585
2533
|
);
|
|
2586
|
-
const triggerChatError = (0,
|
|
2534
|
+
const triggerChatError = (0, import_react14.useCallback)(
|
|
2587
2535
|
(error, operation, originalError) => {
|
|
2588
2536
|
const errorMessage = (error == null ? void 0 : error.message) || (error == null ? void 0 : error.toString()) || "An error occurred";
|
|
2589
2537
|
setChatError({
|
|
@@ -2629,7 +2577,7 @@ function CopilotChat({
|
|
|
2629
2577
|
},
|
|
2630
2578
|
[publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError]
|
|
2631
2579
|
);
|
|
2632
|
-
(0,
|
|
2580
|
+
(0, import_react14.useEffect)(() => {
|
|
2633
2581
|
const id = "chat-component";
|
|
2634
2582
|
setInternalErrorHandler({
|
|
2635
2583
|
[id]: (error) => {
|
|
@@ -2642,7 +2590,7 @@ function CopilotChat({
|
|
|
2642
2590
|
removeInternalErrorHandler == null ? void 0 : removeInternalErrorHandler(id);
|
|
2643
2591
|
};
|
|
2644
2592
|
}, [triggerChatError, setInternalErrorHandler, removeInternalErrorHandler]);
|
|
2645
|
-
(0,
|
|
2593
|
+
(0, import_react14.useEffect)(() => {
|
|
2646
2594
|
if (!imageUploadsEnabled)
|
|
2647
2595
|
return;
|
|
2648
2596
|
const handlePaste = (e) => __async(this, null, function* () {
|
|
@@ -2688,7 +2636,7 @@ function CopilotChat({
|
|
|
2688
2636
|
document.addEventListener("paste", handlePaste);
|
|
2689
2637
|
return () => document.removeEventListener("paste", handlePaste);
|
|
2690
2638
|
}, [imageUploadsEnabled, triggerChatError]);
|
|
2691
|
-
(0,
|
|
2639
|
+
(0, import_react14.useEffect)(() => {
|
|
2692
2640
|
if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
|
|
2693
2641
|
setChatInstructions(instructions || "");
|
|
2694
2642
|
return;
|
|
@@ -2716,8 +2664,8 @@ function CopilotChat({
|
|
|
2716
2664
|
onStopGeneration,
|
|
2717
2665
|
onReloadMessages
|
|
2718
2666
|
);
|
|
2719
|
-
const prevIsLoading = (0,
|
|
2720
|
-
(0,
|
|
2667
|
+
const prevIsLoading = (0, import_react14.useRef)(isLoading);
|
|
2668
|
+
(0, import_react14.useEffect)(() => {
|
|
2721
2669
|
if (prevIsLoading.current !== isLoading) {
|
|
2722
2670
|
if (isLoading) {
|
|
2723
2671
|
triggerObservabilityHook("onChatStarted");
|
|
@@ -2736,7 +2684,7 @@ function CopilotChat({
|
|
|
2736
2684
|
triggerObservabilityHook("onMessageSent", text);
|
|
2737
2685
|
return sendMessage(text, images);
|
|
2738
2686
|
};
|
|
2739
|
-
const chatContext =
|
|
2687
|
+
const chatContext = import_react14.default.useContext(ChatContext);
|
|
2740
2688
|
const isVisible = chatContext ? chatContext.open : true;
|
|
2741
2689
|
const handleRegenerate = (messageId) => {
|
|
2742
2690
|
if (onRegenerate) {
|
|
@@ -2798,14 +2746,14 @@ function CopilotChat({
|
|
|
2798
2746
|
}
|
|
2799
2747
|
triggerObservabilityHook("onFeedbackGiven", message.id, "thumbsDown");
|
|
2800
2748
|
};
|
|
2801
|
-
return /* @__PURE__ */ (0,
|
|
2749
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
|
|
2802
2750
|
chatError && renderError && renderError(__spreadProps(__spreadValues({}, chatError), {
|
|
2803
2751
|
onDismiss: () => setChatError(null),
|
|
2804
2752
|
onRetry: () => {
|
|
2805
2753
|
setChatError(null);
|
|
2806
2754
|
}
|
|
2807
2755
|
})),
|
|
2808
|
-
/* @__PURE__ */ (0,
|
|
2756
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2809
2757
|
Messages2,
|
|
2810
2758
|
{
|
|
2811
2759
|
AssistantMessage: AssistantMessage2,
|
|
@@ -2819,14 +2767,14 @@ function CopilotChat({
|
|
|
2819
2767
|
onThumbsDown: handleThumbsDown,
|
|
2820
2768
|
markdownTagRenderers,
|
|
2821
2769
|
ImageRenderer: ImageRenderer2,
|
|
2822
|
-
ErrorMessage
|
|
2770
|
+
ErrorMessage,
|
|
2823
2771
|
chatError,
|
|
2824
2772
|
RenderTextMessage,
|
|
2825
2773
|
RenderActionExecutionMessage,
|
|
2826
2774
|
RenderAgentStateMessage,
|
|
2827
2775
|
RenderResultMessage,
|
|
2828
2776
|
RenderImageMessage,
|
|
2829
|
-
children: currentSuggestions.length > 0 && /* @__PURE__ */ (0,
|
|
2777
|
+
children: currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2830
2778
|
RenderSuggestionsList,
|
|
2831
2779
|
{
|
|
2832
2780
|
onSuggestionClick: handleSendMessage,
|
|
@@ -2835,9 +2783,9 @@ function CopilotChat({
|
|
|
2835
2783
|
)
|
|
2836
2784
|
}
|
|
2837
2785
|
),
|
|
2838
|
-
imageUploadsEnabled && /* @__PURE__ */ (0,
|
|
2839
|
-
/* @__PURE__ */ (0,
|
|
2840
|
-
/* @__PURE__ */ (0,
|
|
2786
|
+
imageUploadsEnabled && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
|
|
2787
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ImageUploadQueue, { images: selectedImages, onRemoveImage: removeSelectedImage }),
|
|
2788
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2841
2789
|
"input",
|
|
2842
2790
|
{
|
|
2843
2791
|
type: "file",
|
|
@@ -2849,7 +2797,7 @@ function CopilotChat({
|
|
|
2849
2797
|
}
|
|
2850
2798
|
)
|
|
2851
2799
|
] }),
|
|
2852
|
-
/* @__PURE__ */ (0,
|
|
2800
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2853
2801
|
Input2,
|
|
2854
2802
|
{
|
|
2855
2803
|
inProgress: isLoading,
|
|
@@ -2871,12 +2819,12 @@ function WrappedCopilotChat({
|
|
|
2871
2819
|
labels,
|
|
2872
2820
|
className
|
|
2873
2821
|
}) {
|
|
2874
|
-
const chatContext =
|
|
2822
|
+
const chatContext = import_react14.default.useContext(ChatContext);
|
|
2875
2823
|
if (!chatContext) {
|
|
2876
|
-
return /* @__PURE__ */ (0,
|
|
2877
|
-
}, children: /* @__PURE__ */ (0,
|
|
2824
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
|
|
2825
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: `copilotKitChat ${className != null ? className : ""}`, children }) });
|
|
2878
2826
|
}
|
|
2879
|
-
return /* @__PURE__ */ (0,
|
|
2827
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children });
|
|
2880
2828
|
}
|
|
2881
2829
|
var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMessage, onInProgress, onSubmitMessage, onStopGeneration, onReloadMessages) => {
|
|
2882
2830
|
var _a;
|
|
@@ -2900,15 +2848,15 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
2900
2848
|
const generalContext = (0, import_react_core9.useCopilotContext)();
|
|
2901
2849
|
const messagesContext = (0, import_react_core9.useCopilotMessagesContext)();
|
|
2902
2850
|
const { actions } = generalContext;
|
|
2903
|
-
const [suggestionsFailed, setSuggestionsFailed] = (0,
|
|
2904
|
-
const hasGeneratedInitialSuggestions = (0,
|
|
2905
|
-
(0,
|
|
2851
|
+
const [suggestionsFailed, setSuggestionsFailed] = (0, import_react14.useState)(false);
|
|
2852
|
+
const hasGeneratedInitialSuggestions = (0, import_react14.useRef)(false);
|
|
2853
|
+
(0, import_react14.useEffect)(() => {
|
|
2906
2854
|
if (Array.isArray(chatSuggestions)) {
|
|
2907
2855
|
setSuggestions(chatSuggestions);
|
|
2908
2856
|
hasGeneratedInitialSuggestions.current = true;
|
|
2909
2857
|
}
|
|
2910
2858
|
}, [JSON.stringify(chatSuggestions), setSuggestions]);
|
|
2911
|
-
const generateSuggestionsWithErrorHandling = (0,
|
|
2859
|
+
const generateSuggestionsWithErrorHandling = (0, import_react14.useCallback)(
|
|
2912
2860
|
(context) => __async(void 0, null, function* () {
|
|
2913
2861
|
try {
|
|
2914
2862
|
yield generateSuggestions();
|
|
@@ -2919,7 +2867,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
2919
2867
|
}),
|
|
2920
2868
|
[generateSuggestions]
|
|
2921
2869
|
);
|
|
2922
|
-
(0,
|
|
2870
|
+
(0, import_react14.useEffect)(() => {
|
|
2923
2871
|
if (chatSuggestions !== "auto" || isLoadingSuggestions || suggestionsFailed) {
|
|
2924
2872
|
return;
|
|
2925
2873
|
}
|
|
@@ -2949,13 +2897,13 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
2949
2897
|
// Use stable string instead of object reference
|
|
2950
2898
|
generateSuggestionsWithErrorHandling
|
|
2951
2899
|
]);
|
|
2952
|
-
(0,
|
|
2900
|
+
(0, import_react14.useEffect)(() => {
|
|
2953
2901
|
if (chatSuggestions !== "auto") {
|
|
2954
2902
|
hasGeneratedInitialSuggestions.current = false;
|
|
2955
2903
|
setSuggestionsFailed(false);
|
|
2956
2904
|
}
|
|
2957
2905
|
}, [chatSuggestions]);
|
|
2958
|
-
const stableContext = (0,
|
|
2906
|
+
const stableContext = (0, import_react14.useMemo)(
|
|
2959
2907
|
() => __spreadValues(__spreadValues({}, generalContext), messagesContext),
|
|
2960
2908
|
[
|
|
2961
2909
|
// Only include stable dependencies
|
|
@@ -2964,12 +2912,12 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
2964
2912
|
generalContext.isLoading
|
|
2965
2913
|
]
|
|
2966
2914
|
);
|
|
2967
|
-
const resetSuggestions = (0,
|
|
2915
|
+
const resetSuggestions = (0, import_react14.useCallback)(() => {
|
|
2968
2916
|
resetSuggestionsFromHook();
|
|
2969
2917
|
setSuggestionsFailed(false);
|
|
2970
2918
|
hasGeneratedInitialSuggestions.current = false;
|
|
2971
2919
|
}, [resetSuggestionsFromHook]);
|
|
2972
|
-
(0,
|
|
2920
|
+
(0, import_react14.useEffect)(() => {
|
|
2973
2921
|
onInProgress == null ? void 0 : onInProgress(isLoading);
|
|
2974
2922
|
}, [onInProgress, isLoading]);
|
|
2975
2923
|
const safelySendMessage = (messageContent, imagesToUse) => __async(void 0, null, function* () {
|
|
@@ -3115,7 +3063,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
3115
3063
|
// src/components/chat/Modal.tsx
|
|
3116
3064
|
var import_react_core11 = require("@copilotkit/react-core");
|
|
3117
3065
|
var import_shared5 = require("@copilotkit/shared");
|
|
3118
|
-
var
|
|
3066
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
3119
3067
|
var CopilotModalInner = (_a) => {
|
|
3120
3068
|
var _b = _a, {
|
|
3121
3069
|
observabilityHooks,
|
|
@@ -3142,7 +3090,7 @@ var CopilotModalInner = (_a) => {
|
|
|
3142
3090
|
]);
|
|
3143
3091
|
const { copilotApiConfig, setBannerError } = (0, import_react_core11.useCopilotContext)();
|
|
3144
3092
|
const { publicApiKey } = copilotApiConfig;
|
|
3145
|
-
const triggerObservabilityHook = (0,
|
|
3093
|
+
const triggerObservabilityHook = (0, import_react15.useCallback)(
|
|
3146
3094
|
(hookName, ...args) => {
|
|
3147
3095
|
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
3148
3096
|
observabilityHooks[hookName](...args);
|
|
@@ -3162,8 +3110,8 @@ var CopilotModalInner = (_a) => {
|
|
|
3162
3110
|
[publicApiKey, observabilityHooks, setBannerError]
|
|
3163
3111
|
);
|
|
3164
3112
|
const { open } = useChatContext();
|
|
3165
|
-
const prevOpen = (0,
|
|
3166
|
-
(0,
|
|
3113
|
+
const prevOpen = (0, import_react15.useRef)(open);
|
|
3114
|
+
(0, import_react15.useEffect)(() => {
|
|
3167
3115
|
if (prevOpen.current !== open) {
|
|
3168
3116
|
onSetOpen == null ? void 0 : onSetOpen(open);
|
|
3169
3117
|
if (open) {
|
|
@@ -3174,13 +3122,13 @@ var CopilotModalInner = (_a) => {
|
|
|
3174
3122
|
prevOpen.current = open;
|
|
3175
3123
|
}
|
|
3176
3124
|
}, [open, onSetOpen, triggerObservabilityHook]);
|
|
3177
|
-
const memoizedHeader = (0,
|
|
3178
|
-
const memoizedChildren = (0,
|
|
3179
|
-
return /* @__PURE__ */ (0,
|
|
3125
|
+
const memoizedHeader = (0, import_react15.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Header2, {}), [Header2]);
|
|
3126
|
+
const memoizedChildren = (0, import_react15.useMemo)(() => children, [children]);
|
|
3127
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
|
|
3180
3128
|
memoizedChildren,
|
|
3181
|
-
/* @__PURE__ */ (0,
|
|
3182
|
-
/* @__PURE__ */ (0,
|
|
3183
|
-
/* @__PURE__ */ (0,
|
|
3129
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className, children: [
|
|
3130
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Button2, {}),
|
|
3131
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
3184
3132
|
Window2,
|
|
3185
3133
|
{
|
|
3186
3134
|
clickOutsideToClose,
|
|
@@ -3188,7 +3136,7 @@ var CopilotModalInner = (_a) => {
|
|
|
3188
3136
|
hitEscapeToClose,
|
|
3189
3137
|
children: [
|
|
3190
3138
|
memoizedHeader,
|
|
3191
|
-
/* @__PURE__ */ (0,
|
|
3139
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(CopilotChat, __spreadProps(__spreadValues({}, chatProps), { observabilityHooks }))
|
|
3192
3140
|
]
|
|
3193
3141
|
}
|
|
3194
3142
|
)
|
|
@@ -3255,8 +3203,8 @@ var CopilotModal = (_a) => {
|
|
|
3255
3203
|
"children",
|
|
3256
3204
|
"observabilityHooks"
|
|
3257
3205
|
]);
|
|
3258
|
-
const [openState, setOpenState] =
|
|
3259
|
-
return /* @__PURE__ */ (0,
|
|
3206
|
+
const [openState, setOpenState] = import_react15.default.useState(defaultOpen);
|
|
3207
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChatContextProvider, { icons, labels, open: openState, setOpen: setOpenState, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3260
3208
|
CopilotModalInner,
|
|
3261
3209
|
__spreadProps(__spreadValues({
|
|
3262
3210
|
observabilityHooks,
|
|
@@ -3290,22 +3238,22 @@ var CopilotModal = (_a) => {
|
|
|
3290
3238
|
};
|
|
3291
3239
|
|
|
3292
3240
|
// src/components/chat/Popup.tsx
|
|
3293
|
-
var
|
|
3241
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
3294
3242
|
function CopilotPopup(props) {
|
|
3295
3243
|
props = __spreadProps(__spreadValues({}, props), {
|
|
3296
3244
|
className: props.className ? props.className + " copilotKitPopup" : "copilotKitPopup"
|
|
3297
3245
|
});
|
|
3298
|
-
return /* @__PURE__ */ (0,
|
|
3246
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(CopilotModal, __spreadProps(__spreadValues({}, props), { children: props.children }));
|
|
3299
3247
|
}
|
|
3300
3248
|
|
|
3301
3249
|
// src/components/chat/Sidebar.tsx
|
|
3302
|
-
var
|
|
3303
|
-
var
|
|
3250
|
+
var import_react16 = require("react");
|
|
3251
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
3304
3252
|
function CopilotSidebar(props) {
|
|
3305
3253
|
props = __spreadProps(__spreadValues({}, props), {
|
|
3306
3254
|
className: props.className ? props.className + " copilotKitSidebar" : "copilotKitSidebar"
|
|
3307
3255
|
});
|
|
3308
|
-
const [expandedClassName, setExpandedClassName] = (0,
|
|
3256
|
+
const [expandedClassName, setExpandedClassName] = (0, import_react16.useState)(
|
|
3309
3257
|
props.defaultOpen ? "sidebarExpanded" : ""
|
|
3310
3258
|
);
|
|
3311
3259
|
const onSetOpen = (open) => {
|
|
@@ -3313,11 +3261,11 @@ function CopilotSidebar(props) {
|
|
|
3313
3261
|
(_a = props.onSetOpen) == null ? void 0 : _a.call(props, open);
|
|
3314
3262
|
setExpandedClassName(open ? "sidebarExpanded" : "");
|
|
3315
3263
|
};
|
|
3316
|
-
return /* @__PURE__ */ (0,
|
|
3264
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: `copilotKitSidebarContentWrapper ${expandedClassName}`, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CopilotModal, __spreadProps(__spreadValues(__spreadValues({}, props), { onSetOpen }), { children: props.children })) });
|
|
3317
3265
|
}
|
|
3318
3266
|
|
|
3319
3267
|
// src/hooks/use-copilot-chat-suggestions.tsx
|
|
3320
|
-
var
|
|
3268
|
+
var import_react17 = require("react");
|
|
3321
3269
|
var import_react_core12 = require("@copilotkit/react-core");
|
|
3322
3270
|
var import_shared6 = require("@copilotkit/shared");
|
|
3323
3271
|
function useCopilotChatSuggestions({
|
|
@@ -3328,7 +3276,7 @@ function useCopilotChatSuggestions({
|
|
|
3328
3276
|
maxSuggestions = 3
|
|
3329
3277
|
}, dependencies = []) {
|
|
3330
3278
|
const context = (0, import_react_core12.useCopilotContext)();
|
|
3331
|
-
(0,
|
|
3279
|
+
(0, import_react17.useEffect)(() => {
|
|
3332
3280
|
if (available === "disabled")
|
|
3333
3281
|
return;
|
|
3334
3282
|
const id = (0, import_shared6.randomId)();
|