@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.
Files changed (60) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/{chunk-KCRWXHWT.mjs → chunk-DII7M2HW.mjs} +2 -2
  3. package/dist/{chunk-FJFWH5AF.mjs → chunk-GKIR7J5D.mjs} +7 -7
  4. package/dist/{chunk-PHH6DYUW.mjs → chunk-NGA4T3VT.mjs} +3 -3
  5. package/dist/chunk-NGA4T3VT.mjs.map +1 -0
  6. package/dist/{chunk-Z66Y3KRE.mjs → chunk-NJY6RHHQ.mjs} +8 -11
  7. package/dist/chunk-NJY6RHHQ.mjs.map +1 -0
  8. package/dist/{chunk-YO63WHVQ.mjs → chunk-SP2PFXCH.mjs} +2 -2
  9. package/dist/{chunk-QQDCZRPA.mjs → chunk-TNN2ZGO6.mjs} +2 -2
  10. package/dist/{chunk-GDSZGYCE.mjs → chunk-V6DDX4LH.mjs} +2 -2
  11. package/dist/{chunk-FFJHOZX6.mjs → chunk-WBPBTTQD.mjs} +4 -4
  12. package/dist/{chunk-LJAYSRCB.mjs → chunk-WRQST6DJ.mjs} +4 -4
  13. package/dist/components/chat/Chat.js +47 -99
  14. package/dist/components/chat/Chat.js.map +1 -1
  15. package/dist/components/chat/Chat.mjs +5 -6
  16. package/dist/components/chat/Header.mjs +4 -4
  17. package/dist/components/chat/Messages.js +1 -1
  18. package/dist/components/chat/Messages.js.map +1 -1
  19. package/dist/components/chat/Messages.mjs +4 -4
  20. package/dist/components/chat/Modal.js +61 -113
  21. package/dist/components/chat/Modal.js.map +1 -1
  22. package/dist/components/chat/Modal.mjs +10 -11
  23. package/dist/components/chat/Popup.js +63 -115
  24. package/dist/components/chat/Popup.js.map +1 -1
  25. package/dist/components/chat/Popup.mjs +11 -12
  26. package/dist/components/chat/Sidebar.js +65 -117
  27. package/dist/components/chat/Sidebar.js.map +1 -1
  28. package/dist/components/chat/Sidebar.mjs +11 -12
  29. package/dist/components/chat/index.js +67 -119
  30. package/dist/components/chat/index.js.map +1 -1
  31. package/dist/components/chat/index.mjs +14 -15
  32. package/dist/components/chat/messages/ErrorMessage.mjs +57 -4
  33. package/dist/components/chat/messages/ErrorMessage.mjs.map +1 -1
  34. package/dist/components/chat/messages/LegacyRenderMessage.mjs +3 -3
  35. package/dist/components/chat/messages/RenderMessage.mjs +2 -2
  36. package/dist/components/chat/props.d.ts +1 -1
  37. package/dist/components/chat/props.js.map +1 -1
  38. package/dist/components/dev-console/console.mjs +3 -3
  39. package/dist/components/dev-console/index.mjs +4 -4
  40. package/dist/components/index.js +67 -119
  41. package/dist/components/index.js.map +1 -1
  42. package/dist/components/index.mjs +15 -16
  43. package/dist/index.js +69 -121
  44. package/dist/index.js.map +1 -1
  45. package/dist/index.mjs +15 -16
  46. package/package.json +4 -4
  47. package/src/components/chat/Chat.tsx +1 -2
  48. package/src/components/chat/Messages.tsx +1 -1
  49. package/src/components/chat/props.ts +1 -1
  50. package/dist/chunk-PHH6DYUW.mjs.map +0 -1
  51. package/dist/chunk-SRY5COHG.mjs +0 -63
  52. package/dist/chunk-SRY5COHG.mjs.map +0 -1
  53. package/dist/chunk-Z66Y3KRE.mjs.map +0 -1
  54. /package/dist/{chunk-KCRWXHWT.mjs.map → chunk-DII7M2HW.mjs.map} +0 -0
  55. /package/dist/{chunk-FJFWH5AF.mjs.map → chunk-GKIR7J5D.mjs.map} +0 -0
  56. /package/dist/{chunk-YO63WHVQ.mjs.map → chunk-SP2PFXCH.mjs.map} +0 -0
  57. /package/dist/{chunk-QQDCZRPA.mjs.map → chunk-TNN2ZGO6.mjs.map} +0 -0
  58. /package/dist/{chunk-GDSZGYCE.mjs.map → chunk-V6DDX4LH.mjs.map} +0 -0
  59. /package/dist/{chunk-FFJHOZX6.mjs.map → chunk-WBPBTTQD.mjs.map} +0 -0
  60. /package/dist/{chunk-LJAYSRCB.mjs.map → chunk-WRQST6DJ.mjs.map} +0 -0
@@ -82,7 +82,7 @@ __export(Modal_exports, {
82
82
  CopilotModal: () => CopilotModal
83
83
  });
84
84
  module.exports = __toCommonJS(Modal_exports);
85
- var import_react16 = __toESM(require("react"));
85
+ var import_react15 = __toESM(require("react"));
86
86
 
87
87
  // src/components/chat/ChatContext.tsx
88
88
  var import_react = __toESM(require("react"));
@@ -1870,7 +1870,7 @@ var Messages = ({
1870
1870
  RenderMessage: RenderMessage2,
1871
1871
  AssistantMessage: AssistantMessage2,
1872
1872
  UserMessage: UserMessage2,
1873
- ErrorMessage: ErrorMessage2,
1873
+ ErrorMessage,
1874
1874
  ImageRenderer: ImageRenderer2,
1875
1875
  onRegenerate,
1876
1876
  onCopy,
@@ -1939,7 +1939,7 @@ var Messages = ({
1939
1939
  );
1940
1940
  }),
1941
1941
  interrupt,
1942
- chatError && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ErrorMessage2, { error: chatError, isCurrentMessage: true })
1942
+ chatError && ErrorMessage && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ErrorMessage, { error: chatError, isCurrentMessage: true })
1943
1943
  ] }),
1944
1944
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("footer", { className: "copilotKitMessagesFooter", ref: messagesEndRef, children })
1945
1945
  ] });
@@ -2322,67 +2322,15 @@ var Input = ({
2322
2322
  ] });
2323
2323
  };
2324
2324
 
2325
- // src/components/chat/messages/ErrorMessage.tsx
2326
- var import_react14 = require("react");
2327
- var import_jsx_runtime21 = require("react/jsx-runtime");
2328
- var ErrorMessage = (props) => {
2329
- const { icons, labels } = useChatContext();
2330
- const { error, onRegenerate, onCopy, isCurrentMessage } = props;
2331
- const [copied, setCopied] = (0, import_react14.useState)(false);
2332
- const handleCopy = () => {
2333
- const content = error.message;
2334
- if (content && onCopy) {
2335
- navigator.clipboard.writeText(content);
2336
- setCopied(true);
2337
- onCopy(content);
2338
- setTimeout(() => setCopied(false), 2e3);
2339
- } else if (content) {
2340
- navigator.clipboard.writeText(content);
2341
- setCopied(true);
2342
- setTimeout(() => setCopied(false), 2e3);
2343
- }
2344
- };
2345
- const handleRegenerate = () => {
2346
- if (onRegenerate)
2347
- onRegenerate();
2348
- };
2349
- console.log(error);
2350
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "copilotKitMessage copilotKitAssistantMessage", children: [
2351
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Markdown, { content: error.message }),
2352
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: `copilotKitMessageControls ${isCurrentMessage ? "currentMessage" : ""}`, children: [
2353
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2354
- "button",
2355
- {
2356
- className: "copilotKitMessageControlButton",
2357
- onClick: handleRegenerate,
2358
- "aria-label": labels.regenerateResponse,
2359
- title: labels.regenerateResponse,
2360
- children: icons.regenerateIcon
2361
- }
2362
- ),
2363
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2364
- "button",
2365
- {
2366
- className: "copilotKitMessageControlButton",
2367
- onClick: handleCopy,
2368
- "aria-label": labels.copyToClipboard,
2369
- title: labels.copyToClipboard,
2370
- children: copied ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { style: { fontSize: "10px", fontWeight: "bold" }, children: "\u2713" }) : icons.copyIcon
2371
- }
2372
- )
2373
- ] })
2374
- ] });
2375
- };
2376
-
2377
2325
  // src/components/chat/Chat.tsx
2378
- var import_react15 = __toESM(require("react"));
2326
+ var import_react14 = __toESM(require("react"));
2379
2327
  var import_react_core9 = require("@copilotkit/react-core");
2380
2328
  var import_shared3 = require("@copilotkit/shared");
2381
2329
  var import_shared4 = require("@copilotkit/shared");
2382
2330
  var import_react_core10 = require("@copilotkit/react-core");
2383
2331
 
2384
2332
  // src/components/chat/ImageUploadQueue.tsx
2385
- var import_jsx_runtime22 = require("react/jsx-runtime");
2333
+ var import_jsx_runtime21 = require("react/jsx-runtime");
2386
2334
  var ImageUploadQueue = ({
2387
2335
  images,
2388
2336
  onRemoveImage,
@@ -2390,7 +2338,7 @@ var ImageUploadQueue = ({
2390
2338
  }) => {
2391
2339
  if (images.length === 0)
2392
2340
  return null;
2393
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2341
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2394
2342
  "div",
2395
2343
  {
2396
2344
  className: `copilotKitImageUploadQueue ${className}`,
@@ -2401,7 +2349,7 @@ var ImageUploadQueue = ({
2401
2349
  margin: "8px",
2402
2350
  padding: "8px"
2403
2351
  },
2404
- children: images.map((image, index) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
2352
+ children: images.map((image, index) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
2405
2353
  "div",
2406
2354
  {
2407
2355
  className: "copilotKitImageUploadQueueItem",
@@ -2414,7 +2362,7 @@ var ImageUploadQueue = ({
2414
2362
  overflow: "hidden"
2415
2363
  },
2416
2364
  children: [
2417
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2365
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2418
2366
  "img",
2419
2367
  {
2420
2368
  src: `data:${image.contentType};base64,${image.bytes}`,
@@ -2426,7 +2374,7 @@ var ImageUploadQueue = ({
2426
2374
  }
2427
2375
  }
2428
2376
  ),
2429
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2377
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2430
2378
  "button",
2431
2379
  {
2432
2380
  onClick: () => onRemoveImage(index),
@@ -2461,12 +2409,12 @@ var ImageUploadQueue = ({
2461
2409
 
2462
2410
  // src/components/chat/Suggestion.tsx
2463
2411
  var import_react_core8 = require("@copilotkit/react-core");
2464
- var import_jsx_runtime23 = require("react/jsx-runtime");
2412
+ var import_jsx_runtime22 = require("react/jsx-runtime");
2465
2413
  function Suggestion({ title, onClick, partial, className }) {
2466
2414
  if (!title)
2467
2415
  return null;
2468
2416
  const { isLoading } = (0, import_react_core8.useCopilotChatInternal)();
2469
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2417
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2470
2418
  "button",
2471
2419
  {
2472
2420
  disabled: partial || isLoading,
@@ -2476,15 +2424,15 @@ function Suggestion({ title, onClick, partial, className }) {
2476
2424
  },
2477
2425
  className: className || (partial ? "suggestion loading" : "suggestion"),
2478
2426
  "data-test-id": "suggestion",
2479
- children: partial ? SmallSpinnerIcon : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: title })
2427
+ children: partial ? SmallSpinnerIcon : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { children: title })
2480
2428
  }
2481
2429
  );
2482
2430
  }
2483
2431
 
2484
2432
  // src/components/chat/Suggestions.tsx
2485
- var import_jsx_runtime24 = require("react/jsx-runtime");
2433
+ var import_jsx_runtime23 = require("react/jsx-runtime");
2486
2434
  function Suggestions({ suggestions, onSuggestionClick }) {
2487
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "suggestions", children: suggestions.map((suggestion, index) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2435
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "suggestions", children: suggestions.map((suggestion, index) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2488
2436
  Suggestion,
2489
2437
  {
2490
2438
  title: suggestion.title,
@@ -2498,7 +2446,7 @@ function Suggestions({ suggestions, onSuggestionClick }) {
2498
2446
  }
2499
2447
 
2500
2448
  // src/components/chat/Chat.tsx
2501
- var import_jsx_runtime25 = require("react/jsx-runtime");
2449
+ var import_jsx_runtime24 = require("react/jsx-runtime");
2502
2450
  function CopilotChat({
2503
2451
  instructions,
2504
2452
  suggestions = "auto",
@@ -2523,7 +2471,7 @@ function CopilotChat({
2523
2471
  AssistantMessage: AssistantMessage2 = AssistantMessage,
2524
2472
  UserMessage: UserMessage2 = UserMessage,
2525
2473
  ImageRenderer: ImageRenderer2 = ImageRenderer,
2526
- ErrorMessage: ErrorMessage2 = ErrorMessage,
2474
+ ErrorMessage,
2527
2475
  imageUploadsEnabled,
2528
2476
  inputFileAccept = "image/*",
2529
2477
  hideStopButton,
@@ -2546,10 +2494,10 @@ function CopilotChat({
2546
2494
  removeInternalErrorHandler
2547
2495
  } = (0, import_react_core9.useCopilotContext)();
2548
2496
  const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
2549
- const [selectedImages, setSelectedImages] = (0, import_react15.useState)([]);
2550
- const [chatError, setChatError] = (0, import_react15.useState)(null);
2551
- const fileInputRef = (0, import_react15.useRef)(null);
2552
- const triggerObservabilityHook = (0, import_react15.useCallback)(
2497
+ const [selectedImages, setSelectedImages] = (0, import_react14.useState)([]);
2498
+ const [chatError, setChatError] = (0, import_react14.useState)(null);
2499
+ const fileInputRef = (0, import_react14.useRef)(null);
2500
+ const triggerObservabilityHook = (0, import_react14.useCallback)(
2553
2501
  (hookName, ...args) => {
2554
2502
  if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
2555
2503
  observabilityHooks[hookName](...args);
@@ -2568,7 +2516,7 @@ function CopilotChat({
2568
2516
  },
2569
2517
  [publicApiKey, observabilityHooks, setBannerError]
2570
2518
  );
2571
- const triggerChatError = (0, import_react15.useCallback)(
2519
+ const triggerChatError = (0, import_react14.useCallback)(
2572
2520
  (error, operation, originalError) => {
2573
2521
  const errorMessage = (error == null ? void 0 : error.message) || (error == null ? void 0 : error.toString()) || "An error occurred";
2574
2522
  setChatError({
@@ -2614,7 +2562,7 @@ function CopilotChat({
2614
2562
  },
2615
2563
  [publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError]
2616
2564
  );
2617
- (0, import_react15.useEffect)(() => {
2565
+ (0, import_react14.useEffect)(() => {
2618
2566
  const id = "chat-component";
2619
2567
  setInternalErrorHandler({
2620
2568
  [id]: (error) => {
@@ -2627,7 +2575,7 @@ function CopilotChat({
2627
2575
  removeInternalErrorHandler == null ? void 0 : removeInternalErrorHandler(id);
2628
2576
  };
2629
2577
  }, [triggerChatError, setInternalErrorHandler, removeInternalErrorHandler]);
2630
- (0, import_react15.useEffect)(() => {
2578
+ (0, import_react14.useEffect)(() => {
2631
2579
  if (!imageUploadsEnabled)
2632
2580
  return;
2633
2581
  const handlePaste = (e) => __async(this, null, function* () {
@@ -2673,7 +2621,7 @@ function CopilotChat({
2673
2621
  document.addEventListener("paste", handlePaste);
2674
2622
  return () => document.removeEventListener("paste", handlePaste);
2675
2623
  }, [imageUploadsEnabled, triggerChatError]);
2676
- (0, import_react15.useEffect)(() => {
2624
+ (0, import_react14.useEffect)(() => {
2677
2625
  if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
2678
2626
  setChatInstructions(instructions || "");
2679
2627
  return;
@@ -2701,8 +2649,8 @@ function CopilotChat({
2701
2649
  onStopGeneration,
2702
2650
  onReloadMessages
2703
2651
  );
2704
- const prevIsLoading = (0, import_react15.useRef)(isLoading);
2705
- (0, import_react15.useEffect)(() => {
2652
+ const prevIsLoading = (0, import_react14.useRef)(isLoading);
2653
+ (0, import_react14.useEffect)(() => {
2706
2654
  if (prevIsLoading.current !== isLoading) {
2707
2655
  if (isLoading) {
2708
2656
  triggerObservabilityHook("onChatStarted");
@@ -2721,7 +2669,7 @@ function CopilotChat({
2721
2669
  triggerObservabilityHook("onMessageSent", text);
2722
2670
  return sendMessage(text, images);
2723
2671
  };
2724
- const chatContext = import_react15.default.useContext(ChatContext);
2672
+ const chatContext = import_react14.default.useContext(ChatContext);
2725
2673
  const isVisible = chatContext ? chatContext.open : true;
2726
2674
  const handleRegenerate = (messageId) => {
2727
2675
  if (onRegenerate) {
@@ -2783,14 +2731,14 @@ function CopilotChat({
2783
2731
  }
2784
2732
  triggerObservabilityHook("onFeedbackGiven", message.id, "thumbsDown");
2785
2733
  };
2786
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
2734
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
2787
2735
  chatError && renderError && renderError(__spreadProps(__spreadValues({}, chatError), {
2788
2736
  onDismiss: () => setChatError(null),
2789
2737
  onRetry: () => {
2790
2738
  setChatError(null);
2791
2739
  }
2792
2740
  })),
2793
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2741
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2794
2742
  Messages2,
2795
2743
  {
2796
2744
  AssistantMessage: AssistantMessage2,
@@ -2804,14 +2752,14 @@ function CopilotChat({
2804
2752
  onThumbsDown: handleThumbsDown,
2805
2753
  markdownTagRenderers,
2806
2754
  ImageRenderer: ImageRenderer2,
2807
- ErrorMessage: ErrorMessage2,
2755
+ ErrorMessage,
2808
2756
  chatError,
2809
2757
  RenderTextMessage,
2810
2758
  RenderActionExecutionMessage,
2811
2759
  RenderAgentStateMessage,
2812
2760
  RenderResultMessage,
2813
2761
  RenderImageMessage,
2814
- children: currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2762
+ children: currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2815
2763
  RenderSuggestionsList,
2816
2764
  {
2817
2765
  onSuggestionClick: handleSendMessage,
@@ -2820,9 +2768,9 @@ function CopilotChat({
2820
2768
  )
2821
2769
  }
2822
2770
  ),
2823
- imageUploadsEnabled && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
2824
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ImageUploadQueue, { images: selectedImages, onRemoveImage: removeSelectedImage }),
2825
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2771
+ imageUploadsEnabled && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
2772
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ImageUploadQueue, { images: selectedImages, onRemoveImage: removeSelectedImage }),
2773
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2826
2774
  "input",
2827
2775
  {
2828
2776
  type: "file",
@@ -2834,7 +2782,7 @@ function CopilotChat({
2834
2782
  }
2835
2783
  )
2836
2784
  ] }),
2837
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2785
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2838
2786
  Input2,
2839
2787
  {
2840
2788
  inProgress: isLoading,
@@ -2856,12 +2804,12 @@ function WrappedCopilotChat({
2856
2804
  labels,
2857
2805
  className
2858
2806
  }) {
2859
- const chatContext = import_react15.default.useContext(ChatContext);
2807
+ const chatContext = import_react14.default.useContext(ChatContext);
2860
2808
  if (!chatContext) {
2861
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
2862
- }, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: `copilotKitChat ${className != null ? className : ""}`, children }) });
2809
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
2810
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: `copilotKitChat ${className != null ? className : ""}`, children }) });
2863
2811
  }
2864
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children });
2812
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children });
2865
2813
  }
2866
2814
  var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMessage, onInProgress, onSubmitMessage, onStopGeneration, onReloadMessages) => {
2867
2815
  var _a;
@@ -2885,15 +2833,15 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
2885
2833
  const generalContext = (0, import_react_core9.useCopilotContext)();
2886
2834
  const messagesContext = (0, import_react_core9.useCopilotMessagesContext)();
2887
2835
  const { actions } = generalContext;
2888
- const [suggestionsFailed, setSuggestionsFailed] = (0, import_react15.useState)(false);
2889
- const hasGeneratedInitialSuggestions = (0, import_react15.useRef)(false);
2890
- (0, import_react15.useEffect)(() => {
2836
+ const [suggestionsFailed, setSuggestionsFailed] = (0, import_react14.useState)(false);
2837
+ const hasGeneratedInitialSuggestions = (0, import_react14.useRef)(false);
2838
+ (0, import_react14.useEffect)(() => {
2891
2839
  if (Array.isArray(chatSuggestions)) {
2892
2840
  setSuggestions(chatSuggestions);
2893
2841
  hasGeneratedInitialSuggestions.current = true;
2894
2842
  }
2895
2843
  }, [JSON.stringify(chatSuggestions), setSuggestions]);
2896
- const generateSuggestionsWithErrorHandling = (0, import_react15.useCallback)(
2844
+ const generateSuggestionsWithErrorHandling = (0, import_react14.useCallback)(
2897
2845
  (context) => __async(void 0, null, function* () {
2898
2846
  try {
2899
2847
  yield generateSuggestions();
@@ -2904,7 +2852,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
2904
2852
  }),
2905
2853
  [generateSuggestions]
2906
2854
  );
2907
- (0, import_react15.useEffect)(() => {
2855
+ (0, import_react14.useEffect)(() => {
2908
2856
  if (chatSuggestions !== "auto" || isLoadingSuggestions || suggestionsFailed) {
2909
2857
  return;
2910
2858
  }
@@ -2934,13 +2882,13 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
2934
2882
  // Use stable string instead of object reference
2935
2883
  generateSuggestionsWithErrorHandling
2936
2884
  ]);
2937
- (0, import_react15.useEffect)(() => {
2885
+ (0, import_react14.useEffect)(() => {
2938
2886
  if (chatSuggestions !== "auto") {
2939
2887
  hasGeneratedInitialSuggestions.current = false;
2940
2888
  setSuggestionsFailed(false);
2941
2889
  }
2942
2890
  }, [chatSuggestions]);
2943
- const stableContext = (0, import_react15.useMemo)(
2891
+ const stableContext = (0, import_react14.useMemo)(
2944
2892
  () => __spreadValues(__spreadValues({}, generalContext), messagesContext),
2945
2893
  [
2946
2894
  // Only include stable dependencies
@@ -2949,12 +2897,12 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
2949
2897
  generalContext.isLoading
2950
2898
  ]
2951
2899
  );
2952
- const resetSuggestions = (0, import_react15.useCallback)(() => {
2900
+ const resetSuggestions = (0, import_react14.useCallback)(() => {
2953
2901
  resetSuggestionsFromHook();
2954
2902
  setSuggestionsFailed(false);
2955
2903
  hasGeneratedInitialSuggestions.current = false;
2956
2904
  }, [resetSuggestionsFromHook]);
2957
- (0, import_react15.useEffect)(() => {
2905
+ (0, import_react14.useEffect)(() => {
2958
2906
  onInProgress == null ? void 0 : onInProgress(isLoading);
2959
2907
  }, [onInProgress, isLoading]);
2960
2908
  const safelySendMessage = (messageContent, imagesToUse) => __async(void 0, null, function* () {
@@ -3100,7 +3048,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
3100
3048
  // src/components/chat/Modal.tsx
3101
3049
  var import_react_core11 = require("@copilotkit/react-core");
3102
3050
  var import_shared5 = require("@copilotkit/shared");
3103
- var import_jsx_runtime26 = require("react/jsx-runtime");
3051
+ var import_jsx_runtime25 = require("react/jsx-runtime");
3104
3052
  var CopilotModalInner = (_a) => {
3105
3053
  var _b = _a, {
3106
3054
  observabilityHooks,
@@ -3127,7 +3075,7 @@ var CopilotModalInner = (_a) => {
3127
3075
  ]);
3128
3076
  const { copilotApiConfig, setBannerError } = (0, import_react_core11.useCopilotContext)();
3129
3077
  const { publicApiKey } = copilotApiConfig;
3130
- const triggerObservabilityHook = (0, import_react16.useCallback)(
3078
+ const triggerObservabilityHook = (0, import_react15.useCallback)(
3131
3079
  (hookName, ...args) => {
3132
3080
  if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
3133
3081
  observabilityHooks[hookName](...args);
@@ -3147,8 +3095,8 @@ var CopilotModalInner = (_a) => {
3147
3095
  [publicApiKey, observabilityHooks, setBannerError]
3148
3096
  );
3149
3097
  const { open } = useChatContext();
3150
- const prevOpen = (0, import_react16.useRef)(open);
3151
- (0, import_react16.useEffect)(() => {
3098
+ const prevOpen = (0, import_react15.useRef)(open);
3099
+ (0, import_react15.useEffect)(() => {
3152
3100
  if (prevOpen.current !== open) {
3153
3101
  onSetOpen == null ? void 0 : onSetOpen(open);
3154
3102
  if (open) {
@@ -3159,13 +3107,13 @@ var CopilotModalInner = (_a) => {
3159
3107
  prevOpen.current = open;
3160
3108
  }
3161
3109
  }, [open, onSetOpen, triggerObservabilityHook]);
3162
- const memoizedHeader = (0, import_react16.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Header2, {}), [Header2]);
3163
- const memoizedChildren = (0, import_react16.useMemo)(() => children, [children]);
3164
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
3110
+ const memoizedHeader = (0, import_react15.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Header2, {}), [Header2]);
3111
+ const memoizedChildren = (0, import_react15.useMemo)(() => children, [children]);
3112
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
3165
3113
  memoizedChildren,
3166
- /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className, children: [
3167
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Button2, {}),
3168
- /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
3114
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className, children: [
3115
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Button2, {}),
3116
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
3169
3117
  Window2,
3170
3118
  {
3171
3119
  clickOutsideToClose,
@@ -3173,7 +3121,7 @@ var CopilotModalInner = (_a) => {
3173
3121
  hitEscapeToClose,
3174
3122
  children: [
3175
3123
  memoizedHeader,
3176
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(CopilotChat, __spreadProps(__spreadValues({}, chatProps), { observabilityHooks }))
3124
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(CopilotChat, __spreadProps(__spreadValues({}, chatProps), { observabilityHooks }))
3177
3125
  ]
3178
3126
  }
3179
3127
  )
@@ -3240,8 +3188,8 @@ var CopilotModal = (_a) => {
3240
3188
  "children",
3241
3189
  "observabilityHooks"
3242
3190
  ]);
3243
- const [openState, setOpenState] = import_react16.default.useState(defaultOpen);
3244
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ChatContextProvider, { icons, labels, open: openState, setOpen: setOpenState, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
3191
+ const [openState, setOpenState] = import_react15.default.useState(defaultOpen);
3192
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChatContextProvider, { icons, labels, open: openState, setOpen: setOpenState, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3245
3193
  CopilotModalInner,
3246
3194
  __spreadProps(__spreadValues({
3247
3195
  observabilityHooks,