diff --git a/internal/gui/api.go b/internal/gui/api.go index 2a9b36bf0..ab4305fbb 100644 --- a/internal/gui/api.go +++ b/internal/gui/api.go @@ -489,6 +489,8 @@ func Handler(w Windows, gw *gateway.Server) http.Handler { in.CodexAutoReset, in.ClaudeAutoReset = cur.CodexAutoReset, cur.ClaudeAutoReset // and the text size, which the keyboard changes too (text-size below) in.TextSize = cur.TextSize + // the version the Update pill was hidden for, set from the pill + in.UpdateSkip = cur.UpdateSkip if v := strings.TrimSpace(in.Vision); v != "" && v != "off" && v != cur.Vision { if _, _, ok := provider.Resolve(v); !ok { fail(rw, fmt.Errorf("no model %s to describe images", v)) @@ -549,6 +551,24 @@ func Handler(w Windows, gw *gateway.Server) http.Handler { } writeJSON(rw, settingsState()) }) + // the version the header's Update pill is hidden for, until a newer one + // is out: set from the pill, cleared ("") from Settings + mux.HandleFunc("POST /api/settings/update-skip", func(rw http.ResponseWriter, r *http.Request) { + var in struct { + Version string `json:"version"` + } + if err := json.NewDecoder(r.Body).Decode(&in); err != nil { + fail(rw, err) + return + } + s := settings.Load() + s.UpdateSkip = strings.TrimSpace(in.Version) + if err := settings.Save(s); err != nil { + fail(rw, err) + return + } + writeJSON(rw, settingsState()) + }) // whether the agents' lists name a model with its provider's after it or // alone (#335): their files are written again, and Codex asks again mux.HandleFunc("POST /api/settings/plain-names", func(rw http.ResponseWriter, r *http.Request) { diff --git a/internal/gui/assets/app.css b/internal/gui/assets/app.css index 94d5da7b3..d41e17c4b 100644 --- a/internal/gui/assets/app.css +++ b/internal/gui/assets/app.css @@ -224,6 +224,19 @@ body.panel .seg { display: none; } .update:hover { background: var(--accent); color: var(--accent-fg); } .update:active { transform: scale(.96); } .update.busy { pointer-events: none; opacity: .6; } +/* its × on the pill's corner, shown while the pointer is over it: hides + the pill until a newer version is out */ +.update-wrap { position: relative; align-self: center; display: inline-flex; } +.update-hide { + position: absolute; top: -5px; right: 3px; width: 14px; height: 14px; border-radius: 50%; + display: inline-flex; align-items: center; justify-content: center; + color: var(--muted); background: var(--card); box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgba(0,0,0,.12); + opacity: 0; pointer-events: none; transition: opacity .12s, color .12s; +} +.update-wrap:hover .update-hide { opacity: 1; pointer-events: auto; } +.update-hide:focus-visible { opacity: 1; pointer-events: auto; } /* its own rule: Safari before 15.4 drops a list holding it */ +.update-hide:hover { color: var(--fg); } +.update[hidden] + .update-hide, .update.busy + .update-hide { display: none; } /* a narrow header (fitTop): the magpie without its name, Update as its arrow, and at the narrowest the tabs in the row rather than over it */ .top.tight .brand > span:not(.logo), .top.tight .update span { display: none; } diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index c1920c642..be01cbfb0 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -1354,7 +1354,9 @@ function installFrom() { // renderUpdateBadge shows the header's Update pill once a newer magpie is // downloaded (a click restarts into it) or, where magpie can't replace -// itself, out (a click opens the release page). +// itself, out (a click opens the release page). The user may keep it away: +// for good (Settings), or for this version (its ×, or a right-click), until +// a newer one is out. magpie still downloads it and puts it in on quitting. async function renderUpdateBadge() { const b = $("#update"), label = b.querySelector("span"); const u = await api("update").catch(() => null); @@ -1364,9 +1366,15 @@ async function renderUpdateBadge() { delete b.dataset.pulling; b.classList.remove("busy"); } - const on = pulling || (!!u && (u.state === "ready" || u.state === "available" || (u.state === "error" && u.retry))); + const on = pulling || (!!u && !updatePillOff(u.latest) && (u.state === "ready" || u.state === "available" || (u.state === "error" && u.retry))); if (b.hidden !== !on) b.hidden = !on; if (!on) return; + const hide = $("#updateHide"); + hide.setAttribute("aria-label", t("Hide until the next version")); + hide.onclick = b.oncontextmenu = (e) => { + e.preventDefault(); + skipUpdate(u.latest); + }; const restart = async () => { b.classList.add("busy"); label.textContent = t("Restarting…"); @@ -1410,6 +1418,28 @@ async function renderUpdateBadge() { }; } +// updatePillOff is whether the user keeps the Update pill away for v. +function updatePillOff(v) { + const s = state?.settings || {}; + return !!s.noUpdatePill || (!!v && s.updateSkip === v); +} + +// skipUpdate hides the Update pill until a version newer than v is out +// ("" shows it again), and says where it can be brought back. +async function skipUpdate(v) { + $("#update").hidden = true; + try { + const ns = await writingPrefs(api("settings/update-skip", { version: v })); + prefs = ns; + if (state) state.settings = ns; + if (v) status(t("Update hidden until the next version; Settings still has it"), "ok", 3000); + } catch (e) { + status(e.message, "err"); + } + renderUpdateBadge(); + if (view === "settings" && prefs) renderSettings(); +} + // backAsNew waits, in magpie web, for the version the page restarted into // to answer in its place, and reloads the page from it (#111). async function backAsNew(was) { @@ -8854,6 +8884,20 @@ function renderSettings() { return r; }; renderUpdate(row(t("Version"), "", s.version)); + // the header's Update pill, kept away for good or for one version; the + // version row above still says what is out and offers it + const pill = row(t("Update button"), t("Shows in the header when a newer magpie is out"), + "", segs([["off", t("Off")], ["on", t("On")]], s.noUpdatePill ? "off" : "on", (v) => savePrefs({ ...keep, noUpdatePill: v === "off" }).then(renderUpdateBadge))); + pill.classList.add("update-pill-row"); + if (s.updateSkip && !s.noUpdatePill) { + api("update").then((u) => { + if (!pill.isConnected || !u || u.latest !== s.updateSkip) return; + pill.querySelector(".sub").textContent = t("Hidden for {v} until a newer version is out", { v: u.latest }); + const back = el("button", "text", t("Show again")); + back.onclick = () => skipUpdate(""); + pill.querySelector(".val").prepend(back); + }, () => {}); + } const open = el("button", "text", t("Open")); open.onclick = () => api("settings/reveal", {}).catch((e) => status(e.message, "err")); row(t("Config folder"), t("providers, profiles and these settings"), s.dir, copyBtn(s.dir, t("Path")), open); @@ -9676,6 +9720,7 @@ function prefsKeep(s) { trayUsages: s.trayUsages || [], redact: !!s.redact, redactPersonal: !!s.redactPersonal, redactWords: s.redactWords || [], codexWarmup: s.codexWarmup || "", claudeWarmup: s.claudeWarmup || "", codexWarmAt: s.codexWarmAt || "", claudeWarmAt: s.claudeWarmAt || "", workbuddyCheckin: !!s.workbuddyCheckin, noStats: !!s.noStats, + noUpdatePill: !!s.noUpdatePill, trayUsage: s.trayUsage || "", trayUsageEvery: s.trayUsageEvery || 3, vision: s.vision || "", imageGen: s.imageGen || "", currency: s.currency || "usd", usageAlert: s.usageAlert || 0, balanceAlert: s.balanceAlert || 0 }; } diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.js index c72ec996e..f2c6832e8 100644 --- a/internal/gui/assets/i18n.js +++ b/internal/gui/assets/i18n.js @@ -1168,6 +1168,12 @@ const I18N = { "Restart to update": "重启以更新", "Update": "更新", "Update failed": "更新失败", + "Hide until the next version": "隐藏,直到下一个版本", + "Update hidden until the next version; Settings still has it": "已隐藏更新按钮,下一个版本发布时再显示;设置里仍可更新", + "Update button": "更新按钮", + "Shows in the header when a newer magpie is out": "magpie 有新版本时显示在顶栏", + "Hidden for {v} until a newer version is out": "{v} 已隐藏,更新的版本发布时再显示", + "Show again": "重新显示", "Restart to update to {v}": "重启以更新到 {v}", "Restarting…": "正在重启…", "{v} is out": "{v} 已发布", diff --git a/internal/gui/assets/index.html b/internal/gui/assets/index.html index 536ece52c..909965139 100644 --- a/internal/gui/assets/index.html +++ b/internal/gui/assets/index.html @@ -29,10 +29,15 @@
- + + + + diff --git a/internal/gui/settings_keep_test.go b/internal/gui/settings_keep_test.go index 7af42bd2e..76b5342d3 100644 --- a/internal/gui/settings_keep_test.go +++ b/internal/gui/settings_keep_test.go @@ -82,6 +82,7 @@ func TestSettingsSaveKeepsWhatItDoesNotSend(t *testing.T) { CodexAutoReset: []string{"me@example.com"}, ClaudeAutoReset: []string{"me@example.com"}, TextSize: 125, + UpdateSkip: "0.1.500", Window: []int{900, 700}, } if err := settings.Save(was); err != nil { @@ -112,3 +113,32 @@ func TestSettingsSaveKeepsWhatItDoesNotSend(t *testing.T) { } } } + +// The Update pill hidden for one version stays hidden for it through a save +// of the Settings page, which doesn't send it, and comes back once cleared. +func TestUpdateSkip(t *testing.T) { + h := t.TempDir() + t.Setenv("HOME", h) + t.Setenv("XDG_CONFIG_HOME", filepath.Join(h, ".config")) + t.Setenv("XDG_CACHE_HOME", filepath.Join(h, ".cache")) + post := func(path, body string) { + t.Helper() + rec := httptest.NewRecorder() + Handler(nil, nil).ServeHTTP(rec, httptest.NewRequest("POST", path, strings.NewReader(body))) + if rec.Code != http.StatusOK { + t.Fatalf("%s: %d %s", path, rec.Code, rec.Body) + } + } + post("/api/settings/update-skip", `{"version":"0.1.501"}`) + if s := settings.Load(); s.UpdateSkip != "0.1.501" { + t.Fatalf("skip %q", s.UpdateSkip) + } + post("/api/settings", `{"theme":"dark","noUpdatePill":true}`) + if s := settings.Load(); s.UpdateSkip != "0.1.501" || !s.NoUpdatePill || s.Theme != "dark" { + t.Fatalf("after a save: skip %q pill off %v theme %q", s.UpdateSkip, s.NoUpdatePill, s.Theme) + } + post("/api/settings/update-skip", `{"version":""}`) + if s := settings.Load(); s.UpdateSkip != "" || !s.NoUpdatePill { + t.Fatalf("cleared: skip %q pill off %v", s.UpdateSkip, s.NoUpdatePill) + } +} diff --git a/internal/gui/tests/README.md b/internal/gui/tests/README.md index 40fecc48e..a8a430bc1 100644 --- a/internal/gui/tests/README.md +++ b/internal/gui/tests/README.md @@ -263,6 +263,13 @@ and Chinese. magpie too: one click, one check, and the Update pill shows what it found. Its tooltip says so. English and Chinese. +`update-hide.test.cjs` keeps the header's Update pill away when asked (Wang +Hsiaohi on Discord): its ×, shown with the pointer over the pill, hides it for +that version, through a reload, until a newer one is out; a right-click does +the same. Settings → Update button says which version it is hidden for, with +Show again, and turns it off for good; the version row still offers the +restart. No click moves the page. Panel and window, English and Chinese. + `add-sheet.test.cjs` opens the Providers page's add sheet as quiet rows: Subscriptions, Vendors, Relays and On this machine, each with its word on what it is; rows with no border, no second line and no overflow, three to a @@ -593,7 +600,7 @@ with `/api/plugins` faked. With Node.js and Playwright available: ```sh -node --test internal/gui/tests/menu-scroll.test.cjs internal/gui/tests/click-scroll.test.cjs internal/gui/tests/panel-fold.test.cjs internal/gui/tests/rollup-short.test.cjs internal/gui/tests/panel-routing.test.cjs internal/gui/tests/gateway-fold.test.cjs internal/gui/tests/routing-kind.test.cjs internal/gui/tests/balance-fix.test.cjs internal/gui/tests/cli-update.test.cjs internal/gui/tests/login-import.test.cjs internal/gui/tests/agy-launch.test.cjs internal/gui/tests/currency.test.cjs internal/gui/tests/usage-ledger.test.cjs internal/gui/tests/update-check.test.cjs internal/gui/tests/omarchy.test.cjs internal/gui/tests/brand.test.cjs internal/gui/tests/library-loading.test.cjs node --test internal/gui/tests/signin-callback.test.cjs internal/gui/tests/routing-steady.test.cjs internal/gui/tests/old-webkit.test.cjs internal/gui/tests/session-terminal.test.cjs internal/gui/tests/text-size.test.cjs internal/gui/tests/zcode-site.test.cjs internal/gui/tests/rail-tip.test.cjs internal/gui/tests/sync-update.test.cjs internal/gui/tests/plugin-signin.test.cjs internal/gui/tests/plugin-market.test.cjs internal/gui/tests/s3-sync.test.cjs internal/gui/tests/routing-wb-refused.test.cjs internal/gui/tests/routing-shape.test.cjs internal/gui/tests/market-have.test.cjs internal/gui/tests/sessions-today.test.cjs internal/gui/tests/routing-side-calls.test.cjs internal/gui/tests/import-all-skills.test.cjs internal/gui/tests/routing-flood.test.cjs internal/gui/tests/routing-busy.test.cjs internal/gui/tests/own-skill.test.cjs internal/gui/tests/routing-manual.test.cjs internal/gui/tests/tray-usages.test.cjs internal/gui/tests/provider-remove.test.cjs internal/gui/tests/signin-link.test.cjs internal/gui/tests/tray-inuse.test.cjs internal/gui/tests/codex-auto-reset.test.cjs internal/gui/tests/routing-auto-reset.test.cjs internal/gui/tests/claude-resets.test.cjs internal/gui/tests/library-toggle-status.test.cjs internal/gui/tests/library-all.test.cjs internal/gui/tests/routing-reroute-title.test.cjs internal/gui/tests/plain-names.test.cjs internal/gui/tests/panel-effort.test.cjs internal/gui/tests/agent-models-all-hidden.test.cjs internal/gui/tests/omp-roles.test.cjs internal/gui/tests/claude-effort.test.cjs internal/gui/tests/remote-magpie.test.cjs internal/gui/tests/qoder-cn-tile.test.cjs internal/gui/tests/provider-levels-scroll.test.cjs internal/gui/tests/signin-paste-codex.test.cjs internal/gui/tests/usage-alert.test.cjs internal/gui/tests/quota-families.test.cjs internal/gui/tests/provider-search.test.cjs internal/gui/tests/webdav-settings-refresh.test.cjs internal/gui/tests/lan-docker.test.cjs internal/gui/tests/plugin-key-hint.test.cjs +node --test internal/gui/tests/menu-scroll.test.cjs internal/gui/tests/click-scroll.test.cjs internal/gui/tests/panel-fold.test.cjs internal/gui/tests/rollup-short.test.cjs internal/gui/tests/panel-routing.test.cjs internal/gui/tests/gateway-fold.test.cjs internal/gui/tests/routing-kind.test.cjs internal/gui/tests/balance-fix.test.cjs internal/gui/tests/cli-update.test.cjs internal/gui/tests/login-import.test.cjs internal/gui/tests/agy-launch.test.cjs internal/gui/tests/currency.test.cjs internal/gui/tests/usage-ledger.test.cjs internal/gui/tests/update-check.test.cjs internal/gui/tests/omarchy.test.cjs internal/gui/tests/brand.test.cjs internal/gui/tests/library-loading.test.cjs node --test internal/gui/tests/signin-callback.test.cjs internal/gui/tests/routing-steady.test.cjs internal/gui/tests/old-webkit.test.cjs internal/gui/tests/session-terminal.test.cjs internal/gui/tests/text-size.test.cjs internal/gui/tests/zcode-site.test.cjs internal/gui/tests/rail-tip.test.cjs internal/gui/tests/sync-update.test.cjs internal/gui/tests/plugin-signin.test.cjs internal/gui/tests/plugin-market.test.cjs internal/gui/tests/s3-sync.test.cjs internal/gui/tests/routing-wb-refused.test.cjs internal/gui/tests/routing-shape.test.cjs internal/gui/tests/market-have.test.cjs internal/gui/tests/sessions-today.test.cjs internal/gui/tests/routing-side-calls.test.cjs internal/gui/tests/import-all-skills.test.cjs internal/gui/tests/routing-flood.test.cjs internal/gui/tests/routing-busy.test.cjs internal/gui/tests/own-skill.test.cjs internal/gui/tests/routing-manual.test.cjs internal/gui/tests/tray-usages.test.cjs internal/gui/tests/provider-remove.test.cjs internal/gui/tests/signin-link.test.cjs internal/gui/tests/tray-inuse.test.cjs internal/gui/tests/codex-auto-reset.test.cjs internal/gui/tests/routing-auto-reset.test.cjs internal/gui/tests/claude-resets.test.cjs internal/gui/tests/library-toggle-status.test.cjs internal/gui/tests/library-all.test.cjs internal/gui/tests/routing-reroute-title.test.cjs internal/gui/tests/plain-names.test.cjs internal/gui/tests/panel-effort.test.cjs internal/gui/tests/agent-models-all-hidden.test.cjs internal/gui/tests/omp-roles.test.cjs internal/gui/tests/claude-effort.test.cjs internal/gui/tests/remote-magpie.test.cjs internal/gui/tests/qoder-cn-tile.test.cjs internal/gui/tests/provider-levels-scroll.test.cjs internal/gui/tests/signin-paste-codex.test.cjs internal/gui/tests/usage-alert.test.cjs internal/gui/tests/quota-families.test.cjs internal/gui/tests/provider-search.test.cjs internal/gui/tests/webdav-settings-refresh.test.cjs internal/gui/tests/lan-docker.test.cjs internal/gui/tests/plugin-key-hint.test.cjs internal/gui/tests/update-hide.test.cjs ``` If Playwright is installed outside the repository, set `NODE_PATH` to the diff --git a/internal/gui/tests/update-hide.test.cjs b/internal/gui/tests/update-hide.test.cjs new file mode 100644 index 000000000..f84bd2116 --- /dev/null +++ b/internal/gui/tests/update-hide.test.cjs @@ -0,0 +1,165 @@ +// Run with Node's test runner and Playwright on the module path; see README.md. +// The header's Update pill can be kept away (Wang Hsiaohi on Discord). Its ×, +// shown with the pointer over it, hides it for that version: it stays away +// after a reload and comes back once a newer version is out; a right-click +// does the same. Settings → Update button turns it off for good, and says +// which version it is hidden for with a way to show it again. The version +// row still offers the restart. No click moves the page. English and +// Chinese, in the tray panel and the window; no backend, the API is faked. +const assert = require("node:assert/strict"); +const fs = require("node:fs/promises"); +const path = require("node:path"); +const { test } = require("node:test"); +const { chromium, webkit } = require("playwright"); + +const assets = path.resolve(__dirname, "../assets"); + +const words = { + en: { update: "Update", hide: "Hide until the next version", pill: "Update button", off: "Off", on: "On", + hidden: "Hidden for 0.1.401 until a newer version is out", again: "Show again", restart: "Restart to update", version: "Version" }, + zh: { update: "更新", hide: "隐藏,直到下一个版本", pill: "更新按钮", off: "关闭", on: "开启", + hidden: "0.1.401 已隐藏,更新的版本发布时再显示", again: "重新显示", restart: "重启以更新", version: "版本" }, +}; + +function settingsPayload(lang, ctl) { + return { + theme: "light", lang, tray: "panel", quotaLeft: false, currency: "usd", + dock: false, dockWindow: false, proxy: "", redact: false, redactPersonal: false, redactWords: [], + codexWarmup: "", claudeWarmup: "", codexWarmAt: "", claudeWarmAt: "", workbuddyCheckin: false, noStats: false, + trayUsage: "", trayUsageEvery: 3, vision: "", imageGen: "", + noUpdatePill: ctl.off, updateSkip: ctl.skip, + version: "0.1.400", dir: "~/.config/magpie", gateway: "http://127.0.0.1:3425", + proxyNow: "none", proxySource: "none", login: false, + visionModels: [], imageGenModels: [], workbuddyCheckins: [], lanURLs: [], + fx: { rate: 7.2, at: new Date().toISOString(), stale: false }, + }; +} + +// ctl holds what the backend would: the version out, and the two settings +function server(lang, ctl) { + return async (route) => { + const req = route.request(), url = new URL(req.url()); + const json = (data) => route.fulfill({ json: data }); + if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:false};` }); + if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" }); + if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings: settingsPayload(lang, ctl), fx: settingsPayload(lang, ctl).fx }); + if (url.pathname === "/api/settings/update-skip") { + ctl.skips.push(req.postDataJSON().version); + ctl.skip = req.postDataJSON().version; + return json(settingsPayload(lang, ctl)); + } + if (url.pathname === "/api/settings") { + if (req.method() === "POST") { + const body = req.postDataJSON(); + ctl.off = !!body.noUpdatePill; + ctl.saves.push(body); + } + return json(settingsPayload(lang, ctl)); + } + if (url.pathname === "/api/update") return json({ state: "ready", current: "0.1.400", latest: ctl.latest }); + if (url.pathname === "/api/plugins") return json({ plugins: [] }); + if (url.pathname === "/api/usage/quotas") return json([]); + if (url.pathname === "/api/groups") return json({ groups: [], models: [] }); + if (url.pathname.startsWith("/api/")) return json({}); + const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname); + const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)]; + await route.fulfill({ body: await fs.readFile(file), contentType }); + }; +} + +const fresh = (over) => ({ latest: "0.1.401", off: false, skip: "", skips: [], saves: [], ...over }); +// wheel a row into sight, as a user would; a click must then not move the page +async function showRow(page, row) { + await page.locator("#view-settings").hover(); + for (let i = 0; i < 40; i++) { + const box = await row.boundingBox(); + const view = await page.locator("#view-settings").boundingBox(); + if (box && view && box.y >= view.y + 4 && box.y + box.height <= view.y + view.height - 4) break; + await page.mouse.wheel(0, 180); + await page.waitForTimeout(16); + } + await page.waitForTimeout(250); +} +const scrolls = (page) => page.evaluate(() => [window.scrollY, document.scrollingElement.scrollTop, ...[...document.querySelectorAll(".view")].map((v) => v.scrollTop)].join(",")); + +for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) { + test(engine + ": the Update pill can be hidden", async (t) => { + const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" })); + t.after(() => browser.close()); + const open = async (lang, ctl, query) => { + const errors = []; + const page = await (await browser.newContext({ viewport: { width: query.includes("panel") ? 420 : 900, height: 560 }, reducedMotion: "reduce" })).newPage(); + page.setDefaultTimeout(5000); + page.on("pageerror", (e) => errors.push(e.message)); + await page.route("**/*", server(lang, ctl)); + await page.goto("http://magpie.test/" + query); + return { page, errors }; + }; + for (const lang of ["en", "zh"]) { + const w = words[lang]; + await t.test(lang + ": the × hides it for this version, a newer one brings it back", async () => { + const ctl = fresh(); + const { page, errors } = await open(lang, ctl, "?mode=panel"); + const pill = page.locator("#update"), x = page.locator("#updateHide"); + await pill.waitFor({ state: "visible" }); + assert.equal((await pill.innerText()).trim(), w.update); + assert.equal(await x.getAttribute("aria-label"), w.hide); + assert.equal(await x.getAttribute("title"), w.hide); + // out of sight until the pointer is over the pill + assert.equal(await x.evaluate((e) => getComputedStyle(e).opacity), "0"); + await pill.hover(); + await page.waitForFunction(() => getComputedStyle(document.querySelector("#updateHide")).opacity === "1"); + const before = await scrolls(page); + await x.click(); + await pill.waitFor({ state: "hidden" }); + assert.deepEqual(ctl.skips, ["0.1.401"]); + assert.equal(await scrolls(page), before, "the click must not scroll the page"); + assert.equal(await x.isVisible(), false); + await page.reload(); + await page.locator("#sync").waitFor(); + await page.waitForTimeout(400); + assert.equal(await pill.isHidden(), true, "still hidden for 0.1.401"); + ctl.latest = "0.1.402"; + await page.reload(); + await pill.waitFor({ state: "visible" }); + // and a right-click hides it as well + await pill.click({ button: "right" }); + await pill.waitFor({ state: "hidden" }); + assert.deepEqual(ctl.skips, ["0.1.401", "0.1.402"]); + assert.deepEqual(errors, []); + }); + + await t.test(lang + ": Settings turns it off, and shows it again", async () => { + const ctl = fresh({ skip: "0.1.401" }); + const { page, errors } = await open(lang, ctl, "?view=settings"); + const row = page.locator("#about .row.pref", { has: page.locator(".name", { hasText: w.pill }) }); + await row.locator(".sub", { hasText: w.hidden }).waitFor(); + // the version row still offers the update + await page.locator("#about .row.pref", { has: page.locator(".name", { hasText: w.version }) }).locator("button", { hasText: w.restart }).waitFor(); + assert.equal(await page.locator("#update").isHidden(), true); + await showRow(page, row); + await row.locator("button", { hasText: w.again }).click(); + await page.locator("#update").waitFor({ state: "visible" }); + assert.deepEqual(ctl.skips, [""]); + await row.locator(".sub", { hasText: w.hidden }).waitFor({ state: "detached" }); + // off for good: no pill, whatever version is out + await showRow(page, row); + const before = await scrolls(page); + await row.locator("button", { hasText: w.off }).click(); + await page.locator("#update").waitFor({ state: "hidden" }); + assert.equal(ctl.saves.at(-1).noUpdatePill, true); + assert.equal(await scrolls(page), before, "the click must not scroll the page"); + ctl.latest = "0.1.402"; + await page.reload(); + await page.locator("#sync").waitFor(); + await page.waitForTimeout(400); + assert.equal(await page.locator("#update").isHidden(), true); + await showRow(page, row); + await page.locator("#about .row.pref", { has: page.locator(".name", { hasText: w.pill }) }).locator("button", { hasText: w.on }).click(); + await page.locator("#update").waitFor({ state: "visible" }); + assert.equal(ctl.saves.at(-1).noUpdatePill, false); + assert.deepEqual(errors, []); + }); + } + }); +} diff --git a/internal/settings/settings.go b/internal/settings/settings.go index 6a8b2d5eb..590d222c6 100644 --- a/internal/settings/settings.go +++ b/internal/settings/settings.go @@ -97,6 +97,12 @@ type Settings struct { // NoStats stops the one event a day that counts magpie's users (see // internal/stats). NoStats bool `json:"noStats,omitempty"` + // NoUpdatePill keeps the header's Update pill away when a newer magpie + // is out; UpdateSkip is the one version it was hidden for, and a newer + // one brings it back. Either way magpie still downloads the version and + // puts it in as it quits, and Settings' version row still offers it. + NoUpdatePill bool `json:"noUpdatePill,omitempty"` + UpdateSkip string `json:"updateSkip,omitempty"` // Vision is the model that describes an image to a model that can't see // it: a model's id (provider/model, group/), "off" to turn such an // image away, or empty for one magpie picks (see gateway.seer).