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 @@ />