Skip to content

Commit a922889

Browse files
with changes
1 parent 2efd630 commit a922889

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

app/page.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22

33
import { EmailThread } from "@/components/EmailThread";
44
import { EmailsProvider } from "@/lib/hooks/use-emails";
5+
import { CopilotKit } from "@copilotkit/react-core";
6+
import "@copilotkit/react-textarea/styles.css";
57

68
export default function Home() {
79
return (
810
<div className="h-screen">
9-
<EmailsProvider>
10-
<EmailThread />
11-
</EmailsProvider>
11+
<CopilotKit publicApiKey="ck_pub_68042cff5088605d9c8ee8ead7b09c69">
12+
<EmailsProvider>
13+
<EmailThread />
14+
</EmailsProvider>
15+
</CopilotKit>
1216
</div>
1317
);
1418
}

components/Reply.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { useEmails } from "@/lib/hooks/use-emails";
22
import { useState } from "react";
33
import { Button } from "./ui/button";
44
import { Textarea } from "./ui/textarea";
5+
import { CopilotTextarea } from "@copilotkit/react-textarea";
56

67
export function Reply() {
78
const { sendEmail } = useEmails();
@@ -17,7 +18,16 @@ export function Reply() {
1718

1819
return (
1920
<div className="mt-4 pt-4 space-y-2 bg-background p-4 rounded-md border">
20-
<Textarea value={input} onChange={(e) => setInput(e.target.value)} />
21+
<CopilotTextarea
22+
className="min-h-40 border h-40 p-2 overflow-hidden"
23+
value={input}
24+
onChange={(e) => setInput(e.target.value)}
25+
placeholder="Write your reply..."
26+
autosuggestionsConfig={{
27+
textareaPurpose: `Asisst me in replying to this email thread. Remember all important details.`,
28+
chatApiConfigs: {}
29+
}}
30+
/>
2131
<Button disabled={!input} onClick={handleReply}>
2232
Reply
2333
</Button>

lib/hooks/use-emails.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { createContext, useContext, useState, ReactNode } from "react";
22
import { Email } from "../emails.types";
33
import emailHistory from "./email-history.json";
4+
import { useCopilotReadable } from "@copilotkit/react-core";
45

56
type EmailsContextType = {
67
emails: Email[];
@@ -16,6 +17,11 @@ const EmailsContext = createContext<EmailsContextType | undefined>(undefined);
1617
export const EmailsProvider = ({ children }: { children: ReactNode }) => {
1718
const [emails, setEmails] = useState<Email[]>(emailHistory);
1819

20+
useCopilotReadable({
21+
description: "The full history of this email thread",
22+
value: emails,
23+
});
24+
1925
const sendEmail = ({
2026
body
2127
}: {

0 commit comments

Comments
 (0)