From d5333d84873ab76342e36a952c61665aff57e557 Mon Sep 17 00:00:00 2001 From: James Magahern Date: Wed, 18 Feb 2026 22:51:38 -0800 Subject: [PATCH] adjust auto-scrolling and focus behavior --- web/src/App.tsx | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/web/src/App.tsx b/web/src/App.tsx index e03b9e0..891ddb2 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -331,6 +331,14 @@ export default function App() { const initialRouteSelectionRef = useRef(readSidebarSelectionFromUrl()); const hasSyncedSelectionHistoryRef = useRef(false); + const focusComposer = () => { + if (typeof window === "undefined") return; + window.requestAnimationFrame(() => { + const textarea = document.getElementById("composer-input") as HTMLTextAreaElement | null; + textarea?.focus(); + }); + }; + useEffect(() => { if (typeof document === "undefined") return; const textarea = document.getElementById("composer-input") as HTMLTextAreaElement | null; @@ -522,8 +530,15 @@ export default function App() { useEffect(() => { if (draftKind === "search" || selectedItem?.kind === "search") return; - transcriptEndRef.current?.scrollIntoView({ behavior: "smooth", block: "end" }); - }, [draftKind, selectedChat?.messages.length, isSending, selectedItem?.kind]); + transcriptEndRef.current?.scrollIntoView({ behavior: isSending ? "smooth" : "auto", block: "end" }); + }, [draftKind, selectedChat?.messages.length, isSending, selectedItem?.kind, selectedKey]); + + useEffect(() => { + if (isSending) return; + const hasWorkspaceSelection = Boolean(selectedItem) || draftKind !== null; + if (!hasWorkspaceSelection) return; + focusComposer(); + }, [draftKind, isSending, selectedKey]); useEffect(() => { return () => { @@ -994,6 +1009,7 @@ export default function App() { } } finally { setIsSending(false); + focusComposer(); } }; @@ -1154,7 +1170,7 @@ export default function App() { -
+
{!isSearchMode ? ( ) : (