@copilotkit/react-ui 1.10.0-next.7 → 1.10.0-next.9

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 (52) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/{chunk-K344MVUT.mjs → chunk-2KG77MAY.mjs} +62 -8
  3. package/dist/chunk-2KG77MAY.mjs.map +1 -0
  4. package/dist/{chunk-EDWWF7QY.mjs → chunk-6C3YVF5W.mjs} +2 -2
  5. package/dist/{chunk-YH3DHANT.mjs → chunk-7K2X77PW.mjs} +25 -6
  6. package/dist/chunk-7K2X77PW.mjs.map +1 -0
  7. package/dist/{chunk-WBPBTTQD.mjs → chunk-FFJHOZX6.mjs} +4 -4
  8. package/dist/{chunk-V6DDX4LH.mjs → chunk-GDSZGYCE.mjs} +2 -2
  9. package/dist/{chunk-DSY4ZRMN.mjs → chunk-TW4LLLTE.mjs} +2 -2
  10. package/dist/components/chat/Chat.d.ts +23 -12
  11. package/dist/components/chat/Chat.js +61 -7
  12. package/dist/components/chat/Chat.js.map +1 -1
  13. package/dist/components/chat/Chat.mjs +1 -1
  14. package/dist/components/chat/Header.mjs +4 -4
  15. package/dist/components/chat/Modal.d.ts +1 -1
  16. package/dist/components/chat/Modal.js +77 -10
  17. package/dist/components/chat/Modal.js.map +1 -1
  18. package/dist/components/chat/Modal.mjs +6 -6
  19. package/dist/components/chat/Popup.d.ts +1 -1
  20. package/dist/components/chat/Popup.js +77 -10
  21. package/dist/components/chat/Popup.js.map +1 -1
  22. package/dist/components/chat/Popup.mjs +7 -7
  23. package/dist/components/chat/Sidebar.d.ts +1 -1
  24. package/dist/components/chat/Sidebar.js +77 -10
  25. package/dist/components/chat/Sidebar.js.map +1 -1
  26. package/dist/components/chat/Sidebar.mjs +7 -7
  27. package/dist/components/chat/index.d.ts +1 -1
  28. package/dist/components/chat/index.js +77 -10
  29. package/dist/components/chat/index.js.map +1 -1
  30. package/dist/components/chat/index.mjs +8 -8
  31. package/dist/components/chat/props.d.ts +6 -1
  32. package/dist/components/chat/props.js.map +1 -1
  33. package/dist/components/dev-console/console.mjs +3 -3
  34. package/dist/components/dev-console/index.mjs +4 -4
  35. package/dist/components/index.d.ts +1 -1
  36. package/dist/components/index.js +77 -10
  37. package/dist/components/index.js.map +1 -1
  38. package/dist/components/index.mjs +9 -9
  39. package/dist/index.d.ts +1 -1
  40. package/dist/index.js +79 -12
  41. package/dist/index.js.map +1 -1
  42. package/dist/index.mjs +9 -9
  43. package/package.json +4 -4
  44. package/src/components/chat/Chat.tsx +95 -7
  45. package/src/components/chat/Modal.tsx +24 -3
  46. package/src/components/chat/props.ts +7 -1
  47. package/dist/chunk-K344MVUT.mjs.map +0 -1
  48. package/dist/chunk-YH3DHANT.mjs.map +0 -1
  49. /package/dist/{chunk-EDWWF7QY.mjs.map → chunk-6C3YVF5W.mjs.map} +0 -0
  50. /package/dist/{chunk-WBPBTTQD.mjs.map → chunk-FFJHOZX6.mjs.map} +0 -0
  51. /package/dist/{chunk-V6DDX4LH.mjs.map → chunk-GDSZGYCE.mjs.map} +0 -0
  52. /package/dist/{chunk-DSY4ZRMN.mjs.map → chunk-TW4LLLTE.mjs.map} +0 -0
package/dist/index.mjs CHANGED
@@ -4,29 +4,29 @@ import "./chunk-MMVDU6DF.mjs";
4
4
  import "./chunk-SC6JRFAJ.mjs";
5
5
  import {
6
6
  CopilotSidebar
7
- } from "./chunk-DSY4ZRMN.mjs";
7
+ } from "./chunk-TW4LLLTE.mjs";
8
8
  import "./chunk-WB3YULQ4.mjs";
9
9
  import {
10
10
  CopilotPopup
11
- } from "./chunk-EDWWF7QY.mjs";
12
- import "./chunk-YH3DHANT.mjs";
11
+ } from "./chunk-6C3YVF5W.mjs";
12
+ import "./chunk-7K2X77PW.mjs";
13
13
  import "./chunk-C3GSYRC3.mjs";
14
- import "./chunk-V6DDX4LH.mjs";
14
+ import "./chunk-GDSZGYCE.mjs";
15
15
  import "./chunk-V7W6IM2V.mjs";
16
16
  import {
17
17
  CopilotDevConsole
18
- } from "./chunk-WBPBTTQD.mjs";
19
- import "./chunk-KXE2JCUH.mjs";
20
- import "./chunk-NRA3CFEE.mjs";
21
- import "./chunk-BH6PCAAL.mjs";
18
+ } from "./chunk-FFJHOZX6.mjs";
22
19
  import "./chunk-Q5V6S67N.mjs";
23
20
  import {
24
21
  shouldShowDevConsole
25
22
  } from "./chunk-JY2CSDKN.mjs";
23
+ import "./chunk-KXE2JCUH.mjs";
24
+ import "./chunk-NRA3CFEE.mjs";
25
+ import "./chunk-BH6PCAAL.mjs";
26
26
  import "./chunk-UFN2VWSR.mjs";
27
27
  import {
28
28
  CopilotChat
29
- } from "./chunk-K344MVUT.mjs";
29
+ } from "./chunk-2KG77MAY.mjs";
30
30
  import "./chunk-JHUTTP5C.mjs";
31
31
  import {
32
32
  AssistantMessage
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "publishConfig": {
10
10
  "access": "public"
11
11
  },
12
- "version": "1.10.0-next.7",
12
+ "version": "1.10.0-next.9",
13
13
  "sideEffects": [
14
14
  "**/*.css"
15
15
  ],
@@ -51,9 +51,9 @@
51
51
  "rehype-raw": "^7.0.0",
52
52
  "remark-gfm": "^4.0.1",
53
53
  "remark-math": "^6.0.0",
54
- "@copilotkit/react-core": "1.10.0-next.7",
55
- "@copilotkit/runtime-client-gql": "1.10.0-next.7",
56
- "@copilotkit/shared": "1.10.0-next.7"
54
+ "@copilotkit/react-core": "1.10.0-next.9",
55
+ "@copilotkit/runtime-client-gql": "1.10.0-next.9",
56
+ "@copilotkit/shared": "1.10.0-next.9"
57
57
  },
58
58
  "keywords": [
59
59
  "copilotkit",
@@ -85,6 +85,7 @@ import type { SuggestionItem } from "@copilotkit/react-core";
85
85
  import {
86
86
  CopilotKitError,
87
87
  CopilotKitErrorCode,
88
+ CopilotErrorEvent,
88
89
  Message,
89
90
  Severity,
90
91
  ErrorVisibility,
@@ -281,6 +282,18 @@ export interface CopilotChatProps {
281
282
  * These hooks only work when publicApiKey is provided.
282
283
  */
283
284
  observabilityHooks?: CopilotObservabilityHooks;
285
+
286
+ /**
287
+ * Custom error renderer for chat-specific errors.
288
+ * When provided, errors will be displayed inline within the chat interface.
289
+ */
290
+ renderError?: (error: {
291
+ message: string;
292
+ operation?: string;
293
+ timestamp: number;
294
+ onDismiss: () => void;
295
+ onRetry?: () => void;
296
+ }) => React.ReactNode;
284
297
  }
285
298
 
286
299
  interface OnStopGenerationArguments {
@@ -368,19 +381,28 @@ export function CopilotChat({
368
381
  inputFileAccept = "image/*",
369
382
  hideStopButton,
370
383
  observabilityHooks,
384
+ renderError,
371
385
  }: CopilotChatProps) {
372
386
  const { additionalInstructions, setChatInstructions, copilotApiConfig, setBannerError } =
373
387
  useCopilotContext();
388
+
389
+ // Destructure stable values to avoid object reference changes
390
+ const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
374
391
  const [selectedImages, setSelectedImages] = useState<Array<ImageUpload>>([]);
392
+ const [chatError, setChatError] = useState<{
393
+ message: string;
394
+ operation?: string;
395
+ timestamp: number;
396
+ } | null>(null);
375
397
  const fileInputRef = useRef<HTMLInputElement>(null);
376
398
 
377
399
  // Helper function to trigger event hooks only if publicApiKey is provided
378
400
  const triggerObservabilityHook = useCallback(
379
401
  (hookName: keyof CopilotObservabilityHooks, ...args: any[]) => {
380
- if (copilotApiConfig.publicApiKey && observabilityHooks?.[hookName]) {
402
+ if (publicApiKey && observabilityHooks?.[hookName]) {
381
403
  (observabilityHooks[hookName] as any)(...args);
382
404
  }
383
- if (observabilityHooks?.[hookName] && !copilotApiConfig.publicApiKey) {
405
+ if (observabilityHooks?.[hookName] && !publicApiKey) {
384
406
  setBannerError(
385
407
  new CopilotKitError({
386
408
  message: "observabilityHooks requires a publicApiKey to function.",
@@ -392,7 +414,58 @@ export function CopilotChat({
392
414
  styledConsole.publicApiKeyRequired("observabilityHooks");
393
415
  }
394
416
  },
395
- [copilotApiConfig.publicApiKey, observabilityHooks],
417
+ [publicApiKey, observabilityHooks, setBannerError],
418
+ );
419
+
420
+ // Helper function to trigger chat error and render error UI
421
+ const triggerChatError = useCallback(
422
+ (error: any, operation: string, originalError?: any) => {
423
+ const errorMessage = error?.message || error?.toString() || "An error occurred";
424
+
425
+ // Set chat error state for rendering
426
+ setChatError({
427
+ message: errorMessage,
428
+ operation,
429
+ timestamp: Date.now(),
430
+ });
431
+
432
+ // Also trigger observability hook if available
433
+ if (publicApiKey && observabilityHooks?.onError) {
434
+ const errorEvent: CopilotErrorEvent = {
435
+ type: "error",
436
+ timestamp: Date.now(),
437
+ context: {
438
+ source: "ui",
439
+ request: {
440
+ operation,
441
+ url: chatApiEndpoint,
442
+ startTime: Date.now(),
443
+ },
444
+ technical: {
445
+ environment: "browser",
446
+ userAgent: typeof navigator !== "undefined" ? navigator.userAgent : undefined,
447
+ stackTrace: originalError instanceof Error ? originalError.stack : undefined,
448
+ },
449
+ },
450
+ error,
451
+ };
452
+ observabilityHooks.onError(errorEvent);
453
+ }
454
+
455
+ // Show banner error if onError hook is used without publicApiKey
456
+ if (observabilityHooks?.onError && !publicApiKey) {
457
+ setBannerError(
458
+ new CopilotKitError({
459
+ message: "observabilityHooks.onError requires a publicApiKey to function.",
460
+ code: CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
461
+ severity: Severity.CRITICAL,
462
+ visibility: ErrorVisibility.BANNER,
463
+ }),
464
+ );
465
+ styledConsole.publicApiKeyRequired("observabilityHooks.onError");
466
+ }
467
+ },
468
+ [publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError],
396
469
  );
397
470
 
398
471
  // Clipboard paste handler
@@ -436,14 +509,15 @@ export function CopilotChat({
436
509
  const loadedImages = (await Promise.all(imagePromises)).filter((img) => img !== null);
437
510
  setSelectedImages((prev) => [...prev, ...loadedImages]);
438
511
  } catch (error) {
439
- // TODO: Show an error message to the user
512
+ // Trigger chat-level error handler
513
+ triggerChatError(error, "processClipboardImages", error);
440
514
  console.error("Error processing pasted images:", error);
441
515
  }
442
516
  };
443
517
 
444
518
  document.addEventListener("paste", handlePaste);
445
519
  return () => document.removeEventListener("paste", handlePaste);
446
- }, [imageUploadsEnabled]);
520
+ }, [imageUploadsEnabled, triggerChatError]);
447
521
 
448
522
  useEffect(() => {
449
523
  if (!additionalInstructions?.length) {
@@ -563,7 +637,8 @@ export function CopilotChat({
563
637
  const loadedImages = await Promise.all(fileReadPromises);
564
638
  setSelectedImages((prev) => [...prev, ...loadedImages]);
565
639
  } catch (error) {
566
- // TODO: Show an error message to the user
640
+ // Trigger chat-level error handler
641
+ triggerChatError(error, "processUploadedImages", error);
567
642
  console.error("Error reading files:", error);
568
643
  }
569
644
  };
@@ -592,6 +667,19 @@ export function CopilotChat({
592
667
 
593
668
  return (
594
669
  <WrappedCopilotChat icons={icons} labels={labels} className={className}>
670
+ {/* Render error above messages if present */}
671
+ {chatError &&
672
+ renderError &&
673
+ renderError({
674
+ ...chatError,
675
+ onDismiss: () => setChatError(null),
676
+ onRetry: () => {
677
+ // Clear error and potentially retry based on operation
678
+ setChatError(null);
679
+ // TODO: Implement specific retry logic based on operation type
680
+ },
681
+ })}
682
+
595
683
  <Messages
596
684
  AssistantMessage={AssistantMessage}
597
685
  UserMessage={UserMessage}
@@ -886,9 +974,9 @@ export const useCopilotChatLogic = (
886
974
  await runAgent(
887
975
  generalContext.agentSession.agentName,
888
976
  stableContext,
977
+ messagesContext.messages,
889
978
  appendMessage,
890
979
  runChatCompletion,
891
- hint,
892
980
  );
893
981
  }
894
982
  };
@@ -10,6 +10,13 @@ import { CopilotChat, CopilotChatProps } from "./Chat";
10
10
  import { AssistantMessage as DefaultAssistantMessage } from "./messages/AssistantMessage";
11
11
  import { UserMessage as DefaultUserMessage } from "./messages/UserMessage";
12
12
  import { useCopilotContext } from "@copilotkit/react-core";
13
+ import {
14
+ CopilotKitError,
15
+ CopilotKitErrorCode,
16
+ Severity,
17
+ ErrorVisibility,
18
+ styledConsole,
19
+ } from "@copilotkit/shared";
13
20
 
14
21
  export interface CopilotModalProps extends CopilotChatProps {
15
22
  /**
@@ -79,16 +86,30 @@ const CopilotModalInner = ({
79
86
  hitEscapeToClose: boolean;
80
87
  shortcut: string;
81
88
  }) => {
82
- const { copilotApiConfig } = useCopilotContext();
89
+ const { copilotApiConfig, setBannerError } = useCopilotContext();
90
+
91
+ // Destructure stable values to avoid object reference changes
92
+ const { publicApiKey } = copilotApiConfig;
83
93
 
84
94
  // Helper function to trigger event hooks only if publicApiKey is provided
85
95
  const triggerObservabilityHook = useCallback(
86
96
  (hookName: keyof CopilotObservabilityHooks, ...args: any[]) => {
87
- if (copilotApiConfig.publicApiKey && observabilityHooks?.[hookName]) {
97
+ if (publicApiKey && observabilityHooks?.[hookName]) {
88
98
  (observabilityHooks[hookName] as any)(...args);
89
99
  }
100
+ if (observabilityHooks?.[hookName] && !publicApiKey) {
101
+ setBannerError(
102
+ new CopilotKitError({
103
+ message: "observabilityHooks requires a publicApiKey to function.",
104
+ code: CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
105
+ severity: Severity.CRITICAL,
106
+ visibility: ErrorVisibility.BANNER,
107
+ }),
108
+ );
109
+ styledConsole.publicApiKeyRequired("observabilityHooks");
110
+ }
90
111
  },
91
- [copilotApiConfig.publicApiKey, observabilityHooks],
112
+ [publicApiKey, observabilityHooks, setBannerError],
92
113
  );
93
114
 
94
115
  const { open } = useChatContext();
@@ -1,4 +1,4 @@
1
- import { AIMessage, Message, UserMessage } from "@copilotkit/shared";
1
+ import { AIMessage, Message, UserMessage, CopilotErrorEvent } from "@copilotkit/shared";
2
2
  import { CopilotChatSuggestion } from "../../types/suggestions";
3
3
  import { ReactNode } from "react";
4
4
  import { ImageData } from "@copilotkit/shared";
@@ -47,6 +47,12 @@ export interface CopilotObservabilityHooks {
47
47
  * Called when chat generation stops
48
48
  */
49
49
  onChatStopped?: () => void;
50
+
51
+ /**
52
+ * Called when an error occurs in the chat
53
+ * This enables chat-specific error handling UX while preserving system-wide error monitoring
54
+ */
55
+ onError?: (errorEvent: CopilotErrorEvent) => void;
50
56
  }
51
57
 
52
58
  export interface ButtonProps {}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/chat/Chat.tsx"],"sourcesContent":["/**\n * <br/>\n * <img src=\"https://cdn.copilotkit.ai/docs/copilotkit/images/CopilotChat.gif\" width=\"500\" />\n *\n * A chatbot panel component for the CopilotKit framework. The component allows for a high degree\n * of customization through various props and custom CSS.\n *\n * ## Install Dependencies\n *\n * This component is part of the [@copilotkit/react-ui](https://npmjs.com/package/@copilotkit/react-ui) package.\n *\n * ```shell npm2yarn \\\"@copilotkit/react-ui\"\\\n * npm install @copilotkit/react-core @copilotkit/react-ui\n * ```\n *\n * ## Usage\n *\n * ```tsx\n * import { CopilotChat } from \"@copilotkit/react-ui\";\n * import \"@copilotkit/react-ui/styles.css\";\n *\n * <CopilotChat\n * labels={{\n * title: \"Your Assistant\",\n * initial: \"Hi! 👋 How can I assist you today?\",\n * }}\n * />\n * ```\n *\n * ### With Observability Hooks\n *\n * To monitor user interactions, provide the `observabilityHooks` prop.\n * **Note:** This requires a `publicApiKey` in the `<CopilotKit>` provider.\n *\n * ```tsx\n * <CopilotKit publicApiKey=\"YOUR_PUBLIC_API_KEY\">\n * <CopilotChat\n * observabilityHooks={{\n * onMessageSent: (message) => {\n * console.log(\"Message sent:\", message);\n * },\n * }}\n * />\n * </CopilotKit>\n * ```\n *\n * ### Look & Feel\n *\n * By default, CopilotKit components do not have any styles. You can import CopilotKit's stylesheet at the root of your project:\n * ```tsx title=\"YourRootComponent.tsx\"\n * ...\n * import \"@copilotkit/react-ui/styles.css\"; // [!code highlight]\n *\n * export function YourRootComponent() {\n * return (\n * <CopilotKit>\n * ...\n * </CopilotKit>\n * );\n * }\n * ```\n * For more information about how to customize the styles, check out the [Customize Look & Feel](/guides/custom-look-and-feel/customize-built-in-ui-components) guide.\n */\n\nimport {\n ChatContext,\n ChatContextProvider,\n CopilotChatIcons,\n CopilotChatLabels,\n} from \"./ChatContext\";\nimport { Messages as DefaultMessages } from \"./Messages\";\nimport { Input as DefaultInput } from \"./Input\";\nimport { RenderMessage as DefaultRenderMessage } from \"./messages/RenderMessage\";\nimport { AssistantMessage as DefaultAssistantMessage } from \"./messages/AssistantMessage\";\nimport { UserMessage as DefaultUserMessage } from \"./messages/UserMessage\";\nimport { ImageRenderer as DefaultImageRenderer } from \"./messages/ImageRenderer\";\nimport React, { useEffect, useRef, useState, useCallback, useMemo } from \"react\";\nimport {\n SystemMessageFunction,\n useCopilotChatInternal as useCopilotChat,\n useCopilotContext,\n useCopilotMessagesContext,\n} from \"@copilotkit/react-core\";\nimport type { SuggestionItem } from \"@copilotkit/react-core\";\nimport {\n CopilotKitError,\n CopilotKitErrorCode,\n Message,\n Severity,\n ErrorVisibility,\n styledConsole,\n} from \"@copilotkit/shared\";\nimport { randomId } from \"@copilotkit/shared\";\nimport {\n AssistantMessageProps,\n ComponentsMap,\n CopilotObservabilityHooks,\n ImageRendererProps,\n InputProps,\n MessagesProps,\n RenderMessageProps,\n RenderSuggestionsListProps,\n UserMessageProps,\n} from \"./props\";\n\nimport { HintFunction, runAgent, stopAgent } from \"@copilotkit/react-core\";\nimport { ImageUploadQueue } from \"./ImageUploadQueue\";\nimport { Suggestions as DefaultRenderSuggestionsList } from \"./Suggestions\";\n\n/**\n * The type of suggestions to use in the chat.\n *\n * `auto` - Suggestions are generated automatically.\n * `manual` - Suggestions are controlled programmatically.\n * `SuggestionItem[]` - Static suggestions array.\n */\nexport type ChatSuggestions = \"auto\" | \"manual\" | SuggestionItem[];\n\n/**\n * Props for CopilotChat component.\n */\nexport interface CopilotChatProps {\n /**\n * Custom instructions to be added to the system message. Use this property to\n * provide additional context or guidance to the language model, influencing\n * its responses. These instructions can include specific directions,\n * preferences, or criteria that the model should consider when generating\n * its output, thereby tailoring the conversation more precisely to the\n * user's needs or the application's requirements.\n */\n instructions?: string;\n\n /**\n * Controls the behavior of suggestions in the chat interface.\n *\n * `auto` (default) - Suggestions are generated automatically:\n * - When the chat is first opened (empty state)\n * - After each message exchange completes\n * - Uses configuration from `useCopilotChatSuggestions` hooks\n *\n * `manual` - Suggestions are controlled programmatically:\n * - Use `setSuggestions()` to set custom suggestions\n * - Use `generateSuggestions()` to trigger AI generation\n * - Access via `useCopilotChat` hook\n *\n * `SuggestionItem[]` - Static suggestions array:\n * - Always shows the same suggestions\n * - No AI generation involved\n */\n suggestions?: ChatSuggestions;\n\n /**\n * A callback that gets called when the in progress state changes.\n */\n onInProgress?: (inProgress: boolean) => void;\n\n /**\n * A callback that gets called when a new message it submitted.\n */\n onSubmitMessage?: (message: string) => void | Promise<void>;\n\n /**\n * A custom stop generation function.\n */\n onStopGeneration?: OnStopGeneration;\n\n /**\n * A custom reload messages function.\n */\n onReloadMessages?: OnReloadMessages;\n\n /**\n * A callback function to regenerate the assistant's response\n */\n onRegenerate?: (messageId: string) => void;\n\n /**\n * A callback function when the message is copied\n */\n onCopy?: (message: string) => void;\n\n /**\n * A callback function for thumbs up feedback\n */\n onThumbsUp?: (message: Message) => void;\n\n /**\n * A callback function for thumbs down feedback\n */\n onThumbsDown?: (message: Message) => void;\n\n /**\n * A list of markdown components to render in assistant message.\n * Useful when you want to render custom elements in the message (e.g a reference tag element)\n */\n markdownTagRenderers?: ComponentsMap;\n\n /**\n * Icons can be used to set custom icons for the chat window.\n */\n icons?: CopilotChatIcons;\n\n /**\n * Labels can be used to set custom labels for the chat window.\n */\n labels?: CopilotChatLabels;\n\n /**\n * Enable image upload button (image inputs only supported on some models)\n */\n imageUploadsEnabled?: boolean;\n\n /**\n * The 'accept' attribute for the file input used for image uploads.\n * Defaults to \"image/*\".\n */\n inputFileAccept?: string;\n\n /**\n * A function that takes in context string and instructions and returns\n * the system message to include in the chat request.\n * Use this to completely override the system message, when providing\n * instructions is not enough.\n */\n makeSystemMessage?: SystemMessageFunction;\n\n /**\n * A custom assistant message component to use instead of the default.\n */\n AssistantMessage?: React.ComponentType<AssistantMessageProps>;\n\n /**\n * A custom user message component to use instead of the default.\n */\n UserMessage?: React.ComponentType<UserMessageProps>;\n\n /**\n * A custom Messages component to use instead of the default.\n */\n Messages?: React.ComponentType<MessagesProps>;\n\n /**\n * A custom RenderMessage component to use instead of the default.\n *\n * **Warning**: This is a break-glass solution to allow for custom\n * rendering of messages. You are most likely looking to swap out\n * the AssistantMessage and UserMessage components instead which\n * are also props.\n */\n RenderMessage?: React.ComponentType<RenderMessageProps>;\n\n /**\n * A custom suggestions list component to use instead of the default.\n */\n RenderSuggestionsList?: React.ComponentType<RenderSuggestionsListProps>;\n\n /**\n * A custom Input component to use instead of the default.\n */\n Input?: React.ComponentType<InputProps>;\n\n /**\n * A custom image rendering component to use instead of the default.\n */\n ImageRenderer?: React.ComponentType<ImageRendererProps>;\n\n /**\n * A class name to apply to the root element.\n */\n className?: string;\n\n /**\n * Children to render.\n */\n children?: React.ReactNode;\n\n hideStopButton?: boolean;\n\n /**\n * Event hooks for CopilotKit chat events.\n * These hooks only work when publicApiKey is provided.\n */\n observabilityHooks?: CopilotObservabilityHooks;\n}\n\ninterface OnStopGenerationArguments {\n /**\n * The name of the currently executing agent.\n */\n currentAgentName: string | undefined;\n\n /**\n * The messages in the chat.\n */\n messages: Message[];\n\n /**\n * Set the messages in the chat.\n */\n setMessages: (messages: Message[]) => void;\n\n /**\n * Stop chat generation.\n */\n stopGeneration: () => void;\n\n /**\n * Restart the currently executing agent.\n */\n restartCurrentAgent: () => void;\n\n /**\n * Stop the currently executing agent.\n */\n stopCurrentAgent: () => void;\n\n /**\n * Run the currently executing agent.\n */\n runCurrentAgent: (hint?: HintFunction) => Promise<void>;\n\n /**\n * Set the state of the currently executing agent.\n */\n setCurrentAgentState: (state: any) => void;\n}\n\nexport type OnReloadMessagesArguments = OnStopGenerationArguments & {\n /**\n * The message on which \"regenerate\" was pressed\n */\n messageId: string;\n};\n\nexport type OnStopGeneration = (args: OnStopGenerationArguments) => void;\n\nexport type OnReloadMessages = (args: OnReloadMessagesArguments) => void;\n\nexport type ImageUpload = {\n contentType: string;\n bytes: string;\n};\n\nexport function CopilotChat({\n instructions,\n suggestions = \"auto\",\n onSubmitMessage,\n makeSystemMessage,\n onInProgress,\n onStopGeneration,\n onReloadMessages,\n onRegenerate,\n onCopy,\n onThumbsUp,\n onThumbsDown,\n markdownTagRenderers,\n Messages = DefaultMessages,\n RenderMessage = DefaultRenderMessage,\n RenderSuggestionsList = DefaultRenderSuggestionsList,\n Input = DefaultInput,\n className,\n icons,\n labels,\n AssistantMessage = DefaultAssistantMessage,\n UserMessage = DefaultUserMessage,\n ImageRenderer = DefaultImageRenderer,\n imageUploadsEnabled,\n inputFileAccept = \"image/*\",\n hideStopButton,\n observabilityHooks,\n}: CopilotChatProps) {\n const { additionalInstructions, setChatInstructions, copilotApiConfig, setBannerError } =\n useCopilotContext();\n const [selectedImages, setSelectedImages] = useState<Array<ImageUpload>>([]);\n const fileInputRef = useRef<HTMLInputElement>(null);\n\n // Helper function to trigger event hooks only if publicApiKey is provided\n const triggerObservabilityHook = useCallback(\n (hookName: keyof CopilotObservabilityHooks, ...args: any[]) => {\n if (copilotApiConfig.publicApiKey && observabilityHooks?.[hookName]) {\n (observabilityHooks[hookName] as any)(...args);\n }\n if (observabilityHooks?.[hookName] && !copilotApiConfig.publicApiKey) {\n setBannerError(\n new CopilotKitError({\n message: \"observabilityHooks requires a publicApiKey to function.\",\n code: CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,\n severity: Severity.CRITICAL,\n visibility: ErrorVisibility.BANNER,\n }),\n );\n styledConsole.publicApiKeyRequired(\"observabilityHooks\");\n }\n },\n [copilotApiConfig.publicApiKey, observabilityHooks],\n );\n\n // Clipboard paste handler\n useEffect(() => {\n if (!imageUploadsEnabled) return;\n\n const handlePaste = async (e: ClipboardEvent) => {\n const target = e.target as HTMLElement;\n if (!target.parentElement?.classList.contains(\"copilotKitInput\")) return;\n\n const items = Array.from(e.clipboardData?.items || []);\n const imageItems = items.filter((item) => item.type.startsWith(\"image/\"));\n\n if (imageItems.length === 0) return;\n\n e.preventDefault(); // Prevent default paste behavior for images\n\n const imagePromises: Promise<ImageUpload | null>[] = imageItems.map((item) => {\n const file = item.getAsFile();\n if (!file) return Promise.resolve(null);\n\n return new Promise<ImageUpload | null>((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = (e) => {\n const base64String = (e.target?.result as string)?.split(\",\")[1];\n if (base64String) {\n resolve({\n contentType: file.type,\n bytes: base64String,\n });\n } else {\n resolve(null);\n }\n };\n reader.onerror = reject;\n reader.readAsDataURL(file);\n });\n });\n\n try {\n const loadedImages = (await Promise.all(imagePromises)).filter((img) => img !== null);\n setSelectedImages((prev) => [...prev, ...loadedImages]);\n } catch (error) {\n // TODO: Show an error message to the user\n console.error(\"Error processing pasted images:\", error);\n }\n };\n\n document.addEventListener(\"paste\", handlePaste);\n return () => document.removeEventListener(\"paste\", handlePaste);\n }, [imageUploadsEnabled]);\n\n useEffect(() => {\n if (!additionalInstructions?.length) {\n setChatInstructions(instructions || \"\");\n return;\n }\n\n /*\n Will result in a prompt like:\n\n You are a helpful assistant. \n Additionally, follow these instructions:\n - Do not answer questions about the weather.\n - Do not answer questions about the stock market.\"\n */\n const combinedAdditionalInstructions = [\n instructions,\n \"Additionally, follow these instructions:\",\n ...additionalInstructions.map((instruction) => `- ${instruction}`),\n ];\n\n setChatInstructions(combinedAdditionalInstructions.join(\"\\n\") || \"\");\n }, [instructions, additionalInstructions]);\n\n const {\n visibleMessages,\n isLoading,\n sendMessage,\n stopGeneration,\n reloadMessages,\n suggestions: currentSuggestions,\n } = useCopilotChatLogic(\n suggestions,\n makeSystemMessage,\n onInProgress,\n onSubmitMessage,\n onStopGeneration,\n onReloadMessages,\n );\n\n // Track loading state changes for chat start/stop events\n const prevIsLoading = useRef(isLoading);\n useEffect(() => {\n if (prevIsLoading.current !== isLoading) {\n if (isLoading) {\n triggerObservabilityHook(\"onChatStarted\");\n } else {\n triggerObservabilityHook(\"onChatStopped\");\n }\n prevIsLoading.current = isLoading;\n }\n }, [isLoading, triggerObservabilityHook]);\n\n // Wrapper for sendMessage to clear selected images\n const handleSendMessage = (text: string) => {\n const images = selectedImages;\n setSelectedImages([]);\n if (fileInputRef.current) {\n fileInputRef.current.value = \"\";\n }\n\n // Trigger message sent event\n triggerObservabilityHook(\"onMessageSent\", text);\n\n return sendMessage(text, images);\n };\n\n const chatContext = React.useContext(ChatContext);\n const isVisible = chatContext ? chatContext.open : true;\n\n const handleRegenerate = (messageId: string) => {\n if (onRegenerate) {\n onRegenerate(messageId);\n }\n\n // Trigger message regenerated event\n triggerObservabilityHook(\"onMessageRegenerated\", messageId);\n\n reloadMessages(messageId);\n };\n\n const handleCopy = (message: string) => {\n if (onCopy) {\n onCopy(message);\n }\n\n // Trigger message copied event\n triggerObservabilityHook(\"onMessageCopied\", message);\n };\n\n const handleImageUpload = async (event: React.ChangeEvent<HTMLInputElement>) => {\n if (!event.target.files || event.target.files.length === 0) {\n return;\n }\n\n const files = Array.from(event.target.files).filter((file) => file.type.startsWith(\"image/\"));\n if (files.length === 0) return;\n\n const fileReadPromises = files.map((file) => {\n return new Promise<{ contentType: string; bytes: string }>((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = (e) => {\n const base64String = (e.target?.result as string)?.split(\",\")[1] || \"\";\n if (base64String) {\n resolve({\n contentType: file.type,\n bytes: base64String,\n });\n }\n };\n reader.onerror = reject;\n reader.readAsDataURL(file);\n });\n });\n\n try {\n const loadedImages = await Promise.all(fileReadPromises);\n setSelectedImages((prev) => [...prev, ...loadedImages]);\n } catch (error) {\n // TODO: Show an error message to the user\n console.error(\"Error reading files:\", error);\n }\n };\n\n const removeSelectedImage = (index: number) => {\n setSelectedImages((prev) => prev.filter((_, i) => i !== index));\n };\n\n const handleThumbsUp = (message: Message) => {\n if (onThumbsUp) {\n onThumbsUp(message);\n }\n\n // Trigger feedback given event\n triggerObservabilityHook(\"onFeedbackGiven\", message.id, \"thumbsUp\");\n };\n\n const handleThumbsDown = (message: Message) => {\n if (onThumbsDown) {\n onThumbsDown(message);\n }\n\n // Trigger feedback given event\n triggerObservabilityHook(\"onFeedbackGiven\", message.id, \"thumbsDown\");\n };\n\n return (\n <WrappedCopilotChat icons={icons} labels={labels} className={className}>\n <Messages\n AssistantMessage={AssistantMessage}\n UserMessage={UserMessage}\n RenderMessage={RenderMessage}\n messages={visibleMessages}\n inProgress={isLoading}\n onRegenerate={handleRegenerate}\n onCopy={handleCopy}\n onThumbsUp={handleThumbsUp}\n onThumbsDown={handleThumbsDown}\n markdownTagRenderers={markdownTagRenderers}\n ImageRenderer={ImageRenderer}\n >\n {currentSuggestions.length > 0 && (\n <RenderSuggestionsList\n onSuggestionClick={handleSendMessage}\n suggestions={currentSuggestions}\n />\n )}\n </Messages>\n\n {imageUploadsEnabled && (\n <>\n <ImageUploadQueue images={selectedImages} onRemoveImage={removeSelectedImage} />\n <input\n type=\"file\"\n multiple\n ref={fileInputRef}\n onChange={handleImageUpload}\n accept={inputFileAccept}\n style={{ display: \"none\" }}\n />\n </>\n )}\n <Input\n inProgress={isLoading}\n onSend={handleSendMessage}\n isVisible={isVisible}\n onStop={stopGeneration}\n onUpload={imageUploadsEnabled ? () => fileInputRef.current?.click() : undefined}\n hideStopButton={hideStopButton}\n />\n </WrappedCopilotChat>\n );\n}\n\nexport function WrappedCopilotChat({\n children,\n icons,\n labels,\n className,\n}: {\n children: React.ReactNode;\n icons?: CopilotChatIcons;\n labels?: CopilotChatLabels;\n className?: string;\n}) {\n const chatContext = React.useContext(ChatContext);\n if (!chatContext) {\n return (\n <ChatContextProvider icons={icons} labels={labels} open={true} setOpen={() => {}}>\n <div className={`copilotKitChat ${className ?? \"\"}`}>{children}</div>\n </ChatContextProvider>\n );\n }\n return <>{children}</>;\n}\n\nexport const useCopilotChatLogic = (\n chatSuggestions: ChatSuggestions,\n makeSystemMessage?: SystemMessageFunction,\n onInProgress?: (isLoading: boolean) => void,\n onSubmitMessage?: (messageContent: string) => Promise<void> | void,\n onStopGeneration?: OnStopGeneration,\n onReloadMessages?: OnReloadMessages,\n) => {\n const {\n visibleMessages,\n appendMessage,\n setMessages,\n reloadMessages: defaultReloadMessages,\n stopGeneration: defaultStopGeneration,\n runChatCompletion,\n isLoading,\n suggestions,\n setSuggestions,\n generateSuggestions,\n resetSuggestions: resetSuggestionsFromHook,\n isLoadingSuggestions,\n } = useCopilotChat({\n makeSystemMessage,\n });\n\n const generalContext = useCopilotContext();\n const messagesContext = useCopilotMessagesContext();\n\n // Get actions from context for message conversion\n const { actions } = generalContext;\n\n // Suggestion state management\n const [suggestionsFailed, setSuggestionsFailed] = useState(false);\n const hasGeneratedInitialSuggestions = useRef<boolean>(false);\n\n // Handle static suggestions (when suggestions prop is an array)\n useEffect(() => {\n if (Array.isArray(chatSuggestions)) {\n setSuggestions(chatSuggestions);\n hasGeneratedInitialSuggestions.current = true;\n }\n }, [JSON.stringify(chatSuggestions), setSuggestions]);\n\n // Error handling wrapper\n const generateSuggestionsWithErrorHandling = useCallback(\n async (context: string) => {\n try {\n await generateSuggestions();\n } catch (error) {\n console.error(\"Failed to generate suggestions:\", error);\n setSuggestionsFailed(true);\n }\n },\n [generateSuggestions],\n );\n\n // Automatic suggestion generation logic\n useEffect(() => {\n // Only proceed if in auto mode, not currently loading, and not failed\n if (chatSuggestions !== \"auto\" || isLoadingSuggestions || suggestionsFailed) {\n return;\n }\n\n // Don't run during chat loading (when the assistant is responding)\n if (isLoading) {\n return;\n }\n\n // Check if we have any configurations\n if (Object.keys(generalContext.chatSuggestionConfiguration).length === 0) {\n return;\n }\n\n // Generate initial suggestions when chat is empty\n if (visibleMessages.length === 0 && !hasGeneratedInitialSuggestions.current) {\n hasGeneratedInitialSuggestions.current = true;\n generateSuggestionsWithErrorHandling(\"initial\");\n return;\n }\n\n // Generate post-message suggestions after assistant responds\n if (visibleMessages.length > 0 && suggestions.length === 0) {\n generateSuggestionsWithErrorHandling(\"post-message\");\n return;\n }\n }, [\n chatSuggestions,\n isLoadingSuggestions,\n suggestionsFailed,\n visibleMessages.length,\n isLoading,\n suggestions.length,\n Object.keys(generalContext.chatSuggestionConfiguration).join(\",\"), // Use stable string instead of object reference\n generateSuggestionsWithErrorHandling,\n ]);\n\n // Reset suggestion state when switching away from auto mode\n useEffect(() => {\n if (chatSuggestions !== \"auto\") {\n hasGeneratedInitialSuggestions.current = false;\n setSuggestionsFailed(false);\n }\n }, [chatSuggestions]);\n\n // Memoize context to prevent infinite re-renders\n const stableContext = useMemo(\n () => ({\n ...generalContext,\n ...messagesContext,\n }),\n [\n // Only include stable dependencies\n generalContext.actions,\n messagesContext.messages.length,\n generalContext.isLoading,\n ],\n );\n\n // Wrapper for resetSuggestions that also resets local state\n const resetSuggestions = useCallback(() => {\n resetSuggestionsFromHook();\n setSuggestionsFailed(false);\n hasGeneratedInitialSuggestions.current = false;\n }, [resetSuggestionsFromHook]);\n\n useEffect(() => {\n onInProgress?.(isLoading);\n }, [onInProgress, isLoading]);\n\n const sendMessage = async (\n messageContent: string,\n imagesToUse?: Array<{ contentType: string; bytes: string }>,\n ) => {\n const images = imagesToUse || [];\n\n // Clear existing suggestions when user sends a message\n // This prevents stale suggestions from remaining visible during new conversation flow\n if (chatSuggestions === \"auto\" || chatSuggestions === \"manual\") {\n setSuggestions([]);\n }\n\n let firstMessage: Message | null = null;\n\n // Send text message if content provided\n if (messageContent.trim().length > 0) {\n const textMessage: Message = {\n id: randomId(),\n role: \"user\",\n content: messageContent,\n };\n\n // Call user-provided submit handler if available\n if (onSubmitMessage) {\n try {\n await onSubmitMessage(messageContent);\n } catch (error) {\n console.error(\"Error in onSubmitMessage:\", error);\n }\n }\n\n // Send the message and clear suggestions for auto/manual modes\n await appendMessage(textMessage, {\n followUp: images.length === 0,\n clearSuggestions: chatSuggestions === \"auto\" || chatSuggestions === \"manual\",\n });\n\n if (!firstMessage) {\n firstMessage = textMessage;\n }\n }\n\n // Send image messages\n if (images.length > 0) {\n for (let i = 0; i < images.length; i++) {\n const imageMessage = {\n id: randomId(),\n role: \"user\" as const,\n image: {\n format: images[i].contentType.replace(\"image/\", \"\"),\n bytes: images[i].bytes,\n },\n } as unknown as Message;\n await appendMessage(imageMessage, { followUp: i === images.length - 1 });\n if (!firstMessage) {\n firstMessage = imageMessage;\n }\n }\n }\n\n if (!firstMessage) {\n // Should not happen if send button is properly disabled, but handle just in case\n return { role: \"user\", content: \"\", id: randomId() } as Message; // Return a dummy message\n }\n\n // The hook implicitly triggers API call on appendMessage.\n // We return the first message sent (either text or first image)\n return firstMessage;\n };\n\n const messages = visibleMessages;\n const currentAgentName = generalContext.agentSession?.agentName;\n const restartCurrentAgent = async (hint?: HintFunction) => {\n if (generalContext.agentSession) {\n generalContext.setAgentSession({\n ...generalContext.agentSession,\n nodeName: undefined,\n threadId: undefined,\n });\n generalContext.setCoagentStates((prevAgentStates) => {\n return {\n ...prevAgentStates,\n [generalContext.agentSession!.agentName]: {\n ...prevAgentStates[generalContext.agentSession!.agentName],\n threadId: undefined,\n nodeName: undefined,\n runId: undefined,\n },\n };\n });\n }\n };\n const runCurrentAgent = async (hint?: HintFunction) => {\n if (generalContext.agentSession) {\n await runAgent(\n generalContext.agentSession.agentName,\n stableContext,\n appendMessage,\n runChatCompletion,\n hint,\n );\n }\n };\n const stopCurrentAgent = () => {\n if (generalContext.agentSession) {\n stopAgent(generalContext.agentSession.agentName, stableContext);\n }\n };\n const setCurrentAgentState = (state: any) => {\n if (generalContext.agentSession) {\n generalContext.setCoagentStates((prevAgentStates) => {\n return {\n ...prevAgentStates,\n [generalContext.agentSession!.agentName]: {\n state,\n },\n } as any;\n });\n }\n };\n\n function stopGeneration() {\n // Clear suggestions when stopping generation\n setSuggestions([]);\n\n if (onStopGeneration) {\n onStopGeneration({\n messages: messages,\n setMessages,\n stopGeneration: defaultStopGeneration,\n currentAgentName,\n restartCurrentAgent,\n stopCurrentAgent,\n runCurrentAgent,\n setCurrentAgentState,\n });\n } else {\n defaultStopGeneration();\n }\n }\n function reloadMessages(messageId: string) {\n if (onReloadMessages) {\n onReloadMessages({\n messages: messages,\n setMessages,\n stopGeneration: defaultStopGeneration,\n currentAgentName,\n restartCurrentAgent,\n stopCurrentAgent,\n runCurrentAgent,\n setCurrentAgentState,\n messageId,\n });\n } else {\n defaultReloadMessages(messageId);\n }\n }\n\n return {\n messages,\n visibleMessages,\n isLoading,\n suggestions,\n sendMessage,\n stopGeneration,\n reloadMessages,\n resetSuggestions,\n context: stableContext,\n actions,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4EA,OAAO,SAAS,WAAW,QAAQ,UAAU,aAAa,eAAe;AACzE;AAAA,EAEE,0BAA0B;AAAA,EAC1B;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gBAAgB;AAazB,SAAuB,UAAU,iBAAiB;AAufxC,SAQF,UARE,KAQF,YARE;AAzQH,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA,cAAc;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAAA,YAAW;AAAA,EACX,eAAAC,iBAAgB;AAAA,EAChB,wBAAwB;AAAA,EACxB,OAAAC,SAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA,kBAAAC,oBAAmB;AAAA,EACnB,aAAAC,eAAc;AAAA,EACd,eAAAC,iBAAgB;AAAA,EAChB;AAAA,EACA,kBAAkB;AAAA,EAClB;AAAA,EACA;AACF,GAAqB;AACnB,QAAM,EAAE,wBAAwB,qBAAqB,kBAAkB,eAAe,IACpF,kBAAkB;AACpB,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAA6B,CAAC,CAAC;AAC3E,QAAM,eAAe,OAAyB,IAAI;AAGlD,QAAM,2BAA2B;AAAA,IAC/B,CAAC,aAA8C,SA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A,QACA;AAAA,QACA,gBAAgB;AAAA,QAChB;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH,OAAO;AACL,4BAAsB,SAAS;AAAA,IACjC;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,EACF;AACF;","names":["Messages","RenderMessage","Input","AssistantMessage","UserMessage","ImageRenderer","e","_a","_b"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/chat/Modal.tsx"],"sourcesContent":["import React, { useMemo, useCallback, useEffect, useRef } from \"react\";\nimport { ChatContextProvider, useChatContext } from \"./ChatContext\";\nimport { ButtonProps, HeaderProps, WindowProps, CopilotObservabilityHooks } from \"./props\";\nimport { Window as DefaultWindow } from \"./Window\";\nimport { Button as DefaultButton } from \"./Button\";\nimport { Header as DefaultHeader } from \"./Header\";\nimport { Messages as DefaultMessages } from \"./Messages\";\nimport { Input as DefaultInput } from \"./Input\";\nimport { CopilotChat, CopilotChatProps } from \"./Chat\";\nimport { AssistantMessage as DefaultAssistantMessage } from \"./messages/AssistantMessage\";\nimport { UserMessage as DefaultUserMessage } from \"./messages/UserMessage\";\nimport { useCopilotContext } from \"@copilotkit/react-core\";\n\nexport interface CopilotModalProps extends CopilotChatProps {\n /**\n * Whether the chat window should be open by default.\n * @default false\n */\n defaultOpen?: boolean;\n\n /**\n * If the chat window should close when the user clicks outside of it.\n * @default true\n */\n clickOutsideToClose?: boolean;\n\n /**\n * If the chat window should close when the user hits the Escape key.\n * @default true\n */\n hitEscapeToClose?: boolean;\n\n /**\n * The shortcut key to open the chat window.\n * Uses Command-[shortcut] on a Mac and Ctrl-[shortcut] on Windows.\n * @default '/'\n */\n shortcut?: string;\n\n /**\n * A callback that gets called when the chat window opens or closes.\n */\n onSetOpen?: (open: boolean) => void;\n\n /**\n * A custom Window component to use instead of the default.\n */\n Window?: React.ComponentType<WindowProps>;\n\n /**\n * A custom Button component to use instead of the default.\n */\n Button?: React.ComponentType<ButtonProps>;\n\n /**\n * A custom Header component to use instead of the default.\n */\n Header?: React.ComponentType<HeaderProps>;\n}\n\n// Inner component that has access to the Copilot context\nconst CopilotModalInner = ({\n observabilityHooks,\n onSetOpen,\n clickOutsideToClose,\n hitEscapeToClose,\n shortcut,\n className,\n children,\n Window,\n Button,\n Header,\n ...chatProps\n}: Omit<CopilotModalProps, \"icons\" | \"labels\" | \"defaultOpen\"> & {\n Window: React.ComponentType<WindowProps>;\n Button: React.ComponentType<ButtonProps>;\n Header: React.ComponentType<HeaderProps>;\n clickOutsideToClose: boolean;\n hitEscapeToClose: boolean;\n shortcut: string;\n}) => {\n const { copilotApiConfig } = useCopilotContext();\n\n // Helper function to trigger event hooks only if publicApiKey is provided\n const triggerObservabilityHook = useCallback(\n (hookName: keyof CopilotObservabilityHooks, ...args: any[]) => {\n if (copilotApiConfig.publicApiKey && observabilityHooks?.[hookName]) {\n (observabilityHooks[hookName] as any)(...args);\n }\n },\n [copilotApiConfig.publicApiKey, observabilityHooks],\n );\n\n const { open } = useChatContext();\n const prevOpen = useRef(open);\n\n // Monitor open state changes and trigger event hooks\n useEffect(() => {\n if (prevOpen.current !== open) {\n onSetOpen?.(open);\n\n // Trigger chat minimize/expand events\n if (open) {\n triggerObservabilityHook(\"onChatExpanded\");\n } else {\n triggerObservabilityHook(\"onChatMinimized\");\n }\n prevOpen.current = open;\n }\n }, [open, onSetOpen, triggerObservabilityHook]);\n\n const memoizedHeader = useMemo(() => <Header />, [Header]);\n const memoizedChildren = useMemo(() => children, [children]);\n\n return (\n <>\n {memoizedChildren}\n <div className={className}>\n <Button></Button>\n <Window\n clickOutsideToClose={clickOutsideToClose}\n shortcut={shortcut}\n hitEscapeToClose={hitEscapeToClose}\n >\n {memoizedHeader}\n <CopilotChat {...chatProps} observabilityHooks={observabilityHooks} />\n </Window>\n </div>\n </>\n );\n};\n\nexport const CopilotModal = ({\n instructions,\n defaultOpen = false,\n clickOutsideToClose = true,\n hitEscapeToClose = true,\n onSetOpen,\n onSubmitMessage,\n onStopGeneration,\n onReloadMessages,\n shortcut = \"/\",\n icons,\n labels,\n makeSystemMessage,\n onInProgress,\n Window = DefaultWindow,\n Button = DefaultButton,\n Header = DefaultHeader,\n Messages = DefaultMessages,\n Input = DefaultInput,\n AssistantMessage = DefaultAssistantMessage,\n UserMessage = DefaultUserMessage,\n onThumbsUp,\n onThumbsDown,\n onCopy,\n onRegenerate,\n markdownTagRenderers,\n className,\n children,\n observabilityHooks,\n ...props\n}: CopilotModalProps) => {\n const [openState, setOpenState] = React.useState(defaultOpen);\n\n return (\n <ChatContextProvider icons={icons} labels={labels} open={openState} setOpen={setOpenState}>\n <CopilotModalInner\n observabilityHooks={observabilityHooks}\n onSetOpen={onSetOpen}\n clickOutsideToClose={clickOutsideToClose ?? true}\n hitEscapeToClose={hitEscapeToClose ?? true}\n shortcut={shortcut ?? \"/\"}\n className={className}\n Window={Window}\n Button={Button}\n Header={Header}\n instructions={instructions}\n onSubmitMessage={onSubmitMessage}\n onStopGeneration={onStopGeneration}\n onReloadMessages={onReloadMessages}\n makeSystemMessage={makeSystemMessage}\n onInProgress={onInProgress}\n Messages={Messages}\n Input={Input}\n AssistantMessage={AssistantMessage}\n UserMessage={UserMessage}\n onThumbsUp={onThumbsUp}\n onThumbsDown={onThumbsDown}\n onCopy={onCopy}\n onRegenerate={onRegenerate}\n markdownTagRenderers={markdownTagRenderers}\n {...props}\n >\n {children}\n </CopilotModalInner>\n </ChatContextProvider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,SAAS,SAAS,aAAa,WAAW,cAAc;AAW/D,SAAS,yBAAyB;AAoGK,SAInC,UAJmC,KAQ/B,YAR+B;AAlDvC,IAAM,oBAAoB,CAAC,OAmBrB;AAnBqB,eACz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AAAA,MACA,UAAUC;AAAA,MACV,OAAOC;AAAA,MACP,kBAAkBC;AAAA,MAClB,aAAaC;AAAA,MACb;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,OACI,QAzBL;AAAA,MA2BE;AAAA;AAAA,EACH,GACF;AAEJ;","names":["Window","Button","Header","Messages","Input","AssistantMessage","UserMessage"]}