Auto-focus textarea when GlobalChatPane opens

When the global chat pane is opened, the textarea is now automatically
focused so users can immediately start typing without needing to click
on the input field first.
This commit is contained in:
MK Fain committed 2025-12-03 21:08:00 -06:00
1 parent b78a912af1
commit 6457fbda76
2 files changed
+9 -2

No files matched your search

+3 -1
View File
@@ -113,7 +113,7 @@ export function GlobalChatPane() {
}
}, [providerModel, settings.recentlyUsedModels, setProviderModel]);
// Scroll to bottom when chat opens
// Scroll to bottom and focus textarea when chat opens
useEffect(() => {
if (isOpen && scrollAreaRef.current) {
// Small delay to ensure content is rendered
@@ -121,6 +121,8 @@ export function GlobalChatPane() {
if (scrollAreaRef.current) {
scrollAreaRef.current.scrollTop = scrollAreaRef.current.scrollHeight;
}
// Focus the textarea so user can start typing immediately
textareaRef.current?.focus();
});
// Reset scroll tracking when opening
userScrolledUp.current = false;
+6 -1
View File
@@ -127,6 +127,7 @@ export function GlobalChatProvider({ children }: GlobalChatProviderProps) {
});
let fullContent = '';
let loadingReleased = false;
for await (const chunk of stream) {
const delta = chunk.choices[0]?.delta?.content || '';
@@ -143,10 +144,14 @@ export function GlobalChatProvider({ children }: GlobalChatProviderProps) {
});
// Check if the stream is finished (finish_reason is set)
// Only release once to avoid multiple state updates
const finishReason = chunk.choices[0]?.finish_reason;
if (finishReason) {
if (finishReason && !loadingReleased) {
loadingReleased = true;
// Response is complete, release the input immediately
setIsLoading(false);
// Break out of the loop - we don't need any more chunks
break;
}
}