Keep textarea focused in GlobalChatPane after AI responds

- Focus textarea immediately after sending message (not after AI response)
- Add useEffect to refocus textarea when isLoading becomes false
- User can now type their next message right away without clicking
This commit is contained in:
MK Fain committed 2025-12-03 20:40:05 -06:00
1 parent 37071cde85
commit 361b6dae3c
1 file changed
+10 -3
+10 -3
View File
@@ -164,12 +164,19 @@ export function GlobalChatPane() {
const messageContent = input.trim();
setInput('');
await sendMessage(messageContent, providerModel);
// Focus back on textarea
// Focus immediately so user can keep typing
textareaRef.current?.focus();
await sendMessage(messageContent, providerModel);
}, [input, isLoading, providerModel, sendMessage]);
// Refocus textarea when AI finishes responding
useEffect(() => {
if (!isLoading && isOpen && messages.length > 0) {
textareaRef.current?.focus();
}
}, [isLoading, isOpen, messages.length]);
const handleKeyDown = useCallback((e: React.KeyboardEvent<HTMLTextAreaElement>) => {
if (e.key === 'Enter' && !e.shiftKey && !isMobile) {
e.preventDefault();