diff --git a/frontend/src/ChatInput.jsx b/frontend/src/ChatInput.jsx index 060fcf4..8f2cf44 100644 --- a/frontend/src/ChatInput.jsx +++ b/frontend/src/ChatInput.jsx @@ -1,7 +1,16 @@ -import React, { useState } from "react"; +// src/ChatInput.jsx +import React, { useState, useRef, useEffect } from "react"; export default function ChatInput({ onSend, loading }) { const [value, setValue] = useState(""); + const textareaRef = useRef(null); + + // Autofocus on mount and after each retrieval + useEffect(() => { + if (!loading && textareaRef.current) { + textareaRef.current.focus(); + } + }, [loading]); const handleKeyDown = (e) => { if (e.key === "Enter" && !e.shiftKey) { @@ -16,6 +25,7 @@ export default function ChatInput({ onSend, loading }) { return (