auto focus

This commit is contained in:
phact 2025-07-21 12:49:26 -04:00
parent 5ce7f7b312
commit 8466355f59

View file

@ -44,6 +44,7 @@ export default function ChatPage() {
const [isDragOver, setIsDragOver] = useState(false)
const dragCounterRef = useRef(0)
const messagesEndRef = useRef<HTMLDivElement>(null)
const inputRef = useRef<HTMLInputElement>(null)
const scrollToBottom = () => {
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" })
@ -152,6 +153,11 @@ export default function ChatPage() {
scrollToBottom()
}, [messages, streamingMessage])
// Auto-focus the input on component mount
useEffect(() => {
inputRef.current?.focus()
}, [])
const handleSSEStream = async (userMessage: Message) => {
const apiEndpoint = endpoint === "chat" ? "/api/chat" : "/api/langflow"
@ -843,6 +849,7 @@ export default function ChatPage() {
{/* Input Area */}
<form onSubmit={handleSubmit} className="flex gap-2 flex-shrink-0 w-full">
<Input
ref={inputRef}
value={input}
onChange={(e) => setInput(e.target.value)}
placeholder="Ask a question about your documents..."