@copilotkit/react-ui 1.51.2 → 1.51.3-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 (65) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/{chunk-DI7DDMRS.mjs → chunk-4S4ZEKE6.mjs} +2 -2
  3. package/dist/{chunk-BVKKSSB2.mjs → chunk-HKZL4P3F.mjs} +4 -4
  4. package/dist/{chunk-VVCCMYGT.mjs → chunk-O4PPO3K3.mjs} +2 -2
  5. package/dist/{chunk-7OURDQZJ.mjs → chunk-PKSW6ZMQ.mjs} +2 -2
  6. package/dist/{chunk-IHFR6PYG.mjs → chunk-SLM2AOHF.mjs} +2 -2
  7. package/dist/{chunk-HIW7RXCD.mjs → chunk-UH5GQ7QF.mjs} +2 -2
  8. package/dist/{chunk-NCIAFFQ2.mjs → chunk-XEZ5ODJS.mjs} +2 -2
  9. package/dist/{chunk-JZ3RFQQ6.mjs → chunk-XOBQLKUU.mjs} +3 -13
  10. package/dist/chunk-XOBQLKUU.mjs.map +1 -0
  11. package/dist/{chunk-NSJWSIPR.mjs → chunk-YQOESY4Y.mjs} +4 -4
  12. package/dist/components/chat/Chat.js +57 -67
  13. package/dist/components/chat/Chat.js.map +1 -1
  14. package/dist/components/chat/Chat.mjs +6 -6
  15. package/dist/components/chat/Markdown.d.ts +4 -2
  16. package/dist/components/chat/Markdown.js +2 -12
  17. package/dist/components/chat/Markdown.js.map +1 -1
  18. package/dist/components/chat/Markdown.mjs +1 -1
  19. package/dist/components/chat/Messages.js +17 -27
  20. package/dist/components/chat/Messages.js.map +1 -1
  21. package/dist/components/chat/Messages.mjs +5 -5
  22. package/dist/components/chat/Modal.js +64 -74
  23. package/dist/components/chat/Modal.js.map +1 -1
  24. package/dist/components/chat/Modal.mjs +7 -7
  25. package/dist/components/chat/Popup.js +64 -74
  26. package/dist/components/chat/Popup.js.map +1 -1
  27. package/dist/components/chat/Popup.mjs +8 -8
  28. package/dist/components/chat/Sidebar.js +66 -76
  29. package/dist/components/chat/Sidebar.js.map +1 -1
  30. package/dist/components/chat/Sidebar.mjs +8 -8
  31. package/dist/components/chat/index.d.ts +1 -1
  32. package/dist/components/chat/index.js +66 -76
  33. package/dist/components/chat/index.js.map +1 -1
  34. package/dist/components/chat/index.mjs +9 -9
  35. package/dist/components/chat/messages/AssistantMessage.js +4 -14
  36. package/dist/components/chat/messages/AssistantMessage.js.map +1 -1
  37. package/dist/components/chat/messages/AssistantMessage.mjs +2 -2
  38. package/dist/components/chat/messages/ErrorMessage.js +4 -14
  39. package/dist/components/chat/messages/ErrorMessage.js.map +1 -1
  40. package/dist/components/chat/messages/ErrorMessage.mjs +1 -1
  41. package/dist/components/chat/messages/LegacyRenderMessage.js +6 -16
  42. package/dist/components/chat/messages/LegacyRenderMessage.js.map +1 -1
  43. package/dist/components/chat/messages/LegacyRenderMessage.mjs +4 -4
  44. package/dist/components/chat/messages/RenderMessage.js +6 -16
  45. package/dist/components/chat/messages/RenderMessage.js.map +1 -1
  46. package/dist/components/chat/messages/RenderMessage.mjs +3 -3
  47. package/dist/components/index.d.ts +1 -1
  48. package/dist/components/index.js +66 -76
  49. package/dist/components/index.js.map +1 -1
  50. package/dist/components/index.mjs +9 -9
  51. package/dist/index.d.ts +1 -1
  52. package/dist/index.js +66 -76
  53. package/dist/index.js.map +1 -1
  54. package/dist/index.mjs +9 -9
  55. package/package.json +5 -8
  56. package/src/components/chat/Markdown.tsx +8 -17
  57. package/dist/chunk-JZ3RFQQ6.mjs.map +0 -1
  58. /package/dist/{chunk-DI7DDMRS.mjs.map → chunk-4S4ZEKE6.mjs.map} +0 -0
  59. /package/dist/{chunk-BVKKSSB2.mjs.map → chunk-HKZL4P3F.mjs.map} +0 -0
  60. /package/dist/{chunk-VVCCMYGT.mjs.map → chunk-O4PPO3K3.mjs.map} +0 -0
  61. /package/dist/{chunk-7OURDQZJ.mjs.map → chunk-PKSW6ZMQ.mjs.map} +0 -0
  62. /package/dist/{chunk-IHFR6PYG.mjs.map → chunk-SLM2AOHF.mjs.map} +0 -0
  63. /package/dist/{chunk-HIW7RXCD.mjs.map → chunk-UH5GQ7QF.mjs.map} +0 -0
  64. /package/dist/{chunk-NCIAFFQ2.mjs.map → chunk-XEZ5ODJS.mjs.map} +0 -0
  65. /package/dist/{chunk-NSJWSIPR.mjs.map → chunk-YQOESY4Y.mjs.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  CopilotSidebar
3
- } from "../../chunk-DI7DDMRS.mjs";
4
- import "../../chunk-BVKKSSB2.mjs";
3
+ } from "../../chunk-4S4ZEKE6.mjs";
4
+ import "../../chunk-HKZL4P3F.mjs";
5
5
  import "../../chunk-C3GSYRC3.mjs";
6
6
  import "../../chunk-GDSZGYCE.mjs";
7
7
  import "../../chunk-V7W6IM2V.mjs";
@@ -12,20 +12,20 @@ import "../../chunk-KXE2JCUH.mjs";
12
12
  import "../../chunk-NRA3CFEE.mjs";
13
13
  import "../../chunk-BH6PCAAL.mjs";
14
14
  import "../../chunk-UFN2VWSR.mjs";
15
- import "../../chunk-NSJWSIPR.mjs";
15
+ import "../../chunk-YQOESY4Y.mjs";
16
16
  import "../../chunk-VHKHX7GV.mjs";
17
17
  import "../../chunk-6TWQUA2Q.mjs";
18
18
  import "../../chunk-PLHTVHUW.mjs";
19
19
  import "../../chunk-3W6J75HS.mjs";
20
20
  import "../../chunk-ELGRNEAO.mjs";
21
21
  import "../../chunk-QIOJXTIQ.mjs";
22
- import "../../chunk-HIW7RXCD.mjs";
23
- import "../../chunk-7OURDQZJ.mjs";
24
- import "../../chunk-NCIAFFQ2.mjs";
25
- import "../../chunk-IHFR6PYG.mjs";
22
+ import "../../chunk-UH5GQ7QF.mjs";
23
+ import "../../chunk-PKSW6ZMQ.mjs";
24
+ import "../../chunk-XEZ5ODJS.mjs";
25
+ import "../../chunk-SLM2AOHF.mjs";
26
26
  import "../../chunk-DBKRAOH7.mjs";
27
27
  import "../../chunk-RYUCX3ZK.mjs";
28
- import "../../chunk-JZ3RFQQ6.mjs";
28
+ import "../../chunk-XOBQLKUU.mjs";
29
29
  import "../../chunk-IK2BPURM.mjs";
30
30
  import "../../chunk-IEMQ2SQW.mjs";
31
31
  import "../../chunk-XWG3L6QC.mjs";
@@ -15,4 +15,4 @@ import 'react';
15
15
  import 'react/jsx-runtime';
16
16
  import './Modal.js';
17
17
  import '@copilotkit/react-core';
18
- import 'react-markdown';
18
+ import 'streamdown';
@@ -93,7 +93,7 @@ __export(chat_exports, {
93
93
  module.exports = __toCommonJS(chat_exports);
94
94
 
95
95
  // src/components/chat/Modal.tsx
96
- var import_react16 = __toESM(require("react"));
96
+ var import_react15 = __toESM(require("react"));
97
97
 
98
98
  // src/components/chat/ChatContext.tsx
99
99
  var import_react = __toESM(require("react"));
@@ -1034,7 +1034,7 @@ var Header = ({}) => {
1034
1034
  };
1035
1035
 
1036
1036
  // src/components/chat/Messages.tsx
1037
- var import_react10 = require("react");
1037
+ var import_react9 = require("react");
1038
1038
  var import_react_core5 = require("@copilotkit/react-core");
1039
1039
 
1040
1040
  // src/components/chat/messages/UserMessage.tsx
@@ -1066,8 +1066,7 @@ var UserMessage = (props) => {
1066
1066
  };
1067
1067
 
1068
1068
  // src/components/chat/Markdown.tsx
1069
- var import_react7 = require("react");
1070
- var import_react_markdown = __toESM(require("react-markdown"));
1069
+ var import_streamdown = require("streamdown");
1071
1070
 
1072
1071
  // src/components/chat/CodeBlock.tsx
1073
1072
  var import_react6 = require("react");
@@ -1479,9 +1478,6 @@ var highlightStyle = {
1479
1478
  };
1480
1479
 
1481
1480
  // src/components/chat/Markdown.tsx
1482
- var import_remark_gfm = __toESM(require("remark-gfm"));
1483
- var import_remark_math = __toESM(require("remark-math"));
1484
- var import_rehype_raw = __toESM(require("rehype-raw"));
1485
1481
  var import_jsx_runtime12 = require("react/jsx-runtime");
1486
1482
  var defaultComponents = {
1487
1483
  a(_a) {
@@ -1575,24 +1571,18 @@ var defaultComponents = {
1575
1571
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("li", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
1576
1572
  }
1577
1573
  };
1578
- var MemoizedReactMarkdown = (0, import_react7.memo)(
1579
- import_react_markdown.default,
1580
- (prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.components === nextProps.components
1581
- );
1582
1574
  var Markdown = ({ content, components }) => {
1583
1575
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "copilotKitMarkdown", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1584
- MemoizedReactMarkdown,
1576
+ import_streamdown.Streamdown,
1585
1577
  {
1586
1578
  components: __spreadValues(__spreadValues({}, defaultComponents), components),
1587
- remarkPlugins: [import_remark_gfm.default, [import_remark_math.default, { singleDollarTextMath: false }]],
1588
- rehypePlugins: [import_rehype_raw.default],
1589
1579
  children: content
1590
1580
  }
1591
1581
  ) });
1592
1582
  };
1593
1583
 
1594
1584
  // src/components/chat/messages/AssistantMessage.tsx
1595
- var import_react8 = require("react");
1585
+ var import_react7 = require("react");
1596
1586
  var import_jsx_runtime13 = require("react/jsx-runtime");
1597
1587
  var AssistantMessage = (props) => {
1598
1588
  var _a;
@@ -1608,7 +1598,7 @@ var AssistantMessage = (props) => {
1608
1598
  feedback,
1609
1599
  markdownTagRenderers
1610
1600
  } = props;
1611
- const [copied, setCopied] = (0, import_react8.useState)(false);
1601
+ const [copied, setCopied] = (0, import_react7.useState)(false);
1612
1602
  const handleCopy = () => {
1613
1603
  const content2 = (message == null ? void 0 : message.content) || "";
1614
1604
  if (content2 && onCopy) {
@@ -1697,10 +1687,10 @@ var AssistantMessage = (props) => {
1697
1687
  };
1698
1688
 
1699
1689
  // src/components/chat/messages/ImageRenderer.tsx
1700
- var import_react9 = require("react");
1690
+ var import_react8 = require("react");
1701
1691
  var import_jsx_runtime14 = require("react/jsx-runtime");
1702
1692
  var ImageRenderer = ({ image, content, className = "" }) => {
1703
- const [imageError, setImageError] = (0, import_react9.useState)(false);
1693
+ const [imageError, setImageError] = (0, import_react8.useState)(false);
1704
1694
  const imageSrc = `data:image/${image.format};base64,${image.bytes}`;
1705
1695
  const altText = content || "User uploaded image";
1706
1696
  const handleImageError = () => {
@@ -1943,18 +1933,18 @@ var Messages = ({
1943
1933
  var _a;
1944
1934
  const { labels, icons } = useChatContext();
1945
1935
  const { messages: visibleMessages, interrupt } = (0, import_react_core5.useCopilotChatInternal)();
1946
- const initialMessages = (0, import_react10.useMemo)(() => makeInitialMessages(labels.initial), [labels.initial]);
1936
+ const initialMessages = (0, import_react9.useMemo)(() => makeInitialMessages(labels.initial), [labels.initial]);
1947
1937
  const messages = [...initialMessages, ...visibleMessages];
1948
1938
  const { messagesContainerRef, messagesEndRef } = useScrollToBottom(messages);
1949
1939
  const hasLegacyProps = !!(RenderTextMessage || RenderActionExecutionMessage || RenderAgentStateMessage || RenderResultMessage || RenderImageMessage);
1950
- (0, import_react10.useEffect)(() => {
1940
+ (0, import_react9.useEffect)(() => {
1951
1941
  if (hasLegacyProps) {
1952
1942
  console.warn(
1953
1943
  "[CopilotKit] Legacy message render props (RenderTextMessage, RenderActionExecutionMessage, etc.) are deprecated. Please use the unified 'RenderMessage' prop instead. See migration guide: https://docs.copilotkit.ai/migration/render-message"
1954
1944
  );
1955
1945
  }
1956
1946
  }, [hasLegacyProps]);
1957
- const legacyProps = (0, import_react10.useMemo)(
1947
+ const legacyProps = (0, import_react9.useMemo)(
1958
1948
  () => ({
1959
1949
  RenderTextMessage,
1960
1950
  RenderActionExecutionMessage,
@@ -2025,10 +2015,10 @@ function makeInitialMessages(initial) {
2025
2015
  ];
2026
2016
  }
2027
2017
  function useScrollToBottom(messages) {
2028
- const messagesEndRef = (0, import_react10.useRef)(null);
2029
- const messagesContainerRef = (0, import_react10.useRef)(null);
2030
- const isProgrammaticScrollRef = (0, import_react10.useRef)(false);
2031
- const isUserScrollUpRef = (0, import_react10.useRef)(false);
2018
+ const messagesEndRef = (0, import_react9.useRef)(null);
2019
+ const messagesContainerRef = (0, import_react9.useRef)(null);
2020
+ const isProgrammaticScrollRef = (0, import_react9.useRef)(false);
2021
+ const isUserScrollUpRef = (0, import_react9.useRef)(false);
2032
2022
  const scrollToBottom = () => {
2033
2023
  if (messagesContainerRef.current && messagesEndRef.current) {
2034
2024
  isProgrammaticScrollRef.current = true;
@@ -2045,7 +2035,7 @@ function useScrollToBottom(messages) {
2045
2035
  isUserScrollUpRef.current = scrollTop + clientHeight < scrollHeight;
2046
2036
  }
2047
2037
  };
2048
- (0, import_react10.useEffect)(() => {
2038
+ (0, import_react9.useEffect)(() => {
2049
2039
  const container = messagesContainerRef.current;
2050
2040
  if (container) {
2051
2041
  container.addEventListener("scroll", handleScroll);
@@ -2056,7 +2046,7 @@ function useScrollToBottom(messages) {
2056
2046
  }
2057
2047
  };
2058
2048
  }, []);
2059
- (0, import_react10.useEffect)(() => {
2049
+ (0, import_react9.useEffect)(() => {
2060
2050
  const container = messagesContainerRef.current;
2061
2051
  if (!container) {
2062
2052
  return;
@@ -2075,7 +2065,7 @@ function useScrollToBottom(messages) {
2075
2065
  mutationObserver.disconnect();
2076
2066
  };
2077
2067
  }, []);
2078
- (0, import_react10.useEffect)(() => {
2068
+ (0, import_react9.useEffect)(() => {
2079
2069
  isUserScrollUpRef.current = false;
2080
2070
  scrollToBottom();
2081
2071
  }, [messages.filter((m) => m.role === "user").length]);
@@ -2083,12 +2073,12 @@ function useScrollToBottom(messages) {
2083
2073
  }
2084
2074
 
2085
2075
  // src/components/chat/Input.tsx
2086
- var import_react14 = require("react");
2076
+ var import_react13 = require("react");
2087
2077
 
2088
2078
  // src/components/chat/Textarea.tsx
2089
- var import_react11 = require("react");
2079
+ var import_react10 = require("react");
2090
2080
  var import_jsx_runtime18 = require("react/jsx-runtime");
2091
- var AutoResizingTextarea = (0, import_react11.forwardRef)(
2081
+ var AutoResizingTextarea = (0, import_react10.forwardRef)(
2092
2082
  ({
2093
2083
  maxRows = 1,
2094
2084
  placeholder,
@@ -2099,10 +2089,10 @@ var AutoResizingTextarea = (0, import_react11.forwardRef)(
2099
2089
  onCompositionEnd,
2100
2090
  autoFocus
2101
2091
  }, ref) => {
2102
- const internalTextareaRef = (0, import_react11.useRef)(null);
2103
- const [maxHeight, setMaxHeight] = (0, import_react11.useState)(0);
2104
- (0, import_react11.useImperativeHandle)(ref, () => internalTextareaRef.current);
2105
- (0, import_react11.useEffect)(() => {
2092
+ const internalTextareaRef = (0, import_react10.useRef)(null);
2093
+ const [maxHeight, setMaxHeight] = (0, import_react10.useState)(0);
2094
+ (0, import_react10.useImperativeHandle)(ref, () => internalTextareaRef.current);
2095
+ (0, import_react10.useEffect)(() => {
2106
2096
  const calculateMaxHeight = () => {
2107
2097
  const textarea = internalTextareaRef.current;
2108
2098
  if (textarea) {
@@ -2116,7 +2106,7 @@ var AutoResizingTextarea = (0, import_react11.forwardRef)(
2116
2106
  };
2117
2107
  calculateMaxHeight();
2118
2108
  }, [maxRows]);
2119
- (0, import_react11.useEffect)(() => {
2109
+ (0, import_react10.useEffect)(() => {
2120
2110
  const textarea = internalTextareaRef.current;
2121
2111
  if (textarea) {
2122
2112
  textarea.style.height = "auto";
@@ -2148,7 +2138,7 @@ var Textarea_default = AutoResizingTextarea;
2148
2138
  // src/hooks/use-push-to-talk.tsx
2149
2139
  var import_react_core6 = require("@copilotkit/react-core");
2150
2140
  var import_runtime_client_gql2 = require("@copilotkit/runtime-client-gql");
2151
- var import_react12 = require("react");
2141
+ var import_react11 = require("react");
2152
2142
  var startRecording = (mediaStreamRef, mediaRecorderRef, audioContextRef, recordedChunks, onStop) => __async(void 0, null, function* () {
2153
2143
  if (!mediaStreamRef.current || !audioContextRef.current) {
2154
2144
  mediaStreamRef.current = yield navigator.mediaDevices.getUserMedia({ audio: true });
@@ -2197,16 +2187,16 @@ var usePushToTalk = ({
2197
2187
  sendFunction,
2198
2188
  inProgress
2199
2189
  }) => {
2200
- const [pushToTalkState, setPushToTalkState] = (0, import_react12.useState)("idle");
2201
- const mediaStreamRef = (0, import_react12.useRef)(null);
2202
- const audioContextRef = (0, import_react12.useRef)(null);
2203
- const mediaRecorderRef = (0, import_react12.useRef)(null);
2204
- const recordedChunks = (0, import_react12.useRef)([]);
2190
+ const [pushToTalkState, setPushToTalkState] = (0, import_react11.useState)("idle");
2191
+ const mediaStreamRef = (0, import_react11.useRef)(null);
2192
+ const audioContextRef = (0, import_react11.useRef)(null);
2193
+ const mediaRecorderRef = (0, import_react11.useRef)(null);
2194
+ const recordedChunks = (0, import_react11.useRef)([]);
2205
2195
  const generalContext = (0, import_react_core6.useCopilotContext)();
2206
2196
  const messagesContext = (0, import_react_core6.useCopilotMessagesContext)();
2207
2197
  const context = __spreadValues(__spreadValues({}, generalContext), messagesContext);
2208
- const [startReadingFromMessageId, setStartReadingFromMessageId] = (0, import_react12.useState)(null);
2209
- (0, import_react12.useEffect)(() => {
2198
+ const [startReadingFromMessageId, setStartReadingFromMessageId] = (0, import_react11.useState)(null);
2199
+ (0, import_react11.useEffect)(() => {
2210
2200
  if (pushToTalkState === "recording") {
2211
2201
  startRecording(
2212
2202
  mediaStreamRef,
@@ -2234,7 +2224,7 @@ var usePushToTalk = ({
2234
2224
  stopRecording(mediaRecorderRef);
2235
2225
  };
2236
2226
  }, [pushToTalkState]);
2237
- (0, import_react12.useEffect)(() => {
2227
+ (0, import_react11.useEffect)(() => {
2238
2228
  if (inProgress === false && startReadingFromMessageId) {
2239
2229
  const lastMessageIndex = context.messages.findIndex(
2240
2230
  (message) => message.id === startReadingFromMessageId
@@ -2253,7 +2243,7 @@ var usePushToTalk = ({
2253
2243
  var import_react_core7 = require("@copilotkit/react-core");
2254
2244
 
2255
2245
  // src/components/chat/PoweredByTag.tsx
2256
- var import_react13 = require("react");
2246
+ var import_react12 = require("react");
2257
2247
 
2258
2248
  // src/hooks/use-dark-mode.ts
2259
2249
  var useDarkMode = () => {
@@ -2265,9 +2255,9 @@ var useDarkMode = () => {
2265
2255
  // src/components/chat/PoweredByTag.tsx
2266
2256
  var import_jsx_runtime19 = require("react/jsx-runtime");
2267
2257
  function PoweredByTag({ showPoweredBy = true }) {
2268
- const [mounted, setMounted] = (0, import_react13.useState)(false);
2258
+ const [mounted, setMounted] = (0, import_react12.useState)(false);
2269
2259
  const isDark = useDarkMode();
2270
- (0, import_react13.useEffect)(() => {
2260
+ (0, import_react12.useEffect)(() => {
2271
2261
  setMounted(true);
2272
2262
  }, []);
2273
2263
  if (!showPoweredBy) {
@@ -2301,8 +2291,8 @@ var Input = ({
2301
2291
  const copilotContext = (0, import_react_core7.useCopilotContext)();
2302
2292
  const showPoweredBy = !((_a = copilotContext.copilotApiConfig) == null ? void 0 : _a.publicApiKey);
2303
2293
  const pushToTalkConfigured = copilotContext.copilotApiConfig.textToSpeechUrl !== void 0 && copilotContext.copilotApiConfig.transcribeAudioUrl !== void 0;
2304
- const textareaRef = (0, import_react14.useRef)(null);
2305
- const [isComposing, setIsComposing] = (0, import_react14.useState)(false);
2294
+ const textareaRef = (0, import_react13.useRef)(null);
2295
+ const [isComposing, setIsComposing] = (0, import_react13.useState)(false);
2306
2296
  const handleDivClick = (event) => {
2307
2297
  var _a2;
2308
2298
  const target = event.target;
@@ -2312,7 +2302,7 @@ var Input = ({
2312
2302
  return;
2313
2303
  (_a2 = textareaRef.current) == null ? void 0 : _a2.focus();
2314
2304
  };
2315
- const [text, setText] = (0, import_react14.useState)("");
2305
+ const [text, setText] = (0, import_react13.useState)("");
2316
2306
  const send = () => {
2317
2307
  var _a2;
2318
2308
  if (inProgress)
@@ -2326,17 +2316,17 @@ var Input = ({
2326
2316
  inProgress
2327
2317
  });
2328
2318
  const isInProgress = inProgress || pushToTalkState === "transcribing";
2329
- const { buttonIcon, buttonAlt } = (0, import_react14.useMemo)(() => {
2319
+ const { buttonIcon, buttonAlt } = (0, import_react13.useMemo)(() => {
2330
2320
  if (!chatReady)
2331
2321
  return { buttonIcon: context.icons.spinnerIcon, buttonAlt: "Loading" };
2332
2322
  return isInProgress && !hideStopButton && chatReady ? { buttonIcon: context.icons.stopIcon, buttonAlt: "Stop" } : { buttonIcon: context.icons.sendIcon, buttonAlt: "Send" };
2333
2323
  }, [isInProgress, chatReady, hideStopButton, context.icons.stopIcon, context.icons.sendIcon]);
2334
2324
  const showPushToTalk = pushToTalkConfigured && (pushToTalkState === "idle" || pushToTalkState === "recording") && !inProgress;
2335
2325
  const { interrupt } = (0, import_react_core7.useCopilotChatInternal)();
2336
- const canSend = (0, import_react14.useMemo)(() => {
2326
+ const canSend = (0, import_react13.useMemo)(() => {
2337
2327
  return !isInProgress && text.trim().length > 0 && pushToTalkState === "idle" && !interrupt;
2338
2328
  }, [interrupt, isInProgress, text, pushToTalkState]);
2339
- const canStop = (0, import_react14.useMemo)(() => {
2329
+ const canStop = (0, import_react13.useMemo)(() => {
2340
2330
  return isInProgress && !hideStopButton;
2341
2331
  }, [isInProgress, hideStopButton]);
2342
2332
  const sendDisabled = !canSend && !canStop;
@@ -2393,7 +2383,7 @@ var Input = ({
2393
2383
  };
2394
2384
 
2395
2385
  // src/components/chat/Chat.tsx
2396
- var import_react15 = __toESM(require("react"));
2386
+ var import_react14 = __toESM(require("react"));
2397
2387
  var import_react_core9 = require("@copilotkit/react-core");
2398
2388
  var import_shared3 = require("@copilotkit/shared");
2399
2389
 
@@ -2570,13 +2560,13 @@ function CopilotChat({
2570
2560
  removeInternalErrorHandler
2571
2561
  } = (0, import_react_core9.useCopilotContext)();
2572
2562
  const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
2573
- const [selectedImages, setSelectedImages] = (0, import_react15.useState)([]);
2574
- const [chatError, setChatError] = (0, import_react15.useState)(null);
2575
- const [messageFeedback, setMessageFeedback] = (0, import_react15.useState)(
2563
+ const [selectedImages, setSelectedImages] = (0, import_react14.useState)([]);
2564
+ const [chatError, setChatError] = (0, import_react14.useState)(null);
2565
+ const [messageFeedback, setMessageFeedback] = (0, import_react14.useState)(
2576
2566
  {}
2577
2567
  );
2578
- const fileInputRef = (0, import_react15.useRef)(null);
2579
- const triggerObservabilityHook = (0, import_react15.useCallback)(
2568
+ const fileInputRef = (0, import_react14.useRef)(null);
2569
+ const triggerObservabilityHook = (0, import_react14.useCallback)(
2580
2570
  (hookName, ...args) => {
2581
2571
  if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
2582
2572
  observabilityHooks[hookName](...args);
@@ -2595,7 +2585,7 @@ function CopilotChat({
2595
2585
  },
2596
2586
  [publicApiKey, observabilityHooks, setBannerError]
2597
2587
  );
2598
- const triggerChatError = (0, import_react15.useCallback)(
2588
+ const triggerChatError = (0, import_react14.useCallback)(
2599
2589
  (error, operation, originalError) => {
2600
2590
  const errorMessage = (error == null ? void 0 : error.message) || (error == null ? void 0 : error.toString()) || "An error occurred";
2601
2591
  setChatError({
@@ -2641,7 +2631,7 @@ function CopilotChat({
2641
2631
  },
2642
2632
  [publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError]
2643
2633
  );
2644
- (0, import_react15.useEffect)(() => {
2634
+ (0, import_react14.useEffect)(() => {
2645
2635
  const id = "chat-component";
2646
2636
  setInternalErrorHandler({
2647
2637
  [id]: (error) => {
@@ -2654,7 +2644,7 @@ function CopilotChat({
2654
2644
  removeInternalErrorHandler == null ? void 0 : removeInternalErrorHandler(id);
2655
2645
  };
2656
2646
  }, [triggerChatError, setInternalErrorHandler, removeInternalErrorHandler]);
2657
- (0, import_react15.useEffect)(() => {
2647
+ (0, import_react14.useEffect)(() => {
2658
2648
  if (!imageUploadsEnabled)
2659
2649
  return;
2660
2650
  const handlePaste = (e) => __async(this, null, function* () {
@@ -2700,7 +2690,7 @@ function CopilotChat({
2700
2690
  document.addEventListener("paste", handlePaste);
2701
2691
  return () => document.removeEventListener("paste", handlePaste);
2702
2692
  }, [imageUploadsEnabled, triggerChatError]);
2703
- (0, import_react15.useEffect)(() => {
2693
+ (0, import_react14.useEffect)(() => {
2704
2694
  if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
2705
2695
  setChatInstructions(instructions || "");
2706
2696
  return;
@@ -2728,8 +2718,8 @@ function CopilotChat({
2728
2718
  onStopGeneration,
2729
2719
  onReloadMessages
2730
2720
  });
2731
- const prevIsLoading = (0, import_react15.useRef)(isLoading);
2732
- (0, import_react15.useEffect)(() => {
2721
+ const prevIsLoading = (0, import_react14.useRef)(isLoading);
2722
+ (0, import_react14.useEffect)(() => {
2733
2723
  if (prevIsLoading.current !== isLoading) {
2734
2724
  if (isLoading) {
2735
2725
  triggerObservabilityHook("onChatStarted");
@@ -2752,7 +2742,7 @@ function CopilotChat({
2752
2742
  role: "user"
2753
2743
  });
2754
2744
  };
2755
- const chatContext = import_react15.default.useContext(ChatContext);
2745
+ const chatContext = import_react14.default.useContext(ChatContext);
2756
2746
  const isVisible = chatContext ? chatContext.open : true;
2757
2747
  const handleRegenerate = (messageId) => {
2758
2748
  if (onRegenerate) {
@@ -2896,7 +2886,7 @@ function WrappedCopilotChat({
2896
2886
  labels,
2897
2887
  className
2898
2888
  }) {
2899
- const chatContext = import_react15.default.useContext(ChatContext);
2889
+ const chatContext = import_react14.default.useContext(ChatContext);
2900
2890
  if (!chatContext) {
2901
2891
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
2902
2892
  }, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: `copilotKitChat ${className != null ? className : ""}`, children }) });
@@ -2934,7 +2924,7 @@ var CopilotModalInner = (_a) => {
2934
2924
  ]);
2935
2925
  const { copilotApiConfig, setBannerError } = (0, import_react_core10.useCopilotContext)();
2936
2926
  const { publicApiKey } = copilotApiConfig;
2937
- const triggerObservabilityHook = (0, import_react16.useCallback)(
2927
+ const triggerObservabilityHook = (0, import_react15.useCallback)(
2938
2928
  (hookName, ...args) => {
2939
2929
  if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
2940
2930
  observabilityHooks[hookName](...args);
@@ -2954,8 +2944,8 @@ var CopilotModalInner = (_a) => {
2954
2944
  [publicApiKey, observabilityHooks, setBannerError]
2955
2945
  );
2956
2946
  const { open } = useChatContext();
2957
- const prevOpen = (0, import_react16.useRef)(open);
2958
- (0, import_react16.useEffect)(() => {
2947
+ const prevOpen = (0, import_react15.useRef)(open);
2948
+ (0, import_react15.useEffect)(() => {
2959
2949
  if (prevOpen.current !== open) {
2960
2950
  onSetOpen == null ? void 0 : onSetOpen(open);
2961
2951
  if (open) {
@@ -2966,8 +2956,8 @@ var CopilotModalInner = (_a) => {
2966
2956
  prevOpen.current = open;
2967
2957
  }
2968
2958
  }, [open, onSetOpen, triggerObservabilityHook]);
2969
- const memoizedHeader = (0, import_react16.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Header2, {}), [Header2]);
2970
- const memoizedChildren = (0, import_react16.useMemo)(() => children, [children]);
2959
+ const memoizedHeader = (0, import_react15.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Header2, {}), [Header2]);
2960
+ const memoizedChildren = (0, import_react15.useMemo)(() => children, [children]);
2971
2961
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
2972
2962
  memoizedChildren,
2973
2963
  /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className, children: [
@@ -3047,7 +3037,7 @@ var CopilotModal = (_a) => {
3047
3037
  "children",
3048
3038
  "observabilityHooks"
3049
3039
  ]);
3050
- const [openState, setOpenState] = import_react16.default.useState(defaultOpen);
3040
+ const [openState, setOpenState] = import_react15.default.useState(defaultOpen);
3051
3041
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChatContextProvider, { icons, labels, open: openState, setOpen: setOpenState, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3052
3042
  CopilotModalInner,
3053
3043
  __spreadProps(__spreadValues({
@@ -3091,13 +3081,13 @@ function CopilotPopup(props) {
3091
3081
  }
3092
3082
 
3093
3083
  // src/components/chat/Sidebar.tsx
3094
- var import_react17 = require("react");
3084
+ var import_react16 = require("react");
3095
3085
  var import_jsx_runtime27 = require("react/jsx-runtime");
3096
3086
  function CopilotSidebar(props) {
3097
3087
  props = __spreadProps(__spreadValues({}, props), {
3098
3088
  className: props.className ? props.className + " copilotKitSidebar" : "copilotKitSidebar"
3099
3089
  });
3100
- const [expandedClassName, setExpandedClassName] = (0, import_react17.useState)(
3090
+ const [expandedClassName, setExpandedClassName] = (0, import_react16.useState)(
3101
3091
  props.defaultOpen ? "sidebarExpanded" : ""
3102
3092
  );
3103
3093
  const onSetOpen = (open) => {