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 ? ( ) : (