@copilotkit/react-ui 1.10.4-next.1 → 1.10.4-next.2

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 (59) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/{chunk-SHPG2T4O.mjs → chunk-FJFWH5AF.mjs} +3 -3
  3. package/dist/{chunk-FWQRAZ5S.mjs → chunk-KCRWXHWT.mjs} +2 -2
  4. package/dist/{chunk-X5AO5A3L.mjs → chunk-PHH6DYUW.mjs} +5 -2
  5. package/dist/chunk-PHH6DYUW.mjs.map +1 -0
  6. package/dist/{chunk-7XIE7UOW.mjs → chunk-QQDCZRPA.mjs} +2 -2
  7. package/dist/chunk-SRY5COHG.mjs +63 -0
  8. package/dist/chunk-SRY5COHG.mjs.map +1 -0
  9. package/dist/{chunk-EL7NCWNZ.mjs → chunk-Z66Y3KRE.mjs} +51 -21
  10. package/dist/chunk-Z66Y3KRE.mjs.map +1 -0
  11. package/dist/components/chat/Chat.d.ts +24 -13
  12. package/dist/components/chat/Chat.js +144 -62
  13. package/dist/components/chat/Chat.js.map +1 -1
  14. package/dist/components/chat/Chat.mjs +3 -2
  15. package/dist/components/chat/Messages.d.ts +1 -1
  16. package/dist/components/chat/Messages.js +4 -1
  17. package/dist/components/chat/Messages.js.map +1 -1
  18. package/dist/components/chat/Messages.mjs +1 -1
  19. package/dist/components/chat/Modal.d.ts +1 -1
  20. package/dist/components/chat/Modal.js +158 -76
  21. package/dist/components/chat/Modal.js.map +1 -1
  22. package/dist/components/chat/Modal.mjs +4 -3
  23. package/dist/components/chat/Popup.d.ts +1 -1
  24. package/dist/components/chat/Popup.js +160 -78
  25. package/dist/components/chat/Popup.js.map +1 -1
  26. package/dist/components/chat/Popup.mjs +5 -4
  27. package/dist/components/chat/Sidebar.d.ts +1 -1
  28. package/dist/components/chat/Sidebar.js +162 -80
  29. package/dist/components/chat/Sidebar.js.map +1 -1
  30. package/dist/components/chat/Sidebar.mjs +5 -4
  31. package/dist/components/chat/index.d.ts +2 -2
  32. package/dist/components/chat/index.js +164 -82
  33. package/dist/components/chat/index.js.map +1 -1
  34. package/dist/components/chat/index.mjs +6 -5
  35. package/dist/components/chat/messages/ErrorMessage.d.ts +9 -0
  36. package/dist/components/chat/messages/ErrorMessage.js +711 -0
  37. package/dist/components/chat/messages/ErrorMessage.js.map +1 -0
  38. package/dist/components/chat/messages/ErrorMessage.mjs +13 -0
  39. package/dist/components/chat/messages/ErrorMessage.mjs.map +1 -0
  40. package/dist/components/chat/props.d.ts +26 -1
  41. package/dist/components/chat/props.js.map +1 -1
  42. package/dist/components/index.d.ts +2 -2
  43. package/dist/components/index.js +164 -82
  44. package/dist/components/index.js.map +1 -1
  45. package/dist/components/index.mjs +6 -5
  46. package/dist/index.d.ts +2 -2
  47. package/dist/index.js +166 -84
  48. package/dist/index.js.map +1 -1
  49. package/dist/index.mjs +7 -6
  50. package/package.json +4 -4
  51. package/src/components/chat/Chat.tsx +64 -26
  52. package/src/components/chat/Messages.tsx +3 -0
  53. package/src/components/chat/messages/ErrorMessage.tsx +59 -0
  54. package/src/components/chat/props.ts +31 -0
  55. package/dist/chunk-EL7NCWNZ.mjs.map +0 -1
  56. package/dist/chunk-X5AO5A3L.mjs.map +0 -1
  57. /package/dist/{chunk-SHPG2T4O.mjs.map → chunk-FJFWH5AF.mjs.map} +0 -0
  58. /package/dist/{chunk-FWQRAZ5S.mjs.map → chunk-KCRWXHWT.mjs.map} +0 -0
  59. /package/dist/{chunk-7XIE7UOW.mjs.map → chunk-QQDCZRPA.mjs.map} +0 -0
@@ -1242,12 +1242,14 @@ var Messages = ({
1242
1242
  RenderMessage: RenderMessage2,
1243
1243
  AssistantMessage: AssistantMessage2,
1244
1244
  UserMessage: UserMessage2,
1245
+ ErrorMessage: ErrorMessage2,
1245
1246
  ImageRenderer: ImageRenderer2,
1246
1247
  onRegenerate,
1247
1248
  onCopy,
1248
1249
  onThumbsUp,
1249
1250
  onThumbsDown,
1250
1251
  markdownTagRenderers,
1252
+ chatError,
1251
1253
  // Legacy props
1252
1254
  RenderTextMessage,
1253
1255
  RenderActionExecutionMessage,
@@ -1308,7 +1310,8 @@ var Messages = ({
1308
1310
  index
1309
1311
  );
1310
1312
  }),
1311
- interrupt
1313
+ interrupt,
1314
+ chatError && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ErrorMessage2, { error: chatError, isCurrentMessage: true })
1312
1315
  ] }),
1313
1316
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("footer", { className: "copilotKitMessagesFooter", ref: messagesEndRef, children })
1314
1317
  ] });
@@ -1691,15 +1694,67 @@ var Input = ({
1691
1694
  ] });
1692
1695
  };
1693
1696
 
1697
+ // src/components/chat/messages/ErrorMessage.tsx
1698
+ var import_react10 = require("react");
1699
+ var import_jsx_runtime14 = require("react/jsx-runtime");
1700
+ var ErrorMessage = (props) => {
1701
+ const { icons, labels } = useChatContext();
1702
+ const { error, onRegenerate, onCopy, isCurrentMessage } = props;
1703
+ const [copied, setCopied] = (0, import_react10.useState)(false);
1704
+ const handleCopy = () => {
1705
+ const content = error.message;
1706
+ if (content && onCopy) {
1707
+ navigator.clipboard.writeText(content);
1708
+ setCopied(true);
1709
+ onCopy(content);
1710
+ setTimeout(() => setCopied(false), 2e3);
1711
+ } else if (content) {
1712
+ navigator.clipboard.writeText(content);
1713
+ setCopied(true);
1714
+ setTimeout(() => setCopied(false), 2e3);
1715
+ }
1716
+ };
1717
+ const handleRegenerate = () => {
1718
+ if (onRegenerate)
1719
+ onRegenerate();
1720
+ };
1721
+ console.log(error);
1722
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "copilotKitMessage copilotKitAssistantMessage", children: [
1723
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Markdown, { content: error.message }),
1724
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: `copilotKitMessageControls ${isCurrentMessage ? "currentMessage" : ""}`, children: [
1725
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1726
+ "button",
1727
+ {
1728
+ className: "copilotKitMessageControlButton",
1729
+ onClick: handleRegenerate,
1730
+ "aria-label": labels.regenerateResponse,
1731
+ title: labels.regenerateResponse,
1732
+ children: icons.regenerateIcon
1733
+ }
1734
+ ),
1735
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1736
+ "button",
1737
+ {
1738
+ className: "copilotKitMessageControlButton",
1739
+ onClick: handleCopy,
1740
+ "aria-label": labels.copyToClipboard,
1741
+ title: labels.copyToClipboard,
1742
+ children: copied ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { style: { fontSize: "10px", fontWeight: "bold" }, children: "\u2713" }) : icons.copyIcon
1743
+ }
1744
+ )
1745
+ ] })
1746
+ ] });
1747
+ };
1748
+
1694
1749
  // src/components/chat/Chat.tsx
1695
- var import_react10 = __toESM(require("react"));
1750
+ var import_react11 = __toESM(require("react"));
1696
1751
  var import_react_core5 = require("@copilotkit/react-core");
1697
1752
  var import_shared = require("@copilotkit/shared");
1698
1753
  var import_shared2 = require("@copilotkit/shared");
1699
1754
  var import_react_core6 = require("@copilotkit/react-core");
1700
1755
 
1701
1756
  // src/components/chat/ImageUploadQueue.tsx
1702
- var import_jsx_runtime14 = require("react/jsx-runtime");
1757
+ var import_jsx_runtime15 = require("react/jsx-runtime");
1703
1758
  var ImageUploadQueue = ({
1704
1759
  images,
1705
1760
  onRemoveImage,
@@ -1707,7 +1762,7 @@ var ImageUploadQueue = ({
1707
1762
  }) => {
1708
1763
  if (images.length === 0)
1709
1764
  return null;
1710
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1765
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1711
1766
  "div",
1712
1767
  {
1713
1768
  className: `copilotKitImageUploadQueue ${className}`,
@@ -1718,7 +1773,7 @@ var ImageUploadQueue = ({
1718
1773
  margin: "8px",
1719
1774
  padding: "8px"
1720
1775
  },
1721
- children: images.map((image, index) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
1776
+ children: images.map((image, index) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
1722
1777
  "div",
1723
1778
  {
1724
1779
  className: "copilotKitImageUploadQueueItem",
@@ -1731,7 +1786,7 @@ var ImageUploadQueue = ({
1731
1786
  overflow: "hidden"
1732
1787
  },
1733
1788
  children: [
1734
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1789
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1735
1790
  "img",
1736
1791
  {
1737
1792
  src: `data:${image.contentType};base64,${image.bytes}`,
@@ -1743,7 +1798,7 @@ var ImageUploadQueue = ({
1743
1798
  }
1744
1799
  }
1745
1800
  ),
1746
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1801
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1747
1802
  "button",
1748
1803
  {
1749
1804
  onClick: () => onRemoveImage(index),
@@ -1778,12 +1833,12 @@ var ImageUploadQueue = ({
1778
1833
 
1779
1834
  // src/components/chat/Suggestion.tsx
1780
1835
  var import_react_core4 = require("@copilotkit/react-core");
1781
- var import_jsx_runtime15 = require("react/jsx-runtime");
1836
+ var import_jsx_runtime16 = require("react/jsx-runtime");
1782
1837
  function Suggestion({ title, onClick, partial, className }) {
1783
1838
  if (!title)
1784
1839
  return null;
1785
1840
  const { isLoading } = (0, import_react_core4.useCopilotChatInternal)();
1786
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1841
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1787
1842
  "button",
1788
1843
  {
1789
1844
  disabled: partial || isLoading,
@@ -1793,15 +1848,15 @@ function Suggestion({ title, onClick, partial, className }) {
1793
1848
  },
1794
1849
  className: className || (partial ? "suggestion loading" : "suggestion"),
1795
1850
  "data-test-id": "suggestion",
1796
- children: partial ? SmallSpinnerIcon : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { children: title })
1851
+ children: partial ? SmallSpinnerIcon : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { children: title })
1797
1852
  }
1798
1853
  );
1799
1854
  }
1800
1855
 
1801
1856
  // src/components/chat/Suggestions.tsx
1802
- var import_jsx_runtime16 = require("react/jsx-runtime");
1857
+ var import_jsx_runtime17 = require("react/jsx-runtime");
1803
1858
  function Suggestions({ suggestions, onSuggestionClick }) {
1804
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "suggestions", children: suggestions.map((suggestion, index) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1859
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "suggestions", children: suggestions.map((suggestion, index) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1805
1860
  Suggestion,
1806
1861
  {
1807
1862
  title: suggestion.title,
@@ -1815,7 +1870,7 @@ function Suggestions({ suggestions, onSuggestionClick }) {
1815
1870
  }
1816
1871
 
1817
1872
  // src/components/chat/Chat.tsx
1818
- var import_jsx_runtime17 = require("react/jsx-runtime");
1873
+ var import_jsx_runtime18 = require("react/jsx-runtime");
1819
1874
  function CopilotChat({
1820
1875
  instructions,
1821
1876
  suggestions = "auto",
@@ -1840,11 +1895,13 @@ function CopilotChat({
1840
1895
  AssistantMessage: AssistantMessage2 = AssistantMessage,
1841
1896
  UserMessage: UserMessage2 = UserMessage,
1842
1897
  ImageRenderer: ImageRenderer2 = ImageRenderer,
1898
+ ErrorMessage: ErrorMessage2 = ErrorMessage,
1843
1899
  imageUploadsEnabled,
1844
1900
  inputFileAccept = "image/*",
1845
1901
  hideStopButton,
1846
1902
  observabilityHooks,
1847
1903
  renderError,
1904
+ onError,
1848
1905
  // Legacy props - deprecated
1849
1906
  RenderTextMessage,
1850
1907
  RenderActionExecutionMessage,
@@ -1852,12 +1909,19 @@ function CopilotChat({
1852
1909
  RenderResultMessage,
1853
1910
  RenderImageMessage
1854
1911
  }) {
1855
- const { additionalInstructions, setChatInstructions, copilotApiConfig, setBannerError } = (0, import_react_core5.useCopilotContext)();
1912
+ const {
1913
+ additionalInstructions,
1914
+ setChatInstructions,
1915
+ copilotApiConfig,
1916
+ setBannerError,
1917
+ setInternalErrorHandler,
1918
+ removeInternalErrorHandler
1919
+ } = (0, import_react_core5.useCopilotContext)();
1856
1920
  const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
1857
- const [selectedImages, setSelectedImages] = (0, import_react10.useState)([]);
1858
- const [chatError, setChatError] = (0, import_react10.useState)(null);
1859
- const fileInputRef = (0, import_react10.useRef)(null);
1860
- const triggerObservabilityHook = (0, import_react10.useCallback)(
1921
+ const [selectedImages, setSelectedImages] = (0, import_react11.useState)([]);
1922
+ const [chatError, setChatError] = (0, import_react11.useState)(null);
1923
+ const fileInputRef = (0, import_react11.useRef)(null);
1924
+ const triggerObservabilityHook = (0, import_react11.useCallback)(
1861
1925
  (hookName, ...args) => {
1862
1926
  if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
1863
1927
  observabilityHooks[hookName](...args);
@@ -1876,7 +1940,7 @@ function CopilotChat({
1876
1940
  },
1877
1941
  [publicApiKey, observabilityHooks, setBannerError]
1878
1942
  );
1879
- const triggerChatError = (0, import_react10.useCallback)(
1943
+ const triggerChatError = (0, import_react11.useCallback)(
1880
1944
  (error, operation, originalError) => {
1881
1945
  const errorMessage = (error == null ? void 0 : error.message) || (error == null ? void 0 : error.toString()) || "An error occurred";
1882
1946
  setChatError({
@@ -1884,25 +1948,28 @@ function CopilotChat({
1884
1948
  operation,
1885
1949
  timestamp: Date.now()
1886
1950
  });
1887
- if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks.onError)) {
1888
- const errorEvent = {
1889
- type: "error",
1890
- timestamp: Date.now(),
1891
- context: {
1892
- source: "ui",
1893
- request: {
1894
- operation,
1895
- url: chatApiEndpoint,
1896
- startTime: Date.now()
1897
- },
1898
- technical: {
1899
- environment: "browser",
1900
- userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
1901
- stackTrace: originalError instanceof Error ? originalError.stack : void 0
1902
- }
1951
+ const errorEvent = {
1952
+ type: "error",
1953
+ timestamp: Date.now(),
1954
+ context: {
1955
+ source: "ui",
1956
+ request: {
1957
+ operation,
1958
+ url: chatApiEndpoint,
1959
+ startTime: Date.now()
1903
1960
  },
1904
- error
1905
- };
1961
+ technical: {
1962
+ environment: "browser",
1963
+ userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
1964
+ stackTrace: originalError instanceof Error ? originalError.stack : void 0
1965
+ }
1966
+ },
1967
+ error
1968
+ };
1969
+ if (onError) {
1970
+ onError(errorEvent);
1971
+ }
1972
+ if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks.onError)) {
1906
1973
  observabilityHooks.onError(errorEvent);
1907
1974
  }
1908
1975
  if ((observabilityHooks == null ? void 0 : observabilityHooks.onError) && !publicApiKey) {
@@ -1919,7 +1986,20 @@ function CopilotChat({
1919
1986
  },
1920
1987
  [publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError]
1921
1988
  );
1922
- (0, import_react10.useEffect)(() => {
1989
+ (0, import_react11.useEffect)(() => {
1990
+ const id = "chat-component";
1991
+ setInternalErrorHandler({
1992
+ [id]: (error) => {
1993
+ if (!error)
1994
+ return;
1995
+ triggerChatError(error.error, "sendMessage");
1996
+ }
1997
+ });
1998
+ return () => {
1999
+ removeInternalErrorHandler == null ? void 0 : removeInternalErrorHandler(id);
2000
+ };
2001
+ }, [triggerChatError, setInternalErrorHandler, removeInternalErrorHandler]);
2002
+ (0, import_react11.useEffect)(() => {
1923
2003
  if (!imageUploadsEnabled)
1924
2004
  return;
1925
2005
  const handlePaste = (e) => __async(this, null, function* () {
@@ -1965,7 +2045,7 @@ function CopilotChat({
1965
2045
  document.addEventListener("paste", handlePaste);
1966
2046
  return () => document.removeEventListener("paste", handlePaste);
1967
2047
  }, [imageUploadsEnabled, triggerChatError]);
1968
- (0, import_react10.useEffect)(() => {
2048
+ (0, import_react11.useEffect)(() => {
1969
2049
  if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
1970
2050
  setChatInstructions(instructions || "");
1971
2051
  return;
@@ -1993,8 +2073,8 @@ function CopilotChat({
1993
2073
  onStopGeneration,
1994
2074
  onReloadMessages
1995
2075
  );
1996
- const prevIsLoading = (0, import_react10.useRef)(isLoading);
1997
- (0, import_react10.useEffect)(() => {
2076
+ const prevIsLoading = (0, import_react11.useRef)(isLoading);
2077
+ (0, import_react11.useEffect)(() => {
1998
2078
  if (prevIsLoading.current !== isLoading) {
1999
2079
  if (isLoading) {
2000
2080
  triggerObservabilityHook("onChatStarted");
@@ -2013,7 +2093,7 @@ function CopilotChat({
2013
2093
  triggerObservabilityHook("onMessageSent", text);
2014
2094
  return sendMessage(text, images);
2015
2095
  };
2016
- const chatContext = import_react10.default.useContext(ChatContext);
2096
+ const chatContext = import_react11.default.useContext(ChatContext);
2017
2097
  const isVisible = chatContext ? chatContext.open : true;
2018
2098
  const handleRegenerate = (messageId) => {
2019
2099
  if (onRegenerate) {
@@ -2075,14 +2155,14 @@ function CopilotChat({
2075
2155
  }
2076
2156
  triggerObservabilityHook("onFeedbackGiven", message.id, "thumbsDown");
2077
2157
  };
2078
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
2158
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
2079
2159
  chatError && renderError && renderError(__spreadProps(__spreadValues({}, chatError), {
2080
2160
  onDismiss: () => setChatError(null),
2081
2161
  onRetry: () => {
2082
2162
  setChatError(null);
2083
2163
  }
2084
2164
  })),
2085
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2165
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2086
2166
  Messages2,
2087
2167
  {
2088
2168
  AssistantMessage: AssistantMessage2,
@@ -2096,12 +2176,14 @@ function CopilotChat({
2096
2176
  onThumbsDown: handleThumbsDown,
2097
2177
  markdownTagRenderers,
2098
2178
  ImageRenderer: ImageRenderer2,
2179
+ ErrorMessage: ErrorMessage2,
2180
+ chatError,
2099
2181
  RenderTextMessage,
2100
2182
  RenderActionExecutionMessage,
2101
2183
  RenderAgentStateMessage,
2102
2184
  RenderResultMessage,
2103
2185
  RenderImageMessage,
2104
- children: currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2186
+ children: currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2105
2187
  RenderSuggestionsList,
2106
2188
  {
2107
2189
  onSuggestionClick: handleSendMessage,
@@ -2110,9 +2192,9 @@ function CopilotChat({
2110
2192
  )
2111
2193
  }
2112
2194
  ),
2113
- imageUploadsEnabled && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
2114
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ImageUploadQueue, { images: selectedImages, onRemoveImage: removeSelectedImage }),
2115
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2195
+ imageUploadsEnabled && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
2196
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ImageUploadQueue, { images: selectedImages, onRemoveImage: removeSelectedImage }),
2197
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2116
2198
  "input",
2117
2199
  {
2118
2200
  type: "file",
@@ -2124,7 +2206,7 @@ function CopilotChat({
2124
2206
  }
2125
2207
  )
2126
2208
  ] }),
2127
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2209
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2128
2210
  Input2,
2129
2211
  {
2130
2212
  inProgress: isLoading,
@@ -2146,12 +2228,12 @@ function WrappedCopilotChat({
2146
2228
  labels,
2147
2229
  className
2148
2230
  }) {
2149
- const chatContext = import_react10.default.useContext(ChatContext);
2231
+ const chatContext = import_react11.default.useContext(ChatContext);
2150
2232
  if (!chatContext) {
2151
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
2152
- }, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: `copilotKitChat ${className != null ? className : ""}`, children }) });
2233
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
2234
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: `copilotKitChat ${className != null ? className : ""}`, children }) });
2153
2235
  }
2154
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children });
2236
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, { children });
2155
2237
  }
2156
2238
  var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMessage, onInProgress, onSubmitMessage, onStopGeneration, onReloadMessages) => {
2157
2239
  var _a;
@@ -2175,15 +2257,15 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
2175
2257
  const generalContext = (0, import_react_core5.useCopilotContext)();
2176
2258
  const messagesContext = (0, import_react_core5.useCopilotMessagesContext)();
2177
2259
  const { actions } = generalContext;
2178
- const [suggestionsFailed, setSuggestionsFailed] = (0, import_react10.useState)(false);
2179
- const hasGeneratedInitialSuggestions = (0, import_react10.useRef)(false);
2180
- (0, import_react10.useEffect)(() => {
2260
+ const [suggestionsFailed, setSuggestionsFailed] = (0, import_react11.useState)(false);
2261
+ const hasGeneratedInitialSuggestions = (0, import_react11.useRef)(false);
2262
+ (0, import_react11.useEffect)(() => {
2181
2263
  if (Array.isArray(chatSuggestions)) {
2182
2264
  setSuggestions(chatSuggestions);
2183
2265
  hasGeneratedInitialSuggestions.current = true;
2184
2266
  }
2185
2267
  }, [JSON.stringify(chatSuggestions), setSuggestions]);
2186
- const generateSuggestionsWithErrorHandling = (0, import_react10.useCallback)(
2268
+ const generateSuggestionsWithErrorHandling = (0, import_react11.useCallback)(
2187
2269
  (context) => __async(void 0, null, function* () {
2188
2270
  try {
2189
2271
  yield generateSuggestions();
@@ -2194,7 +2276,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
2194
2276
  }),
2195
2277
  [generateSuggestions]
2196
2278
  );
2197
- (0, import_react10.useEffect)(() => {
2279
+ (0, import_react11.useEffect)(() => {
2198
2280
  if (chatSuggestions !== "auto" || isLoadingSuggestions || suggestionsFailed) {
2199
2281
  return;
2200
2282
  }
@@ -2224,13 +2306,13 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
2224
2306
  // Use stable string instead of object reference
2225
2307
  generateSuggestionsWithErrorHandling
2226
2308
  ]);
2227
- (0, import_react10.useEffect)(() => {
2309
+ (0, import_react11.useEffect)(() => {
2228
2310
  if (chatSuggestions !== "auto") {
2229
2311
  hasGeneratedInitialSuggestions.current = false;
2230
2312
  setSuggestionsFailed(false);
2231
2313
  }
2232
2314
  }, [chatSuggestions]);
2233
- const stableContext = (0, import_react10.useMemo)(
2315
+ const stableContext = (0, import_react11.useMemo)(
2234
2316
  () => __spreadValues(__spreadValues({}, generalContext), messagesContext),
2235
2317
  [
2236
2318
  // Only include stable dependencies
@@ -2239,12 +2321,12 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
2239
2321
  generalContext.isLoading
2240
2322
  ]
2241
2323
  );
2242
- const resetSuggestions = (0, import_react10.useCallback)(() => {
2324
+ const resetSuggestions = (0, import_react11.useCallback)(() => {
2243
2325
  resetSuggestionsFromHook();
2244
2326
  setSuggestionsFailed(false);
2245
2327
  hasGeneratedInitialSuggestions.current = false;
2246
2328
  }, [resetSuggestionsFromHook]);
2247
- (0, import_react10.useEffect)(() => {
2329
+ (0, import_react11.useEffect)(() => {
2248
2330
  onInProgress == null ? void 0 : onInProgress(isLoading);
2249
2331
  }, [onInProgress, isLoading]);
2250
2332
  const safelySendMessage = (messageContent, imagesToUse) => __async(void 0, null, function* () {