diff --git a/public/app.js b/public/app.js index 38cc047..c220559 100644 --- a/public/app.js +++ b/public/app.js @@ -1141,6 +1141,20 @@ async function viewThread(main, id) { renderThread(main); } +function chatMsgHTML(m, c) { + const isMsgError = m.isError || /^\[(?:Fehler|Error)\]/i.test(m.text || ''); + return ` +
+ ${m.sender === 'user' ? '' : ` +
+ ${avatar(c.name, c.avatarKey, 'xs')} + ${esc(c.name)} +
+ `} +
${esc(m.text)}
+
`; +} + function renderThread(main) { const { character: c, messages, recentActivity } = state.chat; main.innerHTML = ` @@ -1161,14 +1175,7 @@ function renderThread(main) { : '' }
- ${messages.length ? messages.map((m) => { - const isMsgError = m.isError || /^\[(?:Fehler|Error)\]/i.test(m.text || ''); - return ` -
- ${m.sender === 'user' ? '' : `
${esc(c.name)}
`} -
${esc(m.text)}
-
`; - }).join('') : `
${getNoMsgsText(c)}
`} + ${messages.length ? messages.map((m) => chatMsgHTML(m, c)).join('') : `
${getNoMsgsText(c)}
`}
@@ -1178,6 +1185,13 @@ function renderThread(main) { $('[data-go]', main).addEventListener('click', () => go('chats')); $('#prof').addEventListener('click', () => go('char', c.id)); + $('#thread')?.addEventListener('click', (e) => { + const who = e.target.closest('[data-go-char]'); + if (who) { + const charId = who.getAttribute('data-go-char'); + if (charId) go('char', charId); + } + }); $('#del-thread')?.addEventListener('click', async () => { if (!confirm(t('confirm_delete_chat'))) return; const btn = $('#del-thread'); @@ -2467,10 +2481,7 @@ function initPolling() { state.chat.messages = fresh.messages; const thread = $('#thread'); if (thread) { - thread.innerHTML = fresh.messages.map((m) => ` -
- ${m.sender === 'user' ? '' : `
${esc(state.chat.character.name)}
`}${esc(m.text)} -
`).join('') + '
'; + thread.innerHTML = fresh.messages.map((m) => chatMsgHTML(m, state.chat.character)).join('') + '
'; $('#thread-end')?.scrollIntoView({ block: 'end' }); } } diff --git a/public/styles.css b/public/styles.css index 596e858..1a8248f 100644 --- a/public/styles.css +++ b/public/styles.css @@ -60,6 +60,7 @@ img{max-width:100%;display:block} .post-head{display:flex;gap:10px;align-items:center;margin-bottom:8px} .avatar{width:42px;height:42px;border-radius:50%;flex:none;display:grid;place-items:center;font-weight:700;color:#fff;font-size:16px; background:linear-gradient(135deg,var(--acc),var(--acc2)); object-fit:cover; overflow:hidden} +.avatar.xs{width:20px;height:20px;min-width:20px;min-height:20px;font-size:10px;line-height:1;border-radius:50%;flex:none} .avatar.sm{width:32px;height:32px;font-size:13px} .avatar.lg{width:72px;height:72px;font-size:28px} .who{display:flex;flex-direction:column;line-height:1.25;min-width:0} @@ -144,11 +145,15 @@ input[type=text]:focus,input[type=number]:focus,input[type=password]:focus,texta .chat-list .chat-item:hover{background:var(--card)} .chat-item .last{color:var(--muted);font-size:13.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:56vw} .chat-item .cnt{margin-left:auto;font-size:12px;background:var(--bg2);border:1px solid var(--line);color:var(--muted);border-radius:999px;padding:3px 9px;flex:none} -.thread{display:flex;flex-direction:column;gap:10px;padding-bottom:8px} -.msg{max-width:82%;padding:10px 14px;border-radius:20px;font-size:15px;line-height:1.45;white-space:pre-wrap;word-break:break-word} -.msg.user{align-self:flex-end;background:linear-gradient(135deg,var(--acc),var(--acc2));color:#fff;border-bottom-right-radius:6px} -.msg.char{align-self:flex-start;background:var(--card);border:1px solid var(--line);border-bottom-left-radius:6px} -.msg.char .who-line{font-size:12px;color:var(--acc);font-weight:700;margin-bottom:3px} +.thread{display:flex;flex-direction:column;gap:6px;padding-bottom:8px} +.msg{display:inline-flex;flex-direction:column;width:fit-content;max-width:min(78%, 460px);padding:7px 11px;border-radius:14px;font-size:14px;line-height:1.4;white-space:pre-wrap;word-break:break-word;overflow-wrap:break-word;box-sizing:border-box} +.msg.user{align-self:flex-end;background:linear-gradient(135deg,var(--acc),var(--acc2));color:#fff;border-bottom-right-radius:4px} +.msg.char{align-self:flex-start;background:var(--card);border:1px solid var(--line);border-bottom-left-radius:4px;padding:5px 11px 7px} +.msg.char .who-line{display:inline-flex;align-items:center;gap:6px;font-size:11.5px;color:var(--acc);font-weight:700;margin-bottom:3px;line-height:1.2;cursor:pointer;user-select:none;max-width:100%} +.msg.char .who-line:hover .who-name{text-decoration:underline} +.msg.char .who-line .who-name{white-space:nowrap;overflow:hidden;text-overflow:ellipsis} +.msg-content{white-space:pre-wrap;word-break:break-word;overflow-wrap:break-word} +.msg.typing{padding:8px 12px;height:32px;display:inline-flex;align-items:center} .chat-input{position:sticky;bottom:calc(var(--nav-h) + 6px);display:flex;gap:8px;background:var(--bg);padding-top:8px} .chat-input input{border-radius:999px} .ctx-note{font-size:12.5px;color:var(--muted);background:var(--card);border:1px dashed var(--line);border-radius:12px;padding:8px 12px;margin-bottom:10px}