GUI refinements: drop redundant general-settings drawer entry and topbar delete; per-turn decode speed + first-token lag in the answer badge; compact date+time on message bubbles
This commit is contained in:
1 parent
08ce62bdec
commit
0754262b37
5 files changed
+32
-19
No files matched your search
@@ -124,6 +124,7 @@ body.resizing { cursor: col-resize; user-select: none; }
|
|||||||
/* ---- Message bubbles ---- */
|
/* ---- Message bubbles ---- */
|
||||||
.msg { max-width: 860px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; }
|
.msg { max-width: 860px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; }
|
||||||
.msg .role { font-size: 0.75rem; color: var(--muted); margin-bottom: 4px; }
|
.msg .role { font-size: 0.75rem; color: var(--muted); margin-bottom: 4px; }
|
||||||
|
.msg .role .when { font-variant-numeric: tabular-nums; opacity: 0.85; }
|
||||||
.msg.user { align-items: flex-end; }
|
.msg.user { align-items: flex-end; }
|
||||||
.msg.user .bubble {
|
.msg.user .bubble {
|
||||||
background: var(--user); border-radius: var(--radius) var(--radius) 4px var(--radius);
|
background: var(--user); border-radius: var(--radius) var(--radius) 4px var(--radius);
|
||||||
|
|||||||
+29
-15
@@ -59,9 +59,11 @@ function el(tag, cls, text) {
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
function messageNode(role, content, reasoning, usage) {
|
function messageNode(role, content, reasoning, usage, ts) {
|
||||||
const wrap = el("div", `msg ${role}`);
|
const wrap = el("div", `msg ${role}`);
|
||||||
wrap.appendChild(el("div", "role", role === "user" ? "Tu" : "Assistente"));
|
const roleNode = el("div", "role", role === "user" ? "Tu" : "Assistente");
|
||||||
|
if (ts) roleNode.appendChild(el("span", "when", " · " + stampLabel(ts)));
|
||||||
|
wrap.appendChild(roleNode);
|
||||||
const bubble = el("div", "bubble");
|
const bubble = el("div", "bubble");
|
||||||
if (reasoning) {
|
if (reasoning) {
|
||||||
const det = el("details", "thinking");
|
const det = el("details", "thinking");
|
||||||
@@ -81,7 +83,23 @@ function scrollDown() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function usageText(u) {
|
function usageText(u) {
|
||||||
return u ? `${u.prompt_tokens} + ${u.completion_tokens} token` : null;
|
if (!u) return null;
|
||||||
|
let s = `${u.prompt_tokens} + ${u.completion_tokens} token`;
|
||||||
|
// Per-turn perf when the engine reported timings (live turns; history keeps
|
||||||
|
// only token counts): decode tok/s + first-token lag (engine prefill ms).
|
||||||
|
if (u.decode_ms > 0 && u.completion_tokens > 0) {
|
||||||
|
s += " · " + t("stats.tps", { n: fmt1(u.completion_tokens / (u.decode_ms / 1000)) });
|
||||||
|
}
|
||||||
|
if (u.prompt_ms > 0) s += " · " + t("usage.ttft", { n: fmtInt(u.prompt_ms) });
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compact locale-aware date+time for a message bubble (epoch seconds).
|
||||||
|
function stampLabel(secs) {
|
||||||
|
const d = new Date(secs * 1000);
|
||||||
|
const date = d.toLocaleDateString(I18N.lang, { day: "2-digit", month: "2-digit" });
|
||||||
|
const time = d.toLocaleTimeString(I18N.lang, { hour: "2-digit", minute: "2-digit" });
|
||||||
|
return `${date} ${time}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// A tool-call block (command + an output area filled when the result arrives).
|
// A tool-call block (command + an output area filled when the result arrives).
|
||||||
@@ -145,7 +163,7 @@ function renderTranscript(messages) {
|
|||||||
}
|
}
|
||||||
for (const m of messages) {
|
for (const m of messages) {
|
||||||
if (m.role === "user") {
|
if (m.role === "user") {
|
||||||
t.appendChild(messageNode("user", m.content));
|
t.appendChild(messageNode("user", m.content, null, null, m.created_at));
|
||||||
} else if (m.role === "tool") {
|
} else if (m.role === "tool") {
|
||||||
t.appendChild(toolResultNode(m.content));
|
t.appendChild(toolResultNode(m.content));
|
||||||
} else if (m.role === "assistant") {
|
} else if (m.role === "assistant") {
|
||||||
@@ -161,7 +179,7 @@ function renderTranscript(messages) {
|
|||||||
const usage = m.completion_tokens
|
const usage = m.completion_tokens
|
||||||
? usageText({ prompt_tokens: m.prompt_tokens, completion_tokens: m.completion_tokens })
|
? usageText({ prompt_tokens: m.prompt_tokens, completion_tokens: m.completion_tokens })
|
||||||
: null;
|
: null;
|
||||||
t.appendChild(messageNode("assistant", m.content, m.reasoning_content, usage));
|
t.appendChild(messageNode("assistant", m.content, m.reasoning_content, usage, m.created_at));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -201,10 +219,6 @@ async function newSession() {
|
|||||||
$("#input").focus();
|
$("#input").focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteSession() {
|
|
||||||
if (state.current) await deleteSessionById(state.current);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function renameSessionById(id, currentTitle) {
|
async function renameSessionById(id, currentTitle) {
|
||||||
const input = await showDialog({ title: "Rinomina chat", input: currentTitle, okText: "Salva" });
|
const input = await showDialog({ title: "Rinomina chat", input: currentTitle, okText: "Salva" });
|
||||||
if (input === null) return;
|
if (input === null) return;
|
||||||
@@ -302,7 +316,7 @@ async function sendMessage() {
|
|||||||
const t = $("#transcript");
|
const t = $("#transcript");
|
||||||
const empty = t.querySelector(".empty");
|
const empty = t.querySelector(".empty");
|
||||||
if (empty) empty.remove();
|
if (empty) empty.remove();
|
||||||
const userNode = messageNode("user", content);
|
const userNode = messageNode("user", content, null, null, Date.now() / 1000);
|
||||||
if (attachments.length) {
|
if (attachments.length) {
|
||||||
const row = el("div", "msg-attachments");
|
const row = el("div", "msg-attachments");
|
||||||
for (const a of attachments) row.appendChild(attachChip(a, false));
|
for (const a of attachments) row.appendChild(attachChip(a, false));
|
||||||
@@ -317,7 +331,7 @@ async function sendMessage() {
|
|||||||
state.sessions = await getJSON("/api/sessions");
|
state.sessions = await getJSON("/api/sessions");
|
||||||
renderSessions();
|
renderSessions();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
t.appendChild(messageNode("assistant", `Errore: ${e.message}`));
|
t.appendChild(messageNode("assistant", `Errore: ${e.message}`, null, null, Date.now() / 1000));
|
||||||
} finally {
|
} finally {
|
||||||
state.busy = false;
|
state.busy = false;
|
||||||
$("#send").disabled = false;
|
$("#send").disabled = false;
|
||||||
@@ -344,7 +358,9 @@ async function agentTurn(content, t, attachments) {
|
|||||||
function ensureLive() {
|
function ensureLive() {
|
||||||
if (live) return live;
|
if (live) return live;
|
||||||
const wrap = el("div", "msg assistant");
|
const wrap = el("div", "msg assistant");
|
||||||
wrap.appendChild(el("div", "role", "Assistente"));
|
const roleNode = el("div", "role", "Assistente");
|
||||||
|
roleNode.appendChild(el("span", "when", " · " + stampLabel(Date.now() / 1000)));
|
||||||
|
wrap.appendChild(roleNode);
|
||||||
const bubble = el("div", "bubble");
|
const bubble = el("div", "bubble");
|
||||||
const det = el("details", "thinking");
|
const det = el("details", "thinking");
|
||||||
det.appendChild(el("summary", null, "Pensiero"));
|
det.appendChild(el("summary", null, "Pensiero"));
|
||||||
@@ -412,7 +428,7 @@ async function agentTurn(content, t, attachments) {
|
|||||||
live = null;
|
live = null;
|
||||||
} else if (ev.type === "error") {
|
} else if (ev.type === "error") {
|
||||||
closeLive();
|
closeLive();
|
||||||
t.appendChild(messageNode("assistant", `Errore agent: ${ev.message}`));
|
t.appendChild(messageNode("assistant", `Errore agent: ${ev.message}`, null, null, Date.now() / 1000));
|
||||||
}
|
}
|
||||||
scrollDown();
|
scrollDown();
|
||||||
}
|
}
|
||||||
@@ -782,7 +798,6 @@ function wire() {
|
|||||||
$("#menu").addEventListener("click", openDrawer);
|
$("#menu").addEventListener("click", openDrawer);
|
||||||
$("#scrim").addEventListener("click", closeDrawer);
|
$("#scrim").addEventListener("click", closeDrawer);
|
||||||
$("#new-session").addEventListener("click", newSession);
|
$("#new-session").addEventListener("click", newSession);
|
||||||
$("#delete-session").addEventListener("click", deleteSession);
|
|
||||||
$("#send").addEventListener("click", sendMessage);
|
$("#send").addEventListener("click", sendMessage);
|
||||||
$("#attach").title = t("attach.title");
|
$("#attach").title = t("attach.title");
|
||||||
$("#attach").setAttribute("aria-label", t("attach.title"));
|
$("#attach").setAttribute("aria-label", t("attach.title"));
|
||||||
@@ -798,7 +813,6 @@ function wire() {
|
|||||||
$("#stats-modal").addEventListener("click", (e) => { if (e.target.id === "stats-modal") closeStats(); });
|
$("#stats-modal").addEventListener("click", (e) => { if (e.target.id === "stats-modal") closeStats(); });
|
||||||
document.addEventListener("keydown", (e) => { if (e.key === "Escape" && !$("#stats-modal").hidden) closeStats(); });
|
document.addEventListener("keydown", (e) => { if (e.key === "Escape" && !$("#stats-modal").hidden) closeStats(); });
|
||||||
$("#show-settings").addEventListener("click", () => openSettings("session"));
|
$("#show-settings").addEventListener("click", () => openSettings("session"));
|
||||||
$("#show-general-settings").addEventListener("click", () => { openSettings("general"); closeDrawer(); });
|
|
||||||
$("#set-scope-session").addEventListener("click", () => openSettings("session"));
|
$("#set-scope-session").addEventListener("click", () => openSettings("session"));
|
||||||
$("#set-scope-general").addEventListener("click", () => openSettings("general"));
|
$("#set-scope-general").addEventListener("click", () => openSettings("general"));
|
||||||
$("#set-save").addEventListener("click", saveSettings);
|
$("#set-save").addEventListener("click", saveSettings);
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
"settings.title.general": "General settings",
|
"settings.title.general": "General settings",
|
||||||
"settings.scope.session": "Session",
|
"settings.scope.session": "Session",
|
||||||
"settings.scope.general": "General",
|
"settings.scope.general": "General",
|
||||||
"settings.general.entry": "General settings",
|
|
||||||
"settings.name": "Name",
|
"settings.name": "Name",
|
||||||
"settings.notes": "Notes (chat purpose)",
|
"settings.notes": "Notes (chat purpose)",
|
||||||
"settings.sp": "System Prompt",
|
"settings.sp": "System Prompt",
|
||||||
@@ -22,6 +21,7 @@
|
|||||||
"attach.title": "Attach files or images",
|
"attach.title": "Attach files or images",
|
||||||
"attach.remove": "Remove attachment",
|
"attach.remove": "Remove attachment",
|
||||||
"attach.error": "Upload failed: {msg}",
|
"attach.error": "Upload failed: {msg}",
|
||||||
|
"usage.ttft": "1st token {n} ms",
|
||||||
"stats.title": "Statistics",
|
"stats.title": "Statistics",
|
||||||
"stats.close": "Close",
|
"stats.close": "Close",
|
||||||
"stats.updated": "Updated {time}",
|
"stats.updated": "Updated {time}",
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
"settings.title.general": "Impostazioni generali",
|
"settings.title.general": "Impostazioni generali",
|
||||||
"settings.scope.session": "Sessione",
|
"settings.scope.session": "Sessione",
|
||||||
"settings.scope.general": "Generali",
|
"settings.scope.general": "Generali",
|
||||||
"settings.general.entry": "Impostazioni generali",
|
|
||||||
"settings.name": "Nome",
|
"settings.name": "Nome",
|
||||||
"settings.notes": "Note (scopo della chat)",
|
"settings.notes": "Note (scopo della chat)",
|
||||||
"settings.sp": "System Prompt",
|
"settings.sp": "System Prompt",
|
||||||
@@ -22,6 +21,7 @@
|
|||||||
"attach.title": "Allega file o immagini",
|
"attach.title": "Allega file o immagini",
|
||||||
"attach.remove": "Rimuovi allegato",
|
"attach.remove": "Rimuovi allegato",
|
||||||
"attach.error": "Caricamento fallito: {msg}",
|
"attach.error": "Caricamento fallito: {msg}",
|
||||||
|
"usage.ttft": "1° token {n} ms",
|
||||||
"stats.title": "Statistiche",
|
"stats.title": "Statistiche",
|
||||||
"stats.close": "Chiudi",
|
"stats.close": "Chiudi",
|
||||||
"stats.updated": "Aggiornato {time}",
|
"stats.updated": "Aggiornato {time}",
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<ul id="session-list"></ul>
|
<ul id="session-list"></ul>
|
||||||
<div class="drawer-foot">
|
<div class="drawer-foot">
|
||||||
<button id="show-general-settings" class="btn ghost" data-i18n="settings.general.entry">Impostazioni generali</button>
|
|
||||||
<button id="show-stats" class="btn ghost" data-i18n="stats.title">Statistiche</button>
|
<button id="show-stats" class="btn ghost" data-i18n="stats.title">Statistiche</button>
|
||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
@@ -34,7 +33,6 @@
|
|||||||
<span id="model-name" class="muted"></span>
|
<span id="model-name" class="muted"></span>
|
||||||
</div>
|
</div>
|
||||||
<button id="show-settings" class="btn icon" aria-label="Impostazioni">⚙️</button>
|
<button id="show-settings" class="btn icon" aria-label="Impostazioni">⚙️</button>
|
||||||
<button id="delete-session" class="btn icon danger" aria-label="Elimina sessione">🗑</button>
|
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<section id="transcript" aria-live="polite"></section>
|
<section id="transcript" aria-live="polite"></section>
|
||||||
|
|||||||
Reference in new issue
Block a user