@copilotkit/react-ui 1.10.5-next.9 → 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.
Files changed (43) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/{chunk-QPONDGDJ.mjs → chunk-5HQD6ZPA.mjs} +2 -2
  3. package/dist/{chunk-DSNTTAJX.mjs → chunk-7HAFY2YK.mjs} +3 -3
  4. package/dist/{chunk-CGEAG65D.mjs → chunk-ELGRNEAO.mjs} +7 -2
  5. package/dist/chunk-ELGRNEAO.mjs.map +1 -0
  6. package/dist/{chunk-K2FLPUR5.mjs → chunk-G7VB7A4O.mjs} +2 -2
  7. package/dist/{chunk-SDQTGCT2.mjs → chunk-SNGWNZNH.mjs} +2 -2
  8. package/dist/{chunk-DTRPPNSA.mjs → chunk-ZJCHKHE4.mjs} +2 -2
  9. package/dist/components/chat/Chat.js +36 -29
  10. package/dist/components/chat/Chat.js.map +1 -1
  11. package/dist/components/chat/Chat.mjs +3 -3
  12. package/dist/components/chat/Input.js +14 -7
  13. package/dist/components/chat/Input.js.map +1 -1
  14. package/dist/components/chat/Input.mjs +2 -2
  15. package/dist/components/chat/Modal.js +43 -36
  16. package/dist/components/chat/Modal.js.map +1 -1
  17. package/dist/components/chat/Modal.mjs +4 -4
  18. package/dist/components/chat/Popup.js +43 -36
  19. package/dist/components/chat/Popup.js.map +1 -1
  20. package/dist/components/chat/Popup.mjs +5 -5
  21. package/dist/components/chat/PoweredByTag.js +6 -1
  22. package/dist/components/chat/PoweredByTag.js.map +1 -1
  23. package/dist/components/chat/PoweredByTag.mjs +1 -1
  24. package/dist/components/chat/Sidebar.js +45 -38
  25. package/dist/components/chat/Sidebar.js.map +1 -1
  26. package/dist/components/chat/Sidebar.mjs +5 -5
  27. package/dist/components/chat/index.js +45 -38
  28. package/dist/components/chat/index.js.map +1 -1
  29. package/dist/components/chat/index.mjs +6 -6
  30. package/dist/components/index.js +45 -38
  31. package/dist/components/index.js.map +1 -1
  32. package/dist/components/index.mjs +6 -6
  33. package/dist/index.js +47 -40
  34. package/dist/index.js.map +1 -1
  35. package/dist/index.mjs +11 -11
  36. package/package.json +4 -4
  37. package/src/components/chat/PoweredByTag.tsx +15 -2
  38. package/dist/chunk-CGEAG65D.mjs.map +0 -1
  39. /package/dist/{chunk-QPONDGDJ.mjs.map → chunk-5HQD6ZPA.mjs.map} +0 -0
  40. /package/dist/{chunk-DSNTTAJX.mjs.map → chunk-7HAFY2YK.mjs.map} +0 -0
  41. /package/dist/{chunk-K2FLPUR5.mjs.map → chunk-G7VB7A4O.mjs.map} +0 -0
  42. /package/dist/{chunk-SDQTGCT2.mjs.map → chunk-SNGWNZNH.mjs.map} +0 -0
  43. /package/dist/{chunk-DTRPPNSA.mjs.map → chunk-ZJCHKHE4.mjs.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CopilotModal
3
- } from "../../chunk-DSNTTAJX.mjs";
3
+ } from "../../chunk-7HAFY2YK.mjs";
4
4
  import "../../chunk-C3GSYRC3.mjs";
5
5
  import "../../chunk-GDSZGYCE.mjs";
6
6
  import "../../chunk-V7W6IM2V.mjs";
@@ -11,12 +11,12 @@ import "../../chunk-KXE2JCUH.mjs";
11
11
  import "../../chunk-NRA3CFEE.mjs";
12
12
  import "../../chunk-BH6PCAAL.mjs";
13
13
  import "../../chunk-UFN2VWSR.mjs";
14
- import "../../chunk-K2FLPUR5.mjs";
14
+ import "../../chunk-G7VB7A4O.mjs";
15
15
  import "../../chunk-226ZMOE3.mjs";
16
16
  import "../../chunk-W26XFBEG.mjs";
17
17
  import "../../chunk-PLHTVHUW.mjs";
18
- import "../../chunk-DTRPPNSA.mjs";
19
- import "../../chunk-CGEAG65D.mjs";
18
+ import "../../chunk-ZJCHKHE4.mjs";
19
+ import "../../chunk-ELGRNEAO.mjs";
20
20
  import "../../chunk-QIOJXTIQ.mjs";
21
21
  import "../../chunk-W7ONZTSW.mjs";
22
22
  import "../../chunk-2LIO4Z3E.mjs";
@@ -84,7 +84,7 @@ __export(Popup_exports, {
84
84
  module.exports = __toCommonJS(Popup_exports);
85
85
 
86
86
  // src/components/chat/Modal.tsx
87
- var import_react15 = __toESM(require("react"));
87
+ var import_react16 = __toESM(require("react"));
88
88
 
89
89
  // src/components/chat/ChatContext.tsx
90
90
  var import_react = __toESM(require("react"));
@@ -2036,7 +2036,7 @@ function useScrollToBottom(messages) {
2036
2036
  }
2037
2037
 
2038
2038
  // src/components/chat/Input.tsx
2039
- var import_react13 = require("react");
2039
+ var import_react14 = require("react");
2040
2040
 
2041
2041
  // src/components/chat/Textarea.tsx
2042
2042
  var import_react11 = require("react");
@@ -2205,6 +2205,9 @@ var usePushToTalk = ({
2205
2205
  // src/components/chat/Input.tsx
2206
2206
  var import_react_core7 = require("@copilotkit/react-core");
2207
2207
 
2208
+ // src/components/chat/PoweredByTag.tsx
2209
+ var import_react13 = require("react");
2210
+
2208
2211
  // src/hooks/use-dark-mode.ts
2209
2212
  var useDarkMode = () => {
2210
2213
  if (typeof window === "undefined")
@@ -2215,7 +2218,11 @@ var useDarkMode = () => {
2215
2218
  // src/components/chat/PoweredByTag.tsx
2216
2219
  var import_jsx_runtime19 = require("react/jsx-runtime");
2217
2220
  function PoweredByTag({ showPoweredBy = true }) {
2221
+ const [mounted, setMounted] = (0, import_react13.useState)(false);
2218
2222
  const isDark = useDarkMode();
2223
+ (0, import_react13.useEffect)(() => {
2224
+ setMounted(true);
2225
+ }, []);
2219
2226
  if (!showPoweredBy) {
2220
2227
  return null;
2221
2228
  }
@@ -2226,7 +2233,7 @@ function PoweredByTag({ showPoweredBy = true }) {
2226
2233
  textAlign: "center",
2227
2234
  fontSize: "12px",
2228
2235
  padding: "3px 0",
2229
- color: isDark ? "rgb(69, 69, 69)" : "rgb(214, 214, 214)"
2236
+ color: mounted && isDark ? "rgb(69, 69, 69)" : "rgb(214, 214, 214)"
2230
2237
  };
2231
2238
  return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "poweredBy", style: poweredByStyle, children: "Powered by CopilotKit" }) });
2232
2239
  }
@@ -2247,8 +2254,8 @@ var Input = ({
2247
2254
  const copilotContext = (0, import_react_core7.useCopilotContext)();
2248
2255
  const showPoweredBy = !((_a = copilotContext.copilotApiConfig) == null ? void 0 : _a.publicApiKey);
2249
2256
  const pushToTalkConfigured = copilotContext.copilotApiConfig.textToSpeechUrl !== void 0 && copilotContext.copilotApiConfig.transcribeAudioUrl !== void 0;
2250
- const textareaRef = (0, import_react13.useRef)(null);
2251
- const [isComposing, setIsComposing] = (0, import_react13.useState)(false);
2257
+ const textareaRef = (0, import_react14.useRef)(null);
2258
+ const [isComposing, setIsComposing] = (0, import_react14.useState)(false);
2252
2259
  const handleDivClick = (event) => {
2253
2260
  var _a2;
2254
2261
  const target = event.target;
@@ -2258,7 +2265,7 @@ var Input = ({
2258
2265
  return;
2259
2266
  (_a2 = textareaRef.current) == null ? void 0 : _a2.focus();
2260
2267
  };
2261
- const [text, setText] = (0, import_react13.useState)("");
2268
+ const [text, setText] = (0, import_react14.useState)("");
2262
2269
  const send = () => {
2263
2270
  var _a2;
2264
2271
  if (inProgress)
@@ -2274,13 +2281,13 @@ var Input = ({
2274
2281
  const isInProgress = inProgress || pushToTalkState === "transcribing";
2275
2282
  const buttonIcon = isInProgress && !hideStopButton ? context.icons.stopIcon : context.icons.sendIcon;
2276
2283
  const showPushToTalk = pushToTalkConfigured && (pushToTalkState === "idle" || pushToTalkState === "recording") && !inProgress;
2277
- const canSend = (0, import_react13.useMemo)(() => {
2284
+ const canSend = (0, import_react14.useMemo)(() => {
2278
2285
  var _a2;
2279
2286
  const interruptEvent = (_a2 = copilotContext.langGraphInterruptAction) == null ? void 0 : _a2.event;
2280
2287
  const interruptInProgress = (interruptEvent == null ? void 0 : interruptEvent.name) === "LangGraphInterruptEvent" && !(interruptEvent == null ? void 0 : interruptEvent.response);
2281
2288
  return !isInProgress && text.trim().length > 0 && pushToTalkState === "idle" && !interruptInProgress;
2282
2289
  }, [(_b = copilotContext.langGraphInterruptAction) == null ? void 0 : _b.event, isInProgress, text, pushToTalkState]);
2283
- const canStop = (0, import_react13.useMemo)(() => {
2290
+ const canStop = (0, import_react14.useMemo)(() => {
2284
2291
  return isInProgress && !hideStopButton;
2285
2292
  }, [isInProgress, hideStopButton]);
2286
2293
  const sendDisabled = !canSend && !canStop;
@@ -2336,7 +2343,7 @@ var Input = ({
2336
2343
  };
2337
2344
 
2338
2345
  // src/components/chat/Chat.tsx
2339
- var import_react14 = __toESM(require("react"));
2346
+ var import_react15 = __toESM(require("react"));
2340
2347
  var import_react_core9 = require("@copilotkit/react-core");
2341
2348
  var import_shared3 = require("@copilotkit/shared");
2342
2349
  var import_shared4 = require("@copilotkit/shared");
@@ -2507,10 +2514,10 @@ function CopilotChat({
2507
2514
  removeInternalErrorHandler
2508
2515
  } = (0, import_react_core9.useCopilotContext)();
2509
2516
  const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
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)(
2517
+ const [selectedImages, setSelectedImages] = (0, import_react15.useState)([]);
2518
+ const [chatError, setChatError] = (0, import_react15.useState)(null);
2519
+ const fileInputRef = (0, import_react15.useRef)(null);
2520
+ const triggerObservabilityHook = (0, import_react15.useCallback)(
2514
2521
  (hookName, ...args) => {
2515
2522
  if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
2516
2523
  observabilityHooks[hookName](...args);
@@ -2529,7 +2536,7 @@ function CopilotChat({
2529
2536
  },
2530
2537
  [publicApiKey, observabilityHooks, setBannerError]
2531
2538
  );
2532
- const triggerChatError = (0, import_react14.useCallback)(
2539
+ const triggerChatError = (0, import_react15.useCallback)(
2533
2540
  (error, operation, originalError) => {
2534
2541
  const errorMessage = (error == null ? void 0 : error.message) || (error == null ? void 0 : error.toString()) || "An error occurred";
2535
2542
  setChatError({
@@ -2575,7 +2582,7 @@ function CopilotChat({
2575
2582
  },
2576
2583
  [publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError]
2577
2584
  );
2578
- (0, import_react14.useEffect)(() => {
2585
+ (0, import_react15.useEffect)(() => {
2579
2586
  const id = "chat-component";
2580
2587
  setInternalErrorHandler({
2581
2588
  [id]: (error) => {
@@ -2588,7 +2595,7 @@ function CopilotChat({
2588
2595
  removeInternalErrorHandler == null ? void 0 : removeInternalErrorHandler(id);
2589
2596
  };
2590
2597
  }, [triggerChatError, setInternalErrorHandler, removeInternalErrorHandler]);
2591
- (0, import_react14.useEffect)(() => {
2598
+ (0, import_react15.useEffect)(() => {
2592
2599
  if (!imageUploadsEnabled)
2593
2600
  return;
2594
2601
  const handlePaste = (e) => __async(this, null, function* () {
@@ -2634,7 +2641,7 @@ function CopilotChat({
2634
2641
  document.addEventListener("paste", handlePaste);
2635
2642
  return () => document.removeEventListener("paste", handlePaste);
2636
2643
  }, [imageUploadsEnabled, triggerChatError]);
2637
- (0, import_react14.useEffect)(() => {
2644
+ (0, import_react15.useEffect)(() => {
2638
2645
  if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
2639
2646
  setChatInstructions(instructions || "");
2640
2647
  return;
@@ -2662,8 +2669,8 @@ function CopilotChat({
2662
2669
  onStopGeneration,
2663
2670
  onReloadMessages
2664
2671
  );
2665
- const prevIsLoading = (0, import_react14.useRef)(isLoading);
2666
- (0, import_react14.useEffect)(() => {
2672
+ const prevIsLoading = (0, import_react15.useRef)(isLoading);
2673
+ (0, import_react15.useEffect)(() => {
2667
2674
  if (prevIsLoading.current !== isLoading) {
2668
2675
  if (isLoading) {
2669
2676
  triggerObservabilityHook("onChatStarted");
@@ -2682,7 +2689,7 @@ function CopilotChat({
2682
2689
  triggerObservabilityHook("onMessageSent", text);
2683
2690
  return sendMessage(text, images);
2684
2691
  };
2685
- const chatContext = import_react14.default.useContext(ChatContext);
2692
+ const chatContext = import_react15.default.useContext(ChatContext);
2686
2693
  const isVisible = chatContext ? chatContext.open : true;
2687
2694
  const handleRegenerate = (messageId) => {
2688
2695
  if (onRegenerate) {
@@ -2817,7 +2824,7 @@ function WrappedCopilotChat({
2817
2824
  labels,
2818
2825
  className
2819
2826
  }) {
2820
- const chatContext = import_react14.default.useContext(ChatContext);
2827
+ const chatContext = import_react15.default.useContext(ChatContext);
2821
2828
  if (!chatContext) {
2822
2829
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
2823
2830
  }, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: `copilotKitChat ${className != null ? className : ""}`, children }) });
@@ -2846,15 +2853,15 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
2846
2853
  const generalContext = (0, import_react_core9.useCopilotContext)();
2847
2854
  const messagesContext = (0, import_react_core9.useCopilotMessagesContext)();
2848
2855
  const { actions } = generalContext;
2849
- const [suggestionsFailed, setSuggestionsFailed] = (0, import_react14.useState)(false);
2850
- const hasGeneratedInitialSuggestions = (0, import_react14.useRef)(false);
2851
- (0, import_react14.useEffect)(() => {
2856
+ const [suggestionsFailed, setSuggestionsFailed] = (0, import_react15.useState)(false);
2857
+ const hasGeneratedInitialSuggestions = (0, import_react15.useRef)(false);
2858
+ (0, import_react15.useEffect)(() => {
2852
2859
  if (Array.isArray(chatSuggestions)) {
2853
2860
  setSuggestions(chatSuggestions);
2854
2861
  hasGeneratedInitialSuggestions.current = true;
2855
2862
  }
2856
2863
  }, [JSON.stringify(chatSuggestions), setSuggestions]);
2857
- const generateSuggestionsWithErrorHandling = (0, import_react14.useCallback)(
2864
+ const generateSuggestionsWithErrorHandling = (0, import_react15.useCallback)(
2858
2865
  (context) => __async(void 0, null, function* () {
2859
2866
  try {
2860
2867
  yield generateSuggestions();
@@ -2865,7 +2872,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
2865
2872
  }),
2866
2873
  [generateSuggestions]
2867
2874
  );
2868
- (0, import_react14.useEffect)(() => {
2875
+ (0, import_react15.useEffect)(() => {
2869
2876
  if (chatSuggestions !== "auto" || isLoadingSuggestions || suggestionsFailed) {
2870
2877
  return;
2871
2878
  }
@@ -2895,13 +2902,13 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
2895
2902
  // Use stable string instead of object reference
2896
2903
  generateSuggestionsWithErrorHandling
2897
2904
  ]);
2898
- (0, import_react14.useEffect)(() => {
2905
+ (0, import_react15.useEffect)(() => {
2899
2906
  if (chatSuggestions !== "auto") {
2900
2907
  hasGeneratedInitialSuggestions.current = false;
2901
2908
  setSuggestionsFailed(false);
2902
2909
  }
2903
2910
  }, [chatSuggestions]);
2904
- const stableContext = (0, import_react14.useMemo)(
2911
+ const stableContext = (0, import_react15.useMemo)(
2905
2912
  () => __spreadValues(__spreadValues({}, generalContext), messagesContext),
2906
2913
  [
2907
2914
  // Only include stable dependencies
@@ -2910,12 +2917,12 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
2910
2917
  generalContext.isLoading
2911
2918
  ]
2912
2919
  );
2913
- const resetSuggestions = (0, import_react14.useCallback)(() => {
2920
+ const resetSuggestions = (0, import_react15.useCallback)(() => {
2914
2921
  resetSuggestionsFromHook();
2915
2922
  setSuggestionsFailed(false);
2916
2923
  hasGeneratedInitialSuggestions.current = false;
2917
2924
  }, [resetSuggestionsFromHook]);
2918
- (0, import_react14.useEffect)(() => {
2925
+ (0, import_react15.useEffect)(() => {
2919
2926
  onInProgress == null ? void 0 : onInProgress(isLoading);
2920
2927
  }, [onInProgress, isLoading]);
2921
2928
  const safelySendMessage = (messageContent, imagesToUse) => __async(void 0, null, function* () {
@@ -3088,7 +3095,7 @@ var CopilotModalInner = (_a) => {
3088
3095
  ]);
3089
3096
  const { copilotApiConfig, setBannerError } = (0, import_react_core11.useCopilotContext)();
3090
3097
  const { publicApiKey } = copilotApiConfig;
3091
- const triggerObservabilityHook = (0, import_react15.useCallback)(
3098
+ const triggerObservabilityHook = (0, import_react16.useCallback)(
3092
3099
  (hookName, ...args) => {
3093
3100
  if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
3094
3101
  observabilityHooks[hookName](...args);
@@ -3108,8 +3115,8 @@ var CopilotModalInner = (_a) => {
3108
3115
  [publicApiKey, observabilityHooks, setBannerError]
3109
3116
  );
3110
3117
  const { open } = useChatContext();
3111
- const prevOpen = (0, import_react15.useRef)(open);
3112
- (0, import_react15.useEffect)(() => {
3118
+ const prevOpen = (0, import_react16.useRef)(open);
3119
+ (0, import_react16.useEffect)(() => {
3113
3120
  if (prevOpen.current !== open) {
3114
3121
  onSetOpen == null ? void 0 : onSetOpen(open);
3115
3122
  if (open) {
@@ -3120,8 +3127,8 @@ var CopilotModalInner = (_a) => {
3120
3127
  prevOpen.current = open;
3121
3128
  }
3122
3129
  }, [open, onSetOpen, triggerObservabilityHook]);
3123
- const memoizedHeader = (0, import_react15.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Header2, {}), [Header2]);
3124
- const memoizedChildren = (0, import_react15.useMemo)(() => children, [children]);
3130
+ const memoizedHeader = (0, import_react16.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Header2, {}), [Header2]);
3131
+ const memoizedChildren = (0, import_react16.useMemo)(() => children, [children]);
3125
3132
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
3126
3133
  memoizedChildren,
3127
3134
  /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className, children: [
@@ -3201,7 +3208,7 @@ var CopilotModal = (_a) => {
3201
3208
  "children",
3202
3209
  "observabilityHooks"
3203
3210
  ]);
3204
- const [openState, setOpenState] = import_react15.default.useState(defaultOpen);
3211
+ const [openState, setOpenState] = import_react16.default.useState(defaultOpen);
3205
3212
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChatContextProvider, { icons, labels, open: openState, setOpen: setOpenState, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3206
3213
  CopilotModalInner,
3207
3214
  __spreadProps(__spreadValues({