feat: enhance thinking indicator with reasoning text support
All checks were successful
BotUI CI/CD / build (push) Successful in 40s

This commit is contained in:
Rodrigo Rodriguez (Pragmatismo) 2026-04-14 17:14:12 -03:00
parent c5c042320c
commit 8baae78692

View file

@ -816,7 +816,7 @@ function finalizeStreaming() {
function processMessage(data) {
// Handle thinking indicator from backend
if (data.type === "thinking") {
showThinkingIndicator();
showThinkingIndicator(data.content);
return;
}
if (data.type === "thinking_clear") {
@ -861,8 +861,15 @@ function finalizeStreaming() {
// Thinking indicator (shown while LLM is in reasoning mode)
var thinkingIndicator = null;
function showThinkingIndicator() {
if (thinkingIndicator) return; // Already showing
function showThinkingIndicator(content) {
var text = content || "🤔 Pensando...";
if (thinkingIndicator) {
var textEl = thinkingIndicator.querySelector(".thinking-text");
if (textEl && content) {
textEl.textContent = text;
}
return;
}
var messages = document.getElementById("messages");
if (!messages) return;
@ -872,7 +879,7 @@ function finalizeStreaming() {
thinkingIndicator.className = "message bot";
thinkingIndicator.innerHTML =
'<div class="message-content bot-message">' +
'<span class="thinking-text">🤔 Pensando...</span>' +
'<span class="thinking-text">' + escapeHtml(text) + '</span>' +
"</div>";
messages.appendChild(thinkingIndicator);
scrollToBottom(true);
@ -1142,6 +1149,10 @@ function finalizeStreaming() {
applyThemeData(contentObj.data || {});
return;
}
if (contentObj.type === "thinking" || contentObj.type === "thinking_clear") {
processMessage(contentObj);
return;
}
} catch (e) {
// Content is not JSON, continue processing
}