feat(UI 1.4): умный автоскролл (не мешать чтению) + кнопка «↓»; bump 2026-07-17h
scrollIfPinned() вместо жёсткого scrollTop=scrollHeight (скролл к низу только если у дна); плавающая .jump-latest с aria-label показывается при отскролле вверх/во время стрима. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -138,7 +138,7 @@ MAX_MESSAGE_LEN = 10_000
|
|||||||
|
|
||||||
# ⚠️ Версия UI — единый источник. БАМПАТЬ ПРИ КАЖДОМ ДЕПЛОЕ (формат: YYYY-MM-DD + буква).
|
# ⚠️ Версия UI — единый источник. БАМПАТЬ ПРИ КАЖДОМ ДЕПЛОЕ (формат: YYYY-MM-DD + буква).
|
||||||
# Фронт берёт её через GET /api/version (chat.html + admin.html, элемент .app-version).
|
# Фронт берёт её через 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: path → action name mapping
|
||||||
_AUDIT_MAP = [
|
_AUDIT_MAP = [
|
||||||
|
|||||||
+16
-3
@@ -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 { 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); }
|
.retry-btn:hover { background: rgba(224,49,49,.08); }
|
||||||
:root[data-theme="dark"] .retry-btn { border-color: #ff8585; color: #ff8585; }
|
: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; }
|
.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; }
|
.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 ---
|
// --- Messages ---
|
||||||
const msgs = document.getElementById('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) {
|
function addMsg(type, text, ts) {
|
||||||
const div = document.createElement('div');
|
const div = document.createElement('div');
|
||||||
div.className = 'msg msg-' + type;
|
div.className = 'msg msg-' + type;
|
||||||
@@ -734,7 +747,7 @@ function addMsg(type, text, ts) {
|
|||||||
div.appendChild(rep);
|
div.appendChild(rep);
|
||||||
}
|
}
|
||||||
msgs.appendChild(div);
|
msgs.appendChild(div);
|
||||||
msgs.scrollTop = msgs.scrollHeight;
|
scrollIfPinned();
|
||||||
return div;
|
return div;
|
||||||
}
|
}
|
||||||
function addTyping() {
|
function addTyping() {
|
||||||
@@ -743,7 +756,7 @@ function addTyping() {
|
|||||||
div.id = 'typing-indicator';
|
div.id = 'typing-indicator';
|
||||||
div.textContent = 'Claude думает...';
|
div.textContent = 'Claude думает...';
|
||||||
msgs.appendChild(div);
|
msgs.appendChild(div);
|
||||||
msgs.scrollTop = msgs.scrollHeight;
|
scrollIfPinned();
|
||||||
return div;
|
return div;
|
||||||
}
|
}
|
||||||
function removeTyping() {
|
function removeTyping() {
|
||||||
@@ -994,7 +1007,7 @@ async function runChat(text) {
|
|||||||
aiDiv.innerHTML = renderMarkdown(aiText);
|
aiDiv.innerHTML = renderMarkdown(aiText);
|
||||||
if (timeEl) aiDiv.prepend(timeEl);
|
if (timeEl) aiDiv.prepend(timeEl);
|
||||||
ctrlBtns.forEach(b => aiDiv.appendChild(b));
|
ctrlBtns.forEach(b => aiDiv.appendChild(b));
|
||||||
msgs.scrollTop = msgs.scrollHeight;
|
scrollIfPinned();
|
||||||
} else if (eventType === 'tool') {
|
} else if (eventType === 'tool') {
|
||||||
// Show minimal status, not raw code
|
// Show minimal status, not raw code
|
||||||
const toolNames = {Bash: 'Выполняю...', Read: 'Читаю файл...', Write: 'Создаю файл...', Edit: 'Редактирую...', Glob: 'Ищу файлы...', Grep: 'Ищу в файлах...'};
|
const toolNames = {Bash: 'Выполняю...', Read: 'Читаю файл...', Write: 'Создаю файл...', Edit: 'Редактирую...', Glob: 'Ищу файлы...', Grep: 'Ищу в файлах...'};
|
||||||
|
|||||||
Reference in New Issue
Block a user