Skip to content

An open-source, faster Devin alternative

TypeScript

ui(chat): refocus input after a turn completes

motatoes91b764d439ff
diff --git a/web/src/pages/AgentDetail.tsx b/web/src/pages/AgentDetail.tsx
index 7669a4ad..e2aca29e 100644
--- a/web/src/pages/AgentDetail.tsx
+++ b/web/src/pages/AgentDetail.tsx
@@ -619,6 +619,7 @@ function ChatTab({
typeof crypto !== 'undefined' && 'randomUUID' in crypto ? crypto.randomUUID() : `c-${Date.now()}`,
)
const scrollRef = useRef<HTMLDivElement | null>(null)
+ const inputRef = useRef<HTMLInputElement | null>(null)
useEffect(() => {
if (scrollRef.current) {
@@ -626,6 +627,14 @@ function ChatTab({
}
}, [history, streaming])
+ // Refocus the composer when streaming ends (or starts disabled→enabled)
+ // so the user can keep typing without grabbing the mouse.
+ useEffect(() => {
+ if (!streaming && !disabled) {
+ inputRef.current?.focus()
+ }
+ }, [streaming, disabled])
+
async function send() {
if (!input.trim() || !instanceId || streaming) return
const userMsg = input.trim()
@@ -740,6 +749,7 @@ function ChatTab({
style={{ display: 'flex', gap: 8 }}
>
<input
+ ref={inputRef}
value={input}
onChange={(e) => setInput(e.target.value)}
placeholder={disabled ? 'Agent not ready' : 'Send a message…'}