diff --git a/web/app/_components/BasicPromptAccessories/index.tsx b/web/app/_components/BasicPromptAccessories/index.tsx index 332b9625e..11dbf8be6 100644 --- a/web/app/_components/BasicPromptAccessories/index.tsx +++ b/web/app/_components/BasicPromptAccessories/index.tsx @@ -1,7 +1,7 @@ "use client"; import { useSetAtom } from "jotai"; -import SecondaryButton from "../SecondaryButton"; +import { InformationCircleIcon } from "@heroicons/react/24/outline"; import SendButton from "../SendButton"; import { showingAdvancedPromptAtom } from "@/_helpers/atoms/Modal.atom"; @@ -11,22 +11,21 @@ const BasicPromptAccessories: React.FC = () => { const shouldShowAdvancedPrompt = false; return ( -
- {shouldShowAdvancedPrompt && ( - setShowingAdvancedPrompt(true)} - /> - )} -
- {!shouldShowAdvancedPrompt && } +
+ {/* Add future accessories here, e.g upload a file */} +
+
+ {/* */} +
+
+
+ +
); }; diff --git a/web/app/_components/BasicPromptInput/index.tsx b/web/app/_components/BasicPromptInput/index.tsx index 7ff99d540..38df07895 100644 --- a/web/app/_components/BasicPromptInput/index.tsx +++ b/web/app/_components/BasicPromptInput/index.tsx @@ -7,7 +7,7 @@ import useCreateConversation from "@/_hooks/useCreateConversation"; import useInitModel from "@/_hooks/useInitModel"; import useSendChatMessage from "@/_hooks/useSendChatMessage"; import { useAtom, useAtomValue } from "jotai"; -import { ChangeEvent } from "react"; +import { ChangeEvent, useEffect, useRef } from "react"; const BasicPromptInput: React.FC = () => { const activeConversationId = useAtomValue(getActiveConvoIdAtom); @@ -18,9 +18,7 @@ const BasicPromptInput: React.FC = () => { const { initModel } = useInitModel(); - const handleMessageChange = (event: ChangeEvent) => { - setCurrentPrompt(event.target.value); - }; + const textareaRef = useRef(null); const handleKeyDown = async ( event: React.KeyboardEvent @@ -44,17 +42,53 @@ const BasicPromptInput: React.FC = () => { } }; + useEffect(() => { + adjustTextareaHeight(); + }, [currentPrompt]); + + const handleMessageChange = (event: ChangeEvent) => { + setCurrentPrompt(event.target.value); + }; + + // Auto adjust textarea height based on content + const MAX_ROWS = 30; + + const adjustTextareaHeight = () => { + if (textareaRef.current) { + textareaRef.current.style.height = "auto"; // 1 row + const scrollHeight = textareaRef.current.scrollHeight; + const maxScrollHeight = + parseInt(window.getComputedStyle(textareaRef.current).lineHeight, 10) * + MAX_ROWS; + textareaRef.current.style.height = `${Math.min( + scrollHeight, + maxScrollHeight + )}px`; + } + }; + return ( -