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