From e46cbeb2bf6d2d9064ca1cb5ee1bda7bc8eae27e Mon Sep 17 00:00:00 2001 From: Benson Wong Date: Sun, 28 Jun 2026 04:16:23 +0000 Subject: [PATCH] ui: refocus message input after chat generation completes - Add ref prop to ExpandableTextarea to expose the underlying textarea - Track streaming state transitions in ChatInterface and refocus the input via $effect when isStreaming flips to false --- .../src/components/playground/ChatInterface.svelte | 10 ++++++++++ .../components/playground/ExpandableTextarea.svelte | 3 +++ 2 files changed, 13 insertions(+) diff --git a/ui-svelte/src/components/playground/ChatInterface.svelte b/ui-svelte/src/components/playground/ChatInterface.svelte index f3471b75..6b0e260b 100644 --- a/ui-svelte/src/components/playground/ChatInterface.svelte +++ b/ui-svelte/src/components/playground/ChatInterface.svelte @@ -37,6 +37,7 @@ let reasoningStartTime = $state(0); let abortController = $state(null); let messagesContainer: HTMLDivElement | undefined = $state(); + let inputRef: HTMLTextAreaElement | null = $state(null); let showSettings = $state(false); let attachedImages = $state([]); let fileInput = $state(null); @@ -49,6 +50,14 @@ playgroundStores.chatStreaming.set(isStreaming); }); + let wasStreaming = $state(false); + $effect(() => { + if (wasStreaming && !isStreaming) { + inputRef?.focus(); + } + wasStreaming = isStreaming; + }); + function handleMessagesScroll() { if (!messagesContainer) return; const { scrollTop, scrollHeight, clientHeight } = messagesContainer; @@ -454,6 +463,7 @@ />