From f287022ac053946176eec79ae92551bdd8c48b75 Mon Sep 17 00:00:00 2001 From: Henry Li Date: Mon, 2 Feb 2026 10:18:02 +0800 Subject: [PATCH] feat: integrate PromptInputProvider into ChatLayout and utilize prompt input controller in ChatPage --- frontend/src/app/workspace/chats/[thread_id]/layout.tsx | 7 ++++++- frontend/src/app/workspace/chats/[thread_id]/page.tsx | 6 ++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/workspace/chats/[thread_id]/layout.tsx b/frontend/src/app/workspace/chats/[thread_id]/layout.tsx index 744493e..098d24f 100644 --- a/frontend/src/app/workspace/chats/[thread_id]/layout.tsx +++ b/frontend/src/app/workspace/chats/[thread_id]/layout.tsx @@ -1,5 +1,6 @@ "use client"; +import { PromptInputProvider } from "@/components/ai-elements/prompt-input"; import { ArtifactsProvider } from "@/components/workspace/artifacts"; export default function ChatLayout({ @@ -7,5 +8,9 @@ export default function ChatLayout({ }: { children: React.ReactNode; }) { - return {children}; + return ( + + {children} + + ); } diff --git a/frontend/src/app/workspace/chats/[thread_id]/page.tsx b/frontend/src/app/workspace/chats/[thread_id]/page.tsx index 6f9db87..e307ae2 100644 --- a/frontend/src/app/workspace/chats/[thread_id]/page.tsx +++ b/frontend/src/app/workspace/chats/[thread_id]/page.tsx @@ -5,6 +5,7 @@ import { useParams, useRouter, useSearchParams } from "next/navigation"; import { useCallback, useEffect, useMemo, useState } from "react"; import { ConversationEmptyState } from "@/components/ai-elements/conversation"; +import { usePromptInputController } from "@/components/ai-elements/prompt-input"; import { Button } from "@/components/ui/button"; import { ResizableHandle, @@ -53,6 +54,7 @@ export default function ChatPage() { } = useArtifacts(); const { thread_id: threadIdFromPath } = useParams<{ thread_id: string }>(); const searchParams = useSearchParams(); + const promptInputController = usePromptInputController(); const inputInitialValue = useMemo(() => { if (threadIdFromPath !== "new" || searchParams.get("mode") !== "skill") { return undefined; @@ -62,6 +64,7 @@ export default function ChatPage() { useEffect(() => { if (inputInitialValue) { setTimeout(() => { + promptInputController.textInput.setInput(inputInitialValue); const textarea = document.querySelector("textarea"); if (textarea) { textarea.focus(); @@ -70,7 +73,7 @@ export default function ChatPage() { } }, 100); } - }, [inputInitialValue]); + }, [inputInitialValue, promptInputController.textInput]); const isNewThread = useMemo( () => threadIdFromPath === "new", [threadIdFromPath], @@ -272,7 +275,6 @@ export default function ChatPage() { context={settings.context} extraHeader={isNewThread && } disabled={env.NEXT_PUBLIC_STATIC_WEBSITE_ONLY === "true"} - initialValue={inputInitialValue} onContextChange={(context) => setSettings("context", context) }