@copilotkit/react-ui 0.3.0 → 0.4.0

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 (228) hide show
  1. package/.turbo/turbo-build.log +192 -13
  2. package/CHANGELOG.md +11 -0
  3. package/LICENSE +21 -0
  4. package/dist/chunk-46XC7ODX.mjs +72 -0
  5. package/dist/chunk-46XC7ODX.mjs.map +1 -0
  6. package/dist/chunk-4HK6C362.mjs +106 -0
  7. package/dist/chunk-4HK6C362.mjs.map +1 -0
  8. package/dist/chunk-6LAC5RA2.mjs +28 -0
  9. package/dist/chunk-6LAC5RA2.mjs.map +1 -0
  10. package/dist/chunk-6LRNF2VU.mjs +12 -0
  11. package/dist/chunk-6LRNF2VU.mjs.map +1 -0
  12. package/dist/chunk-7NSRDJ5C.mjs +3 -0
  13. package/dist/chunk-7NSRDJ5C.mjs.map +1 -0
  14. package/dist/chunk-BB6IP63P.mjs +29 -0
  15. package/dist/chunk-BB6IP63P.mjs.map +1 -0
  16. package/dist/chunk-BIPCPNHG.mjs +18 -0
  17. package/dist/chunk-BIPCPNHG.mjs.map +1 -0
  18. package/dist/chunk-BS6RR2DJ.mjs +25 -0
  19. package/dist/chunk-BS6RR2DJ.mjs.map +1 -0
  20. package/dist/chunk-DOMJCSI6.mjs +26 -0
  21. package/dist/chunk-DOMJCSI6.mjs.map +1 -0
  22. package/dist/chunk-E2YBQYWM.mjs +69 -0
  23. package/dist/chunk-E2YBQYWM.mjs.map +1 -0
  24. package/dist/chunk-E5BOIXYO.mjs +45 -0
  25. package/dist/chunk-E5BOIXYO.mjs.map +1 -0
  26. package/dist/chunk-H4VKQGVU.mjs +3 -0
  27. package/dist/chunk-H4VKQGVU.mjs.map +1 -0
  28. package/dist/chunk-I2AB5FK4.mjs +123 -0
  29. package/dist/chunk-I2AB5FK4.mjs.map +1 -0
  30. package/dist/chunk-IU3WTXLQ.mjs +3 -0
  31. package/dist/chunk-IU3WTXLQ.mjs.map +1 -0
  32. package/dist/chunk-KR7MH7XO.mjs +481 -0
  33. package/dist/chunk-KR7MH7XO.mjs.map +1 -0
  34. package/dist/chunk-KXJV37FS.mjs +33 -0
  35. package/dist/chunk-KXJV37FS.mjs.map +1 -0
  36. package/dist/chunk-MC6KTH4X.mjs +12 -0
  37. package/dist/chunk-MC6KTH4X.mjs.map +1 -0
  38. package/dist/chunk-MRXNTQOX.mjs +55 -0
  39. package/dist/chunk-MRXNTQOX.mjs.map +1 -0
  40. package/dist/chunk-N7KB3Z57.mjs +23 -0
  41. package/dist/chunk-N7KB3Z57.mjs.map +1 -0
  42. package/dist/chunk-QEXWZWJL.mjs +75 -0
  43. package/dist/chunk-QEXWZWJL.mjs.map +1 -0
  44. package/dist/chunk-RSONJDLO.mjs +28 -0
  45. package/dist/chunk-RSONJDLO.mjs.map +1 -0
  46. package/dist/chunk-SF56HSZW.mjs +48 -0
  47. package/dist/chunk-SF56HSZW.mjs.map +1 -0
  48. package/dist/chunk-TVTG3V4F.mjs +40 -0
  49. package/dist/chunk-TVTG3V4F.mjs.map +1 -0
  50. package/dist/chunk-U6NJWGTV.mjs +3 -0
  51. package/dist/chunk-U6NJWGTV.mjs.map +1 -0
  52. package/dist/chunk-V6QYUEJR.mjs +47 -0
  53. package/dist/chunk-V6QYUEJR.mjs.map +1 -0
  54. package/dist/chunk-VQNV2DHJ.mjs +142 -0
  55. package/dist/chunk-VQNV2DHJ.mjs.map +1 -0
  56. package/dist/chunk-VSNDSL6W.mjs +74 -0
  57. package/dist/chunk-VSNDSL6W.mjs.map +1 -0
  58. package/dist/chunk-XZFO2YEG.mjs +53 -0
  59. package/dist/chunk-XZFO2YEG.mjs.map +1 -0
  60. package/dist/components/chat-components/chat-list.d.ts +8 -0
  61. package/dist/components/chat-components/chat-list.mjs +13 -0
  62. package/dist/components/chat-components/chat-list.mjs.map +1 -0
  63. package/dist/components/chat-components/chat-message-actions.d.ts +8 -0
  64. package/dist/components/chat-components/chat-message-actions.mjs +8 -0
  65. package/dist/components/chat-components/chat-message-actions.mjs.map +1 -0
  66. package/dist/components/chat-components/chat-message.d.ts +8 -0
  67. package/dist/components/chat-components/chat-message.mjs +11 -0
  68. package/dist/components/chat-components/chat-message.mjs.map +1 -0
  69. package/dist/components/chat-components/chat-panel.d.ts +8 -0
  70. package/dist/components/chat-components/chat-panel.mjs +10 -0
  71. package/dist/components/chat-components/chat-panel.mjs.map +1 -0
  72. package/dist/components/chat-components/chat-scroll-anchor.d.ts +6 -0
  73. package/dist/components/chat-components/chat-scroll-anchor.mjs +5 -0
  74. package/dist/components/chat-components/chat-scroll-anchor.mjs.map +1 -0
  75. package/dist/components/chat-components/clear-history.d.ts +9 -0
  76. package/dist/components/chat-components/clear-history.mjs +81 -0
  77. package/dist/components/chat-components/clear-history.mjs.map +1 -0
  78. package/dist/components/chat-components/copilot-chat.d.ts +12 -0
  79. package/dist/components/chat-components/copilot-chat.mjs +22 -0
  80. package/dist/components/chat-components/copilot-chat.mjs.map +1 -0
  81. package/dist/components/chat-components/default-empty-screen.d.ts +8 -0
  82. package/dist/components/chat-components/default-empty-screen.mjs +8 -0
  83. package/dist/components/chat-components/default-empty-screen.mjs.map +1 -0
  84. package/dist/components/chat-components/external-link.d.ts +6 -0
  85. package/dist/components/chat-components/external-link.mjs +4 -0
  86. package/dist/components/chat-components/external-link.mjs.map +1 -0
  87. package/dist/components/chat-components/markdown.d.ts +6 -0
  88. package/dist/components/chat-components/markdown.mjs +4 -0
  89. package/dist/components/chat-components/markdown.mjs.map +1 -0
  90. package/dist/components/chat-components/prompt-form.d.ts +9 -0
  91. package/dist/components/chat-components/prompt-form.mjs +9 -0
  92. package/dist/components/chat-components/prompt-form.mjs.map +1 -0
  93. package/dist/components/chat-components/theme-toggle.d.ts +3 -0
  94. package/dist/components/chat-components/theme-toggle.mjs +36 -0
  95. package/dist/components/chat-components/theme-toggle.mjs.map +1 -0
  96. package/dist/components/chat-components/toaster.d.ts +1 -0
  97. package/dist/components/chat-components/toaster.mjs +4 -0
  98. package/dist/components/chat-components/toaster.mjs.map +1 -0
  99. package/dist/components/chat-components/ui/alert-dialog.d.ts +20 -0
  100. package/dist/components/chat-components/ui/alert-dialog.mjs +6 -0
  101. package/dist/components/chat-components/ui/alert-dialog.mjs.map +1 -0
  102. package/dist/components/chat-components/ui/badge.d.ts +12 -0
  103. package/dist/components/chat-components/ui/badge.mjs +31 -0
  104. package/dist/components/chat-components/ui/badge.mjs.map +1 -0
  105. package/dist/components/chat-components/ui/button.d.ts +14 -0
  106. package/dist/components/chat-components/ui/button.mjs +5 -0
  107. package/dist/components/chat-components/ui/button.mjs.map +1 -0
  108. package/dist/components/chat-components/ui/codeblock.d.ts +14 -0
  109. package/dist/components/chat-components/ui/codeblock.mjs +8 -0
  110. package/dist/components/chat-components/ui/codeblock.mjs.map +1 -0
  111. package/dist/components/chat-components/ui/dialog.d.ts +18 -0
  112. package/dist/components/chat-components/ui/dialog.mjs +119 -0
  113. package/dist/components/chat-components/ui/dialog.mjs.map +1 -0
  114. package/dist/components/chat-components/ui/dropdown-menu.d.ts +24 -0
  115. package/dist/components/chat-components/ui/dropdown-menu.mjs +84 -0
  116. package/dist/components/chat-components/ui/dropdown-menu.mjs.map +1 -0
  117. package/dist/components/chat-components/ui/icons.d.ts +33 -0
  118. package/dist/components/chat-components/ui/icons.mjs +5 -0
  119. package/dist/components/chat-components/ui/icons.mjs.map +1 -0
  120. package/dist/components/chat-components/ui/input.d.ts +7 -0
  121. package/dist/components/chat-components/ui/input.mjs +23 -0
  122. package/dist/components/chat-components/ui/input.mjs.map +1 -0
  123. package/dist/components/chat-components/ui/label.d.ts +8 -0
  124. package/dist/components/chat-components/ui/label.mjs +22 -0
  125. package/dist/components/chat-components/ui/label.mjs.map +1 -0
  126. package/dist/components/chat-components/ui/select.d.ts +13 -0
  127. package/dist/components/chat-components/ui/select.mjs +99 -0
  128. package/dist/components/chat-components/ui/select.mjs.map +1 -0
  129. package/dist/components/chat-components/ui/separator.d.ts +6 -0
  130. package/dist/components/chat-components/ui/separator.mjs +5 -0
  131. package/dist/components/chat-components/ui/separator.mjs.map +1 -0
  132. package/dist/components/chat-components/ui/sheet.d.ts +19 -0
  133. package/dist/components/chat-components/ui/sheet.mjs +109 -0
  134. package/dist/components/chat-components/ui/sheet.mjs.map +1 -0
  135. package/dist/components/chat-components/ui/switch.d.ts +6 -0
  136. package/dist/components/chat-components/ui/switch.mjs +27 -0
  137. package/dist/components/chat-components/ui/switch.mjs.map +1 -0
  138. package/dist/components/chat-components/ui/textarea.d.ts +7 -0
  139. package/dist/components/chat-components/ui/textarea.mjs +22 -0
  140. package/dist/components/chat-components/ui/textarea.mjs.map +1 -0
  141. package/dist/components/chat-components/ui/tooltip.d.ts +9 -0
  142. package/dist/components/chat-components/ui/tooltip.mjs +5 -0
  143. package/dist/components/chat-components/ui/tooltip.mjs.map +1 -0
  144. package/dist/components/index.d.ts +9 -0
  145. package/dist/components/index.mjs +26 -0
  146. package/dist/components/index.mjs.map +1 -0
  147. package/dist/components/sidebar/copilot-sidebar-ui-provider.d.ts +8 -0
  148. package/dist/components/sidebar/copilot-sidebar-ui-provider.mjs +25 -0
  149. package/dist/components/sidebar/copilot-sidebar-ui-provider.mjs.map +1 -0
  150. package/dist/components/sidebar/copilot-sidebar.d.ts +6 -0
  151. package/dist/components/sidebar/copilot-sidebar.mjs +23 -0
  152. package/dist/components/sidebar/copilot-sidebar.mjs.map +1 -0
  153. package/dist/components/sidebar/sidebar-context.d.ts +9 -0
  154. package/dist/components/sidebar/sidebar-context.mjs +4 -0
  155. package/dist/components/sidebar/sidebar-context.mjs.map +1 -0
  156. package/dist/context/index.d.ts +1 -0
  157. package/dist/context/index.mjs +3 -0
  158. package/dist/context/index.mjs.map +1 -0
  159. package/dist/hooks/index.d.ts +1 -0
  160. package/dist/hooks/index.mjs +3 -0
  161. package/dist/hooks/index.mjs.map +1 -0
  162. package/dist/hooks/use-at-bottom.d.ts +3 -0
  163. package/dist/hooks/use-at-bottom.mjs +4 -0
  164. package/dist/hooks/use-at-bottom.mjs.map +1 -0
  165. package/dist/hooks/use-copy-to-clipboard.d.ts +9 -0
  166. package/dist/hooks/use-copy-to-clipboard.mjs +4 -0
  167. package/dist/hooks/use-copy-to-clipboard.mjs.map +1 -0
  168. package/dist/hooks/use-enter-submit.d.ts +8 -0
  169. package/dist/hooks/use-enter-submit.mjs +4 -0
  170. package/dist/hooks/use-enter-submit.mjs.map +1 -0
  171. package/dist/index.css +1249 -1
  172. package/dist/index.css.map +1 -0
  173. package/dist/index.d.ts +9 -36
  174. package/dist/index.mjs +29 -26
  175. package/dist/index.mjs.map +1 -0
  176. package/dist/lib/utils.d.ts +8 -0
  177. package/dist/lib/utils.mjs +4 -0
  178. package/dist/lib/utils.mjs.map +1 -0
  179. package/dist/types/index.d.ts +1 -0
  180. package/dist/types/index.mjs +3 -0
  181. package/dist/types/index.mjs.map +1 -0
  182. package/dist/types/types.d.ts +16 -0
  183. package/dist/types/types.mjs +3 -0
  184. package/dist/types/types.mjs.map +1 -0
  185. package/package.json +8 -8
  186. package/src/components/chat-components/chat-list.tsx +8 -8
  187. package/src/components/chat-components/chat-message-actions.tsx +14 -14
  188. package/src/components/chat-components/chat-message.tsx +26 -26
  189. package/src/components/chat-components/chat-panel.tsx +18 -18
  190. package/src/components/chat-components/chat-scroll-anchor.tsx +12 -12
  191. package/src/components/chat-components/clear-history.tsx +22 -22
  192. package/src/components/chat-components/copilot-chat.tsx +45 -50
  193. package/src/components/chat-components/default-empty-screen.tsx +24 -22
  194. package/src/components/chat-components/external-link.tsx +4 -4
  195. package/src/components/chat-components/markdown.tsx +3 -3
  196. package/src/components/chat-components/prompt-form.tsx +27 -27
  197. package/src/components/chat-components/theme-toggle.tsx +11 -11
  198. package/src/components/chat-components/toaster.tsx +2 -2
  199. package/src/components/chat-components/ui/alert-dialog.tsx +35 -35
  200. package/src/components/chat-components/ui/badge.tsx +14 -14
  201. package/src/components/chat-components/ui/button.tsx +26 -26
  202. package/src/components/chat-components/ui/codeblock.tsx +70 -70
  203. package/src/components/chat-components/ui/dialog.tsx +29 -29
  204. package/src/components/chat-components/ui/dropdown-menu.tsx +35 -35
  205. package/src/components/chat-components/ui/icons.tsx +96 -96
  206. package/src/components/chat-components/ui/input.tsx +7 -7
  207. package/src/components/chat-components/ui/label.tsx +10 -10
  208. package/src/components/chat-components/ui/select.tsx +30 -30
  209. package/src/components/chat-components/ui/separator.tsx +10 -10
  210. package/src/components/chat-components/ui/sheet.tsx +31 -31
  211. package/src/components/chat-components/ui/switch.tsx +9 -9
  212. package/src/components/chat-components/ui/textarea.tsx +7 -7
  213. package/src/components/chat-components/ui/tooltip.tsx +11 -11
  214. package/src/components/index.ts +6 -6
  215. package/src/components/sidebar/copilot-sidebar-ui-provider.tsx +34 -31
  216. package/src/components/sidebar/copilot-sidebar.tsx +9 -9
  217. package/src/components/sidebar/sidebar-context.tsx +5 -5
  218. package/src/context/index.ts +1 -1
  219. package/src/hooks/index.ts +1 -1
  220. package/src/hooks/use-at-bottom.tsx +10 -10
  221. package/src/hooks/use-copy-to-clipboard.tsx +14 -14
  222. package/src/hooks/use-enter-submit.tsx +9 -9
  223. package/src/index.tsx +4 -4
  224. package/src/lib/utils.ts +20 -20
  225. package/src/types/index.ts +1 -1
  226. package/src/types/types.ts +10 -10
  227. package/tsup.config.ts +3 -4
  228. package/dist/index.js +0 -53
@@ -1,29 +1,29 @@
1
- 'use client'
1
+ "use client";
2
2
 
3
- import * as React from 'react'
4
- import { useInView } from 'react-intersection-observer'
3
+ import * as React from "react";
4
+ import { useInView } from "react-intersection-observer";
5
5
 
6
- import { useAtBottom } from '../../hooks/use-at-bottom'
6
+ import { useAtBottom } from "../../hooks/use-at-bottom";
7
7
 
8
8
  interface ChatScrollAnchorProps {
9
- trackVisibility?: boolean
9
+ trackVisibility?: boolean;
10
10
  }
11
11
 
12
12
  export function ChatScrollAnchor({ trackVisibility }: ChatScrollAnchorProps) {
13
- const isAtBottom = useAtBottom()
13
+ const isAtBottom = useAtBottom();
14
14
  const { ref, entry, inView } = useInView({
15
15
  trackVisibility,
16
16
  delay: 100,
17
- rootMargin: '0px 0px -150px 0px'
18
- })
17
+ rootMargin: "0px 0px -150px 0px",
18
+ });
19
19
 
20
20
  React.useEffect(() => {
21
21
  if (isAtBottom && trackVisibility && !inView) {
22
22
  entry?.target.scrollIntoView({
23
- block: 'start'
24
- })
23
+ block: "start",
24
+ });
25
25
  }
26
- }, [inView, entry, isAtBottom, trackVisibility])
26
+ }, [inView, entry, isAtBottom, trackVisibility]);
27
27
 
28
- return <div ref={ref} className="h-px w-full" />
28
+ return <div ref={ref} className="h-px w-full" />;
29
29
  }
@@ -1,11 +1,11 @@
1
- 'use client'
1
+ "use client";
2
2
 
3
- import * as React from 'react'
4
- import { useRouter } from 'next/navigation'
5
- import { toast } from 'react-hot-toast'
3
+ import * as React from "react";
4
+ import { useRouter } from "next/navigation";
5
+ import { toast } from "react-hot-toast";
6
6
 
7
- import { ServerActionResult } from "../../types/types"
8
- import { Button } from './ui/button'
7
+ import { ServerActionResult } from "../../types/types";
8
+ import { Button } from "./ui/button";
9
9
  import {
10
10
  AlertDialog,
11
11
  AlertDialogAction,
@@ -15,18 +15,18 @@ import {
15
15
  AlertDialogFooter,
16
16
  AlertDialogHeader,
17
17
  AlertDialogTitle,
18
- AlertDialogTrigger
19
- } from './ui/alert-dialog'
20
- import { IconSpinner } from './ui/icons'
18
+ AlertDialogTrigger,
19
+ } from "./ui/alert-dialog";
20
+ import { IconSpinner } from "./ui/icons";
21
21
 
22
22
  interface ClearHistoryProps {
23
- clearChats: () => ServerActionResult<void>
23
+ clearChats: () => ServerActionResult<void>;
24
24
  }
25
25
 
26
26
  export function ClearHistory({ clearChats }: ClearHistoryProps) {
27
- const [open, setOpen] = React.useState(false)
28
- const [isPending, startTransition] = React.useTransition()
29
- const router = useRouter()
27
+ const [open, setOpen] = React.useState(false);
28
+ const [isPending, startTransition] = React.useTransition();
29
+ const router = useRouter();
30
30
 
31
31
  return (
32
32
  <AlertDialog open={open} onOpenChange={setOpen}>
@@ -49,18 +49,18 @@ export function ClearHistory({ clearChats }: ClearHistoryProps) {
49
49
  <AlertDialogAction
50
50
  disabled={isPending}
51
51
  onClick={(event: any) => {
52
- event.preventDefault()
52
+ event.preventDefault();
53
53
  startTransition(async () => {
54
- const result = await clearChats()
54
+ const result = await clearChats();
55
55
 
56
- if (result && 'error' in result) {
57
- toast.error(result.error)
58
- return
56
+ if (result && "error" in result) {
57
+ toast.error(result.error);
58
+ return;
59
59
  }
60
60
 
61
- setOpen(false)
62
- router.push('/')
63
- })
61
+ setOpen(false);
62
+ router.push("/");
63
+ });
64
64
  }}
65
65
  >
66
66
  {isPending && <IconSpinner className="mr-2 animate-spin" />}
@@ -69,5 +69,5 @@ export function ClearHistory({ clearChats }: ClearHistoryProps) {
69
69
  </AlertDialogFooter>
70
70
  </AlertDialogContent>
71
71
  </AlertDialog>
72
- )
72
+ );
73
73
  }
@@ -1,61 +1,56 @@
1
- 'use client'
1
+ "use client";
2
2
 
3
- import React from 'react'
3
+ import React from "react";
4
4
 
5
- import { ChatList } from './chat-list'
6
- import { ChatPanel } from './chat-panel'
7
- import { DefaultEmptyScreen, EmptyScreenProps } from './default-empty-screen'
8
- import { ChatScrollAnchor } from './chat-scroll-anchor'
9
- import { UseCopilotChatOptions } from "@copilotkit/react-core"
10
- import { useCopilotChat } from "@copilotkit/react-core"
5
+ import { ChatList } from "./chat-list";
6
+ import { ChatPanel } from "./chat-panel";
7
+ import { DefaultEmptyScreen, EmptyScreenProps } from "./default-empty-screen";
8
+ import { ChatScrollAnchor } from "./chat-scroll-anchor";
9
+ import { UseCopilotChatOptions } from "@copilotkit/react-core";
10
+ import { useCopilotChat } from "@copilotkit/react-core";
11
11
 
12
12
  interface ChatComponentInjectionsProps {
13
- EmptyScreen?: React.FC<EmptyScreenProps>
13
+ EmptyScreen?: React.FC<EmptyScreenProps>;
14
14
  }
15
15
 
16
16
  interface CopilotChatProps
17
17
  extends UseCopilotChatOptions,
18
18
  ChatComponentInjectionsProps {}
19
19
 
20
- export function CopilotChat({
21
- id,
22
- initialMessages,
23
- makeSystemMessage,
24
- EmptyScreen = DefaultEmptyScreen
25
- }: CopilotChatProps) {
26
- const { visibleMessages, append, reload, stop, isLoading, input, setInput } =
27
- useCopilotChat({ id, initialMessages, makeSystemMessage })
28
-
29
- return (
30
- <div
31
- className="w-full h-full flex flex-col overflow-hidden box-border items-start"
32
- >
33
- <div
34
- className="pt-5 px-5 overflow-y-auto overflow-x-hidden w-full flex-grow"
35
- >
36
- {visibleMessages.length ? (
37
- <div className="pl-0 pr-6">
38
- <ChatList messages={visibleMessages} />
39
- <ChatScrollAnchor trackVisibility={isLoading} />
40
- </div>
41
- ) : (
42
- <EmptyScreen setInput={setInput} />
43
- )}
44
- </div>
45
-
46
- <div className="flex-shrink-0 w-full">
47
- <ChatPanel
48
- id={id}
49
- isLoading={isLoading}
50
- stop={stop}
51
- append={append}
52
- reload={reload}
53
- messages={visibleMessages}
54
- input={input}
55
- setInput={setInput}
56
- />
20
+ export function CopilotChat({
21
+ id,
22
+ initialMessages,
23
+ makeSystemMessage,
24
+ EmptyScreen = DefaultEmptyScreen,
25
+ }: CopilotChatProps) {
26
+ const { visibleMessages, append, reload, stop, isLoading, input, setInput } =
27
+ useCopilotChat({ id, initialMessages, makeSystemMessage });
28
+
29
+ return (
30
+ <div className="w-full h-full flex flex-col overflow-hidden box-border items-start">
31
+ <div className="pt-5 px-5 overflow-y-auto overflow-x-hidden w-full flex-grow">
32
+ {visibleMessages.length ? (
33
+ <div className="pl-0 pr-6">
34
+ <ChatList messages={visibleMessages} />
35
+ <ChatScrollAnchor trackVisibility={isLoading} />
57
36
  </div>
58
- </div>
59
- )
60
- }
61
-
37
+ ) : (
38
+ <EmptyScreen setInput={setInput} />
39
+ )}
40
+ </div>
41
+
42
+ <div className="flex-shrink-0 w-full">
43
+ <ChatPanel
44
+ id={id}
45
+ isLoading={isLoading}
46
+ stop={stop}
47
+ append={append}
48
+ reload={reload}
49
+ messages={visibleMessages}
50
+ input={input}
51
+ setInput={setInput}
52
+ />
53
+ </div>
54
+ </div>
55
+ );
56
+ }
@@ -1,43 +1,45 @@
1
- 'use client'
2
- import React from 'react'
3
- import { UseChatHelpers } from 'ai/react'
1
+ "use client";
2
+ import React from "react";
3
+ import { UseChatHelpers } from "ai/react";
4
4
 
5
- import { Button } from './ui/button'
6
- import { ExternalLink } from './external-link'
7
- import { IconArrowRight } from './ui/icons'
5
+ import { Button } from "./ui/button";
6
+ import { ExternalLink } from "./external-link";
7
+ import { IconArrowRight } from "./ui/icons";
8
8
 
9
9
  const exampleMessages = [
10
10
  {
11
- heading: 'Explain technical concepts',
12
- message: `What is a "serverless function"?`
11
+ heading: "Explain technical concepts",
12
+ message: `What is a "serverless function"?`,
13
13
  },
14
14
  {
15
- heading: 'Summarize an article',
16
- message: 'Summarize the following article for a 2nd grader: \n'
15
+ heading: "Summarize an article",
16
+ message: "Summarize the following article for a 2nd grader: \n",
17
17
  },
18
18
  {
19
- heading: 'Draft an email',
20
- message: `Draft an email to my boss about the following: \n`
21
- }
22
- ]
19
+ heading: "Draft an email",
20
+ message: `Draft an email to my boss about the following: \n`,
21
+ },
22
+ ];
23
23
 
24
24
  export interface EmptyScreenProps {
25
- setInput: React.Dispatch<React.SetStateAction<string>>
25
+ setInput: React.Dispatch<React.SetStateAction<string>>;
26
26
  }
27
27
 
28
- export const DefaultEmptyScreen: React.FC<EmptyScreenProps> = props => {
28
+ export const DefaultEmptyScreen: React.FC<EmptyScreenProps> = (props) => {
29
29
  return (
30
30
  <div className="mx-auto max-w-2xl px-4">
31
31
  <div className="rounded-lg border bg-background p-8">
32
- <h1 className="mb-2 text-lg font-semibold">Welcome to Copilot! 👋</h1>
32
+ <h1 className="mb-2 text-lg font-semibold">
33
+ Welcome to CopilotKit! 👋
34
+ </h1>
33
35
  <p className="mb-2 leading-normal text-muted-foreground">
34
- This is a Copilot built with{' '}
36
+ This is a Copilot built with{" "}
35
37
  <ExternalLink href="https://recursively.ai">
36
38
  recursively.ai's
37
- </ExternalLink>{' '}
39
+ </ExternalLink>{" "}
38
40
  <ExternalLink href="https://github.com/RecursivelyAI/CopilotKit">
39
41
  CopilotKit
40
- </ExternalLink>{' '}
42
+ </ExternalLink>{" "}
41
43
  .
42
44
  </p>
43
45
  <p className="leading-normal text-muted-foreground">
@@ -58,5 +60,5 @@ export const DefaultEmptyScreen: React.FC<EmptyScreenProps> = props => {
58
60
  </div>
59
61
  </div>
60
62
  </div>
61
- )
62
- }
63
+ );
64
+ };
@@ -1,9 +1,9 @@
1
1
  export function ExternalLink({
2
2
  href,
3
- children
3
+ children,
4
4
  }: {
5
- href: string
6
- children: React.ReactNode
5
+ href: string;
6
+ children: React.ReactNode;
7
7
  }) {
8
8
  return (
9
9
  <a
@@ -25,5 +25,5 @@ export function ExternalLink({
25
25
  ></path>
26
26
  </svg>
27
27
  </a>
28
- )
28
+ );
29
29
  }
@@ -1,9 +1,9 @@
1
- import { FC, memo } from 'react'
2
- import ReactMarkdown, { Options } from 'react-markdown'
1
+ import { FC, memo } from "react";
2
+ import ReactMarkdown, { Options } from "react-markdown";
3
3
 
4
4
  export const MemoizedReactMarkdown: FC<Options> = memo(
5
5
  ReactMarkdown,
6
6
  (prevProps, nextProps) =>
7
7
  prevProps.children === nextProps.children &&
8
8
  prevProps.className === nextProps.className
9
- )
9
+ );
@@ -1,44 +1,44 @@
1
- import * as React from 'react'
2
- import TextareaAutosize from 'react-textarea-autosize'
3
- import { UseChatHelpers } from 'ai/react'
1
+ import * as React from "react";
2
+ import TextareaAutosize from "react-textarea-autosize";
3
+ import { UseChatHelpers } from "ai/react";
4
4
 
5
- import { useEnterSubmit } from '../../hooks/use-enter-submit'
6
- import { cn } from '../../lib/utils'
7
- import { Button, buttonVariants } from './ui/button'
8
- import { Tooltip, TooltipContent, TooltipTrigger } from './ui/tooltip'
9
- import { IconArrowElbow, IconPlus } from './ui/icons'
10
- import Link from 'next/link'
5
+ import { useEnterSubmit } from "../../hooks/use-enter-submit";
6
+ import { cn } from "../../lib/utils";
7
+ import { Button, buttonVariants } from "./ui/button";
8
+ import { Tooltip, TooltipContent, TooltipTrigger } from "./ui/tooltip";
9
+ import { IconArrowElbow, IconPlus } from "./ui/icons";
10
+ import Link from "next/link";
11
11
 
12
12
  export interface PromptProps
13
- extends Pick<UseChatHelpers, 'input' | 'setInput'> {
14
- onSubmit: (value: string) => Promise<void>
15
- isLoading: boolean
13
+ extends Pick<UseChatHelpers, "input" | "setInput"> {
14
+ onSubmit: (value: string) => Promise<void>;
15
+ isLoading: boolean;
16
16
  }
17
17
 
18
18
  export function PromptForm({
19
19
  onSubmit,
20
20
  input,
21
21
  setInput,
22
- isLoading
22
+ isLoading,
23
23
  }: PromptProps) {
24
- const { formRef, onKeyDown } = useEnterSubmit()
25
- const inputRef = React.useRef<HTMLTextAreaElement>(null)
24
+ const { formRef, onKeyDown } = useEnterSubmit();
25
+ const inputRef = React.useRef<HTMLTextAreaElement>(null);
26
26
 
27
27
  React.useEffect(() => {
28
28
  if (inputRef.current) {
29
- inputRef.current.focus()
29
+ inputRef.current.focus();
30
30
  }
31
- }, [])
31
+ }, []);
32
32
 
33
33
  return (
34
34
  <form
35
- onSubmit={async e => {
36
- e.preventDefault()
35
+ onSubmit={async (e) => {
36
+ e.preventDefault();
37
37
  if (!input?.trim()) {
38
- return
38
+ return;
39
39
  }
40
- setInput('')
41
- await onSubmit(input)
40
+ setInput("");
41
+ await onSubmit(input);
42
42
  }}
43
43
  ref={formRef}
44
44
  >
@@ -48,8 +48,8 @@ export function PromptForm({
48
48
  <Link
49
49
  href="/"
50
50
  className={cn(
51
- buttonVariants({ size: 'sm', variant: 'outline' }),
52
- 'absolute left-0 top-4 h-8 w-8 rounded-full bg-background p-0 sm:left-4'
51
+ buttonVariants({ size: "sm", variant: "outline" }),
52
+ "absolute left-0 top-4 h-8 w-8 rounded-full bg-background p-0 sm:left-4"
53
53
  )}
54
54
  >
55
55
  <IconPlus />
@@ -64,7 +64,7 @@ export function PromptForm({
64
64
  onKeyDown={onKeyDown}
65
65
  rows={1}
66
66
  value={input}
67
- onChange={e => setInput(e.target.value)}
67
+ onChange={(e) => setInput(e.target.value)}
68
68
  placeholder="Send a message."
69
69
  spellCheck={false}
70
70
  className="min-h-[60px] w-full resize-none bg-transparent px-4 py-[1.3rem] focus-within:outline-none sm:text-sm"
@@ -75,7 +75,7 @@ export function PromptForm({
75
75
  <Button
76
76
  type="submit"
77
77
  size="icon"
78
- disabled={isLoading || input === ''}
78
+ disabled={isLoading || input === ""}
79
79
  className=" bg-slate-300"
80
80
  >
81
81
  <IconArrowElbow />
@@ -87,5 +87,5 @@ export function PromptForm({
87
87
  </div>
88
88
  </div>
89
89
  </form>
90
- )
90
+ );
91
91
  }
@@ -1,14 +1,14 @@
1
- 'use client'
1
+ "use client";
2
2
 
3
- import * as React from 'react'
4
- import { useTheme } from 'next-themes'
3
+ import * as React from "react";
4
+ import { useTheme } from "next-themes";
5
5
 
6
- import { Button } from './ui/button'
7
- import { IconMoon, IconSun } from './ui/icons'
6
+ import { Button } from "./ui/button";
7
+ import { IconMoon, IconSun } from "./ui/icons";
8
8
 
9
9
  export function ThemeToggle() {
10
- const { setTheme, theme } = useTheme()
11
- const [_, startTransition] = React.useTransition()
10
+ const { setTheme, theme } = useTheme();
11
+ const [_, startTransition] = React.useTransition();
12
12
 
13
13
  return (
14
14
  <Button
@@ -16,16 +16,16 @@ export function ThemeToggle() {
16
16
  size="icon"
17
17
  onClick={() => {
18
18
  startTransition(() => {
19
- setTheme(theme === 'light' ? 'dark' : 'light')
20
- })
19
+ setTheme(theme === "light" ? "dark" : "light");
20
+ });
21
21
  }}
22
22
  >
23
- {!theme ? null : theme === 'dark' ? (
23
+ {!theme ? null : theme === "dark" ? (
24
24
  <IconMoon className="transition-all" />
25
25
  ) : (
26
26
  <IconSun className="transition-all" />
27
27
  )}
28
28
  <span className="sr-only">Toggle theme</span>
29
29
  </Button>
30
- )
30
+ );
31
31
  }
@@ -1,3 +1,3 @@
1
- 'use client'
1
+ "use client";
2
2
 
3
- export { Toaster } from 'react-hot-toast'
3
+ export { Toaster } from "react-hot-toast";
@@ -1,14 +1,14 @@
1
- 'use client'
1
+ "use client";
2
2
 
3
- import * as React from 'react'
4
- import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog'
3
+ import * as React from "react";
4
+ import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
5
5
 
6
- import { cn } from '../../../lib/utils'
7
- import { buttonVariants } from './button'
6
+ import { cn } from "../../../lib/utils";
7
+ import { buttonVariants } from "./button";
8
8
 
9
- const AlertDialog = AlertDialogPrimitive.Root
9
+ const AlertDialog = AlertDialogPrimitive.Root;
10
10
 
11
- const AlertDialogTrigger = AlertDialogPrimitive.Trigger
11
+ const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
12
12
 
13
13
  const AlertDialogPortal = ({
14
14
  className,
@@ -20,8 +20,8 @@ const AlertDialogPortal = ({
20
20
  {children}
21
21
  </div>
22
22
  </AlertDialogPrimitive.Portal>
23
- )
24
- AlertDialogPortal.displayName = AlertDialogPrimitive.Portal.displayName
23
+ );
24
+ AlertDialogPortal.displayName = AlertDialogPrimitive.Portal.displayName;
25
25
 
26
26
  const AlertDialogOverlay = React.forwardRef<
27
27
  React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
@@ -29,14 +29,14 @@ const AlertDialogOverlay = React.forwardRef<
29
29
  >(({ className, children, ...props }, ref) => (
30
30
  <AlertDialogPrimitive.Overlay
31
31
  className={cn(
32
- 'fixed inset-0 z-50 bg-background/80 backdrop-blur-sm transition-opacity animate-in fade-in',
32
+ "fixed inset-0 z-50 bg-background/80 backdrop-blur-sm transition-opacity animate-in fade-in",
33
33
  className
34
34
  )}
35
35
  {...props}
36
36
  ref={ref}
37
37
  />
38
- ))
39
- AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName
38
+ ));
39
+ AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
40
40
 
41
41
  const AlertDialogContent = React.forwardRef<
42
42
  React.ElementRef<typeof AlertDialogPrimitive.Content>,
@@ -47,14 +47,14 @@ const AlertDialogContent = React.forwardRef<
47
47
  <AlertDialogPrimitive.Content
48
48
  ref={ref}
49
49
  className={cn(
50
- 'fixed z-50 grid w-full max-w-lg scale-100 gap-4 border bg-background p-6 opacity-100 shadow-lg animate-in fade-in-90 slide-in-from-bottom-10 sm:rounded-lg sm:zoom-in-90 sm:slide-in-from-bottom-0 md:w-full',
50
+ "fixed z-50 grid w-full max-w-lg scale-100 gap-4 border bg-background p-6 opacity-100 shadow-lg animate-in fade-in-90 slide-in-from-bottom-10 sm:rounded-lg sm:zoom-in-90 sm:slide-in-from-bottom-0 md:w-full",
51
51
  className
52
52
  )}
53
53
  {...props}
54
54
  />
55
55
  </AlertDialogPortal>
56
- ))
57
- AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName
56
+ ));
57
+ AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;
58
58
 
59
59
  const AlertDialogHeader = ({
60
60
  className,
@@ -62,13 +62,13 @@ const AlertDialogHeader = ({
62
62
  }: React.HTMLAttributes<HTMLDivElement>) => (
63
63
  <div
64
64
  className={cn(
65
- 'flex flex-col space-y-2 text-center sm:text-left',
65
+ "flex flex-col space-y-2 text-center sm:text-left",
66
66
  className
67
67
  )}
68
68
  {...props}
69
69
  />
70
- )
71
- AlertDialogHeader.displayName = 'AlertDialogHeader'
70
+ );
71
+ AlertDialogHeader.displayName = "AlertDialogHeader";
72
72
 
73
73
  const AlertDialogFooter = ({
74
74
  className,
@@ -76,13 +76,13 @@ const AlertDialogFooter = ({
76
76
  }: React.HTMLAttributes<HTMLDivElement>) => (
77
77
  <div
78
78
  className={cn(
79
- 'flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2',
79
+ "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
80
80
  className
81
81
  )}
82
82
  {...props}
83
83
  />
84
- )
85
- AlertDialogFooter.displayName = 'AlertDialogFooter'
84
+ );
85
+ AlertDialogFooter.displayName = "AlertDialogFooter";
86
86
 
87
87
  const AlertDialogTitle = React.forwardRef<
88
88
  React.ElementRef<typeof AlertDialogPrimitive.Title>,
@@ -90,11 +90,11 @@ const AlertDialogTitle = React.forwardRef<
90
90
  >(({ className, ...props }, ref) => (
91
91
  <AlertDialogPrimitive.Title
92
92
  ref={ref}
93
- className={cn('text-lg font-semibold', className)}
93
+ className={cn("text-lg font-semibold", className)}
94
94
  {...props}
95
95
  />
96
- ))
97
- AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName
96
+ ));
97
+ AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
98
98
 
99
99
  const AlertDialogDescription = React.forwardRef<
100
100
  React.ElementRef<typeof AlertDialogPrimitive.Description>,
@@ -102,12 +102,12 @@ const AlertDialogDescription = React.forwardRef<
102
102
  >(({ className, ...props }, ref) => (
103
103
  <AlertDialogPrimitive.Description
104
104
  ref={ref}
105
- className={cn('text-sm text-muted-foreground', className)}
105
+ className={cn("text-sm text-muted-foreground", className)}
106
106
  {...props}
107
107
  />
108
- ))
108
+ ));
109
109
  AlertDialogDescription.displayName =
110
- AlertDialogPrimitive.Description.displayName
110
+ AlertDialogPrimitive.Description.displayName;
111
111
 
112
112
  const AlertDialogAction = React.forwardRef<
113
113
  React.ElementRef<typeof AlertDialogPrimitive.Action>,
@@ -118,8 +118,8 @@ const AlertDialogAction = React.forwardRef<
118
118
  className={cn(buttonVariants(), className)}
119
119
  {...props}
120
120
  />
121
- ))
122
- AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName
121
+ ));
122
+ AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;
123
123
 
124
124
  const AlertDialogCancel = React.forwardRef<
125
125
  React.ElementRef<typeof AlertDialogPrimitive.Cancel>,
@@ -128,14 +128,14 @@ const AlertDialogCancel = React.forwardRef<
128
128
  <AlertDialogPrimitive.Cancel
129
129
  ref={ref}
130
130
  className={cn(
131
- buttonVariants({ variant: 'outline' }),
132
- 'mt-2 sm:mt-0',
131
+ buttonVariants({ variant: "outline" }),
132
+ "mt-2 sm:mt-0",
133
133
  className
134
134
  )}
135
135
  {...props}
136
136
  />
137
- ))
138
- AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName
137
+ ));
138
+ AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
139
139
 
140
140
  export {
141
141
  AlertDialog,
@@ -146,5 +146,5 @@ export {
146
146
  AlertDialogTitle,
147
147
  AlertDialogDescription,
148
148
  AlertDialogAction,
149
- AlertDialogCancel
150
- }
149
+ AlertDialogCancel,
150
+ };