diff --git a/wwwroot/js/history.js b/wwwroot/js/history.js index 5c7ab13..ff7c4d3 100644 --- a/wwwroot/js/history.js +++ b/wwwroot/js/history.js @@ -110,7 +110,7 @@ async function loadLatestArchive() { switch (msg.type) { case 'text': div.className = msg.role === 'user' ? 'msg user archived' : 'msg assistant archived'; - div.textContent = msg.content; + div.textContent = (msg.content || '').trim(); if (msg.role === 'user' && msg.attachmentCount > 0) { let names = []; try { if (msg.attachmentNames) names = JSON.parse(msg.attachmentNames); } catch {} @@ -137,7 +137,7 @@ async function loadLatestArchive() { case 'error': div.className = 'msg system-info archived'; div.style.color = '#ff6b6b'; - div.textContent = msg.content; + div.textContent = (msg.content || '').trim(); break; default: continue; diff --git a/wwwroot/js/ui.js b/wwwroot/js/ui.js index 51d2614..e470d37 100644 --- a/wwwroot/js/ui.js +++ b/wwwroot/js/ui.js @@ -25,7 +25,7 @@ function addUserBubble(text, streamed = false) { const div = document.createElement('div'); div.className = 'msg user'; if (streamed) div.classList.add('streamed'); - div.textContent = text; + div.textContent = (text || '').trim(); chatEl().appendChild(div); scrollDown(); } @@ -33,7 +33,7 @@ function addUserBubble(text, streamed = false) { function addAssistantBubble(text) { const div = document.createElement('div'); div.className = 'msg assistant'; - div.textContent = text; + div.textContent = (text || '').trim(); chatEl().appendChild(div); scrollDown(); return div; @@ -44,7 +44,7 @@ function addErrorBubble(text, streamed = false) { div.className = 'msg system-info'; if (streamed) div.classList.add('streamed'); div.style.color = '#ff6b6b'; - div.textContent = text; + div.textContent = (text || '').trim(); chatEl().appendChild(div); scrollDown(); }