From bdecea3234ce477b1ca282171e6a341b9934e902 Mon Sep 17 00:00:00 2001 From: anor Date: Fri, 17 Jul 2026 21:35:56 +1000 Subject: [PATCH] =?UTF-8?q?feat(UI=201.4):=20=D1=83=D0=BC=D0=BD=D1=8B?= =?UTF-8?q?=D0=B9=20=D0=B0=D0=B2=D1=82=D0=BE=D1=81=D0=BA=D1=80=D0=BE=D0=BB?= =?UTF-8?q?=D0=BB=20(=D0=BD=D0=B5=20=D0=BC=D0=B5=D1=88=D0=B0=D1=82=D1=8C?= =?UTF-8?q?=20=D1=87=D1=82=D0=B5=D0=BD=D0=B8=D1=8E)=20+=20=D0=BA=D0=BD?= =?UTF-8?q?=D0=BE=D0=BF=D0=BA=D0=B0=20=C2=AB=E2=86=93=C2=BB;=20bump=202026?= =?UTF-8?q?-07-17h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit scrollIfPinned() вместо жёсткого scrollTop=scrollHeight (скролл к низу только если у дна); плавающая .jump-latest с aria-label показывается при отскролле вверх/во время стрима. Co-Authored-By: Claude Opus 4.8 (1M context) --- main.py | 2 +- static/chat.html | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 4d3d909..b42891e 100644 --- a/main.py +++ b/main.py @@ -138,7 +138,7 @@ MAX_MESSAGE_LEN = 10_000 # ⚠️ Версия UI — единый источник. БАМПАТЬ ПРИ КАЖДОМ ДЕПЛОЕ (формат: YYYY-MM-DD + буква). # Фронт берёт её через GET /api/version (chat.html + admin.html, элемент .app-version). -APP_VERSION = "2026-07-17g" +APP_VERSION = "2026-07-17h" # Audit: path → action name mapping _AUDIT_MAP = [ diff --git a/static/chat.html b/static/chat.html index e6ec5b2..10922b4 100644 --- a/static/chat.html +++ b/static/chat.html @@ -82,6 +82,8 @@ button { font-family: inherit; } .retry-btn { display: inline-block; margin-top: .5rem; background: transparent; border: 1px solid #e03131; border-radius: 6px; cursor: pointer; font-size: .78rem; padding: .25rem .7rem; color: #e03131; transition: all .15s; } .retry-btn:hover { background: rgba(224,49,49,.08); } :root[data-theme="dark"] .retry-btn { border-color: #ff8585; color: #ff8585; } +.jump-latest { position: fixed; right: 24px; bottom: 100px; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer; font-size: 1.15rem; line-height: 1; display: none; align-items: center; justify-content: center; box-shadow: 0 2px 10px rgba(0,0,0,.18); z-index: 50; } +.jump-latest:hover { background: var(--bg-hover, var(--border)); } .msg-system { align-self: center; background: var(--system-bg); border: none; font-size: .8rem; color: var(--system-text); box-shadow: none; padding: .4rem .8rem; } .typing { align-self: flex-start; color: var(--text-light); font-style: italic; font-size: .85rem; padding: .4rem 0; } @@ -679,6 +681,17 @@ async function authFetch(url, opts={}) { // --- Messages --- const msgs = document.getElementById('messages'); +// Умный автоскролл: скроллим к низу только если пользователь уже «у дна» (иначе +// он читает выше — не дёргаем). Кнопка «↓» возвращает вниз. +function isPinned() { return msgs.scrollHeight - msgs.scrollTop - msgs.clientHeight < 80; } +function scrollIfPinned() { if (isPinned()) { msgs.scrollTop = msgs.scrollHeight; } else { jumpBtn.style.display = 'flex'; } } +const jumpBtn = document.createElement('button'); +jumpBtn.className = 'jump-latest'; jumpBtn.textContent = '↓'; +jumpBtn.title = 'К последнему'; jumpBtn.setAttribute('aria-label', 'К последнему сообщению'); +jumpBtn.style.display = 'none'; +jumpBtn.onclick = () => { msgs.scrollTop = msgs.scrollHeight; jumpBtn.style.display = 'none'; }; +document.body.appendChild(jumpBtn); +msgs.addEventListener('scroll', () => { jumpBtn.style.display = isPinned() ? 'none' : 'flex'; }); function addMsg(type, text, ts) { const div = document.createElement('div'); div.className = 'msg msg-' + type; @@ -734,7 +747,7 @@ function addMsg(type, text, ts) { div.appendChild(rep); } msgs.appendChild(div); - msgs.scrollTop = msgs.scrollHeight; + scrollIfPinned(); return div; } function addTyping() { @@ -743,7 +756,7 @@ function addTyping() { div.id = 'typing-indicator'; div.textContent = 'Claude думает...'; msgs.appendChild(div); - msgs.scrollTop = msgs.scrollHeight; + scrollIfPinned(); return div; } function removeTyping() { @@ -994,7 +1007,7 @@ async function runChat(text) { aiDiv.innerHTML = renderMarkdown(aiText); if (timeEl) aiDiv.prepend(timeEl); ctrlBtns.forEach(b => aiDiv.appendChild(b)); - msgs.scrollTop = msgs.scrollHeight; + scrollIfPinned(); } else if (eventType === 'tool') { // Show minimal status, not raw code const toolNames = {Bash: 'Выполняю...', Read: 'Читаю файл...', Write: 'Создаю файл...', Edit: 'Редактирую...', Glob: 'Ищу файлы...', Grep: 'Ищу в файлах...'};