@copilotkit/react-ui 0.37.0-mme-pre.0 → 0.37.0-mme-fix-textarea-css.1

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 (38) hide show
  1. package/.turbo/turbo-build.log +37 -37
  2. package/CHANGELOG.md +16 -4
  3. package/dist/{chunk-KQE7L7HP.mjs → chunk-7BARTDT5.mjs} +2 -2
  4. package/dist/{chunk-3DHJ2JME.mjs → chunk-MLU5AGTZ.mjs} +26 -12
  5. package/dist/chunk-MLU5AGTZ.mjs.map +1 -0
  6. package/dist/{chunk-SGWTTKGT.mjs → chunk-UN4W7WK4.mjs} +2 -2
  7. package/dist/{chunk-BVPRLTHR.mjs → chunk-Z6NNH6PN.mjs} +2 -2
  8. package/dist/components/chat/Chat.d.ts +3 -5
  9. package/dist/components/chat/Chat.js +25 -11
  10. package/dist/components/chat/Chat.js.map +1 -1
  11. package/dist/components/chat/Chat.mjs +1 -1
  12. package/dist/components/chat/Modal.js +25 -11
  13. package/dist/components/chat/Modal.js.map +1 -1
  14. package/dist/components/chat/Modal.mjs +2 -2
  15. package/dist/components/chat/Popup.js +25 -11
  16. package/dist/components/chat/Popup.js.map +1 -1
  17. package/dist/components/chat/Popup.mjs +3 -3
  18. package/dist/components/chat/Sidebar.js +25 -11
  19. package/dist/components/chat/Sidebar.js.map +1 -1
  20. package/dist/components/chat/Sidebar.mjs +3 -3
  21. package/dist/components/chat/index.js +25 -11
  22. package/dist/components/chat/index.js.map +1 -1
  23. package/dist/components/chat/index.mjs +4 -4
  24. package/dist/components/index.js +25 -11
  25. package/dist/components/index.js.map +1 -1
  26. package/dist/components/index.mjs +4 -4
  27. package/dist/index.css +0 -369
  28. package/dist/index.css.map +1 -1
  29. package/dist/index.js +25 -11
  30. package/dist/index.js.map +1 -1
  31. package/dist/index.mjs +4 -4
  32. package/package.json +6 -6
  33. package/src/components/chat/Chat.tsx +26 -14
  34. package/src/styles.css +0 -4
  35. package/dist/chunk-3DHJ2JME.mjs.map +0 -1
  36. /package/dist/{chunk-KQE7L7HP.mjs.map → chunk-7BARTDT5.mjs.map} +0 -0
  37. /package/dist/{chunk-SGWTTKGT.mjs.map → chunk-UN4W7WK4.mjs.map} +0 -0
  38. /package/dist/{chunk-BVPRLTHR.mjs.map → chunk-Z6NNH6PN.mjs.map} +0 -0
@@ -1,5 +1,5 @@
1
1
 
2
- > @copilotkit/react-ui@0.37.0-mme-pre.0 build /home/runner/work/CopilotKit/CopilotKit/CopilotKit/packages/react-ui
2
+ > @copilotkit/react-ui@0.37.0-mme-fix-textarea-css.1 build /home/runner/work/CopilotKit/CopilotKit/CopilotKit/packages/react-ui
3
3
  > tsup --clean
4
4
 
5
5
  CLI Building entry: src/index.tsx, src/components/index.ts, src/context/index.ts, src/hooks/index.ts, src/hooks/use-copilot-chat-suggestions.tsx, src/hooks/use-copy-to-clipboard.tsx, src/hooks/use-push-to-talk.tsx, src/lib/utils.test.ts, src/lib/utils.ts, src/types/index.ts, src/types/suggestions.ts, src/types/types.ts, src/components/chat/Button.tsx, src/components/chat/Chat.tsx, src/components/chat/ChatContext.tsx, src/components/chat/CodeBlock.tsx, src/components/chat/Header.tsx, src/components/chat/Icons.tsx, src/components/chat/Input.tsx, src/components/chat/Markdown.tsx, src/components/chat/Messages.tsx, src/components/chat/Modal.tsx, src/components/chat/Popup.tsx, src/components/chat/Response.tsx, src/components/chat/Sidebar.tsx, src/components/chat/Suggestion.tsx, src/components/chat/Textarea.tsx, src/components/chat/Window.tsx, src/components/chat/index.tsx, src/components/chat/props.ts
@@ -22,16 +22,16 @@ Browserslist: caniuse-lite is outdated. Please run:
22
22
  ESM dist/chunk-7NSRDJ5C.mjs 43.00 B
23
23
  ESM dist/chunk-JD7BAH7U.mjs 43.00 B
24
24
  ESM dist/chunk-MRFF7GSQ.mjs 43.00 B
25
- ESM dist/chunk-KQE7L7HP.mjs 1.02 KB
25
+ ESM dist/chunk-7BARTDT5.mjs 1.02 KB
26
26
  ESM dist/chunk-WB3YULQ4.mjs 43.00 B
27
- ESM dist/chunk-SGWTTKGT.mjs 573.00 B
27
+ ESM dist/chunk-UN4W7WK4.mjs 573.00 B
28
+ ESM dist/chunk-Z6NNH6PN.mjs 2.17 KB
28
29
  ESM dist/chunk-B7DNOYVQ.mjs 3.80 KB
29
- ESM dist/chunk-BVPRLTHR.mjs 2.17 KB
30
30
  ESM dist/chunk-PAQWLSA4.mjs 566.00 B
31
- ESM dist/chunk-3DHJ2JME.mjs 4.58 KB
32
31
  ESM dist/chunk-RT2XG2T7.mjs 825.00 B
33
- ESM dist/chunk-BL65ZC6L.mjs 2.77 KB
32
+ ESM dist/chunk-MLU5AGTZ.mjs 4.76 KB
34
33
  ESM dist/chunk-4MKP23AD.mjs 3.43 KB
34
+ ESM dist/chunk-BL65ZC6L.mjs 2.77 KB
35
35
  ESM dist/chunk-YQFVRDNC.mjs 1.53 KB
36
36
  ESM dist/chunk-7FES2IQA.mjs 4.96 KB
37
37
  ESM dist/chunk-YQ3D5IQV.mjs 2.17 KB
@@ -48,7 +48,7 @@ Browserslist: caniuse-lite is outdated. Please run:
48
48
  ESM dist/hooks/use-push-to-talk.mjs 290.00 B
49
49
  ESM dist/chunk-ANO23V2M.mjs 4.87 KB
50
50
  ESM dist/chunk-MRXNTQOX.mjs 1.89 KB
51
- ESM dist/index.css 22.07 KB
51
+ ESM dist/index.css 16.08 KB
52
52
  ESM dist/components/chat/Sidebar.mjs 721.00 B
53
53
  ESM dist/types/index.mjs 66.00 B
54
54
  ESM dist/components/chat/Suggestion.mjs 233.00 B
@@ -57,8 +57,8 @@ Browserslist: caniuse-lite is outdated. Please run:
57
57
  ESM dist/components/chat/index.mjs 946.00 B
58
58
  ESM dist/components/chat/props.mjs 69.00 B
59
59
  ESM dist/components/chat/Header.mjs 214.00 B
60
- ESM dist/components/chat/Input.mjs 281.00 B
61
60
  ESM dist/components/chat/Icons.mjs 515.00 B
61
+ ESM dist/components/chat/Input.mjs 281.00 B
62
62
  ESM dist/components/chat/Markdown.mjs 255.00 B
63
63
  ESM dist/components/chat/Messages.mjs 325.00 B
64
64
  ESM dist/components/chat/Modal.mjs 680.00 B
@@ -79,16 +79,16 @@ Browserslist: caniuse-lite is outdated. Please run:
79
79
  ESM dist/chunk-7NSRDJ5C.mjs.map 71.00 B
80
80
  ESM dist/chunk-JD7BAH7U.mjs.map 71.00 B
81
81
  ESM dist/chunk-MRFF7GSQ.mjs.map 71.00 B
82
- ESM dist/chunk-KQE7L7HP.mjs.map 3.03 KB
82
+ ESM dist/chunk-7BARTDT5.mjs.map 3.03 KB
83
83
  ESM dist/chunk-WB3YULQ4.mjs.map 71.00 B
84
- ESM dist/chunk-SGWTTKGT.mjs.map 2.10 KB
84
+ ESM dist/chunk-UN4W7WK4.mjs.map 2.10 KB
85
+ ESM dist/chunk-Z6NNH6PN.mjs.map 4.36 KB
85
86
  ESM dist/chunk-B7DNOYVQ.mjs.map 6.70 KB
86
- ESM dist/chunk-BVPRLTHR.mjs.map 4.36 KB
87
87
  ESM dist/chunk-PAQWLSA4.mjs.map 773.00 B
88
- ESM dist/chunk-3DHJ2JME.mjs.map 10.65 KB
89
88
  ESM dist/chunk-RT2XG2T7.mjs.map 1.12 KB
90
- ESM dist/chunk-BL65ZC6L.mjs.map 4.27 KB
89
+ ESM dist/chunk-MLU5AGTZ.mjs.map 10.93 KB
91
90
  ESM dist/chunk-4MKP23AD.mjs.map 5.64 KB
91
+ ESM dist/chunk-BL65ZC6L.mjs.map 4.27 KB
92
92
  ESM dist/chunk-YQFVRDNC.mjs.map 2.80 KB
93
93
  ESM dist/chunk-7FES2IQA.mjs.map 8.84 KB
94
94
  ESM dist/chunk-YQ3D5IQV.mjs.map 3.22 KB
@@ -105,7 +105,7 @@ Browserslist: caniuse-lite is outdated. Please run:
105
105
  ESM dist/hooks/use-push-to-talk.mjs.map 71.00 B
106
106
  ESM dist/chunk-ANO23V2M.mjs.map 8.44 KB
107
107
  ESM dist/chunk-MRXNTQOX.mjs.map 71.00 B
108
- ESM dist/index.css.map 33.94 KB
108
+ ESM dist/index.css.map 20.93 KB
109
109
  ESM dist/components/chat/Sidebar.mjs.map 71.00 B
110
110
  ESM dist/types/index.mjs.map 71.00 B
111
111
  ESM dist/components/chat/Suggestion.mjs.map 71.00 B
@@ -114,8 +114,8 @@ Browserslist: caniuse-lite is outdated. Please run:
114
114
  ESM dist/components/chat/index.mjs.map 71.00 B
115
115
  ESM dist/components/chat/props.mjs.map 71.00 B
116
116
  ESM dist/components/chat/Header.mjs.map 71.00 B
117
- ESM dist/components/chat/Input.mjs.map 71.00 B
118
117
  ESM dist/components/chat/Icons.mjs.map 71.00 B
118
+ ESM dist/components/chat/Input.mjs.map 71.00 B
119
119
  ESM dist/components/chat/Markdown.mjs.map 71.00 B
120
120
  ESM dist/components/chat/Messages.mjs.map 71.00 B
121
121
  ESM dist/components/chat/Modal.mjs.map 71.00 B
@@ -128,22 +128,21 @@ Browserslist: caniuse-lite is outdated. Please run:
128
128
  ESM dist/components/chat/Chat.mjs.map 71.00 B
129
129
  ESM dist/components/chat/ChatContext.mjs.map 71.00 B
130
130
  ESM dist/components/chat/CodeBlock.mjs.map 71.00 B
131
- ESM ⚡️ Build success in 1509ms
132
- CJS dist/index.js 56.14 KB
133
- CJS dist/index.css 22.07 KB
134
- CJS dist/components/index.js 55.38 KB
131
+ ESM ⚡️ Build success in 1272ms
132
+ CJS dist/index.js 56.37 KB
135
133
  CJS dist/context/index.js 803.00 B
136
134
  CJS dist/hooks/index.js 1.79 KB
135
+ CJS dist/components/index.js 55.61 KB
137
136
  CJS dist/hooks/use-copilot-chat-suggestions.js 1.86 KB
138
137
  CJS dist/hooks/use-copy-to-clipboard.js 2.30 KB
139
- CJS dist/hooks/use-push-to-talk.js 6.66 KB
140
138
  CJS dist/lib/utils.test.js 182.00 B
139
+ CJS dist/hooks/use-push-to-talk.js 6.66 KB
141
140
  CJS dist/lib/utils.js 2.40 KB
142
141
  CJS dist/types/index.js 797.00 B
143
142
  CJS dist/types/suggestions.js 821.00 B
144
143
  CJS dist/types/types.js 797.00 B
145
144
  CJS dist/components/chat/Button.js 2.91 KB
146
- CJS dist/components/chat/Chat.js 46.93 KB
145
+ CJS dist/components/chat/Chat.js 47.15 KB
147
146
  CJS dist/components/chat/ChatContext.js 9.47 KB
148
147
  CJS dist/components/chat/CodeBlock.js 14.30 KB
149
148
  CJS dist/components/chat/Header.js 2.63 KB
@@ -151,30 +150,30 @@ Browserslist: caniuse-lite is outdated. Please run:
151
150
  CJS dist/components/chat/Input.js 11.01 KB
152
151
  CJS dist/components/chat/Markdown.js 16.47 KB
153
152
  CJS dist/components/chat/Messages.js 22.23 KB
154
- CJS dist/components/chat/Modal.js 53.86 KB
155
- CJS dist/components/chat/Popup.js 54.30 KB
153
+ CJS dist/components/chat/Modal.js 54.08 KB
154
+ CJS dist/components/chat/Popup.js 54.52 KB
156
155
  CJS dist/components/chat/Response.js 2.67 KB
157
- CJS dist/components/chat/Sidebar.js 54.82 KB
156
+ CJS dist/components/chat/Sidebar.js 55.05 KB
158
157
  CJS dist/components/chat/Suggestion.js 5.95 KB
159
158
  CJS dist/components/chat/Textarea.js 2.51 KB
160
159
  CJS dist/components/chat/Window.js 5.46 KB
161
- CJS dist/components/chat/index.js 55.37 KB
160
+ CJS dist/index.css 16.08 KB
162
161
  CJS dist/components/chat/props.js 807.00 B
163
- CJS dist/index.js.map 97.60 KB
164
- CJS dist/index.css.map 33.94 KB
165
- CJS dist/components/index.js.map 93.76 KB
162
+ CJS dist/components/chat/index.js 55.60 KB
163
+ CJS dist/index.js.map 97.88 KB
166
164
  CJS dist/context/index.js.map 139.00 B
167
165
  CJS dist/hooks/index.js.map 3.89 KB
166
+ CJS dist/components/index.js.map 94.04 KB
168
167
  CJS dist/hooks/use-copilot-chat-suggestions.js.map 3.80 KB
169
168
  CJS dist/hooks/use-copy-to-clipboard.js.map 1.21 KB
170
- CJS dist/hooks/use-push-to-talk.js.map 8.50 KB
171
169
  CJS dist/lib/utils.test.js.map 352.00 B
170
+ CJS dist/hooks/use-push-to-talk.js.map 8.50 KB
172
171
  CJS dist/lib/utils.js.map 1.55 KB
173
172
  CJS dist/types/index.js.map 137.00 B
174
173
  CJS dist/types/suggestions.js.map 259.00 B
175
174
  CJS dist/types/types.js.map 478.00 B
176
175
  CJS dist/components/chat/Button.js.map 5.47 KB
177
- CJS dist/components/chat/Chat.js.map 75.87 KB
176
+ CJS dist/components/chat/Chat.js.map 76.15 KB
178
177
  CJS dist/components/chat/ChatContext.js.map 13.89 KB
179
178
  CJS dist/components/chat/CodeBlock.js.map 24.33 KB
180
179
  CJS dist/components/chat/Header.js.map 5.11 KB
@@ -182,22 +181,23 @@ Browserslist: caniuse-lite is outdated. Please run:
182
181
  CJS dist/components/chat/Input.js.map 19.36 KB
183
182
  CJS dist/components/chat/Markdown.js.map 27.58 KB
184
183
  CJS dist/components/chat/Messages.js.map 40.73 KB
185
- CJS dist/components/chat/Modal.js.map 88.67 KB
186
- CJS dist/components/chat/Popup.js.map 90.73 KB
184
+ CJS dist/components/chat/Modal.js.map 88.95 KB
185
+ CJS dist/components/chat/Popup.js.map 91.01 KB
187
186
  CJS dist/components/chat/Response.js.map 5.19 KB
188
- CJS dist/components/chat/Sidebar.js.map 91.68 KB
187
+ CJS dist/components/chat/Sidebar.js.map 91.96 KB
189
188
  CJS dist/components/chat/Suggestion.js.map 12.87 KB
190
189
  CJS dist/components/chat/Textarea.js.map 2.83 KB
191
190
  CJS dist/components/chat/Window.js.map 6.76 KB
192
- CJS dist/components/chat/index.js.map 94.00 KB
191
+ CJS dist/index.css.map 20.93 KB
193
192
  CJS dist/components/chat/props.js.map 1.06 KB
194
- CJS ⚡️ Build success in 1601ms
195
- DTS ⚡️ Build success in 7878ms
193
+ CJS dist/components/chat/index.js.map 94.28 KB
194
+ CJS ⚡️ Build success in 1340ms
195
+ DTS ⚡️ Build success in 8307ms
196
196
  DTS dist/index.d.ts 629.00 B
197
197
  DTS dist/components/chat/props.d.ts 1007.00 B
198
198
  DTS dist/components/chat/Popup.d.ts 1.77 KB
199
199
  DTS dist/components/chat/Sidebar.d.ts 332.00 B
200
- DTS dist/components/chat/Chat.d.ts 4.66 KB
200
+ DTS dist/components/chat/Chat.d.ts 4.56 KB
201
201
  DTS dist/components/chat/ChatContext.d.ts 2.83 KB
202
202
  DTS dist/hooks/use-copilot-chat-suggestions.d.ts 2.67 KB
203
203
  DTS dist/components/chat/Modal.d.ts 1.79 KB
package/CHANGELOG.md CHANGED
@@ -1,16 +1,28 @@
1
1
  # ui
2
2
 
3
- ## 0.37.0-mme-pre.0
3
+ ## 0.37.0-mme-fix-textarea-css.1
4
4
 
5
5
  ### Minor Changes
6
6
 
7
- - Azure support
7
+ - Remove unneeded tailwind components
8
8
 
9
9
  ### Patch Changes
10
10
 
11
11
  - Updated dependencies
12
- - @copilotkit/react-core@0.37.0-mme-pre.0
13
- - @copilotkit/shared@0.37.0-mme-pre.0
12
+ - @copilotkit/react-core@0.37.0-mme-fix-textarea-css.1
13
+ - @copilotkit/shared@0.37.0-mme-fix-textarea-css.1
14
+
15
+ ## 0.37.0-mme-fix-feedback-readable.0
16
+
17
+ ### Minor Changes
18
+
19
+ - Fix: Stale CopilotReadable
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies
24
+ - @copilotkit/react-core@0.37.0-mme-fix-feedback-readable.0
25
+ - @copilotkit/shared@0.37.0-mme-fix-feedback-readable.0
14
26
 
15
27
  ## 0.36.0
16
28
 
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CopilotModal
3
- } from "./chunk-BVPRLTHR.mjs";
3
+ } from "./chunk-Z6NNH6PN.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-KQE7L7HP.mjs.map
30
+ //# sourceMappingURL=chunk-7BARTDT5.mjs.map
@@ -37,7 +37,18 @@ function CopilotChat({
37
37
  icons,
38
38
  labels
39
39
  }) {
40
- const { visibleMessages, isLoading, currentSuggestions, sendMessage, stop, reload } = useCopilotChatLogic(instructions, makeSystemMessage, onInProgress, onSubmitMessage);
40
+ const context = useCopilotContext();
41
+ useEffect(() => {
42
+ context.setChatInstructions(instructions || "");
43
+ }, [instructions]);
44
+ const {
45
+ visibleMessages,
46
+ isLoading,
47
+ currentSuggestions,
48
+ sendMessage,
49
+ stopGeneration,
50
+ reloadMessages
51
+ } = useCopilotChatLogic(makeSystemMessage, onInProgress, onSubmitMessage);
41
52
  const chatContext = React.useContext(ChatContext);
42
53
  const isVisible = chatContext ? chatContext.open : true;
43
54
  return /* @__PURE__ */ jsxs(WrappedCopilotChat, { icons, labels, className, children: [
@@ -56,7 +67,13 @@ function CopilotChat({
56
67
  index
57
68
  )) })
58
69
  ] }),
59
- showResponseButton && visibleMessages.length > 0 && /* @__PURE__ */ jsx(ResponseButton2, { onClick: isLoading ? stop : reload, inProgress: isLoading })
70
+ showResponseButton && visibleMessages.length > 0 && /* @__PURE__ */ jsx(
71
+ ResponseButton2,
72
+ {
73
+ onClick: isLoading ? stopGeneration : reloadMessages,
74
+ inProgress: isLoading
75
+ }
76
+ )
60
77
  ] }),
61
78
  /* @__PURE__ */ jsx(Input2, { inProgress: isLoading, onSend: sendMessage, isVisible })
62
79
  ] });
@@ -75,11 +92,10 @@ function WrappedCopilotChat({
75
92
  return /* @__PURE__ */ jsx(Fragment, { children });
76
93
  }
77
94
  var SUGGESTIONS_DEBOUNCE_TIMEOUT = 1e3;
78
- var useCopilotChatLogic = (instructions, makeSystemMessage, onInProgress, onSubmitMessage) => {
79
- const { visibleMessages, append, reload, stop, isLoading, input, setInput } = useCopilotChat({
95
+ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) => {
96
+ const { visibleMessages, appendMessage, reloadMessages, stopGeneration, isLoading } = useCopilotChat({
80
97
  id: nanoid(),
81
- makeSystemMessage,
82
- additionalInstructions: instructions
98
+ makeSystemMessage
83
99
  });
84
100
  const [currentSuggestions, setCurrentSuggestions] = useState([]);
85
101
  const suggestionsAbortControllerRef = useRef(null);
@@ -120,7 +136,7 @@ var useCopilotChatLogic = (instructions, makeSystemMessage, onInProgress, onSubm
120
136
  content: messageContent,
121
137
  role: "user"
122
138
  };
123
- append(message);
139
+ appendMessage(message);
124
140
  return message;
125
141
  });
126
142
  return {
@@ -128,10 +144,8 @@ var useCopilotChatLogic = (instructions, makeSystemMessage, onInProgress, onSubm
128
144
  isLoading,
129
145
  currentSuggestions,
130
146
  sendMessage,
131
- stop,
132
- reload,
133
- input,
134
- setInput
147
+ stopGeneration,
148
+ reloadMessages
135
149
  };
136
150
  };
137
151
 
@@ -140,4 +154,4 @@ export {
140
154
  WrappedCopilotChat,
141
155
  useCopilotChatLogic
142
156
  };
143
- //# sourceMappingURL=chunk-3DHJ2JME.mjs.map
157
+ //# sourceMappingURL=chunk-MLU5AGTZ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/chat/Chat.tsx"],"sourcesContent":["/**\n * An embeddable chat panel for CopilotKit.\n *\n * <img src=\"/images/CopilotChat/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 * <RequestExample>\n * ```jsx CopilotChat Example\n * import { CopilotChat } from \"@copilotkit/react-ui\";\n *\n * <CopilotChat\n * labels={{\n * title: \"Your Assistant\",\n * initial: \"Hi! 👋 How can I assist you today?\",\n * }}\n * />\n * ```\n * </RequestExample>\n *\n * ## Custom CSS\n *\n * You can customize the colors of the panel by overriding the CSS variables\n * defined in the [default styles](https://github.com/CopilotKit/CopilotKit/blob/main/CopilotKit/packages/react-ui/src/css/colors.css).\n *\n * For example, to set the primary color to purple:\n *\n * ```jsx\n * <div style={{ \"--copilot-kit-primary-color\": \"#7D5BA6\" }}>\n * <CopilotPopup />\n * </div>\n * ```\n *\n * To further customize the panel, you can override the CSS classes defined\n * [here](https://github.com/CopilotKit/CopilotKit/blob/main/CopilotKit/packages/react-ui/src/css/).\n *\n * For example:\n *\n * ```css\n * .copilotKitButton {\n * border-radius: 0;\n * }\n * ```\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 { ResponseButton as DefaultResponseButton } from \"./Response\";\nimport { Suggestion } from \"./Suggestion\";\nimport React, { useEffect, useRef, useState } from \"react\";\nimport { SystemMessageFunction, useCopilotChat, useCopilotContext } from \"@copilotkit/react-core\";\nimport { nanoid } from \"nanoid\";\nimport { reloadSuggestions } from \"./Suggestion\";\nimport { CopilotChatSuggestion } from \"../../types/suggestions\";\nimport { Message } from \"@copilotkit/shared\";\nimport { InputProps, MessagesProps, ResponseButtonProps } from \"./props\";\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 * 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;\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 * 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 * Whether to show the response button.\n * @default true\n */\n showResponseButton?: boolean;\n\n /**\n * A custom Messages component to use instead of the default.\n */\n Messages?: React.ComponentType<MessagesProps>;\n\n /**\n * A custom Input component to use instead of the default.\n */\n Input?: React.ComponentType<InputProps>;\n\n /**\n * A custom ResponseButton component to use instead of the default.\n */\n ResponseButton?: React.ComponentType<ResponseButtonProps>;\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\nexport function CopilotChat({\n instructions,\n onSubmitMessage,\n makeSystemMessage,\n showResponseButton = true,\n onInProgress,\n Messages = DefaultMessages,\n Input = DefaultInput,\n ResponseButton = DefaultResponseButton,\n className,\n icons,\n labels,\n}: CopilotChatProps) {\n const context = useCopilotContext();\n\n useEffect(() => {\n context.setChatInstructions(instructions || \"\");\n }, [instructions]);\n\n const {\n visibleMessages,\n isLoading,\n currentSuggestions,\n sendMessage,\n stopGeneration,\n reloadMessages,\n } = useCopilotChatLogic(makeSystemMessage, onInProgress, onSubmitMessage);\n\n const chatContext = React.useContext(ChatContext);\n const isVisible = chatContext ? chatContext.open : true;\n\n return (\n <WrappedCopilotChat icons={icons} labels={labels} className={className}>\n <Messages messages={visibleMessages} inProgress={isLoading}>\n {currentSuggestions.length > 0 && (\n <div>\n <h6>Suggested:</h6>\n <div className=\"suggestions\">\n {currentSuggestions.map((suggestion, index) => (\n <Suggestion\n key={index}\n title={suggestion.title}\n message={suggestion.message}\n partial={suggestion.partial}\n className={suggestion.className}\n onClick={(message) => sendMessage(message)}\n />\n ))}\n </div>\n </div>\n )}\n {showResponseButton && visibleMessages.length > 0 && (\n <ResponseButton\n onClick={isLoading ? stopGeneration : reloadMessages}\n inProgress={isLoading}\n />\n )}\n </Messages>\n <Input inProgress={isLoading} onSend={sendMessage} isVisible={isVisible} />\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\nconst SUGGESTIONS_DEBOUNCE_TIMEOUT = 1000;\n\nexport const useCopilotChatLogic = (\n makeSystemMessage?: SystemMessageFunction,\n onInProgress?: (isLoading: boolean) => void,\n onSubmitMessage?: (messageContent: string) => void,\n) => {\n const { visibleMessages, appendMessage, reloadMessages, stopGeneration, isLoading } =\n useCopilotChat({\n id: nanoid(),\n makeSystemMessage,\n });\n\n const [currentSuggestions, setCurrentSuggestions] = useState<CopilotChatSuggestion[]>([]);\n const suggestionsAbortControllerRef = useRef<AbortController | null>(null);\n const debounceTimerRef = useRef<any>();\n\n const abortSuggestions = () => {\n suggestionsAbortControllerRef.current?.abort();\n suggestionsAbortControllerRef.current = null;\n };\n\n const context = useCopilotContext();\n\n useEffect(() => {\n onInProgress?.(isLoading);\n\n abortSuggestions();\n\n debounceTimerRef.current = setTimeout(\n () => {\n if (!isLoading && Object.keys(context.chatSuggestionConfiguration).length !== 0) {\n suggestionsAbortControllerRef.current = new AbortController();\n reloadSuggestions(\n context,\n context.chatSuggestionConfiguration,\n setCurrentSuggestions,\n suggestionsAbortControllerRef,\n );\n }\n },\n currentSuggestions.length == 0 ? 0 : SUGGESTIONS_DEBOUNCE_TIMEOUT,\n );\n\n return () => {\n clearTimeout(debounceTimerRef.current);\n };\n }, [isLoading, context.chatSuggestionConfiguration]);\n\n const sendMessage = async (messageContent: string) => {\n abortSuggestions();\n setCurrentSuggestions([]);\n onSubmitMessage?.(messageContent);\n const message: Message = {\n id: nanoid(),\n content: messageContent,\n role: \"user\",\n };\n appendMessage(message);\n return message;\n };\n\n return {\n visibleMessages,\n isLoading,\n currentSuggestions,\n sendMessage,\n stopGeneration,\n reloadMessages,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwDA,OAAO,SAAS,WAAW,QAAQ,gBAAgB;AACnD,SAAgC,gBAAgB,yB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jB,0BAAsB,CAAC,CAAC;AACxB,uDAAkB;AAClB,UAAM,UAAmB;AAAA,MACvB,IAAI,OAAO;AAAA,MACX,SAAS;AAAA,MACT,MAAM;AAAA,IACR;AACA,kBAAc,OAAO;AACrB,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["Messages","Input","ResponseButton"]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CopilotModal
3
- } from "./chunk-BVPRLTHR.mjs";
3
+ } from "./chunk-Z6NNH6PN.mjs";
4
4
  import {
5
5
  __spreadProps,
6
6
  __spreadValues
@@ -18,4 +18,4 @@ function CopilotPopup(props) {
18
18
  export {
19
19
  CopilotPopup
20
20
  };
21
- //# sourceMappingURL=chunk-SGWTTKGT.mjs.map
21
+ //# sourceMappingURL=chunk-UN4W7WK4.mjs.map
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-RT2XG2T7.mjs";
10
10
  import {
11
11
  CopilotChat
12
- } from "./chunk-3DHJ2JME.mjs";
12
+ } from "./chunk-MLU5AGTZ.mjs";
13
13
  import {
14
14
  Input
15
15
  } from "./chunk-BL65ZC6L.mjs";
@@ -90,4 +90,4 @@ var CopilotModal = ({
90
90
  export {
91
91
  CopilotModal
92
92
  };
93
- //# sourceMappingURL=chunk-BVPRLTHR.mjs.map
93
+ //# sourceMappingURL=chunk-Z6NNH6PN.mjs.map
@@ -120,15 +120,13 @@ declare function WrappedCopilotChat({ children, icons, labels, className, }: {
120
120
  labels?: CopilotChatLabels;
121
121
  className?: string;
122
122
  }): JSX.Element;
123
- declare const useCopilotChatLogic: (instructions?: string, makeSystemMessage?: SystemMessageFunction, onInProgress?: ((isLoading: boolean) => void) | undefined, onSubmitMessage?: ((messageContent: string) => void) | undefined) => {
123
+ declare const useCopilotChatLogic: (makeSystemMessage?: SystemMessageFunction, onInProgress?: ((isLoading: boolean) => void) | undefined, onSubmitMessage?: ((messageContent: string) => void) | undefined) => {
124
124
  visibleMessages: Message[];
125
125
  isLoading: boolean;
126
126
  currentSuggestions: CopilotChatSuggestion[];
127
127
  sendMessage: (messageContent: string) => Promise<Message>;
128
- stop: () => void;
129
- reload: () => Promise<void>;
130
- input: string;
131
- setInput: React__default.Dispatch<React__default.SetStateAction<string>>;
128
+ stopGeneration: () => void;
129
+ reloadMessages: () => Promise<void>;
132
130
  };
133
131
 
134
132
  export { CopilotChat, CopilotChatProps, WrappedCopilotChat, useCopilotChatLogic };
@@ -1290,7 +1290,18 @@ function CopilotChat({
1290
1290
  icons,
1291
1291
  labels
1292
1292
  }) {
1293
- const { visibleMessages, isLoading, currentSuggestions, sendMessage, stop, reload } = useCopilotChatLogic(instructions, makeSystemMessage, onInProgress, onSubmitMessage);
1293
+ const context = (0, import_react_core5.useCopilotContext)();
1294
+ (0, import_react8.useEffect)(() => {
1295
+ context.setChatInstructions(instructions || "");
1296
+ }, [instructions]);
1297
+ const {
1298
+ visibleMessages,
1299
+ isLoading,
1300
+ currentSuggestions,
1301
+ sendMessage,
1302
+ stopGeneration,
1303
+ reloadMessages
1304
+ } = useCopilotChatLogic(makeSystemMessage, onInProgress, onSubmitMessage);
1294
1305
  const chatContext = import_react8.default.useContext(ChatContext);
1295
1306
  const isVisible = chatContext ? chatContext.open : true;
1296
1307
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
@@ -1309,7 +1320,13 @@ function CopilotChat({
1309
1320
  index
1310
1321
  )) })
1311
1322
  ] }),
1312
- showResponseButton && visibleMessages.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ResponseButton2, { onClick: isLoading ? stop : reload, inProgress: isLoading })
1323
+ showResponseButton && visibleMessages.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1324
+ ResponseButton2,
1325
+ {
1326
+ onClick: isLoading ? stopGeneration : reloadMessages,
1327
+ inProgress: isLoading
1328
+ }
1329
+ )
1313
1330
  ] }),
1314
1331
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Input2, { inProgress: isLoading, onSend: sendMessage, isVisible })
1315
1332
  ] });
@@ -1328,11 +1345,10 @@ function WrappedCopilotChat({
1328
1345
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children });
1329
1346
  }
1330
1347
  var SUGGESTIONS_DEBOUNCE_TIMEOUT = 1e3;
1331
- var useCopilotChatLogic = (instructions, makeSystemMessage, onInProgress, onSubmitMessage) => {
1332
- const { visibleMessages, append, reload, stop, isLoading, input, setInput } = (0, import_react_core5.useCopilotChat)({
1348
+ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) => {
1349
+ const { visibleMessages, appendMessage, reloadMessages, stopGeneration, isLoading } = (0, import_react_core5.useCopilotChat)({
1333
1350
  id: (0, import_nanoid2.nanoid)(),
1334
- makeSystemMessage,
1335
- additionalInstructions: instructions
1351
+ makeSystemMessage
1336
1352
  });
1337
1353
  const [currentSuggestions, setCurrentSuggestions] = (0, import_react8.useState)([]);
1338
1354
  const suggestionsAbortControllerRef = (0, import_react8.useRef)(null);
@@ -1373,7 +1389,7 @@ var useCopilotChatLogic = (instructions, makeSystemMessage, onInProgress, onSubm
1373
1389
  content: messageContent,
1374
1390
  role: "user"
1375
1391
  };
1376
- append(message);
1392
+ appendMessage(message);
1377
1393
  return message;
1378
1394
  });
1379
1395
  return {
@@ -1381,10 +1397,8 @@ var useCopilotChatLogic = (instructions, makeSystemMessage, onInProgress, onSubm
1381
1397
  isLoading,
1382
1398
  currentSuggestions,
1383
1399
  sendMessage,
1384
- stop,
1385
- reload,
1386
- input,
1387
- setInput
1400
+ stopGeneration,
1401
+ reloadMessages
1388
1402
  };
1389
1403
  };
1390
1404
  // Annotate the CommonJS export names for ESM import in node: