From e7ca027116b1f3dd45188462232d1f0c1a5524ae Mon Sep 17 00:00:00 2001 From: anor Date: Thu, 26 Mar 2026 16:02:59 +1000 Subject: [PATCH] =?UTF-8?q?feat:=20=D0=B4=D0=B0=D1=82=D0=B0=20=D0=B8=20?= =?UTF-8?q?=D0=B2=D1=80=D0=B5=D0=BC=D1=8F=20=D1=81=D0=BE=D0=BE=D0=B1=D1=89?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B9=20=D0=B2=20=D1=87=D0=B0=D1=82=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Каждое сообщение показывает timestamp (дд.мм.гг, чч:мм). Новые сообщения — текущее время, история — из БД. Co-Authored-By: Claude Opus 4.6 (1M context) --- static/chat.html | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/static/chat.html b/static/chat.html index ed4b835..f28a547 100644 --- a/static/chat.html +++ b/static/chat.html @@ -43,7 +43,8 @@ body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Robo .header-actions button:hover { background: var(--bg); border-color: var(--accent); color: var(--accent); } #messages { flex: 1; overflow-y: auto; padding: 1.2rem 1rem; display: flex; flex-direction: column; gap: .7rem; max-width: 900px; width: 100%; margin: 0 auto; } -.msg { max-width: 85%; padding: .8rem 1.1rem; border-radius: var(--radius-lg); line-height: 1.6; white-space: pre-wrap; word-break: break-word; font-size: .9rem; box-shadow: var(--shadow-sm); } +.msg { max-width: 85%; padding: .8rem 1.1rem; border-radius: var(--radius-lg); line-height: 1.6; white-space: pre-wrap; word-break: break-word; font-size: .9rem; box-shadow: var(--shadow-sm); position: relative; } +.msg-time { display: block; font-size: .65rem; color: var(--text-muted, #999); margin-bottom: .3rem; opacity: .7; } .msg-user { align-self: flex-end; background: var(--user-bg); color: var(--user-text); border-bottom-right-radius: 4px; } .msg-ai { align-self: flex-start; background: var(--ai-bg); border: 1px solid var(--ai-border); border-bottom-left-radius: 4px; } @@ -210,15 +211,23 @@ function authHeaders() { // --- Messages --- const msgs = document.getElementById('messages'); -function addMsg(type, text) { +function addMsg(type, text, ts) { const div = document.createElement('div'); div.className = 'msg msg-' + type; + // Timestamp + const time = document.createElement('span'); + time.className = 'msg-time'; + const d = ts ? new Date(ts < 1e12 ? ts * 1000 : ts) : new Date(); + time.textContent = d.toLocaleString('ru-RU', {day:'2-digit',month:'2-digit',year:'2-digit',hour:'2-digit',minute:'2-digit'}); + div.appendChild(time); // Store raw text for copy and streaming div._rawText = text; if (type === 'ai') { div.innerHTML = renderMarkdown(text); + div.prepend(time); } else { div.textContent = text; + div.prepend(time); } if (type !== 'system') { const btn = document.createElement('button'); @@ -446,9 +455,9 @@ async function loadHistory() { if (history.length === 0) return; msgs.innerHTML = ''; for (const m of history) { - if (m.role === 'user') addMsg('user', m.content); - else if (m.role === 'assistant') addMsg('ai', m.content); - else if (m.role === 'system') addMsg('system', m.content); + if (m.role === 'user') addMsg('user', m.content, m.timestamp); + else if (m.role === 'assistant') addMsg('ai', m.content, m.timestamp); + else if (m.role === 'system') addMsg('system', m.content, m.timestamp); } } catch {} }