From 398218b8dd8daeb1748824a1f694bccc88db1ac2 Mon Sep 17 00:00:00 2001 From: anor Date: Tue, 24 Mar 2026 21:44:31 +1000 Subject: [PATCH] =?UTF-8?q?fix:=20=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=9A=D0=BE=D0=BF=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=20?= =?UTF-8?q?=D0=B2=D0=B8=D0=B4=D0=BD=D0=B0=20=D0=BF=D1=80=D0=B8=20=D1=81?= =?UTF-8?q?=D1=82=D1=80=D0=B8=D0=BC=D0=B8=D0=BD=D0=B3=D0=B5=20(=D0=BD?= =?UTF-8?q?=D0=B5=20=D0=B7=D0=B0=D1=82=D0=B8=D1=80=D0=B0=D0=B5=D1=82=D1=81?= =?UTF-8?q?=D1=8F=20textContent)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Проблема: aiDiv.textContent = aiText перезаписывал весь контент включая кнопку. Теперь обновляется только текстовая нода (firstChild). Co-Authored-By: Claude Opus 4.6 (1M context) --- static/chat.html | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/static/chat.html b/static/chat.html index 9eaae98..087d450 100644 --- a/static/chat.html +++ b/static/chat.html @@ -160,7 +160,8 @@ function addMsg(type, text) { btn.className = 'copy-btn'; btn.textContent = 'Копировать'; btn.onclick = () => { - navigator.clipboard.writeText(div.textContent.replace('Копировать', '').trim()); + const text = div.firstChild ? div.firstChild.textContent.trim() : div.textContent.replace('Копировать', '').trim(); + navigator.clipboard.writeText(text); btn.textContent = 'Скопировано'; btn.classList.add('copied'); setTimeout(() => { btn.textContent = 'Копировать'; btn.classList.remove('copied'); }, 1500); @@ -299,9 +300,12 @@ async function sendMessage() { } else if (line.startsWith('data: ')) { const data = JSON.parse(line.slice(6)); if (eventType === 'text') { - if (!aiDiv) aiDiv = addMsg('ai', ''); + if (!aiDiv) { + aiDiv = addMsg('ai', ''); + aiDiv._textNode = aiDiv.firstChild; // text node before copy button + } aiText += data.text; - aiDiv.textContent = aiText; + if (aiDiv._textNode) aiDiv._textNode.textContent = aiText; msgs.scrollTop = msgs.scrollHeight; } else if (eventType === 'tool') { // Show minimal status, not raw code