From 31ec5f5c17dd57a4e36bc8009e444767a819157e Mon Sep 17 00:00:00 2001 From: abhi1992002 Date: Tue, 3 Feb 2026 10:52:22 +0530 Subject: [PATCH] Add Chat input --- .../ChatMessagesContainer.tsx | 124 ++++++++---------- .../src/app/(platform)/copilot-2/page.tsx | 44 +++++-- .../copilot-2/tools/FindBlocks/helpers.tsx | 101 +++++++------- 3 files changed, 135 insertions(+), 134 deletions(-) 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 d0a6739f1a..98142300be 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 @@ -26,81 +26,61 @@ 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 ( - - ); - default: - return null; - } - })} - - - )) - )} - {status === "submitted" && ( - - -

Thinking...

+ + + {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 ( + + ); + default: + return null; + } + })} - )} - {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" - /> - -
-
-
+ )) + )} + {status === "submitted" && ( + + +

Thinking...

+
+
+ )} + {error && ( +
+ Error: {error.message} +
+ )} + + + ); }; 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 c560a3ee39..7ce6d7874a 100644 --- a/autogpt_platform/frontend/src/app/(platform)/copilot-2/page.tsx +++ b/autogpt_platform/frontend/src/app/(platform)/copilot-2/page.tsx @@ -8,6 +8,7 @@ import { ChatSidebar } from "./components/ChatSidebar/ChatSidebar"; import { EmptySession } from "./components/EmptySession/EmptySession"; import { ChatMessagesContainer } from "./components/ChatMessagesContainer/ChatMessagesContainer"; import { postV2CreateSession } from "@/app/api/__generated__/endpoints/chat/chat"; +import { ChatInput } from "@/components/contextual/Chat/components/ChatInput/ChatInput"; export default function Page() { const [sessionId, setSessionId] = useQueryState("sessionId", parseAsString); @@ -62,22 +63,43 @@ export default function Page() { setInput(""); } + function onSend(message: string) { + sendMessage({ text: message }); + } + return (
- {sessionId ? ( - +
+ {sessionId ? ( + + ) : ( + + )} +
+
+ {}} + placeholder="You can search or just ask" /> - ) : ( - - )} +
+
+
); } diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot-2/tools/FindBlocks/helpers.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot-2/tools/FindBlocks/helpers.tsx index ea3758fea2..495d803c13 100644 --- a/autogpt_platform/frontend/src/app/(platform)/copilot-2/tools/FindBlocks/helpers.tsx +++ b/autogpt_platform/frontend/src/app/(platform)/copilot-2/tools/FindBlocks/helpers.tsx @@ -1,57 +1,56 @@ import { ToolUIPart } from "ai"; -import { FindBlockInput, FindBlockOutput, FindBlockToolPart } from "./FindBlocks"; -import { CheckCircleIcon, CircleNotchIcon, XCircleIcon } from "@phosphor-icons/react"; +import { + FindBlockInput, + FindBlockOutput, + FindBlockToolPart, +} from "./FindBlocks"; +import { + CheckCircleIcon, + CircleNotchIcon, + XCircleIcon, +} from "@phosphor-icons/react"; export const getAnimationText = (part: FindBlockToolPart): string => { - switch (part.state) { - case "input-streaming": - return "Searching blocks for you"; - - case "input-available": { - const query = (part.input as FindBlockInput).query; - return `Finding "${query}" blocks`; - } - - case "output-available": { - const parsed = JSON.parse(part.output as string) as FindBlockOutput; - if (parsed) { - return `Found ${parsed.count} "${(part.input as FindBlockInput).query}" blocks`; - } - return "Found blocks"; - } - - case "output-error": - return "Error finding blocks"; - - default: - return "Processing"; + switch (part.state) { + case "input-streaming": + return "Searching blocks for you"; + + case "input-available": { + const query = (part.input as FindBlockInput).query; + return `Finding "${query}" blocks`; } - } - - export const StateIcon = ({ state }: { state: ToolUIPart["state"] }) => { - switch (state) { - case "input-streaming": - case "input-available": - return ( - - ); - case "output-available": - return ( - - ); - case "output-error": - return ( - - ); - default: - return null; + + case "output-available": { + const parsed = JSON.parse(part.output as string) as FindBlockOutput; + if (parsed) { + return `Found ${parsed.count} "${(part.input as FindBlockInput).query}" blocks`; + } + return "Found blocks"; } + + case "output-error": + return "Error finding blocks"; + + default: + return "Processing"; } - \ No newline at end of file +}; + +export const StateIcon = ({ state }: { state: ToolUIPart["state"] }) => { + switch (state) { + case "input-streaming": + case "input-available": + return ( + + ); + case "output-available": + return ; + case "output-error": + return ; + default: + return null; + } +};