diff --git a/internal/gui/assets/app.css b/internal/gui/assets/app.css index 3fc7d4754..c426a8a43 100644 --- a/internal/gui/assets/app.css +++ b/internal/gui/assets/app.css @@ -3600,6 +3600,7 @@ html.theming, html.theming *, html.theming *::before, html.theming *::after { .whatsnew .wn-ver { display: flex; align-items: center; gap: 8px; font-size: 13px; } .whatsnew .wn-ver b { font-weight: 600; } .whatsnew .wn-since { margin-left: 10px; font-size: 12px; color: var(--muted); } +.whatsnew .wn-range { max-width: min(220px, 55%); } .whatsnew .wn-notes { font-size: 12.5px; line-height: 1.55; color: var(--fg-2); overflow-wrap: anywhere; user-select: text; -webkit-user-select: text; } .whatsnew .wn-h { margin: 10px 0 2px; font-size: 12px; font-weight: 600; color: var(--fg); } .whatsnew .wn-h1, .whatsnew .wn-h2 { font-size: 12.5px; } diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index bcc2396ea..127124192 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -4365,13 +4365,34 @@ async function whatsNewOnce() { // waiting update (pending), which the app puts first. The notes that // couldn't be had (the site failing, #661) say so, with a retry and the // release page, apart from a version that has none. -async function openWhatsNew(b) { +// last: the range picked (wnRange), "" since the last update; a failed ask +// keeps the notes last shown (wnKept). +let wnKept = null; +async function openWhatsNew(b, last = "") { if (b) { b.disabled = true; b.classList.add("busy"); } - const w = await api(updatePath("whatsnew?all=1")).catch(() => null); + const w = await api(updatePath("whatsnew?all=1" + (last && "&last=" + last))).catch(() => null); if (b) { b.disabled = false; b.classList.remove("busy"); } - const list = w?.releases || []; + let list = w?.releases || [], failed = !w || !!w.error; + if (!failed) wnKept = list; + else if (!list.length && wnKept) list = wnKept; if (!list.length && !w?.current) return status(t("Couldn't load the release notes"), "err"); - showWhatsNew(list, false, { failed: !w || !!w.error, current: w?.current, url: w?.url, retry: () => openWhatsNew() }); + showWhatsNew(list, false, { failed, current: w?.current, url: w?.url, last, retry: () => openWhatsNew(null, last) }); +} + +// wnRange is Settings' pick of which notes (Linka): since the last update, +// or this version and 10, 20, 50 or 100 before it +function wnRange(last) { + const name = (v) => v ? t("This version and {n} before", { n: v }) : t("Since the last update"); + const b = el("button", "sess-pick wn-range"); + b.type = "button"; + b.setAttribute("aria-haspopup", "menu"); + b.append(el("span", "", name(last)), svg(CHEV, 11, 1.6)); + b.onclick = (e) => { + e.stopPropagation(); + if (b.classList.contains("open")) return closeProtoMenu(); + openProtoMenu(b, ["", "10", "20", "50", "100"].map((v) => ({ v, name: name(v), note: "", literalName: true })), last, (v) => v !== last && openWhatsNew(b, v), "Release notes shown", "sess-menu", "right"); + }; + return b; } // auto: shown by itself after an update, with "Don't show again today" @@ -4383,6 +4404,7 @@ function showWhatsNew(releases, auto, more = {}) { const ed = el("div", "editor whatsnew"); const head = el("div", "ehead"); head.append(el("b", "", t("What's new in {v}", { v: "v" + (releases[0]?.version || more.current) }))); + if (!auto) head.append(el("span", "grow"), wnRange(more.last || "")); ed.append(head); for (const r of releases) { const sec = el("section", "wn-rel"); @@ -4410,7 +4432,7 @@ function showWhatsNew(releases, auto, more = {}) { } if (more.url) acts.append(noteLink(t("Open the release page"), more.url)); sec.append(h, p, acts); - ed.append(sec); + head.after(sec); // above the notes kept from before } const bar = el("div", "bar"); const ok = el("button", "text primary", t("Close")); @@ -7188,62 +7210,6 @@ function renderArchive() { } else err?.remove(); } -// What was read back from the archive, by "/": the archive's -// copy, or {busy} while it is read, or {error}. -const archivedCalls = new Map(); - -function headersPanel(label, first, headers) { - const panel = el("section", "call-body"); - const head = el("div", "call-body-head"); - const lines = [first, ...Object.keys(headers || {}).sort().flatMap((k) => headers[k].map((v) => `${k}: ${v}`))].filter(Boolean); - head.append(el("span", "call-body-label", label), el("span", "grow"), copyBtn(lines.join("\n"), label)); - const pre = el("pre"); - pre.append(el("code", "", lines.join("\n"))); - panel.append(head, pre); - return panel; -} - -// The archived file, whole, however large: to the browser in magpie web, -// to Downloads in the app (#447). -async function downloadArchive(name, b) { - const [date, aid] = name.split("/"); - const q = `date=${encodeURIComponent(date)}&id=${encodeURIComponent(aid)}`; - if (web) { - const a = el("a"); - a.href = "/api/archive/file?" + q; - a.download = ""; - a.click(); - return; - } - b.classList.add("busy"); - b.disabled = true; - try { - const r = await api("archive/export?" + q, {}); - status(t("Saved to {path}", { path: r.path }), "ok"); - } catch (e) { - status(t(e.message), "err"); - } finally { - b.classList.remove("busy"); - b.disabled = false; - } -} - -// one body read back from the archive: shown, or, past 256 KB, only its -// size — the server leaves it out — for the file to be downloaded whole -function archiveBodyPanel(label, part, id, key = id) { - if (part.omitted) { - const panel = el("section", "call-body"); - const head = el("div", "call-body-head"); - head.append(el("span", "call-body-label", t(label)), el("span", "call-body-count", fmtBytes(part.size))); - panel.append(head, el("p", "call-archive-big", t("Too long to show here. Download the archive to read it whole."))); - return panel; - } - // cut where the archive stops: its limit, or 256 KB in one from before #447 - const cut = part.truncated && (part.size ? t("first {n} of {size}", { n: fmtBytes(new Blob([part.body]).size), size: fmtBytes(part.size) }) : true); - return callBodyPanel(label, part.body, cut, id, key); -} - - // An agent's model field, and whether any of its options come from provider p. function modelField(a) { const agent = state.agents.find((x) => x.id === a.id); diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.js index 256695f08..be209c088 100644 --- a/internal/gui/assets/i18n.js +++ b/internal/gui/assets/i18n.js @@ -3015,6 +3015,9 @@ const I18N = { "What's new in {v}": "{v} 更新内容", "What changed since {v}": "自 {v} 以来的更新内容", "Not installed yet": "尚未安装", + "Since the last update": "上次更新以来", + "This version and {n} before": "当前版本及之前 {n} 个版本", + "Release notes shown": "显示的更新说明", "Don't show again today": "今天不再弹出", "Couldn't load the release notes": "无法获取更新说明", "No release notes provided.": "这个版本没有更新说明。", @@ -6946,6 +6949,9 @@ const I18N = { "What's new in {v}": "{v} 更新內容", "What changed since {v}": "自 {v} 以來的更新內容", "Not installed yet": "尚未安裝", + "Since the last update": "上次更新以來", + "This version and {n} before": "目前版本及之前 {n} 個版本", + "Release notes shown": "顯示的更新說明", "Don't show again today": "今天不再彈出", "Couldn't load the release notes": "無法取得更新說明", "No release notes provided.": "這個版本沒有更新說明。", @@ -10889,6 +10895,9 @@ const I18N = { "What's new in {v}": "{v} の新機能", "What changed since {v}": "{v} からの変更点", "Not installed yet": "まだインストールされていません", + "Since the last update": "前回のアップデート以降", + "This version and {n} before": "このバージョンと前の {n} 件", + "Release notes shown": "表示するリリースノート", "Don't show again today": "今日はもう表示しない", "Couldn't load the release notes": "リリースノートを読み込めませんでした", "No release notes provided.": "リリースノートはありません。", @@ -14842,6 +14851,9 @@ const I18N = { "What's new in {v}": "Neu in {v}", "What changed since {v}": "Was sich seit {v} geändert hat", "Not installed yet": "Noch nicht installiert", + "Since the last update": "Seit dem letzten Update", + "This version and {n} before": "Diese Version und {n} davor", + "Release notes shown": "Angezeigte Versionshinweise", "Don't show again today": "Heute nicht mehr anzeigen", "Couldn't load the release notes": "Versionshinweise konnten nicht geladen werden", "No release notes provided.": "Keine Versionshinweise vorhanden.", diff --git a/internal/gui/assets/plugins/usage/page.js b/internal/gui/assets/plugins/usage/page.js index da85aaea3..b4934c1b7 100644 --- a/internal/gui/assets/plugins/usage/page.js +++ b/internal/gui/assets/plugins/usage/page.js @@ -2,6 +2,62 @@ // app.js, whose helpers and state it shares, and before start.js shows the // first page. let usageHidOpen = false; // the hidden agents shown under their line + +// What was read back from the archive, by "/": the archive's +// copy, or {busy} while it is read, or {error}. +const archivedCalls = new Map(); + +function headersPanel(label, first, headers) { + const panel = el("section", "call-body"); + const head = el("div", "call-body-head"); + const lines = [first, ...Object.keys(headers || {}).sort().flatMap((k) => headers[k].map((v) => `${k}: ${v}`))].filter(Boolean); + head.append(el("span", "call-body-label", label), el("span", "grow"), copyBtn(lines.join("\n"), label)); + const pre = el("pre"); + pre.append(el("code", "", lines.join("\n"))); + panel.append(head, pre); + return panel; +} + +// The archived file, whole, however large: to the browser in magpie web, +// to Downloads in the app (#447). +async function downloadArchive(name, b) { + const [date, aid] = name.split("/"); + const q = `date=${encodeURIComponent(date)}&id=${encodeURIComponent(aid)}`; + if (web) { + const a = el("a"); + a.href = "/api/archive/file?" + q; + a.download = ""; + a.click(); + return; + } + b.classList.add("busy"); + b.disabled = true; + try { + const r = await api("archive/export?" + q, {}); + status(t("Saved to {path}", { path: r.path }), "ok"); + } catch (e) { + status(t(e.message), "err"); + } finally { + b.classList.remove("busy"); + b.disabled = false; + } +} + +// one body read back from the archive: shown, or, past 256 KB, only its +// size — the server leaves it out — for the file to be downloaded whole +function archiveBodyPanel(label, part, id, key = id) { + if (part.omitted) { + const panel = el("section", "call-body"); + const head = el("div", "call-body-head"); + head.append(el("span", "call-body-label", t(label)), el("span", "call-body-count", fmtBytes(part.size))); + panel.append(head, el("p", "call-archive-big", t("Too long to show here. Download the archive to read it whole."))); + return panel; + } + // cut where the archive stops: its limit, or 256 KB in one from before #447 + const cut = part.truncated && (part.size ? t("first {n} of {size}", { n: fmtBytes(new Blob([part.body]).size), size: fmtBytes(part.size) }) : true); + return callBodyPanel(label, part.body, cut, id, key); +} + // A call the archive kept, by "/": read back when asked, and its // file downloaded, drawn again by redraw as it is read — under a request's // row on the Usage page, and under a Routing trace's (plugins/routing draws diff --git a/internal/gui/tests/whats-new-range.test.cjs b/internal/gui/tests/whats-new-range.test.cjs new file mode 100644 index 000000000..f4351247c --- /dev/null +++ b/internal/gui/tests/whats-new-range.test.cjs @@ -0,0 +1,215 @@ +// Run with Node's test runner and Playwright on the module path; see README.md. +// Settings › About › What's new picks which notes it shows (Linka on +// Discord): since the last update, as before and by default, or this +// version and the 10, 20, 50 or 100 before it. The pick is the app's own +// menu (a pill in the dialog's head), never a native