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

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 (57) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/{chunk-FWQRAZ5S.mjs → chunk-53C3S7R3.mjs} +2 -2
  3. package/dist/{chunk-7XIE7UOW.mjs → chunk-73V4ZLAN.mjs} +2 -2
  4. package/dist/{chunk-SHPG2T4O.mjs → chunk-AUCJZBT5.mjs} +3 -3
  5. package/dist/{chunk-X5AO5A3L.mjs → chunk-EELILZTD.mjs} +5 -2
  6. package/dist/chunk-EELILZTD.mjs.map +1 -0
  7. package/dist/{chunk-EL7NCWNZ.mjs → chunk-WOYNUDPM.mjs} +48 -21
  8. package/dist/chunk-WOYNUDPM.mjs.map +1 -0
  9. package/dist/components/chat/Chat.d.ts +24 -13
  10. package/dist/components/chat/Chat.js +50 -20
  11. package/dist/components/chat/Chat.js.map +1 -1
  12. package/dist/components/chat/Chat.mjs +2 -2
  13. package/dist/components/chat/Messages.d.ts +1 -1
  14. package/dist/components/chat/Messages.js +4 -1
  15. package/dist/components/chat/Messages.js.map +1 -1
  16. package/dist/components/chat/Messages.mjs +1 -1
  17. package/dist/components/chat/Modal.d.ts +1 -1
  18. package/dist/components/chat/Modal.js +50 -20
  19. package/dist/components/chat/Modal.js.map +1 -1
  20. package/dist/components/chat/Modal.mjs +3 -3
  21. package/dist/components/chat/Popup.d.ts +1 -1
  22. package/dist/components/chat/Popup.js +50 -20
  23. package/dist/components/chat/Popup.js.map +1 -1
  24. package/dist/components/chat/Popup.mjs +4 -4
  25. package/dist/components/chat/Sidebar.d.ts +1 -1
  26. package/dist/components/chat/Sidebar.js +50 -20
  27. package/dist/components/chat/Sidebar.js.map +1 -1
  28. package/dist/components/chat/Sidebar.mjs +4 -4
  29. package/dist/components/chat/index.d.ts +2 -2
  30. package/dist/components/chat/index.js +50 -20
  31. package/dist/components/chat/index.js.map +1 -1
  32. package/dist/components/chat/index.mjs +5 -5
  33. package/dist/components/chat/messages/ErrorMessage.d.ts +9 -0
  34. package/dist/components/chat/messages/ErrorMessage.js +711 -0
  35. package/dist/components/chat/messages/ErrorMessage.js.map +1 -0
  36. package/dist/components/chat/messages/ErrorMessage.mjs +66 -0
  37. package/dist/components/chat/messages/ErrorMessage.mjs.map +1 -0
  38. package/dist/components/chat/props.d.ts +26 -1
  39. package/dist/components/chat/props.js.map +1 -1
  40. package/dist/components/index.d.ts +2 -2
  41. package/dist/components/index.js +50 -20
  42. package/dist/components/index.js.map +1 -1
  43. package/dist/components/index.mjs +5 -5
  44. package/dist/index.d.ts +2 -2
  45. package/dist/index.js +50 -20
  46. package/dist/index.js.map +1 -1
  47. package/dist/index.mjs +6 -6
  48. package/package.json +4 -4
  49. package/src/components/chat/Chat.tsx +63 -26
  50. package/src/components/chat/Messages.tsx +3 -0
  51. package/src/components/chat/messages/ErrorMessage.tsx +59 -0
  52. package/src/components/chat/props.ts +31 -0
  53. package/dist/chunk-EL7NCWNZ.mjs.map +0 -1
  54. package/dist/chunk-X5AO5A3L.mjs.map +0 -1
  55. /package/dist/{chunk-FWQRAZ5S.mjs.map → chunk-53C3S7R3.mjs.map} +0 -0
  56. /package/dist/{chunk-7XIE7UOW.mjs.map → chunk-73V4ZLAN.mjs.map} +0 -0
  57. /package/dist/{chunk-SHPG2T4O.mjs.map → chunk-AUCJZBT5.mjs.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  CopilotPopup
3
- } from "../../chunk-7XIE7UOW.mjs";
4
- import "../../chunk-SHPG2T4O.mjs";
3
+ } from "../../chunk-73V4ZLAN.mjs";
4
+ import "../../chunk-AUCJZBT5.mjs";
5
5
  import "../../chunk-C3GSYRC3.mjs";
6
6
  import "../../chunk-GDSZGYCE.mjs";
7
7
  import "../../chunk-V7W6IM2V.mjs";
@@ -12,14 +12,14 @@ 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-EL7NCWNZ.mjs";
15
+ import "../../chunk-WOYNUDPM.mjs";
16
16
  import "../../chunk-226ZMOE3.mjs";
17
17
  import "../../chunk-W26XFBEG.mjs";
18
18
  import "../../chunk-PLHTVHUW.mjs";
19
19
  import "../../chunk-DTRPPNSA.mjs";
20
20
  import "../../chunk-CGEAG65D.mjs";
21
21
  import "../../chunk-QIOJXTIQ.mjs";
22
- import "../../chunk-X5AO5A3L.mjs";
22
+ import "../../chunk-EELILZTD.mjs";
23
23
  import "../../chunk-YO63WHVQ.mjs";
24
24
  import "../../chunk-LJAYSRCB.mjs";
25
25
  import "../../chunk-X477GDGZ.mjs";
@@ -7,7 +7,7 @@ import '../../types/suggestions.js';
7
7
  import './Chat.js';
8
8
  import '@copilotkit/react-core/dist/types/coagent-state';
9
9
  import '@copilotkit/react-core/dist/hooks/use-tree';
10
- import '@copilotkit/react-core/dist/copilot-context-256f9020';
10
+ import '@copilotkit/react-core/dist/copilot-context-59740e82';
11
11
  import '@copilotkit/react-core/dist/types/coagent-action';
12
12
  import '@copilotkit/react-core';
13
13
  import '@copilotkit/runtime-client-gql';
@@ -1873,12 +1873,14 @@ var Messages = ({
1873
1873
  RenderMessage: RenderMessage2,
1874
1874
  AssistantMessage: AssistantMessage2,
1875
1875
  UserMessage: UserMessage2,
1876
+ ErrorMessage,
1876
1877
  ImageRenderer: ImageRenderer2,
1877
1878
  onRegenerate,
1878
1879
  onCopy,
1879
1880
  onThumbsUp,
1880
1881
  onThumbsDown,
1881
1882
  markdownTagRenderers,
1883
+ chatError,
1882
1884
  // Legacy props
1883
1885
  RenderTextMessage,
1884
1886
  RenderActionExecutionMessage,
@@ -1939,7 +1941,8 @@ var Messages = ({
1939
1941
  index
1940
1942
  );
1941
1943
  }),
1942
- interrupt
1944
+ interrupt,
1945
+ chatError && ErrorMessage && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ErrorMessage, { error: chatError, isCurrentMessage: true })
1943
1946
  ] }),
1944
1947
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("footer", { className: "copilotKitMessagesFooter", ref: messagesEndRef, children })
1945
1948
  ] });
@@ -2471,11 +2474,13 @@ function CopilotChat({
2471
2474
  AssistantMessage: AssistantMessage2 = AssistantMessage,
2472
2475
  UserMessage: UserMessage2 = UserMessage,
2473
2476
  ImageRenderer: ImageRenderer2 = ImageRenderer,
2477
+ ErrorMessage,
2474
2478
  imageUploadsEnabled,
2475
2479
  inputFileAccept = "image/*",
2476
2480
  hideStopButton,
2477
2481
  observabilityHooks,
2478
2482
  renderError,
2483
+ onError,
2479
2484
  // Legacy props - deprecated
2480
2485
  RenderTextMessage,
2481
2486
  RenderActionExecutionMessage,
@@ -2483,7 +2488,14 @@ function CopilotChat({
2483
2488
  RenderResultMessage,
2484
2489
  RenderImageMessage
2485
2490
  }) {
2486
- const { additionalInstructions, setChatInstructions, copilotApiConfig, setBannerError } = (0, import_react_core9.useCopilotContext)();
2491
+ const {
2492
+ additionalInstructions,
2493
+ setChatInstructions,
2494
+ copilotApiConfig,
2495
+ setBannerError,
2496
+ setInternalErrorHandler,
2497
+ removeInternalErrorHandler
2498
+ } = (0, import_react_core9.useCopilotContext)();
2487
2499
  const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
2488
2500
  const [selectedImages, setSelectedImages] = (0, import_react14.useState)([]);
2489
2501
  const [chatError, setChatError] = (0, import_react14.useState)(null);
@@ -2515,25 +2527,28 @@ function CopilotChat({
2515
2527
  operation,
2516
2528
  timestamp: Date.now()
2517
2529
  });
2518
- if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks.onError)) {
2519
- const errorEvent = {
2520
- type: "error",
2521
- timestamp: Date.now(),
2522
- context: {
2523
- source: "ui",
2524
- request: {
2525
- operation,
2526
- url: chatApiEndpoint,
2527
- startTime: Date.now()
2528
- },
2529
- technical: {
2530
- environment: "browser",
2531
- userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
2532
- stackTrace: originalError instanceof Error ? originalError.stack : void 0
2533
- }
2530
+ const errorEvent = {
2531
+ type: "error",
2532
+ timestamp: Date.now(),
2533
+ context: {
2534
+ source: "ui",
2535
+ request: {
2536
+ operation,
2537
+ url: chatApiEndpoint,
2538
+ startTime: Date.now()
2534
2539
  },
2535
- error
2536
- };
2540
+ technical: {
2541
+ environment: "browser",
2542
+ userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
2543
+ stackTrace: originalError instanceof Error ? originalError.stack : void 0
2544
+ }
2545
+ },
2546
+ error
2547
+ };
2548
+ if (onError) {
2549
+ onError(errorEvent);
2550
+ }
2551
+ if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks.onError)) {
2537
2552
  observabilityHooks.onError(errorEvent);
2538
2553
  }
2539
2554
  if ((observabilityHooks == null ? void 0 : observabilityHooks.onError) && !publicApiKey) {
@@ -2550,6 +2565,19 @@ function CopilotChat({
2550
2565
  },
2551
2566
  [publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError]
2552
2567
  );
2568
+ (0, import_react14.useEffect)(() => {
2569
+ const id = "chat-component";
2570
+ setInternalErrorHandler({
2571
+ [id]: (error) => {
2572
+ if (!error)
2573
+ return;
2574
+ triggerChatError(error.error, "sendMessage");
2575
+ }
2576
+ });
2577
+ return () => {
2578
+ removeInternalErrorHandler == null ? void 0 : removeInternalErrorHandler(id);
2579
+ };
2580
+ }, [triggerChatError, setInternalErrorHandler, removeInternalErrorHandler]);
2553
2581
  (0, import_react14.useEffect)(() => {
2554
2582
  if (!imageUploadsEnabled)
2555
2583
  return;
@@ -2727,6 +2755,8 @@ function CopilotChat({
2727
2755
  onThumbsDown: handleThumbsDown,
2728
2756
  markdownTagRenderers,
2729
2757
  ImageRenderer: ImageRenderer2,
2758
+ ErrorMessage,
2759
+ chatError,
2730
2760
  RenderTextMessage,
2731
2761
  RenderActionExecutionMessage,
2732
2762
  RenderAgentStateMessage,