From 78092b88fe86655a926fe6949499959d90ceaaf5 Mon Sep 17 00:00:00 2001 From: Jicheng Lu <103353@smsassist.com> Date: Thu, 4 Sep 2025 10:57:55 -0500 Subject: [PATCH 1/2] refine chat text area focus --- .../[agentId]/[conversationId]/chat-box.svelte | 18 ++++++++++++++++++ .../chat-util/chat-text-area.svelte | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte b/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte index 82d53688..904000f2 100644 --- a/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte +++ b/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte @@ -215,6 +215,9 @@ // const editor = lastBotMsg?.rich_content?.editor || ''; loadTextEditor = true; // TEXT_EDITORS.includes(editor) || !Object.values(EditorType).includes(editor); loadEditor = !isSendingMsg && !isThinking && loadTextEditor && messageQueue.length === 0; + if (loadEditor) { + focusChatTextArea(); + } } $: { @@ -270,12 +273,26 @@ handleChatAction(e); } }); + + await focusChatTextArea(); }); function handleLogoutAction() { resetLocalStorage(true); } + function focusChatTextArea() { + return new Promise(resolve => { + tick().then(() => { + const textarea = document.getElementById('chat-textarea'); + if (textarea) { + textarea.focus(); + } + resolve('focused'); + }); + }); + } + /** @param {any} e */ function handleNewChatAction(e) { if (!isCreatingNewConv && !isThinking && !isSendingMsg) { @@ -1947,6 +1964,7 @@