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 ---- */
|
||||
.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 .when { font-variant-numeric: tabular-nums; opacity: 0.85; }
|
||||
.msg.user { align-items: flex-end; }
|
||||
.msg.user .bubble {
|
||||
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;
|
||||
}
|
||||
|
||||
function messageNode(role, content, reasoning, usage) {
|
||||
function messageNode(role, content, reasoning, usage, ts) {
|
||||
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");
|
||||
if (reasoning) {
|
||||
const det = el("details", "thinking");
|
||||
@@ -81,7 +83,23 @@ function scrollDown() {
|
||||
}
|
||||
|
||||
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).
|
||||
@@ -145,7 +163,7 @@ function renderTranscript(messages) {
|
||||
}
|
||||
for (const m of messages) {
|
||||
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") {
|
||||
t.appendChild(toolResultNode(m.content));
|
||||
} else if (m.role === "assistant") {
|
||||
@@ -161,7 +179,7 @@ function renderTranscript(messages) {
|
||||
const usage = m.completion_tokens
|
||||
? usageText({ prompt_tokens: m.prompt_tokens, completion_tokens: m.completion_tokens })
|
||||
: 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();
|
||||
}
|
||||
|
||||
async function deleteSession() {
|
||||
if (state.current) await deleteSessionById(state.current);
|
||||
}
|
||||
|
||||
async function renameSessionById(id, currentTitle) {
|
||||
const input = await showDialog({ title: "Rinomina chat", input: currentTitle, okText: "Salva" });
|
||||
if (input === null) return;
|
||||
@@ -302,7 +316,7 @@ async function sendMessage() {
|
||||
const t = $("#transcript");
|
||||
const empty = t.querySelector(".empty");
|
||||
if (empty) empty.remove();
|
||||
const userNode = messageNode("user", content);
|
||||
const userNode = messageNode("user", content, null, null, Date.now() / 1000);
|
||||
if (attachments.length) {
|
||||
const row = el("div", "msg-attachments");
|
||||
for (const a of attachments) row.appendChild(attachChip(a, false));
|
||||
@@ -317,7 +331,7 @@ async function sendMessage() {
|
||||
state.sessions = await getJSON("/api/sessions");
|
||||
renderSessions();
|
||||
} catch (e) {
|
||||
t.appendChild(messageNode("assistant", `Errore: ${e.message}`));
|
||||
t.appendChild(messageNode("assistant", `Errore: ${e.message}`, null, null, Date.now() / 1000));
|
||||
} finally {
|
||||
state.busy = false;
|
||||
$("#send").disabled = false;
|
||||
@@ -344,7 +358,9 @@ async function agentTurn(content, t, attachments) {
|
||||
function ensureLive() {
|
||||
if (live) return live;
|
||||
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 det = el("details", "thinking");
|
||||
det.appendChild(el("summary", null, "Pensiero"));
|
||||
@@ -412,7 +428,7 @@ async function agentTurn(content, t, attachments) {
|
||||
live = null;
|
||||
} else if (ev.type === "error") {
|
||||
closeLive();
|
||||
t.appendChild(messageNode("assistant", `Errore agent: ${ev.message}`));
|
||||
t.appendChild(messageNode("assistant", `Errore agent: ${ev.message}`, null, null, Date.now() / 1000));
|
||||
}
|
||||
scrollDown();
|
||||
}
|
||||
@@ -782,7 +798,6 @@ function wire() {
|
||||
$("#menu").addEventListener("click", openDrawer);
|
||||
$("#scrim").addEventListener("click", closeDrawer);
|
||||
$("#new-session").addEventListener("click", newSession);
|
||||
$("#delete-session").addEventListener("click", deleteSession);
|
||||
$("#send").addEventListener("click", sendMessage);
|
||||
$("#attach").title = 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(); });
|
||||
document.addEventListener("keydown", (e) => { if (e.key === "Escape" && !$("#stats-modal").hidden) closeStats(); });
|
||||
$("#show-settings").addEventListener("click", () => openSettings("session"));
|
||||
$("#show-general-settings").addEventListener("click", () => { openSettings("general"); closeDrawer(); });
|
||||
$("#set-scope-session").addEventListener("click", () => openSettings("session"));
|
||||
$("#set-scope-general").addEventListener("click", () => openSettings("general"));
|
||||
$("#set-save").addEventListener("click", saveSettings);
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
"settings.title.general": "General settings",
|
||||
"settings.scope.session": "Session",
|
||||
"settings.scope.general": "General",
|
||||
"settings.general.entry": "General settings",
|
||||
"settings.name": "Name",
|
||||
"settings.notes": "Notes (chat purpose)",
|
||||
"settings.sp": "System Prompt",
|
||||
@@ -22,6 +21,7 @@
|
||||
"attach.title": "Attach files or images",
|
||||
"attach.remove": "Remove attachment",
|
||||
"attach.error": "Upload failed: {msg}",
|
||||
"usage.ttft": "1st token {n} ms",
|
||||
"stats.title": "Statistics",
|
||||
"stats.close": "Close",
|
||||
"stats.updated": "Updated {time}",
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
"settings.title.general": "Impostazioni generali",
|
||||
"settings.scope.session": "Sessione",
|
||||
"settings.scope.general": "Generali",
|
||||
"settings.general.entry": "Impostazioni generali",
|
||||
"settings.name": "Nome",
|
||||
"settings.notes": "Note (scopo della chat)",
|
||||
"settings.sp": "System Prompt",
|
||||
@@ -22,6 +21,7 @@
|
||||
"attach.title": "Allega file o immagini",
|
||||
"attach.remove": "Rimuovi allegato",
|
||||
"attach.error": "Caricamento fallito: {msg}",
|
||||
"usage.ttft": "1° token {n} ms",
|
||||
"stats.title": "Statistiche",
|
||||
"stats.close": "Chiudi",
|
||||
"stats.updated": "Aggiornato {time}",
|
||||
|
||||
Reference in new issue
Block a user