@copilotkit/react-ui 1.10.0-next.0 → 1.10.0-next.10

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 (117) hide show
  1. package/CHANGELOG.md +112 -0
  2. package/dist/{chunk-O7KTFUAN.mjs → chunk-226ZMOE3.mjs} +2 -2
  3. package/dist/{chunk-WHDNKXMP.mjs → chunk-BJHJBS5M.mjs} +46 -6
  4. package/dist/chunk-BJHJBS5M.mjs.map +1 -0
  5. package/dist/{chunk-Z4XPPVZT.mjs → chunk-EYRKZDP5.mjs} +1 -1
  6. package/dist/chunk-EYRKZDP5.mjs.map +1 -0
  7. package/dist/{chunk-SGFUVPDB.mjs → chunk-FFJHOZX6.mjs} +2 -2
  8. package/dist/{chunk-WPVTPQ7X.mjs → chunk-GBP47ONN.mjs} +2 -2
  9. package/dist/chunk-GBP47ONN.mjs.map +1 -0
  10. package/dist/{chunk-GVKA7RQQ.mjs → chunk-GDSZGYCE.mjs} +2 -2
  11. package/dist/{chunk-LXCD3K7B.mjs → chunk-GJ4SX4JE.mjs} +152 -36
  12. package/dist/chunk-GJ4SX4JE.mjs.map +1 -0
  13. package/dist/{chunk-VLNT34X3.mjs → chunk-J5ZZR6YB.mjs} +2 -2
  14. package/dist/chunk-J5ZZR6YB.mjs.map +1 -0
  15. package/dist/{chunk-QN7T3GWI.mjs → chunk-JY2CSDKN.mjs} +4 -6
  16. package/dist/chunk-JY2CSDKN.mjs.map +1 -0
  17. package/dist/chunk-MIVUCSGO.mjs +126 -0
  18. package/dist/chunk-MIVUCSGO.mjs.map +1 -0
  19. package/dist/{chunk-JHUTTP5C.mjs → chunk-T5QU6KSB.mjs} +5 -1
  20. package/dist/chunk-T5QU6KSB.mjs.map +1 -0
  21. package/dist/{chunk-Q2467VHZ.mjs → chunk-W26XFBEG.mjs} +2 -2
  22. package/dist/chunk-W26XFBEG.mjs.map +1 -0
  23. package/dist/chunk-Y44VLEUH.mjs +222 -0
  24. package/dist/chunk-Y44VLEUH.mjs.map +1 -0
  25. package/dist/components/chat/Chat.d.ts +52 -15
  26. package/dist/components/chat/Chat.js +1136 -869
  27. package/dist/components/chat/Chat.js.map +1 -1
  28. package/dist/components/chat/Chat.mjs +9 -8
  29. package/dist/components/chat/Header.js +6 -8
  30. package/dist/components/chat/Header.js.map +1 -1
  31. package/dist/components/chat/Header.mjs +3 -3
  32. package/dist/components/chat/Messages.d.ts +1 -1
  33. package/dist/components/chat/Messages.js +984 -23
  34. package/dist/components/chat/Messages.js.map +1 -1
  35. package/dist/components/chat/Messages.mjs +9 -1
  36. package/dist/components/chat/Modal.d.ts +2 -2
  37. package/dist/components/chat/Modal.js +1267 -931
  38. package/dist/components/chat/Modal.js.map +1 -1
  39. package/dist/components/chat/Modal.mjs +13 -12
  40. package/dist/components/chat/Popup.d.ts +1 -1
  41. package/dist/components/chat/Popup.js +1269 -933
  42. package/dist/components/chat/Popup.js.map +1 -1
  43. package/dist/components/chat/Popup.mjs +14 -13
  44. package/dist/components/chat/Sidebar.d.ts +1 -1
  45. package/dist/components/chat/Sidebar.js +1269 -933
  46. package/dist/components/chat/Sidebar.js.map +1 -1
  47. package/dist/components/chat/Sidebar.mjs +14 -13
  48. package/dist/components/chat/Suggestion.js +1 -1
  49. package/dist/components/chat/Suggestion.js.map +1 -1
  50. package/dist/components/chat/Suggestion.mjs +1 -1
  51. package/dist/components/chat/Suggestions.js +1 -1
  52. package/dist/components/chat/Suggestions.js.map +1 -1
  53. package/dist/components/chat/Suggestions.mjs +2 -2
  54. package/dist/components/chat/index.d.ts +2 -2
  55. package/dist/components/chat/index.js +1271 -935
  56. package/dist/components/chat/index.js.map +1 -1
  57. package/dist/components/chat/index.mjs +20 -19
  58. package/dist/components/chat/messages/LegacyRenderMessage.d.ts +28 -0
  59. package/dist/components/chat/messages/LegacyRenderMessage.js +980 -0
  60. package/dist/components/chat/messages/LegacyRenderMessage.js.map +1 -0
  61. package/dist/components/chat/messages/LegacyRenderMessage.mjs +17 -0
  62. package/dist/components/chat/messages/LegacyRenderMessage.mjs.map +1 -0
  63. package/dist/components/chat/messages/RenderMessage.js +4 -0
  64. package/dist/components/chat/messages/RenderMessage.js.map +1 -1
  65. package/dist/components/chat/messages/RenderMessage.mjs +1 -1
  66. package/dist/components/chat/props.d.ts +94 -2
  67. package/dist/components/chat/props.js.map +1 -1
  68. package/dist/components/dev-console/console.d.ts +1 -0
  69. package/dist/components/dev-console/console.js +6 -8
  70. package/dist/components/dev-console/console.js.map +1 -1
  71. package/dist/components/dev-console/console.mjs +2 -2
  72. package/dist/components/dev-console/index.d.ts +1 -3
  73. package/dist/components/dev-console/index.js +7 -9
  74. package/dist/components/dev-console/index.js.map +1 -1
  75. package/dist/components/dev-console/index.mjs +2 -2
  76. package/dist/components/dev-console/utils.d.ts +2 -2
  77. package/dist/components/dev-console/utils.js +2 -4
  78. package/dist/components/dev-console/utils.js.map +1 -1
  79. package/dist/components/dev-console/utils.mjs +1 -1
  80. package/dist/components/index.d.ts +3 -5
  81. package/dist/components/index.js +1272 -936
  82. package/dist/components/index.js.map +1 -1
  83. package/dist/components/index.mjs +20 -19
  84. package/dist/hooks/index.js.map +1 -1
  85. package/dist/hooks/index.mjs +1 -1
  86. package/dist/hooks/use-copilot-chat-suggestions.d.ts +1 -1
  87. package/dist/hooks/use-copilot-chat-suggestions.js.map +1 -1
  88. package/dist/hooks/use-copilot-chat-suggestions.mjs +1 -1
  89. package/dist/index.d.ts +3 -5
  90. package/dist/index.js +1303 -967
  91. package/dist/index.js.map +1 -1
  92. package/dist/index.mjs +21 -20
  93. package/package.json +6 -6
  94. package/src/components/chat/Chat.tsx +242 -24
  95. package/src/components/chat/Messages.tsx +58 -5
  96. package/src/components/chat/Modal.tsx +128 -41
  97. package/src/components/chat/Popup.tsx +21 -1
  98. package/src/components/chat/Sidebar.tsx +23 -1
  99. package/src/components/chat/Suggestion.tsx +1 -1
  100. package/src/components/chat/messages/LegacyRenderMessage.tsx +143 -0
  101. package/src/components/chat/messages/RenderMessage.tsx +3 -0
  102. package/src/components/chat/props.ts +110 -1
  103. package/src/components/dev-console/utils.ts +1 -6
  104. package/src/hooks/use-copilot-chat-suggestions.tsx +1 -1
  105. package/dist/chunk-GJ3MFNBX.mjs +0 -144
  106. package/dist/chunk-GJ3MFNBX.mjs.map +0 -1
  107. package/dist/chunk-JHUTTP5C.mjs.map +0 -1
  108. package/dist/chunk-LXCD3K7B.mjs.map +0 -1
  109. package/dist/chunk-Q2467VHZ.mjs.map +0 -1
  110. package/dist/chunk-QN7T3GWI.mjs.map +0 -1
  111. package/dist/chunk-VLNT34X3.mjs.map +0 -1
  112. package/dist/chunk-WHDNKXMP.mjs.map +0 -1
  113. package/dist/chunk-WPVTPQ7X.mjs.map +0 -1
  114. package/dist/chunk-Z4XPPVZT.mjs.map +0 -1
  115. /package/dist/{chunk-O7KTFUAN.mjs.map → chunk-226ZMOE3.mjs.map} +0 -0
  116. /package/dist/{chunk-SGFUVPDB.mjs.map → chunk-FFJHOZX6.mjs.map} +0 -0
  117. /package/dist/{chunk-GVKA7RQQ.mjs.map → chunk-GDSZGYCE.mjs.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,117 @@
1
1
  # ui
2
2
 
3
+ ## 1.10.0-next.10
4
+
5
+ ### Patch Changes
6
+
7
+ - 6d1de58: - fix: address issues that would cause headless UI breaking changes in the next release
8
+
9
+ Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
10
+
11
+ - fix: more fixes addressing breaking changes in new Headless UI
12
+
13
+ Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
14
+
15
+ - chore: address linting issues
16
+
17
+ Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
18
+
19
+ - chore: fixing branding and docs
20
+
21
+ Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
22
+
23
+ - chore: more docs fixing
24
+
25
+ Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
26
+
27
+ - Updated dependencies [6d1de58]
28
+ - @copilotkit/react-core@1.10.0-next.10
29
+ - @copilotkit/shared@1.10.0-next.10
30
+ - @copilotkit/runtime-client-gql@1.10.0-next.10
31
+
32
+ ## 1.10.0-next.9
33
+
34
+ ### Patch Changes
35
+
36
+ - 2354be4: - feat(chat): implement custom error handling in CopilotChat and Modal components
37
+
38
+ - Added `renderError` prop to `CopilotChat` for inline error rendering.
39
+ - Introduced `triggerChatError` function to manage chat-specific errors and observability hooks.
40
+ - Updated `Modal` to handle observability hooks with public API key checks.
41
+ - Enhanced `CopilotObservabilityHooks` interface to include `onError` for error event handling.
42
+ - @copilotkit/react-core@1.10.0-next.9
43
+ - @copilotkit/runtime-client-gql@1.10.0-next.9
44
+ - @copilotkit/shared@1.10.0-next.9
45
+
46
+ ## 1.10.0-next.8
47
+
48
+ ### Patch Changes
49
+
50
+ - Updated dependencies [6de24ce]
51
+ - @copilotkit/react-core@1.10.0-next.8
52
+ - @copilotkit/runtime-client-gql@1.10.0-next.8
53
+ - @copilotkit/shared@1.10.0-next.8
54
+
55
+ ## 1.10.0-next.7
56
+
57
+ ### Patch Changes
58
+
59
+ - @copilotkit/runtime-client-gql@1.10.0-next.7
60
+ - @copilotkit/react-core@1.10.0-next.7
61
+ - @copilotkit/shared@1.10.0-next.7
62
+
63
+ ## 1.10.0-next.6
64
+
65
+ ### Patch Changes
66
+
67
+ - @copilotkit/runtime-client-gql@1.10.0-next.6
68
+ - @copilotkit/react-core@1.10.0-next.6
69
+ - @copilotkit/shared@1.10.0-next.6
70
+
71
+ ## 1.10.0-next.5
72
+
73
+ ### Patch Changes
74
+
75
+ - a8c0263: - feat: add event hooks system for chat components
76
+ - Updated dependencies [a8c0263]
77
+ - @copilotkit/shared@1.10.0-next.5
78
+ - @copilotkit/react-core@1.10.0-next.5
79
+ - @copilotkit/runtime-client-gql@1.10.0-next.5
80
+
81
+ ## 1.10.0-next.4
82
+
83
+ ### Patch Changes
84
+
85
+ - 967d0ab: - refactor(chat): separate useCopilotChat into internal implementation and public API
86
+ - Updated dependencies [967d0ab]
87
+ - @copilotkit/react-core@1.10.0-next.4
88
+ - @copilotkit/runtime-client-gql@1.10.0-next.4
89
+ - @copilotkit/shared@1.10.0-next.4
90
+
91
+ ## 1.10.0-next.3
92
+
93
+ ### Patch Changes
94
+
95
+ - @copilotkit/runtime-client-gql@1.10.0-next.3
96
+ - @copilotkit/react-core@1.10.0-next.3
97
+ - @copilotkit/shared@1.10.0-next.3
98
+
99
+ ## 1.10.0-next.2
100
+
101
+ ### Patch Changes
102
+
103
+ - @copilotkit/runtime-client-gql@1.10.0-next.2
104
+ - @copilotkit/react-core@1.10.0-next.2
105
+ - @copilotkit/shared@1.10.0-next.2
106
+
107
+ ## 1.10.0-next.1
108
+
109
+ ### Patch Changes
110
+
111
+ - @copilotkit/runtime-client-gql@1.10.0-next.1
112
+ - @copilotkit/react-core@1.10.0-next.1
113
+ - @copilotkit/shared@1.10.0-next.1
114
+
3
115
  ## 1.10.0-next.0
4
116
 
5
117
  ### Minor Changes
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Suggestion
3
- } from "./chunk-Q2467VHZ.mjs";
3
+ } from "./chunk-W26XFBEG.mjs";
4
4
 
5
5
  // src/components/chat/Suggestions.tsx
6
6
  import { jsx } from "react/jsx-runtime";
@@ -21,4 +21,4 @@ function Suggestions({ suggestions, onSuggestionClick }) {
21
21
  export {
22
22
  Suggestions
23
23
  };
24
- //# sourceMappingURL=chunk-O7KTFUAN.mjs.map
24
+ //# sourceMappingURL=chunk-226ZMOE3.mjs.map
@@ -1,10 +1,17 @@
1
+ import {
2
+ LegacyRenderMessage
3
+ } from "./chunk-MIVUCSGO.mjs";
1
4
  import {
2
5
  useChatContext
3
6
  } from "./chunk-IEMQ2SQW.mjs";
7
+ import {
8
+ __spreadProps,
9
+ __spreadValues
10
+ } from "./chunk-MRXNTQOX.mjs";
4
11
 
5
12
  // src/components/chat/Messages.tsx
6
13
  import { useEffect, useMemo, useRef } from "react";
7
- import { useCopilotChat } from "@copilotkit/react-core";
14
+ import { useCopilotChatInternal as useCopilotChat } from "@copilotkit/react-core";
8
15
  import { jsx, jsxs } from "react/jsx-runtime";
9
16
  var Messages = ({
10
17
  inProgress,
@@ -12,23 +19,55 @@ var Messages = ({
12
19
  RenderMessage,
13
20
  AssistantMessage,
14
21
  UserMessage,
22
+ ImageRenderer,
15
23
  onRegenerate,
16
24
  onCopy,
17
25
  onThumbsUp,
18
26
  onThumbsDown,
19
- markdownTagRenderers
27
+ markdownTagRenderers,
28
+ // Legacy props
29
+ RenderTextMessage,
30
+ RenderActionExecutionMessage,
31
+ RenderAgentStateMessage,
32
+ RenderResultMessage,
33
+ RenderImageMessage
20
34
  }) => {
21
35
  const { labels } = useChatContext();
22
- const { visibleMessages, interrupt } = useCopilotChat();
36
+ const { messages: visibleMessages, interrupt } = useCopilotChat();
23
37
  const initialMessages = useMemo(() => makeInitialMessages(labels.initial), [labels.initial]);
24
38
  const messages = [...initialMessages, ...visibleMessages];
25
39
  const { messagesContainerRef, messagesEndRef } = useScrollToBottom(messages);
40
+ const hasLegacyProps = !!(RenderTextMessage || RenderActionExecutionMessage || RenderAgentStateMessage || RenderResultMessage || RenderImageMessage);
41
+ useEffect(() => {
42
+ if (hasLegacyProps) {
43
+ console.warn(
44
+ "[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"
45
+ );
46
+ }
47
+ }, [hasLegacyProps]);
48
+ const legacyProps = useMemo(
49
+ () => ({
50
+ RenderTextMessage,
51
+ RenderActionExecutionMessage,
52
+ RenderAgentStateMessage,
53
+ RenderResultMessage,
54
+ RenderImageMessage
55
+ }),
56
+ [
57
+ RenderTextMessage,
58
+ RenderActionExecutionMessage,
59
+ RenderAgentStateMessage,
60
+ RenderResultMessage,
61
+ RenderImageMessage
62
+ ]
63
+ );
64
+ const MessageRenderer = hasLegacyProps ? (props) => /* @__PURE__ */ jsx(LegacyRenderMessage, __spreadProps(__spreadValues({}, props), { legacyProps })) : RenderMessage;
26
65
  return /* @__PURE__ */ jsxs("div", { className: "copilotKitMessages", ref: messagesContainerRef, children: [
27
66
  /* @__PURE__ */ jsxs("div", { className: "copilotKitMessagesContainer", children: [
28
67
  messages.map((message, index) => {
29
68
  const isCurrentMessage = index === messages.length - 1;
30
69
  return /* @__PURE__ */ jsx(
31
- RenderMessage,
70
+ MessageRenderer,
32
71
  {
33
72
  message,
34
73
  inProgress,
@@ -36,6 +75,7 @@ var Messages = ({
36
75
  isCurrentMessage,
37
76
  AssistantMessage,
38
77
  UserMessage,
78
+ ImageRenderer,
39
79
  onRegenerate,
40
80
  onCopy,
41
81
  onThumbsUp,
@@ -65,7 +105,7 @@ function makeInitialMessages(initial) {
65
105
  return [
66
106
  {
67
107
  id: initial,
68
- role: "system",
108
+ role: "assistant",
69
109
  content: initial
70
110
  }
71
111
  ];
@@ -132,4 +172,4 @@ export {
132
172
  Messages,
133
173
  useScrollToBottom
134
174
  };
135
- //# sourceMappingURL=chunk-WHDNKXMP.mjs.map
175
+ //# sourceMappingURL=chunk-BJHJBS5M.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/chat/Messages.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef } from \"react\";\nimport { MessagesProps } from \"./props\";\nimport { useChatContext } from \"./ChatContext\";\nimport { Message } from \"@copilotkit/shared\";\nimport { useCopilotChatInternal as useCopilotChat } from \"@copilotkit/react-core\";\nimport { LegacyRenderMessage, LegacyRenderProps } from \"./messages/LegacyRenderMessage\";\n\nexport const Messages = ({\n inProgress,\n children,\n RenderMessage,\n AssistantMessage,\n UserMessage,\n ImageRenderer,\n onRegenerate,\n onCopy,\n onThumbsUp,\n onThumbsDown,\n markdownTagRenderers,\n\n // Legacy props\n RenderTextMessage,\n RenderActionExecutionMessage,\n RenderAgentStateMessage,\n RenderResultMessage,\n RenderImageMessage,\n}: MessagesProps) => {\n const { labels } = useChatContext();\n const { messages: visibleMessages, interrupt } = useCopilotChat();\n const initialMessages = useMemo(() => makeInitialMessages(labels.initial), [labels.initial]);\n const messages = [...initialMessages, ...visibleMessages];\n const { messagesContainerRef, messagesEndRef } = useScrollToBottom(messages);\n\n // Check if any legacy props are provided\n const hasLegacyProps = !!(\n RenderTextMessage ||\n RenderActionExecutionMessage ||\n RenderAgentStateMessage ||\n RenderResultMessage ||\n RenderImageMessage\n );\n\n // Show deprecation warning if legacy props are used\n useEffect(() => {\n if (hasLegacyProps) {\n console.warn(\n \"[CopilotKit] Legacy message render props (RenderTextMessage, RenderActionExecutionMessage, etc.) are deprecated. \" +\n \"Please use the unified 'RenderMessage' prop instead. \" +\n \"See migration guide: https://docs.copilotkit.ai/migration/render-message\",\n );\n }\n }, [hasLegacyProps]);\n\n // Create legacy props object for the adapter\n const legacyProps: LegacyRenderProps = useMemo(\n () => ({\n RenderTextMessage,\n RenderActionExecutionMessage,\n RenderAgentStateMessage,\n RenderResultMessage,\n RenderImageMessage,\n }),\n [\n RenderTextMessage,\n RenderActionExecutionMessage,\n RenderAgentStateMessage,\n RenderResultMessage,\n RenderImageMessage,\n ],\n );\n\n // Determine which render component to use\n const MessageRenderer = hasLegacyProps\n ? (props: any) => <LegacyRenderMessage {...props} legacyProps={legacyProps} />\n : RenderMessage;\n\n return (\n <div className=\"copilotKitMessages\" ref={messagesContainerRef}>\n <div className=\"copilotKitMessagesContainer\">\n {messages.map((message, index) => {\n const isCurrentMessage = index === messages.length - 1;\n return (\n <MessageRenderer\n key={index}\n message={message}\n inProgress={inProgress}\n index={index}\n isCurrentMessage={isCurrentMessage}\n AssistantMessage={AssistantMessage}\n UserMessage={UserMessage}\n ImageRenderer={ImageRenderer}\n onRegenerate={onRegenerate}\n onCopy={onCopy}\n onThumbsUp={onThumbsUp}\n onThumbsDown={onThumbsDown}\n markdownTagRenderers={markdownTagRenderers}\n />\n );\n })}\n {interrupt}\n </div>\n <footer className=\"copilotKitMessagesFooter\" ref={messagesEndRef}>\n {children}\n </footer>\n </div>\n );\n};\n\nfunction makeInitialMessages(initial: string | string[] | undefined): Message[] {\n if (!initial) return [];\n\n if (Array.isArray(initial)) {\n return initial.map((message) => {\n return {\n id: message,\n role: \"assistant\",\n content: message,\n };\n });\n }\n\n return [\n {\n id: initial,\n role: \"assistant\",\n content: initial,\n },\n ];\n}\n\nexport function useScrollToBottom(messages: Message[]) {\n const messagesEndRef = useRef<HTMLDivElement>(null);\n const messagesContainerRef = useRef<HTMLDivElement | null>(null);\n const isProgrammaticScrollRef = useRef(false);\n const isUserScrollUpRef = useRef(false);\n\n const scrollToBottom = () => {\n if (messagesContainerRef.current && messagesEndRef.current) {\n isProgrammaticScrollRef.current = true;\n messagesContainerRef.current.scrollTop = messagesContainerRef.current.scrollHeight;\n }\n };\n\n const handleScroll = () => {\n if (isProgrammaticScrollRef.current) {\n isProgrammaticScrollRef.current = false;\n return;\n }\n\n if (messagesContainerRef.current) {\n const { scrollTop, scrollHeight, clientHeight } = messagesContainerRef.current;\n isUserScrollUpRef.current = scrollTop + clientHeight < scrollHeight;\n }\n };\n\n useEffect(() => {\n const container = messagesContainerRef.current;\n if (container) {\n container.addEventListener(\"scroll\", handleScroll);\n }\n return () => {\n if (container) {\n container.removeEventListener(\"scroll\", handleScroll);\n }\n };\n }, []);\n\n useEffect(() => {\n const container = messagesContainerRef.current;\n if (!container) {\n return;\n }\n\n const mutationObserver = new MutationObserver(() => {\n if (!isUserScrollUpRef.current) {\n scrollToBottom();\n }\n });\n\n mutationObserver.observe(container, {\n childList: true,\n subtree: true,\n characterData: true,\n });\n\n return () => {\n mutationObserver.disconnect();\n };\n }, []);\n\n useEffect(() => {\n isUserScrollUpRef.current = false;\n scrollToBottom();\n }, [messages.filter((m) => m.role === \"user\").length]);\n\n return { messagesEndRef, messagesContainerRef };\n}\n"],"mappings":"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","names":[]}
@@ -29,4 +29,4 @@ function useCopilotChatSuggestions({
29
29
  export {
30
30
  useCopilotChatSuggestions
31
31
  };
32
- //# sourceMappingURL=chunk-Z4XPPVZT.mjs.map
32
+ //# sourceMappingURL=chunk-EYRKZDP5.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/use-copilot-chat-suggestions.tsx"],"sourcesContent":["/**\n * <Callout type=\"warning\">\n * useCopilotChatSuggestions is experimental. The interface is not final and\n * can change without notice.\n * </Callout>\n *\n * `useCopilotReadable` is a React hook that provides app-state and other information\n * to the Copilot. Optionally, the hook can also handle hierarchical state within your\n * application, passing these parent-child relationships to the Copilot.\n *\n * <br/>\n * <img src=\"https://cdn.copilotkit.ai/docs/copilotkit/images/use-copilot-chat-suggestions/use-copilot-chat-suggestions.gif\" width=\"500\" />\n *\n * ## Usage\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 * ### Simple Usage\n *\n * ```tsx\n * import { useCopilotChatSuggestions } from \"@copilotkit/react-ui\";\n *\n * export function MyComponent() {\n * const [employees, setEmployees] = useState([]);\n *\n * useCopilotChatSuggestions({\n * instructions: `The following employees are on duty: ${JSON.stringify(employees)}`,\n * });\n * }\n * ```\n *\n * ### Dependency Management\n *\n * ```tsx\n * import { useCopilotChatSuggestions } from \"@copilotkit/react-ui\";\n *\n * export function MyComponent() {\n * useCopilotChatSuggestions(\n * {\n * instructions: \"Suggest the most relevant next actions.\",\n * },\n * [appState],\n * );\n * }\n * ```\n *\n * In the example above, the suggestions are generated based on the given instructions.\n * The hook monitors `appState`, and updates suggestions accordingly whenever it changes.\n *\n * ### Behavior and Lifecycle\n *\n * The hook registers the configuration with the chat context upon component mount and\n * removes it on unmount, ensuring a clean and efficient lifecycle management.\n */\n\nimport { useEffect } from \"react\";\nimport { useCopilotContext } from \"@copilotkit/react-core\";\nimport { randomId } from \"@copilotkit/shared\";\n\ninterface UseCopilotChatSuggestionsConfiguration {\n /**\n * A prompt or instructions for the GPT to generate suggestions.\n */\n instructions: string;\n /**\n * The minimum number of suggestions to generate. Defaults to `1`.\n * @default 1\n */\n minSuggestions?: number;\n /**\n * The maximum number of suggestions to generate. Defaults to `3`.\n * @default 1\n */\n maxSuggestions?: number;\n\n /**\n * Whether the suggestions are available. Defaults to `enabled`.\n * @default enabled\n */\n available?: \"enabled\" | \"disabled\";\n\n /**\n * An optional class name to apply to the suggestions.\n */\n className?: string;\n}\n\nexport function useCopilotChatSuggestions(\n {\n available = \"enabled\",\n instructions,\n className,\n minSuggestions = 1,\n maxSuggestions = 3,\n }: UseCopilotChatSuggestionsConfiguration,\n dependencies: any[] = [],\n) {\n const context = useCopilotContext();\n\n useEffect(() => {\n if (available === \"disabled\") return;\n\n const id = randomId();\n\n context.addChatSuggestionConfiguration(id, {\n instructions,\n minSuggestions,\n maxSuggestions,\n className,\n });\n\n return () => {\n context.removeChatSuggestionConfiguration(id);\n };\n }, [...dependencies, instructions, minSuggestions, maxSuggestions, className, available]);\n}\n"],"mappings":";AA6DA,SAAS,iBAAiB;AAC1B,SAAS,yBAAyB;AAClC,SAAS,gBAAgB;AA8BlB,SAAS,0BACd;AAAA,EACE,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB,iBAAiB;AACnB,GACA,eAAsB,CAAC,GACvB;AACA,QAAM,UAAU,kBAAkB;AAElC,YAAU,MAAM;AACd,QAAI,cAAc;AAAY;AAE9B,UAAM,KAAK,SAAS;AAEpB,YAAQ,+BAA+B,IAAI;AAAA,MACzC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,WAAO,MAAM;AACX,cAAQ,kCAAkC,EAAE;AAAA,IAC9C;AAAA,EACF,GAAG,CAAC,GAAG,cAAc,cAAc,gBAAgB,gBAAgB,WAAW,SAAS,CAAC;AAC1F;","names":[]}
@@ -10,7 +10,7 @@ import {
10
10
  logMessages,
11
11
  logReadables,
12
12
  shouldShowDevConsole
13
- } from "./chunk-QN7T3GWI.mjs";
13
+ } from "./chunk-JY2CSDKN.mjs";
14
14
  import {
15
15
  CopilotKitHelpModal
16
16
  } from "./chunk-NRA3CFEE.mjs";
@@ -199,4 +199,4 @@ export {
199
199
  CopilotDevConsole,
200
200
  DebugMenuButton
201
201
  };
202
- //# sourceMappingURL=chunk-SGFUVPDB.mjs.map
202
+ //# sourceMappingURL=chunk-FFJHOZX6.mjs.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CopilotModal
3
- } from "./chunk-GJ3MFNBX.mjs";
3
+ } from "./chunk-Y44VLEUH.mjs";
4
4
  import {
5
5
  __spreadProps,
6
6
  __spreadValues
@@ -27,4 +27,4 @@ function CopilotSidebar(props) {
27
27
  export {
28
28
  CopilotSidebar
29
29
  };
30
- //# sourceMappingURL=chunk-WPVTPQ7X.mjs.map
30
+ //# sourceMappingURL=chunk-GBP47ONN.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/chat/Sidebar.tsx"],"sourcesContent":["/**\n * <br/>\n * <img src=\"https://cdn.copilotkit.ai/docs/copilotkit/images/CopilotSidebar.gif\" width=\"500\" />\n *\n * A chatbot sidebar component for the CopilotKit framework. Highly customizable through various props and custom CSS.\n *\n * See [CopilotPopup](/reference/components/chat/CopilotPopup) for a popup version of this component.\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 { CopilotSidebar } from \"@copilotkit/react-ui\";\n * import \"@copilotkit/react-ui/styles.css\";\n *\n * <CopilotSidebar\n * labels={{\n * title: \"Your Assistant\",\n * initial: \"Hi! 👋 How can I assist you today?\",\n * }}\n * >\n * <YourApp/>\n * </CopilotSidebar>\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 * <CopilotSidebar\n * observabilityHooks={{\n * onChatExpanded: () => {\n * console.log(\"Sidebar opened\");\n * },\n * onChatMinimized: () => {\n * console.log(\"Sidebar closed\");\n * },\n * }}\n * >\n * <YourApp/>\n * </CopilotSidebar>\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 */\nimport React, { useState } from \"react\";\nimport { CopilotModal, CopilotModalProps } from \"./Modal\";\n\nexport function CopilotSidebar(props: CopilotModalProps) {\n props = {\n ...props,\n className: props.className ? props.className + \" copilotKitSidebar\" : \"copilotKitSidebar\",\n };\n const [expandedClassName, setExpandedClassName] = useState(\n props.defaultOpen ? \"sidebarExpanded\" : \"\",\n );\n\n const onSetOpen = (open: boolean) => {\n props.onSetOpen?.(open);\n setExpandedClassName(open ? \"sidebarExpanded\" : \"\");\n };\n\n return (\n <div className={`copilotKitSidebarContentWrapper ${expandedClassName}`}>\n <CopilotModal {...props} {...{ onSetOpen }}>\n {props.children}\n </CopilotModal>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAuEA,SAAgB,gBAAgB;AAmB1B;AAhBC,SAAS,eAAe,OAA0B;AACvD,UAAQ,iCACH,QADG;AAAA,IAEN,WAAW,MAAM,YAAY,MAAM,YAAY,uBAAuB;AAAA,EACxE;AACA,QAAM,CAAC,mBAAmB,oBAAoB,IAAI;AAAA,IAChD,MAAM,cAAc,oBAAoB;AAAA,EAC1C;AAEA,QAAM,YAAY,CAAC,SAAkB;AAnFvC;AAoFI,gBAAM,cAAN,+BAAkB;AAClB,yBAAqB,OAAO,oBAAoB,EAAE;AAAA,EACpD;AAEA,SACE,oBAAC,SAAI,WAAW,mCAAmC,qBACjD,8BAAC,8DAAiB,QAAW,EAAE,UAAU,IAAxC,EACE,gBAAM,WACT,GACF;AAEJ;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CopilotDevConsole
3
- } from "./chunk-SGFUVPDB.mjs";
3
+ } from "./chunk-FFJHOZX6.mjs";
4
4
  import {
5
5
  useChatContext
6
6
  } from "./chunk-IEMQ2SQW.mjs";
@@ -29,4 +29,4 @@ var Header = ({}) => {
29
29
  export {
30
30
  Header
31
31
  };
32
- //# sourceMappingURL=chunk-GVKA7RQQ.mjs.map
32
+ //# sourceMappingURL=chunk-GDSZGYCE.mjs.map
@@ -1,6 +1,18 @@
1
+ import {
2
+ Suggestions
3
+ } from "./chunk-226ZMOE3.mjs";
4
+ import {
5
+ ImageUploadQueue
6
+ } from "./chunk-PLHTVHUW.mjs";
7
+ import {
8
+ Input
9
+ } from "./chunk-DTRPPNSA.mjs";
10
+ import {
11
+ Messages
12
+ } from "./chunk-BJHJBS5M.mjs";
1
13
  import {
2
14
  RenderMessage
3
- } from "./chunk-JHUTTP5C.mjs";
15
+ } from "./chunk-T5QU6KSB.mjs";
4
16
  import {
5
17
  AssistantMessage
6
18
  } from "./chunk-GCKKSSBU.mjs";
@@ -10,18 +22,6 @@ import {
10
22
  import {
11
23
  UserMessage
12
24
  } from "./chunk-VVL6JFCJ.mjs";
13
- import {
14
- Suggestions
15
- } from "./chunk-O7KTFUAN.mjs";
16
- import {
17
- ImageUploadQueue
18
- } from "./chunk-PLHTVHUW.mjs";
19
- import {
20
- Input
21
- } from "./chunk-DTRPPNSA.mjs";
22
- import {
23
- Messages
24
- } from "./chunk-WHDNKXMP.mjs";
25
25
  import {
26
26
  ChatContext,
27
27
  ChatContextProvider
@@ -35,10 +35,17 @@ import {
35
35
  // src/components/chat/Chat.tsx
36
36
  import React, { useEffect, useRef, useState, useCallback, useMemo } from "react";
37
37
  import {
38
- useCopilotChat,
38
+ useCopilotChatInternal as useCopilotChat,
39
39
  useCopilotContext,
40
40
  useCopilotMessagesContext
41
41
  } from "@copilotkit/react-core";
42
+ import {
43
+ CopilotKitError,
44
+ CopilotKitErrorCode,
45
+ Severity,
46
+ ErrorVisibility,
47
+ styledConsole
48
+ } from "@copilotkit/shared";
42
49
  import { randomId } from "@copilotkit/shared";
43
50
  import { runAgent, stopAgent } from "@copilotkit/react-core";
44
51
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -67,11 +74,83 @@ function CopilotChat({
67
74
  ImageRenderer: ImageRenderer2 = ImageRenderer,
68
75
  imageUploadsEnabled,
69
76
  inputFileAccept = "image/*",
70
- hideStopButton
77
+ hideStopButton,
78
+ observabilityHooks,
79
+ renderError,
80
+ // Legacy props - deprecated
81
+ RenderTextMessage,
82
+ RenderActionExecutionMessage,
83
+ RenderAgentStateMessage,
84
+ RenderResultMessage,
85
+ RenderImageMessage
71
86
  }) {
72
- const { additionalInstructions, setChatInstructions } = useCopilotContext();
87
+ const { additionalInstructions, setChatInstructions, copilotApiConfig, setBannerError } = useCopilotContext();
88
+ const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
73
89
  const [selectedImages, setSelectedImages] = useState([]);
90
+ const [chatError, setChatError] = useState(null);
74
91
  const fileInputRef = useRef(null);
92
+ const triggerObservabilityHook = useCallback(
93
+ (hookName, ...args) => {
94
+ if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
95
+ observabilityHooks[hookName](...args);
96
+ }
97
+ if ((observabilityHooks == null ? void 0 : observabilityHooks[hookName]) && !publicApiKey) {
98
+ setBannerError(
99
+ new CopilotKitError({
100
+ message: "observabilityHooks requires a publicApiKey to function.",
101
+ code: CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
102
+ severity: Severity.CRITICAL,
103
+ visibility: ErrorVisibility.BANNER
104
+ })
105
+ );
106
+ styledConsole.publicApiKeyRequired("observabilityHooks");
107
+ }
108
+ },
109
+ [publicApiKey, observabilityHooks, setBannerError]
110
+ );
111
+ const triggerChatError = useCallback(
112
+ (error, operation, originalError) => {
113
+ const errorMessage = (error == null ? void 0 : error.message) || (error == null ? void 0 : error.toString()) || "An error occurred";
114
+ setChatError({
115
+ message: errorMessage,
116
+ operation,
117
+ timestamp: Date.now()
118
+ });
119
+ if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks.onError)) {
120
+ const errorEvent = {
121
+ type: "error",
122
+ timestamp: Date.now(),
123
+ context: {
124
+ source: "ui",
125
+ request: {
126
+ operation,
127
+ url: chatApiEndpoint,
128
+ startTime: Date.now()
129
+ },
130
+ technical: {
131
+ environment: "browser",
132
+ userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
133
+ stackTrace: originalError instanceof Error ? originalError.stack : void 0
134
+ }
135
+ },
136
+ error
137
+ };
138
+ observabilityHooks.onError(errorEvent);
139
+ }
140
+ if ((observabilityHooks == null ? void 0 : observabilityHooks.onError) && !publicApiKey) {
141
+ setBannerError(
142
+ new CopilotKitError({
143
+ message: "observabilityHooks.onError requires a publicApiKey to function.",
144
+ code: CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
145
+ severity: Severity.CRITICAL,
146
+ visibility: ErrorVisibility.BANNER
147
+ })
148
+ );
149
+ styledConsole.publicApiKeyRequired("observabilityHooks.onError");
150
+ }
151
+ },
152
+ [publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError]
153
+ );
75
154
  useEffect(() => {
76
155
  if (!imageUploadsEnabled)
77
156
  return;
@@ -111,12 +190,13 @@ function CopilotChat({
111
190
  const loadedImages = (yield Promise.all(imagePromises)).filter((img) => img !== null);
112
191
  setSelectedImages((prev) => [...prev, ...loadedImages]);
113
192
  } catch (error) {
193
+ triggerChatError(error, "processClipboardImages", error);
114
194
  console.error("Error processing pasted images:", error);
115
195
  }
116
196
  });
117
197
  document.addEventListener("paste", handlePaste);
118
198
  return () => document.removeEventListener("paste", handlePaste);
119
- }, [imageUploadsEnabled]);
199
+ }, [imageUploadsEnabled, triggerChatError]);
120
200
  useEffect(() => {
121
201
  if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
122
202
  setChatInstructions(instructions || "");
@@ -130,7 +210,7 @@ function CopilotChat({
130
210
  setChatInstructions(combinedAdditionalInstructions.join("\n") || "");
131
211
  }, [instructions, additionalInstructions]);
132
212
  const {
133
- visibleMessages,
213
+ messages,
134
214
  isLoading,
135
215
  sendMessage,
136
216
  stopGeneration,
@@ -144,12 +224,24 @@ function CopilotChat({
144
224
  onStopGeneration,
145
225
  onReloadMessages
146
226
  );
227
+ const prevIsLoading = useRef(isLoading);
228
+ useEffect(() => {
229
+ if (prevIsLoading.current !== isLoading) {
230
+ if (isLoading) {
231
+ triggerObservabilityHook("onChatStarted");
232
+ } else {
233
+ triggerObservabilityHook("onChatStopped");
234
+ }
235
+ prevIsLoading.current = isLoading;
236
+ }
237
+ }, [isLoading, triggerObservabilityHook]);
147
238
  const handleSendMessage = (text) => {
148
239
  const images = selectedImages;
149
240
  setSelectedImages([]);
150
241
  if (fileInputRef.current) {
151
242
  fileInputRef.current.value = "";
152
243
  }
244
+ triggerObservabilityHook("onMessageSent", text);
153
245
  return sendMessage(text, images);
154
246
  };
155
247
  const chatContext = React.useContext(ChatContext);
@@ -158,12 +250,14 @@ function CopilotChat({
158
250
  if (onRegenerate) {
159
251
  onRegenerate(messageId);
160
252
  }
253
+ triggerObservabilityHook("onMessageRegenerated", messageId);
161
254
  reloadMessages(messageId);
162
255
  };
163
256
  const handleCopy = (message) => {
164
257
  if (onCopy) {
165
258
  onCopy(message);
166
259
  }
260
+ triggerObservabilityHook("onMessageCopied", message);
167
261
  };
168
262
  const handleImageUpload = (event) => __async(this, null, function* () {
169
263
  if (!event.target.files || event.target.files.length === 0) {
@@ -193,27 +287,51 @@ function CopilotChat({
193
287
  const loadedImages = yield Promise.all(fileReadPromises);
194
288
  setSelectedImages((prev) => [...prev, ...loadedImages]);
195
289
  } catch (error) {
290
+ triggerChatError(error, "processUploadedImages", error);
196
291
  console.error("Error reading files:", error);
197
292
  }
198
293
  });
199
294
  const removeSelectedImage = (index) => {
200
295
  setSelectedImages((prev) => prev.filter((_, i) => i !== index));
201
296
  };
297
+ const handleThumbsUp = (message) => {
298
+ if (onThumbsUp) {
299
+ onThumbsUp(message);
300
+ }
301
+ triggerObservabilityHook("onFeedbackGiven", message.id, "thumbsUp");
302
+ };
303
+ const handleThumbsDown = (message) => {
304
+ if (onThumbsDown) {
305
+ onThumbsDown(message);
306
+ }
307
+ triggerObservabilityHook("onFeedbackGiven", message.id, "thumbsDown");
308
+ };
202
309
  return /* @__PURE__ */ jsxs(WrappedCopilotChat, { icons, labels, className, children: [
310
+ chatError && renderError && renderError(__spreadProps(__spreadValues({}, chatError), {
311
+ onDismiss: () => setChatError(null),
312
+ onRetry: () => {
313
+ setChatError(null);
314
+ }
315
+ })),
203
316
  /* @__PURE__ */ jsx(
204
317
  Messages2,
205
318
  {
206
319
  AssistantMessage: AssistantMessage2,
207
320
  UserMessage: UserMessage2,
208
321
  RenderMessage: RenderMessage2,
209
- messages: visibleMessages,
322
+ messages,
210
323
  inProgress: isLoading,
211
324
  onRegenerate: handleRegenerate,
212
325
  onCopy: handleCopy,
213
- onThumbsUp,
214
- onThumbsDown,
326
+ onThumbsUp: handleThumbsUp,
327
+ onThumbsDown: handleThumbsDown,
215
328
  markdownTagRenderers,
216
329
  ImageRenderer: ImageRenderer2,
330
+ RenderTextMessage,
331
+ RenderActionExecutionMessage,
332
+ RenderAgentStateMessage,
333
+ RenderResultMessage,
334
+ RenderImageMessage,
217
335
  children: currentSuggestions.length > 0 && /* @__PURE__ */ jsx(
218
336
  RenderSuggestionsList,
219
337
  {
@@ -269,8 +387,8 @@ function WrappedCopilotChat({
269
387
  var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onSubmitMessage, onStopGeneration, onReloadMessages) => {
270
388
  var _a;
271
389
  const {
272
- visibleMessages,
273
- appendMessage,
390
+ messages,
391
+ sendMessage,
274
392
  setMessages,
275
393
  reloadMessages: defaultReloadMessages,
276
394
  stopGeneration: defaultStopGeneration,
@@ -316,12 +434,12 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
316
434
  if (Object.keys(generalContext.chatSuggestionConfiguration).length === 0) {
317
435
  return;
318
436
  }
319
- if (visibleMessages.length === 0 && !hasGeneratedInitialSuggestions.current) {
437
+ if (messages.length === 0 && !hasGeneratedInitialSuggestions.current) {
320
438
  hasGeneratedInitialSuggestions.current = true;
321
439
  generateSuggestionsWithErrorHandling("initial");
322
440
  return;
323
441
  }
324
- if (visibleMessages.length > 0 && suggestions.length === 0) {
442
+ if (messages.length > 0 && suggestions.length === 0) {
325
443
  generateSuggestionsWithErrorHandling("post-message");
326
444
  return;
327
445
  }
@@ -329,7 +447,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
329
447
  chatSuggestions,
330
448
  isLoadingSuggestions,
331
449
  suggestionsFailed,
332
- visibleMessages.length,
450
+ messages.length,
333
451
  isLoading,
334
452
  suggestions.length,
335
453
  Object.keys(generalContext.chatSuggestionConfiguration).join(","),
@@ -359,7 +477,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
359
477
  useEffect(() => {
360
478
  onInProgress == null ? void 0 : onInProgress(isLoading);
361
479
  }, [onInProgress, isLoading]);
362
- const sendMessage = (messageContent, imagesToUse) => __async(void 0, null, function* () {
480
+ const safelySendMessage = (messageContent, imagesToUse) => __async(void 0, null, function* () {
363
481
  const images = imagesToUse || [];
364
482
  if (chatSuggestions === "auto" || chatSuggestions === "manual") {
365
483
  setSuggestions([]);
@@ -378,7 +496,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
378
496
  console.error("Error in onSubmitMessage:", error);
379
497
  }
380
498
  }
381
- yield appendMessage(textMessage, {
499
+ yield sendMessage(textMessage, {
382
500
  followUp: images.length === 0,
383
501
  clearSuggestions: chatSuggestions === "auto" || chatSuggestions === "manual"
384
502
  });
@@ -396,7 +514,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
396
514
  bytes: images[i].bytes
397
515
  }
398
516
  };
399
- yield appendMessage(imageMessage, { followUp: i === images.length - 1 });
517
+ yield sendMessage(imageMessage, { followUp: i === images.length - 1 });
400
518
  if (!firstMessage) {
401
519
  firstMessage = imageMessage;
402
520
  }
@@ -407,7 +525,6 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
407
525
  }
408
526
  return firstMessage;
409
527
  });
410
- const messages = visibleMessages;
411
528
  const currentAgentName = (_a = generalContext.agentSession) == null ? void 0 : _a.agentName;
412
529
  const restartCurrentAgent = (hint) => __async(void 0, null, function* () {
413
530
  if (generalContext.agentSession) {
@@ -431,9 +548,9 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
431
548
  yield runAgent(
432
549
  generalContext.agentSession.agentName,
433
550
  stableContext,
434
- appendMessage,
435
- runChatCompletion,
436
- hint
551
+ messagesContext.messages,
552
+ sendMessage,
553
+ runChatCompletion
437
554
  );
438
555
  }
439
556
  });
@@ -489,10 +606,9 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
489
606
  }
490
607
  return {
491
608
  messages,
492
- visibleMessages,
493
609
  isLoading,
494
610
  suggestions,
495
- sendMessage,
611
+ sendMessage: safelySendMessage,
496
612
  stopGeneration,
497
613
  reloadMessages,
498
614
  resetSuggestions,
@@ -506,4 +622,4 @@ export {
506
622
  WrappedCopilotChat,
507
623
  useCopilotChatLogic
508
624
  };
509
- //# sourceMappingURL=chunk-LXCD3K7B.mjs.map
625
+ //# sourceMappingURL=chunk-GJ4SX4JE.mjs.map