From 3e60e6be03a710c2802f9bf620db32bf99b213a0 Mon Sep 17 00:00:00 2001 From: dwrz Date: Fri, 26 Jun 2026 14:50:39 +0000 Subject: [PATCH] Fix spinner location --- internal/service/static/main.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/internal/service/static/main.js b/internal/service/static/main.js index db48368..a426743 100644 --- a/internal/service/static/main.js +++ b/internal/service/static/main.js @@ -160,7 +160,9 @@ class Odidere { this.isAutoScrollEnabled = true; this._lastScrollTop = 0; localStorage.removeItem(STORAGE_KEY); - this.$chat.innerHTML = ''; + this.$chat.querySelectorAll(':scope > .message').forEach((el) => { + el.remove(); + }); this.#clearAttachments(); this.$textInput.value = ''; this.$textInput.style.height = 'auto'; @@ -1805,7 +1807,7 @@ class Odidere { this.$send.classList.toggle('loading', loading); this.$send.setAttribute('aria-label', loading ? 'Stop' : 'Send message'); // Show/hide the spinner in the chat area. - // Positioning is handled by #renderMessages to ensure it's always at the end. + // The spinner is a permanent last child of #chat; messages are inserted before it. this.$chatLoading.hidden = !loading; // Keep the send button enabled during loading so it can act as a stop button. this.$ptt.disabled = loading; @@ -2164,11 +2166,6 @@ class Odidere { this.#renderAssistantMessage(msg, msg.meta ?? meta, toolResults); } - - // Ensure the loading spinner is always at the end of the chat. - if (!this.$chatLoading.hidden) { - this.$chat.appendChild(this.$chatLoading); - } } /** @@ -2218,7 +2215,7 @@ class Odidere { this.#handleDeleteClick(e, message.id), ); - this.$chat.appendChild($msg); + this.$chat.insertBefore($msg, this.$chatLoading); this.#scrollToBottom(); } @@ -2250,7 +2247,7 @@ class Odidere { $msg.querySelector('[data-action="copy"]').remove(); $msg.querySelector('[data-action="delete"]').remove(); - this.$chat.appendChild($msg); + this.$chat.insertBefore($msg, this.$chatLoading); this.#scrollToBottom(); return $msg; } @@ -2465,7 +2462,7 @@ class Odidere { this.#handleDeleteClick(e, message.id), ); - this.$chat.appendChild($msg); + this.$chat.insertBefore($msg, this.$chatLoading); this.#scrollToBottom(); } @@ -2478,7 +2475,7 @@ class Odidere { this.$tplErrorMessage.content.cloneNode(true).firstElementChild; $msg.querySelector('.message__content').textContent = message; - this.$chat.appendChild($msg); + this.$chat.insertBefore($msg, this.$chatLoading); this.#scrollToBottom(); }