mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 08:23:34 +00:00
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:
1 parent
b78a912af1
commit
6457fbda76
2 files changed
+9
-2
No files matched your search
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user