From 761904b5ab294d0b6b66aa9ca614b39a76e6cb53 Mon Sep 17 00:00:00 2001 From: yetone Date: Sun, 25 Oct 2026 01:08:02 +0800 Subject: [PATCH] whatsnew: Settings' What's new can show this version and the 10, 20, 50 or 100 before it (Linka) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Linka (linkaww, Discord, 10-25): 希望「关于 - 更新内容」加个可选项,查看 「上次更新以来 / 当前版本前 10 / 20 / 50 / 100 个版本」的更新说明. Settings › About › What's new now has a pill in its head (the app's menu, sess-pick, never a native select): "Since the last update", the default and what it showed before, or "This version and {n} before" for 10, 20, 50 and 100. The dialog shown by itself after an update has no pill and is unchanged. - site/worker.js: /api/notes takes limit=, the newest that many after upto, so a request for 11 isn't answered with 100. - internal/update: NotesBack(ctx, upto, n, lang) asks upto and limit n+1; Back(notes, upto, n) keeps upto and the n releases before it, newest first, Install sections stripped, empties dropped. It is not capped at MaxNotes (40), which only Between keeps. - internal/gui/whatsnew.go: /api/whatsnew?all=1&last=N, for N in 10/20/50/100 only (anything else is the default). Cached per language, the longest range asked kept, and a shorter one cut from it, so picking 10 after 100 asks nothing and a reopen asks nothing. A failed fetch is unknown: the reply carries error and whatever range was had before. - app.js: openWhatsNew(b, last) and wnRange. A pick that fails keeps the notes last shown, says "Couldn't load the release notes" with Try again above them, and Try again asks the same range. - The archive helpers (archivedCalls, headersPanel, downloadArchive, archiveBodyPanel), used only by the Usage page, moved to plugins/usage/page.js as d08b6118b did, so app.js stays under its budget (1,319,177 of 1,321,336); no budget raised. - i18n: three strings in zh, zh-TW, ja and de. Run at the pushed head (rebased on origin/main 0d2a10116): - go test -count=1 -tags nogui ./internal/update/ ./internal/gui/ in a sandbox HOME: ok (TestNotesBack, TestWhatsNewBackRanges, TestCoreScriptBudget among them). - gofmt -l: none. go build ./...; go vet ./...; GOOS=linux go vet -tags nogui ./...; GOOS=windows go vet ./...: ok. - node --test site/worker.test.mjs: 21 pass (new: limit keeps the newest that many up to upto; "", 0, x and -1 mean no limit). - GUI at this head, both engines: whats-new-range (new), whats-new, whats-new-failed, i18n-keys, ledger-cache-unknown, request-archive and request-archive-usage (the Usage page holds the moved helpers): 50 of 50. whats-new-range.test.cjs alone is 12 of 12: five languages x two engines plus the post-update dialog in both. Covers the default label and no last= asked, the menu's head and five items, 10 then 100, the same pick asking nothing, a failed 50 keeping the 100 shown with the error above, Try again, no scroll, no left-border accent, and a 440px window with the pill inside the dialog. - Whole GUI suite (869 files), chromium then webkit, concurrency 4: still running at push time, started at 1f156ba40 (the same change on e57e78563); the tree was rebased under it at 01:45. Chromium at 01:46: 1725 top-level tests passed, 7 red, none in a What's new or Usage file: agents' sign-ins, Plugins › Built-in, zh-TW 420px context map, gateway mode, an MCP server out of the library, and "a menu opened from a long text box's rule stays open" (en, zh). They will be checked against origin/main and filed or fixed when the run ends. Before the rebase, usage-ledger's "newest live route needs no return-to-live button" was red here and on an origin/main e57e78563 copy alike (#3104, #3001). Broken by hand, each red, then restored: - the pill not added to the head: whats-new-range red. - the kept notes not used on a failure: red at "the notes shown before are kept". - the ?last= route skipped: TestWhatsNewBackRanges red. - Back not cutting to n+1: TestNotesBack red. Not tried: - the real site: the test fakes /api/notes and /api/whatsnew. The site holds GitHub's newest 100 releases, so "100 before" on the newest version can show at most 100. An undeployed site ignores limit; the app cuts the list itself. - the real app window (Wails/WebKitGTK); only Playwright's engines. - go test ./... in full was not run: the machine had a queue of other sessions' full suites, and the owner's rule is not to hold a verified commit behind one. Known limits: a range view carries no pending (waiting update) notes; if a longer cached range dropped an Install-only release, a range cut from it can reach one release further back than a fresh ask would. --- internal/gui/assets/app.css | 1 + internal/gui/assets/app.js | 88 +++----- internal/gui/assets/i18n.js | 12 ++ internal/gui/assets/plugins/usage/page.js | 56 +++++ internal/gui/tests/whats-new-range.test.cjs | 215 ++++++++++++++++++++ internal/gui/whatsnew.go | 64 ++++++ internal/gui/whatsnew_back_test.go | 174 ++++++++++++++++ internal/update/notes.go | 57 +++++- internal/update/notes_test.go | 61 ++++++ site/worker.js | 6 +- site/worker.test.mjs | 10 + 11 files changed, 681 insertions(+), 63 deletions(-) create mode 100644 internal/gui/tests/whats-new-range.test.cjs create mode 100644 internal/gui/whatsnew_back_test.go 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