diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot-2/components/ChatMessagesContainer/ChatMessagesContainer.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot-2/components/ChatMessagesContainer/ChatMessagesContainer.tsx index 7806dcb9f2..61ddb04e56 100644 --- a/autogpt_platform/frontend/src/app/(platform)/copilot-2/components/ChatMessagesContainer/ChatMessagesContainer.tsx +++ b/autogpt_platform/frontend/src/app/(platform)/copilot-2/components/ChatMessagesContainer/ChatMessagesContainer.tsx @@ -1,122 +1,103 @@ import { - Conversation, - ConversationContent, - ConversationEmptyState, - ConversationScrollButton, - } from "@/components/ai-elements/conversation"; - import { - Message, - MessageContent, - MessageResponse, - } from "@/components/ai-elements/message"; + Conversation, + ConversationContent, + ConversationEmptyState, + ConversationScrollButton, +} from "@/components/ai-elements/conversation"; +import { + Message, + MessageContent, + MessageResponse, +} from "@/components/ai-elements/message"; import { MessageSquareIcon } from "lucide-react"; import { UIMessage, UIDataTypes, UITools } from "ai"; - +import { FindBlocksTool } from "../../tools/FindBlocks/FindBlocks"; interface ChatMessagesContainerProps { - messages: UIMessage[]; - status: string; - error: Error | undefined; - handleSubmit: (e: React.FormEvent) => void; - input: string; - setInput: (input: string) => void; - } + messages: UIMessage[]; + status: string; + error: Error | undefined; + handleSubmit: (e: React.FormEvent) => void; + input: string; + setInput: (input: string) => void; +} -export const ChatMessagesContainer = ({messages, status, error, handleSubmit, input, setInput}: ChatMessagesContainerProps) => { +export const ChatMessagesContainer = ({ + messages, + status, + error, + handleSubmit, + input, + setInput, +}: ChatMessagesContainerProps) => { return (
- - - {messages.length === 0 ? ( - } - title="Start a conversation" - description="Type a message below to begin chatting" - /> - ) : ( - messages.map((message) => ( - - - {message.parts.map((part, i) => { - switch (part.type) { - case "text": - return ( - - {part.text} - - ); - case "tool-find_block": - return ( -
- {part.state === "input-streaming" && ( -

Finding blocks for you

- )} - {part.state === "input-available" && ( -

- Searching blocks for{" "} - {(part.input as { query: string }).query} -

- )} - {part.state === "output-available" && ( -

- Found{" "} - { - ( - JSON.parse(part.output as string) as { - count: number; - } - ).count - }{" "} - blocks -

- )} -
- ); - default: - return null; - } - })} -
-
- )) - )} - {status === "submitted" && ( - + + + {messages.length === 0 ? ( + } + title="Start a conversation" + description="Type a message below to begin chatting" + /> + ) : ( + messages.map((message) => ( + -

Thinking...

+ {message.parts.map((part, i) => { + switch (part.type) { + case "text": + return ( + + {part.text} + + ); + case "tool-find_block": + return ( + + ); + default: + return null; + } + })}
- )} - {error && ( -
- Error: {error.message} -
- )} -
- -
+ )) + )} + {status === "submitted" && ( + + +

Thinking...

+
+
+ )} + {error && ( +
+ Error: {error.message} +
+ )} +
+ +
-
-
- setInput(e.target.value)} - disabled={status !== "ready"} - placeholder="Say something..." - className="flex-1 rounded-md border border-zinc-300 px-4 py-2 focus:border-zinc-500 focus:outline-none" - /> - -
-
-
+
+
+ setInput(e.target.value)} + disabled={status !== "ready"} + placeholder="Say something..." + className="flex-1 rounded-md border border-zinc-300 px-4 py-2 focus:border-zinc-500 focus:outline-none" + /> + +
+
+ ); -}; \ No newline at end of file +}; diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot-2/components/ChatSidebar/ChatSidebar.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot-2/components/ChatSidebar/ChatSidebar.tsx index fca1fd897a..f7304b19c2 100644 --- a/autogpt_platform/frontend/src/app/(platform)/copilot-2/components/ChatSidebar/ChatSidebar.tsx +++ b/autogpt_platform/frontend/src/app/(platform)/copilot-2/components/ChatSidebar/ChatSidebar.tsx @@ -2,7 +2,13 @@ import { useState } from "react"; import { postV2CreateSession } from "@/app/api/__generated__/endpoints/chat/chat"; import { parseAsString, useQueryState } from "nuqs"; -export const ChatSidebar = ({ isCreating, setIsCreating }: { isCreating: boolean, setIsCreating: (isCreating: boolean) => void }) => { +export const ChatSidebar = ({ + isCreating, + setIsCreating, +}: { + isCreating: boolean; + setIsCreating: (isCreating: boolean) => void; +}) => { const [sessionId, setSessionId] = useQueryState("sessionId", parseAsString); async function createSession(): Promise { @@ -29,17 +35,15 @@ export const ChatSidebar = ({ isCreating, setIsCreating }: { isCreating: boolean } } - return (
- -
- + + ); -}; \ No newline at end of file +}; diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot-2/components/EmptySession/EmptySession.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot-2/components/EmptySession/EmptySession.tsx index c1ebe51641..136c1aa168 100644 --- a/autogpt_platform/frontend/src/app/(platform)/copilot-2/components/EmptySession/EmptySession.tsx +++ b/autogpt_platform/frontend/src/app/(platform)/copilot-2/components/EmptySession/EmptySession.tsx @@ -20,4 +20,4 @@ export function EmptySession({ isCreating, onCreateSession }: Props) { ); -} \ No newline at end of file +} diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot-2/components/MorphingTextAnimation/MorphingTextAnimation.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot-2/components/MorphingTextAnimation/MorphingTextAnimation.tsx new file mode 100644 index 0000000000..5137022233 --- /dev/null +++ b/autogpt_platform/frontend/src/app/(platform)/copilot-2/components/MorphingTextAnimation/MorphingTextAnimation.tsx @@ -0,0 +1,57 @@ +import { useEffect, useState } from "react"; +import { AnimatePresence, motion } from "framer-motion"; + +const MorphingTextAnimationComponent = ({ + currentText, +}: { + currentText: string; +}) => { + const letters = currentText.split(""); + return ( + + {letters.map((char, index) => ( + + {char === " " ? "\u00A0" : char} + + ))} + + ); +}; + +export const MorphingTextAnimation = () => { + const textArray = ["Searching for Twitter blocks", "Found 10 twitter blocks"]; + const [currentText, setCurrentText] = useState(textArray[0]); + + useEffect(() => { + const interval = setInterval(() => { + setCurrentText(textArray[Math.floor(Math.random() * textArray.length)]); + }, 1000); + return () => clearInterval(interval); + }, []); + + return ( +
+ + + + + +
+ ); +}; diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot-2/page.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot-2/page.tsx index 6c275c6b8e..c560a3ee39 100644 --- a/autogpt_platform/frontend/src/app/(platform)/copilot-2/page.tsx +++ b/autogpt_platform/frontend/src/app/(platform)/copilot-2/page.tsx @@ -57,12 +57,11 @@ export default function Page() { function handleMessageSubmit(e: React.FormEvent) { e.preventDefault(); if (!input.trim() || !sessionId) return; - + sendMessage({ text: input }); setInput(""); } - return (
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot-2/store/chat-store.ts b/autogpt_platform/frontend/src/app/(platform)/copilot-2/store/chat-store.ts deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot-2/tools/FindBlocks/FindBlocks.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot-2/tools/FindBlocks/FindBlocks.tsx new file mode 100644 index 0000000000..1bff1c64bc --- /dev/null +++ b/autogpt_platform/frontend/src/app/(platform)/copilot-2/tools/FindBlocks/FindBlocks.tsx @@ -0,0 +1,17 @@ +import { UIMessage, UIDataTypes, UITools, UIMessagePart } from "ai"; + +export const FindBlocksTool = ({ + message, + i, + part, +}: { + message: UIMessage; + i: number; + part: UIMessagePart; +}) => { + return ( +
+

Find Blocks

+
+ ); +}; diff --git a/autogpt_platform/frontend/src/components/ai-elements/conversation.tsx b/autogpt_platform/frontend/src/components/ai-elements/conversation.tsx index fd00cef39b..91689b1423 100644 --- a/autogpt_platform/frontend/src/components/ai-elements/conversation.tsx +++ b/autogpt_platform/frontend/src/components/ai-elements/conversation.tsx @@ -1,5 +1,6 @@ "use client"; +import { MorphingTextAnimation } from "@/app/(platform)/copilot-2/components/MorphingTextAnimation/MorphingTextAnimation"; import { Button } from "@/components/ui/button"; import { cn } from "@/lib/utils"; import { ArrowDownIcon } from "lucide-react"; @@ -50,18 +51,23 @@ export const ConversationEmptyState = ({
{children ?? ( <> - {icon &&
{icon}
} + {icon && ( +
{icon}
+ )}
-

{title}

+

{title}

{description && ( -

{description}

+

+ {description} +

)} +
)} @@ -84,8 +90,8 @@ export const ConversationScrollButton = ({ !isAtBottom && (