diff --git a/README.md b/README.md index ddd255f..69f57fb 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ whiskr is a private, self-hosted web chat interface for interacting with AI mode ## TODO - resizable chat box +- cost tracker - settings - auto-retry on edit - ctrl+enter vs enter for sending diff --git a/static/js/chat.js b/static/js/chat.js index 68f2e34..1ac6ddc 100644 --- a/static/js/chat.js +++ b/static/js/chat.js @@ -39,8 +39,20 @@ let searchAvailable = false, activeMessage; + function updateScrollButton() { + const bottom = $messages.scrollHeight - ($messages.scrollTop + $messages.offsetHeight); + + if (bottom >= 80) { + $bottom.classList.remove("hidden"); + } else { + $bottom.classList.add("hidden"); + } + } + function scroll(force = false) { if (!autoScrolling && !force) { + updateScrollButton(); + return; } @@ -160,13 +172,13 @@ _toggle.addEventListener("click", () => { this.#expanded = !this.#expanded; + this.#_message.classList.toggle("expanded", this.#expanded); + if (this.#expanded) { this.#updateReasoningHeight(); - - this.#_message.classList.add("expanded"); - } else { - this.#_message.classList.remove("expanded"); } + + updateScrollButton(); }); // message reasoning (height wrapper) @@ -211,6 +223,8 @@ _call.addEventListener("click", () => { this.#_tool.classList.toggle("expanded"); + + updateScrollButton(); }); // tool call name @@ -423,6 +437,8 @@ this.#updateToolHeight(); noScroll || scroll(); + + updateScrollButton(); } if (!only || only === "statistics") { @@ -435,7 +451,7 @@ price = cost < 1 ? `${fixed(cost * 100, 1)}ct` : `$${fixed(cost, 2)}`; html = [ - provider ? `