diff --git a/src/khoj/interface/web/chat.html b/src/khoj/interface/web/chat.html index f8fd2a60..44bfdaeb 100644 --- a/src/khoj/interface/web/chat.html +++ b/src/khoj/interface/web/chat.html @@ -61,6 +61,7 @@ // Add message by user to chat body renderMessage(query, "you"); document.getElementById("chat-input").value = ""; + autoResize(); document.getElementById("chat-input").setAttribute("disabled", "disabled"); // Generate backend API URL to execute query @@ -128,12 +129,21 @@ } function incrementalChat(event) { - // Send chat message on 'Enter' - if (event.key === 'Enter') { + if (!event.shiftKey && event.key === 'Enter') { chat(); } } + function autoResize() { + const textarea = document.getElementById('chat-input'); + const scrollTop = textarea.scrollTop; + textarea.style.height = '0'; + const scrollHeight = textarea.scrollHeight; + textarea.style.height = Math.min(scrollHeight, 200) + 'px'; + textarea.scrollTop = scrollTop; + document.getElementById("chat-body").scrollTop = document.getElementById("chat-body").scrollHeight; + } + window.onload = function () { fetch('/api/chat/history?client=web') .then(response => response.json()) @@ -207,7 +217,7 @@