Fix spinner location

This commit is contained in:
dwrz
2026-06-26 14:50:39 +00:00
parent f6fb21d40c
commit 3e60e6be03

View File

@@ -160,7 +160,9 @@ class Odidere {
this.isAutoScrollEnabled = true; this.isAutoScrollEnabled = true;
this._lastScrollTop = 0; this._lastScrollTop = 0;
localStorage.removeItem(STORAGE_KEY); localStorage.removeItem(STORAGE_KEY);
this.$chat.innerHTML = ''; this.$chat.querySelectorAll(':scope > .message').forEach((el) => {
el.remove();
});
this.#clearAttachments(); this.#clearAttachments();
this.$textInput.value = ''; this.$textInput.value = '';
this.$textInput.style.height = 'auto'; this.$textInput.style.height = 'auto';
@@ -1805,7 +1807,7 @@ class Odidere {
this.$send.classList.toggle('loading', loading); this.$send.classList.toggle('loading', loading);
this.$send.setAttribute('aria-label', loading ? 'Stop' : 'Send message'); this.$send.setAttribute('aria-label', loading ? 'Stop' : 'Send message');
// Show/hide the spinner in the chat area. // 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; this.$chatLoading.hidden = !loading;
// Keep the send button enabled during loading so it can act as a stop button. // Keep the send button enabled during loading so it can act as a stop button.
this.$ptt.disabled = loading; this.$ptt.disabled = loading;
@@ -2164,11 +2166,6 @@ class Odidere {
this.#renderAssistantMessage(msg, msg.meta ?? meta, toolResults); 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.#handleDeleteClick(e, message.id),
); );
this.$chat.appendChild($msg); this.$chat.insertBefore($msg, this.$chatLoading);
this.#scrollToBottom(); this.#scrollToBottom();
} }
@@ -2250,7 +2247,7 @@ class Odidere {
$msg.querySelector('[data-action="copy"]').remove(); $msg.querySelector('[data-action="copy"]').remove();
$msg.querySelector('[data-action="delete"]').remove(); $msg.querySelector('[data-action="delete"]').remove();
this.$chat.appendChild($msg); this.$chat.insertBefore($msg, this.$chatLoading);
this.#scrollToBottom(); this.#scrollToBottom();
return $msg; return $msg;
} }
@@ -2465,7 +2462,7 @@ class Odidere {
this.#handleDeleteClick(e, message.id), this.#handleDeleteClick(e, message.id),
); );
this.$chat.appendChild($msg); this.$chat.insertBefore($msg, this.$chatLoading);
this.#scrollToBottom(); this.#scrollToBottom();
} }
@@ -2478,7 +2475,7 @@ class Odidere {
this.$tplErrorMessage.content.cloneNode(true).firstElementChild; this.$tplErrorMessage.content.cloneNode(true).firstElementChild;
$msg.querySelector('.message__content').textContent = message; $msg.querySelector('.message__content').textContent = message;
this.$chat.appendChild($msg); this.$chat.insertBefore($msg, this.$chatLoading);
this.#scrollToBottom(); this.#scrollToBottom();
} }