diff --git a/src/lib/components/chat/MessageInput.svelte b/src/lib/components/chat/MessageInput.svelte index bb941c90..d2fe8ca2 100644 --- a/src/lib/components/chat/MessageInput.svelte +++ b/src/lib/components/chat/MessageInput.svelte @@ -298,6 +298,24 @@ submitPrompt(prompt); } }} + on:keydown={(e) => { + if (prompt === '' && e.key == 'ArrowUp') { + e.preventDefault(); + + const userMessageElement = [ + ...document.getElementsByClassName('user-message') + ]?.at(-1); + + const editButton = [ + ...document.getElementsByClassName('edit-user-message-button') + ]?.at(-1); + + console.log(userMessageElement); + + userMessageElement.scrollIntoView({ block: 'center' }); + editButton?.click(); + } + }} rows="1" on:input={(e) => { e.target.style.height = ''; diff --git a/src/lib/components/chat/Messages/UserMessage.svelte b/src/lib/components/chat/Messages/UserMessage.svelte index a760ce3a..693d20e2 100644 --- a/src/lib/components/chat/Messages/UserMessage.svelte +++ b/src/lib/components/chat/Messages/UserMessage.svelte @@ -24,6 +24,8 @@ editElement.style.height = ''; editElement.style.height = `${editElement.scrollHeight}px`; + + editElement?.focus(); }; const editMessageConfirmHandler = async () => { @@ -43,7 +45,9 @@
- You +
+ You +
{ editMessageHandler(); }}