@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
package/dist/components/index.js
CHANGED
|
@@ -95,7 +95,7 @@ __export(components_exports, {
|
|
|
95
95
|
module.exports = __toCommonJS(components_exports);
|
|
96
96
|
|
|
97
97
|
// src/components/chat/Modal.tsx
|
|
98
|
-
var
|
|
98
|
+
var import_react15 = __toESM(require("react"));
|
|
99
99
|
|
|
100
100
|
// src/components/chat/ChatContext.tsx
|
|
101
101
|
var import_react = __toESM(require("react"));
|
|
@@ -1883,7 +1883,7 @@ var Messages = ({
|
|
|
1883
1883
|
RenderMessage: RenderMessage2,
|
|
1884
1884
|
AssistantMessage: AssistantMessage2,
|
|
1885
1885
|
UserMessage: UserMessage2,
|
|
1886
|
-
ErrorMessage
|
|
1886
|
+
ErrorMessage,
|
|
1887
1887
|
ImageRenderer: ImageRenderer2,
|
|
1888
1888
|
onRegenerate,
|
|
1889
1889
|
onCopy,
|
|
@@ -1952,7 +1952,7 @@ var Messages = ({
|
|
|
1952
1952
|
);
|
|
1953
1953
|
}),
|
|
1954
1954
|
interrupt,
|
|
1955
|
-
chatError && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1955
|
+
chatError && ErrorMessage && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ErrorMessage, { error: chatError, isCurrentMessage: true })
|
|
1956
1956
|
] }),
|
|
1957
1957
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("footer", { className: "copilotKitMessagesFooter", ref: messagesEndRef, children })
|
|
1958
1958
|
] });
|
|
@@ -2335,67 +2335,15 @@ var Input = ({
|
|
|
2335
2335
|
] });
|
|
2336
2336
|
};
|
|
2337
2337
|
|
|
2338
|
-
// src/components/chat/messages/ErrorMessage.tsx
|
|
2339
|
-
var import_react14 = require("react");
|
|
2340
|
-
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2341
|
-
var ErrorMessage = (props) => {
|
|
2342
|
-
const { icons, labels } = useChatContext();
|
|
2343
|
-
const { error, onRegenerate, onCopy, isCurrentMessage } = props;
|
|
2344
|
-
const [copied, setCopied] = (0, import_react14.useState)(false);
|
|
2345
|
-
const handleCopy = () => {
|
|
2346
|
-
const content = error.message;
|
|
2347
|
-
if (content && onCopy) {
|
|
2348
|
-
navigator.clipboard.writeText(content);
|
|
2349
|
-
setCopied(true);
|
|
2350
|
-
onCopy(content);
|
|
2351
|
-
setTimeout(() => setCopied(false), 2e3);
|
|
2352
|
-
} else if (content) {
|
|
2353
|
-
navigator.clipboard.writeText(content);
|
|
2354
|
-
setCopied(true);
|
|
2355
|
-
setTimeout(() => setCopied(false), 2e3);
|
|
2356
|
-
}
|
|
2357
|
-
};
|
|
2358
|
-
const handleRegenerate = () => {
|
|
2359
|
-
if (onRegenerate)
|
|
2360
|
-
onRegenerate();
|
|
2361
|
-
};
|
|
2362
|
-
console.log(error);
|
|
2363
|
-
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "copilotKitMessage copilotKitAssistantMessage", children: [
|
|
2364
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Markdown, { content: error.message }),
|
|
2365
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: `copilotKitMessageControls ${isCurrentMessage ? "currentMessage" : ""}`, children: [
|
|
2366
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2367
|
-
"button",
|
|
2368
|
-
{
|
|
2369
|
-
className: "copilotKitMessageControlButton",
|
|
2370
|
-
onClick: handleRegenerate,
|
|
2371
|
-
"aria-label": labels.regenerateResponse,
|
|
2372
|
-
title: labels.regenerateResponse,
|
|
2373
|
-
children: icons.regenerateIcon
|
|
2374
|
-
}
|
|
2375
|
-
),
|
|
2376
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2377
|
-
"button",
|
|
2378
|
-
{
|
|
2379
|
-
className: "copilotKitMessageControlButton",
|
|
2380
|
-
onClick: handleCopy,
|
|
2381
|
-
"aria-label": labels.copyToClipboard,
|
|
2382
|
-
title: labels.copyToClipboard,
|
|
2383
|
-
children: copied ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { style: { fontSize: "10px", fontWeight: "bold" }, children: "\u2713" }) : icons.copyIcon
|
|
2384
|
-
}
|
|
2385
|
-
)
|
|
2386
|
-
] })
|
|
2387
|
-
] });
|
|
2388
|
-
};
|
|
2389
|
-
|
|
2390
2338
|
// src/components/chat/Chat.tsx
|
|
2391
|
-
var
|
|
2339
|
+
var import_react14 = __toESM(require("react"));
|
|
2392
2340
|
var import_react_core9 = require("@copilotkit/react-core");
|
|
2393
2341
|
var import_shared3 = require("@copilotkit/shared");
|
|
2394
2342
|
var import_shared4 = require("@copilotkit/shared");
|
|
2395
2343
|
var import_react_core10 = require("@copilotkit/react-core");
|
|
2396
2344
|
|
|
2397
2345
|
// src/components/chat/ImageUploadQueue.tsx
|
|
2398
|
-
var
|
|
2346
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2399
2347
|
var ImageUploadQueue = ({
|
|
2400
2348
|
images,
|
|
2401
2349
|
onRemoveImage,
|
|
@@ -2403,7 +2351,7 @@ var ImageUploadQueue = ({
|
|
|
2403
2351
|
}) => {
|
|
2404
2352
|
if (images.length === 0)
|
|
2405
2353
|
return null;
|
|
2406
|
-
return /* @__PURE__ */ (0,
|
|
2354
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2407
2355
|
"div",
|
|
2408
2356
|
{
|
|
2409
2357
|
className: `copilotKitImageUploadQueue ${className}`,
|
|
@@ -2414,7 +2362,7 @@ var ImageUploadQueue = ({
|
|
|
2414
2362
|
margin: "8px",
|
|
2415
2363
|
padding: "8px"
|
|
2416
2364
|
},
|
|
2417
|
-
children: images.map((image, index) => /* @__PURE__ */ (0,
|
|
2365
|
+
children: images.map((image, index) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
2418
2366
|
"div",
|
|
2419
2367
|
{
|
|
2420
2368
|
className: "copilotKitImageUploadQueueItem",
|
|
@@ -2427,7 +2375,7 @@ var ImageUploadQueue = ({
|
|
|
2427
2375
|
overflow: "hidden"
|
|
2428
2376
|
},
|
|
2429
2377
|
children: [
|
|
2430
|
-
/* @__PURE__ */ (0,
|
|
2378
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2431
2379
|
"img",
|
|
2432
2380
|
{
|
|
2433
2381
|
src: `data:${image.contentType};base64,${image.bytes}`,
|
|
@@ -2439,7 +2387,7 @@ var ImageUploadQueue = ({
|
|
|
2439
2387
|
}
|
|
2440
2388
|
}
|
|
2441
2389
|
),
|
|
2442
|
-
/* @__PURE__ */ (0,
|
|
2390
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2443
2391
|
"button",
|
|
2444
2392
|
{
|
|
2445
2393
|
onClick: () => onRemoveImage(index),
|
|
@@ -2474,12 +2422,12 @@ var ImageUploadQueue = ({
|
|
|
2474
2422
|
|
|
2475
2423
|
// src/components/chat/Suggestion.tsx
|
|
2476
2424
|
var import_react_core8 = require("@copilotkit/react-core");
|
|
2477
|
-
var
|
|
2425
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2478
2426
|
function Suggestion({ title, onClick, partial, className }) {
|
|
2479
2427
|
if (!title)
|
|
2480
2428
|
return null;
|
|
2481
2429
|
const { isLoading } = (0, import_react_core8.useCopilotChatInternal)();
|
|
2482
|
-
return /* @__PURE__ */ (0,
|
|
2430
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2483
2431
|
"button",
|
|
2484
2432
|
{
|
|
2485
2433
|
disabled: partial || isLoading,
|
|
@@ -2489,15 +2437,15 @@ function Suggestion({ title, onClick, partial, className }) {
|
|
|
2489
2437
|
},
|
|
2490
2438
|
className: className || (partial ? "suggestion loading" : "suggestion"),
|
|
2491
2439
|
"data-test-id": "suggestion",
|
|
2492
|
-
children: partial ? SmallSpinnerIcon : /* @__PURE__ */ (0,
|
|
2440
|
+
children: partial ? SmallSpinnerIcon : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { children: title })
|
|
2493
2441
|
}
|
|
2494
2442
|
);
|
|
2495
2443
|
}
|
|
2496
2444
|
|
|
2497
2445
|
// src/components/chat/Suggestions.tsx
|
|
2498
|
-
var
|
|
2446
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
2499
2447
|
function Suggestions({ suggestions, onSuggestionClick }) {
|
|
2500
|
-
return /* @__PURE__ */ (0,
|
|
2448
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "suggestions", children: suggestions.map((suggestion, index) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2501
2449
|
Suggestion,
|
|
2502
2450
|
{
|
|
2503
2451
|
title: suggestion.title,
|
|
@@ -2511,7 +2459,7 @@ function Suggestions({ suggestions, onSuggestionClick }) {
|
|
|
2511
2459
|
}
|
|
2512
2460
|
|
|
2513
2461
|
// src/components/chat/Chat.tsx
|
|
2514
|
-
var
|
|
2462
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2515
2463
|
function CopilotChat({
|
|
2516
2464
|
instructions,
|
|
2517
2465
|
suggestions = "auto",
|
|
@@ -2536,7 +2484,7 @@ function CopilotChat({
|
|
|
2536
2484
|
AssistantMessage: AssistantMessage2 = AssistantMessage,
|
|
2537
2485
|
UserMessage: UserMessage2 = UserMessage,
|
|
2538
2486
|
ImageRenderer: ImageRenderer2 = ImageRenderer,
|
|
2539
|
-
ErrorMessage
|
|
2487
|
+
ErrorMessage,
|
|
2540
2488
|
imageUploadsEnabled,
|
|
2541
2489
|
inputFileAccept = "image/*",
|
|
2542
2490
|
hideStopButton,
|
|
@@ -2559,10 +2507,10 @@ function CopilotChat({
|
|
|
2559
2507
|
removeInternalErrorHandler
|
|
2560
2508
|
} = (0, import_react_core9.useCopilotContext)();
|
|
2561
2509
|
const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
|
|
2562
|
-
const [selectedImages, setSelectedImages] = (0,
|
|
2563
|
-
const [chatError, setChatError] = (0,
|
|
2564
|
-
const fileInputRef = (0,
|
|
2565
|
-
const triggerObservabilityHook = (0,
|
|
2510
|
+
const [selectedImages, setSelectedImages] = (0, import_react14.useState)([]);
|
|
2511
|
+
const [chatError, setChatError] = (0, import_react14.useState)(null);
|
|
2512
|
+
const fileInputRef = (0, import_react14.useRef)(null);
|
|
2513
|
+
const triggerObservabilityHook = (0, import_react14.useCallback)(
|
|
2566
2514
|
(hookName, ...args) => {
|
|
2567
2515
|
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
2568
2516
|
observabilityHooks[hookName](...args);
|
|
@@ -2581,7 +2529,7 @@ function CopilotChat({
|
|
|
2581
2529
|
},
|
|
2582
2530
|
[publicApiKey, observabilityHooks, setBannerError]
|
|
2583
2531
|
);
|
|
2584
|
-
const triggerChatError = (0,
|
|
2532
|
+
const triggerChatError = (0, import_react14.useCallback)(
|
|
2585
2533
|
(error, operation, originalError) => {
|
|
2586
2534
|
const errorMessage = (error == null ? void 0 : error.message) || (error == null ? void 0 : error.toString()) || "An error occurred";
|
|
2587
2535
|
setChatError({
|
|
@@ -2627,7 +2575,7 @@ function CopilotChat({
|
|
|
2627
2575
|
},
|
|
2628
2576
|
[publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError]
|
|
2629
2577
|
);
|
|
2630
|
-
(0,
|
|
2578
|
+
(0, import_react14.useEffect)(() => {
|
|
2631
2579
|
const id = "chat-component";
|
|
2632
2580
|
setInternalErrorHandler({
|
|
2633
2581
|
[id]: (error) => {
|
|
@@ -2640,7 +2588,7 @@ function CopilotChat({
|
|
|
2640
2588
|
removeInternalErrorHandler == null ? void 0 : removeInternalErrorHandler(id);
|
|
2641
2589
|
};
|
|
2642
2590
|
}, [triggerChatError, setInternalErrorHandler, removeInternalErrorHandler]);
|
|
2643
|
-
(0,
|
|
2591
|
+
(0, import_react14.useEffect)(() => {
|
|
2644
2592
|
if (!imageUploadsEnabled)
|
|
2645
2593
|
return;
|
|
2646
2594
|
const handlePaste = (e) => __async(this, null, function* () {
|
|
@@ -2686,7 +2634,7 @@ function CopilotChat({
|
|
|
2686
2634
|
document.addEventListener("paste", handlePaste);
|
|
2687
2635
|
return () => document.removeEventListener("paste", handlePaste);
|
|
2688
2636
|
}, [imageUploadsEnabled, triggerChatError]);
|
|
2689
|
-
(0,
|
|
2637
|
+
(0, import_react14.useEffect)(() => {
|
|
2690
2638
|
if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
|
|
2691
2639
|
setChatInstructions(instructions || "");
|
|
2692
2640
|
return;
|
|
@@ -2714,8 +2662,8 @@ function CopilotChat({
|
|
|
2714
2662
|
onStopGeneration,
|
|
2715
2663
|
onReloadMessages
|
|
2716
2664
|
);
|
|
2717
|
-
const prevIsLoading = (0,
|
|
2718
|
-
(0,
|
|
2665
|
+
const prevIsLoading = (0, import_react14.useRef)(isLoading);
|
|
2666
|
+
(0, import_react14.useEffect)(() => {
|
|
2719
2667
|
if (prevIsLoading.current !== isLoading) {
|
|
2720
2668
|
if (isLoading) {
|
|
2721
2669
|
triggerObservabilityHook("onChatStarted");
|
|
@@ -2734,7 +2682,7 @@ function CopilotChat({
|
|
|
2734
2682
|
triggerObservabilityHook("onMessageSent", text);
|
|
2735
2683
|
return sendMessage(text, images);
|
|
2736
2684
|
};
|
|
2737
|
-
const chatContext =
|
|
2685
|
+
const chatContext = import_react14.default.useContext(ChatContext);
|
|
2738
2686
|
const isVisible = chatContext ? chatContext.open : true;
|
|
2739
2687
|
const handleRegenerate = (messageId) => {
|
|
2740
2688
|
if (onRegenerate) {
|
|
@@ -2796,14 +2744,14 @@ function CopilotChat({
|
|
|
2796
2744
|
}
|
|
2797
2745
|
triggerObservabilityHook("onFeedbackGiven", message.id, "thumbsDown");
|
|
2798
2746
|
};
|
|
2799
|
-
return /* @__PURE__ */ (0,
|
|
2747
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
|
|
2800
2748
|
chatError && renderError && renderError(__spreadProps(__spreadValues({}, chatError), {
|
|
2801
2749
|
onDismiss: () => setChatError(null),
|
|
2802
2750
|
onRetry: () => {
|
|
2803
2751
|
setChatError(null);
|
|
2804
2752
|
}
|
|
2805
2753
|
})),
|
|
2806
|
-
/* @__PURE__ */ (0,
|
|
2754
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2807
2755
|
Messages2,
|
|
2808
2756
|
{
|
|
2809
2757
|
AssistantMessage: AssistantMessage2,
|
|
@@ -2817,14 +2765,14 @@ function CopilotChat({
|
|
|
2817
2765
|
onThumbsDown: handleThumbsDown,
|
|
2818
2766
|
markdownTagRenderers,
|
|
2819
2767
|
ImageRenderer: ImageRenderer2,
|
|
2820
|
-
ErrorMessage
|
|
2768
|
+
ErrorMessage,
|
|
2821
2769
|
chatError,
|
|
2822
2770
|
RenderTextMessage,
|
|
2823
2771
|
RenderActionExecutionMessage,
|
|
2824
2772
|
RenderAgentStateMessage,
|
|
2825
2773
|
RenderResultMessage,
|
|
2826
2774
|
RenderImageMessage,
|
|
2827
|
-
children: currentSuggestions.length > 0 && /* @__PURE__ */ (0,
|
|
2775
|
+
children: currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2828
2776
|
RenderSuggestionsList,
|
|
2829
2777
|
{
|
|
2830
2778
|
onSuggestionClick: handleSendMessage,
|
|
@@ -2833,9 +2781,9 @@ function CopilotChat({
|
|
|
2833
2781
|
)
|
|
2834
2782
|
}
|
|
2835
2783
|
),
|
|
2836
|
-
imageUploadsEnabled && /* @__PURE__ */ (0,
|
|
2837
|
-
/* @__PURE__ */ (0,
|
|
2838
|
-
/* @__PURE__ */ (0,
|
|
2784
|
+
imageUploadsEnabled && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
|
|
2785
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ImageUploadQueue, { images: selectedImages, onRemoveImage: removeSelectedImage }),
|
|
2786
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2839
2787
|
"input",
|
|
2840
2788
|
{
|
|
2841
2789
|
type: "file",
|
|
@@ -2847,7 +2795,7 @@ function CopilotChat({
|
|
|
2847
2795
|
}
|
|
2848
2796
|
)
|
|
2849
2797
|
] }),
|
|
2850
|
-
/* @__PURE__ */ (0,
|
|
2798
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2851
2799
|
Input2,
|
|
2852
2800
|
{
|
|
2853
2801
|
inProgress: isLoading,
|
|
@@ -2869,12 +2817,12 @@ function WrappedCopilotChat({
|
|
|
2869
2817
|
labels,
|
|
2870
2818
|
className
|
|
2871
2819
|
}) {
|
|
2872
|
-
const chatContext =
|
|
2820
|
+
const chatContext = import_react14.default.useContext(ChatContext);
|
|
2873
2821
|
if (!chatContext) {
|
|
2874
|
-
return /* @__PURE__ */ (0,
|
|
2875
|
-
}, children: /* @__PURE__ */ (0,
|
|
2822
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
|
|
2823
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: `copilotKitChat ${className != null ? className : ""}`, children }) });
|
|
2876
2824
|
}
|
|
2877
|
-
return /* @__PURE__ */ (0,
|
|
2825
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children });
|
|
2878
2826
|
}
|
|
2879
2827
|
var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMessage, onInProgress, onSubmitMessage, onStopGeneration, onReloadMessages) => {
|
|
2880
2828
|
var _a;
|
|
@@ -2898,15 +2846,15 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
2898
2846
|
const generalContext = (0, import_react_core9.useCopilotContext)();
|
|
2899
2847
|
const messagesContext = (0, import_react_core9.useCopilotMessagesContext)();
|
|
2900
2848
|
const { actions } = generalContext;
|
|
2901
|
-
const [suggestionsFailed, setSuggestionsFailed] = (0,
|
|
2902
|
-
const hasGeneratedInitialSuggestions = (0,
|
|
2903
|
-
(0,
|
|
2849
|
+
const [suggestionsFailed, setSuggestionsFailed] = (0, import_react14.useState)(false);
|
|
2850
|
+
const hasGeneratedInitialSuggestions = (0, import_react14.useRef)(false);
|
|
2851
|
+
(0, import_react14.useEffect)(() => {
|
|
2904
2852
|
if (Array.isArray(chatSuggestions)) {
|
|
2905
2853
|
setSuggestions(chatSuggestions);
|
|
2906
2854
|
hasGeneratedInitialSuggestions.current = true;
|
|
2907
2855
|
}
|
|
2908
2856
|
}, [JSON.stringify(chatSuggestions), setSuggestions]);
|
|
2909
|
-
const generateSuggestionsWithErrorHandling = (0,
|
|
2857
|
+
const generateSuggestionsWithErrorHandling = (0, import_react14.useCallback)(
|
|
2910
2858
|
(context) => __async(void 0, null, function* () {
|
|
2911
2859
|
try {
|
|
2912
2860
|
yield generateSuggestions();
|
|
@@ -2917,7 +2865,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
2917
2865
|
}),
|
|
2918
2866
|
[generateSuggestions]
|
|
2919
2867
|
);
|
|
2920
|
-
(0,
|
|
2868
|
+
(0, import_react14.useEffect)(() => {
|
|
2921
2869
|
if (chatSuggestions !== "auto" || isLoadingSuggestions || suggestionsFailed) {
|
|
2922
2870
|
return;
|
|
2923
2871
|
}
|
|
@@ -2947,13 +2895,13 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
2947
2895
|
// Use stable string instead of object reference
|
|
2948
2896
|
generateSuggestionsWithErrorHandling
|
|
2949
2897
|
]);
|
|
2950
|
-
(0,
|
|
2898
|
+
(0, import_react14.useEffect)(() => {
|
|
2951
2899
|
if (chatSuggestions !== "auto") {
|
|
2952
2900
|
hasGeneratedInitialSuggestions.current = false;
|
|
2953
2901
|
setSuggestionsFailed(false);
|
|
2954
2902
|
}
|
|
2955
2903
|
}, [chatSuggestions]);
|
|
2956
|
-
const stableContext = (0,
|
|
2904
|
+
const stableContext = (0, import_react14.useMemo)(
|
|
2957
2905
|
() => __spreadValues(__spreadValues({}, generalContext), messagesContext),
|
|
2958
2906
|
[
|
|
2959
2907
|
// Only include stable dependencies
|
|
@@ -2962,12 +2910,12 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
2962
2910
|
generalContext.isLoading
|
|
2963
2911
|
]
|
|
2964
2912
|
);
|
|
2965
|
-
const resetSuggestions = (0,
|
|
2913
|
+
const resetSuggestions = (0, import_react14.useCallback)(() => {
|
|
2966
2914
|
resetSuggestionsFromHook();
|
|
2967
2915
|
setSuggestionsFailed(false);
|
|
2968
2916
|
hasGeneratedInitialSuggestions.current = false;
|
|
2969
2917
|
}, [resetSuggestionsFromHook]);
|
|
2970
|
-
(0,
|
|
2918
|
+
(0, import_react14.useEffect)(() => {
|
|
2971
2919
|
onInProgress == null ? void 0 : onInProgress(isLoading);
|
|
2972
2920
|
}, [onInProgress, isLoading]);
|
|
2973
2921
|
const safelySendMessage = (messageContent, imagesToUse) => __async(void 0, null, function* () {
|
|
@@ -3113,7 +3061,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
3113
3061
|
// src/components/chat/Modal.tsx
|
|
3114
3062
|
var import_react_core11 = require("@copilotkit/react-core");
|
|
3115
3063
|
var import_shared5 = require("@copilotkit/shared");
|
|
3116
|
-
var
|
|
3064
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
3117
3065
|
var CopilotModalInner = (_a) => {
|
|
3118
3066
|
var _b = _a, {
|
|
3119
3067
|
observabilityHooks,
|
|
@@ -3140,7 +3088,7 @@ var CopilotModalInner = (_a) => {
|
|
|
3140
3088
|
]);
|
|
3141
3089
|
const { copilotApiConfig, setBannerError } = (0, import_react_core11.useCopilotContext)();
|
|
3142
3090
|
const { publicApiKey } = copilotApiConfig;
|
|
3143
|
-
const triggerObservabilityHook = (0,
|
|
3091
|
+
const triggerObservabilityHook = (0, import_react15.useCallback)(
|
|
3144
3092
|
(hookName, ...args) => {
|
|
3145
3093
|
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
3146
3094
|
observabilityHooks[hookName](...args);
|
|
@@ -3160,8 +3108,8 @@ var CopilotModalInner = (_a) => {
|
|
|
3160
3108
|
[publicApiKey, observabilityHooks, setBannerError]
|
|
3161
3109
|
);
|
|
3162
3110
|
const { open } = useChatContext();
|
|
3163
|
-
const prevOpen = (0,
|
|
3164
|
-
(0,
|
|
3111
|
+
const prevOpen = (0, import_react15.useRef)(open);
|
|
3112
|
+
(0, import_react15.useEffect)(() => {
|
|
3165
3113
|
if (prevOpen.current !== open) {
|
|
3166
3114
|
onSetOpen == null ? void 0 : onSetOpen(open);
|
|
3167
3115
|
if (open) {
|
|
@@ -3172,13 +3120,13 @@ var CopilotModalInner = (_a) => {
|
|
|
3172
3120
|
prevOpen.current = open;
|
|
3173
3121
|
}
|
|
3174
3122
|
}, [open, onSetOpen, triggerObservabilityHook]);
|
|
3175
|
-
const memoizedHeader = (0,
|
|
3176
|
-
const memoizedChildren = (0,
|
|
3177
|
-
return /* @__PURE__ */ (0,
|
|
3123
|
+
const memoizedHeader = (0, import_react15.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Header2, {}), [Header2]);
|
|
3124
|
+
const memoizedChildren = (0, import_react15.useMemo)(() => children, [children]);
|
|
3125
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
|
|
3178
3126
|
memoizedChildren,
|
|
3179
|
-
/* @__PURE__ */ (0,
|
|
3180
|
-
/* @__PURE__ */ (0,
|
|
3181
|
-
/* @__PURE__ */ (0,
|
|
3127
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className, children: [
|
|
3128
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Button2, {}),
|
|
3129
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
3182
3130
|
Window2,
|
|
3183
3131
|
{
|
|
3184
3132
|
clickOutsideToClose,
|
|
@@ -3186,7 +3134,7 @@ var CopilotModalInner = (_a) => {
|
|
|
3186
3134
|
hitEscapeToClose,
|
|
3187
3135
|
children: [
|
|
3188
3136
|
memoizedHeader,
|
|
3189
|
-
/* @__PURE__ */ (0,
|
|
3137
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(CopilotChat, __spreadProps(__spreadValues({}, chatProps), { observabilityHooks }))
|
|
3190
3138
|
]
|
|
3191
3139
|
}
|
|
3192
3140
|
)
|
|
@@ -3253,8 +3201,8 @@ var CopilotModal = (_a) => {
|
|
|
3253
3201
|
"children",
|
|
3254
3202
|
"observabilityHooks"
|
|
3255
3203
|
]);
|
|
3256
|
-
const [openState, setOpenState] =
|
|
3257
|
-
return /* @__PURE__ */ (0,
|
|
3204
|
+
const [openState, setOpenState] = import_react15.default.useState(defaultOpen);
|
|
3205
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChatContextProvider, { icons, labels, open: openState, setOpen: setOpenState, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3258
3206
|
CopilotModalInner,
|
|
3259
3207
|
__spreadProps(__spreadValues({
|
|
3260
3208
|
observabilityHooks,
|
|
@@ -3288,22 +3236,22 @@ var CopilotModal = (_a) => {
|
|
|
3288
3236
|
};
|
|
3289
3237
|
|
|
3290
3238
|
// src/components/chat/Popup.tsx
|
|
3291
|
-
var
|
|
3239
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
3292
3240
|
function CopilotPopup(props) {
|
|
3293
3241
|
props = __spreadProps(__spreadValues({}, props), {
|
|
3294
3242
|
className: props.className ? props.className + " copilotKitPopup" : "copilotKitPopup"
|
|
3295
3243
|
});
|
|
3296
|
-
return /* @__PURE__ */ (0,
|
|
3244
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(CopilotModal, __spreadProps(__spreadValues({}, props), { children: props.children }));
|
|
3297
3245
|
}
|
|
3298
3246
|
|
|
3299
3247
|
// src/components/chat/Sidebar.tsx
|
|
3300
|
-
var
|
|
3301
|
-
var
|
|
3248
|
+
var import_react16 = require("react");
|
|
3249
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
3302
3250
|
function CopilotSidebar(props) {
|
|
3303
3251
|
props = __spreadProps(__spreadValues({}, props), {
|
|
3304
3252
|
className: props.className ? props.className + " copilotKitSidebar" : "copilotKitSidebar"
|
|
3305
3253
|
});
|
|
3306
|
-
const [expandedClassName, setExpandedClassName] = (0,
|
|
3254
|
+
const [expandedClassName, setExpandedClassName] = (0, import_react16.useState)(
|
|
3307
3255
|
props.defaultOpen ? "sidebarExpanded" : ""
|
|
3308
3256
|
);
|
|
3309
3257
|
const onSetOpen = (open) => {
|
|
@@ -3311,7 +3259,7 @@ function CopilotSidebar(props) {
|
|
|
3311
3259
|
(_a = props.onSetOpen) == null ? void 0 : _a.call(props, open);
|
|
3312
3260
|
setExpandedClassName(open ? "sidebarExpanded" : "");
|
|
3313
3261
|
};
|
|
3314
|
-
return /* @__PURE__ */ (0,
|
|
3262
|
+
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 })) });
|
|
3315
3263
|
}
|
|
3316
3264
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3317
3265
|
0 && (module.exports = {
|