From 0acba61a35cbfd98995050b20afa49985cf71040 Mon Sep 17 00:00:00 2001 From: yetone Date: Tue, 3 Nov 2026 17:58:06 +0800 Subject: [PATCH] gui: a lone plugin's check-in tab is named for it, not "Plugins" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ljq906416 and justrun_way on X couldn't find WorkBuddy's daily check-in after it moved to its plugin. The WorkBuddy plugin (0.2.0 on) checks in itself, so magpie hides its own WorkBuddy tab under Settings › Usage's check-in tabs and the switch sits under a tab labelled "Plugins" (插件), which nobody looking for WorkBuddy reads. With one plugin checking in, the tab now carries that plugin's name (WorkBuddy), as a built-in's tab does; two or more still share "Plugins". The label is set through data-en, so a language change keeps it. Run (wsl-run, Linux, Chromium + WebKit, en/zh/zh-TW/ja/de): plugin-checkin, checkin-reason, checkin-reason-once and i18n-keys: 64 pass, 0 fail. The new two-plugin test checks the shared tab's translated name and both rows; the 440px test checks the lone tab reads "FakeCo". Broken by hand: with the old app.js the 440px test fails in chromium en and zh (expected FakeCo, read "Plugins"); the two-plugin test passes there, as it guards the shared case. Size budgets summed by hand the way TestCoreScriptBudget does (the Go package needs cgo, which wsl lacks): app.js 1,308,499 of 1,316,874, core 1,529,963 of 1,533,802, no raise. Not tried: the real app with a signed-in WorkBuddy plugin. --- internal/gui/assets/app.js | 7 ++++-- internal/gui/tests/plugin-checkin.test.cjs | 27 +++++++++++++++++++--- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index f1a2efaa9..951bc211e 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -22457,8 +22457,11 @@ async function renderUpdate(r, u) { // a Daily check-in row per plugin that checks in itself (auth.checkin) function renderPluginCheckins(s) { - const ps = s.checkinPlugins || []; - $("#warmTab-plugins").hidden = !ps.length; + const ps = s.checkinPlugins || [], tab = $("#warmTab-plugins"); + tab.hidden = !ps.length; + // one plugin checking in: its tab is its name, as a built-in's is + tab.dataset.en = ps.length === 1 ? ps[0].name || ps[0].id : "Plugins"; + tab.textContent = t(tab.dataset.en); setWarmTab(warmTab); $("#pluginCheckinList").replaceChildren(...ps.map((p) => { const row = el("div", "row pref"); diff --git a/internal/gui/tests/plugin-checkin.test.cjs b/internal/gui/tests/plugin-checkin.test.cjs index 357064593..a02abb3f6 100644 --- a/internal/gui/tests/plugin-checkin.test.cjs +++ b/internal/gui/tests/plugin-checkin.test.cjs @@ -72,12 +72,12 @@ const quotas = () => [ { provider: "codex", name: "Codex", icon: "openai", plan: "Plus", windows: [{ name: "5 hours", used: 20 }] }, ]; -function serve(lang, asked) { +function serve(lang, asked, more = []) { const settings = { theme: "light", lang, quotaLeft: false, currency: "usd", pluginCheckins: { fakeco: false }, checkinPlugins: [{ id: "fakeco", name: "FakeCo", on: false, checkins: [ { user: "ann", by: "plugin:fakeco", vendor: "FakeCo", day: today, outcome: "claimed", credit: 50, streak: 3 }, { user: "bob", by: "plugin:fakeco", vendor: "FakeCo", day: today, outcome: "captcha" }, - ] }] }; + ] }, ...more] }; return async (route) => { const url = new URL(route.request().url()); const json = (data) => route.fulfill({ json: data }); @@ -173,6 +173,26 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", assert.deepEqual(errors, []); }); + test(`${engine} ${lang}: two plugins checking in share one Plugins tab`, async (t) => { + const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" })); + t.after(() => browser.close()); + const page = await (await browser.newContext({ viewport: { width: 900, height: 900 }, reducedMotion: "reduce" })).newPage(); + page.setDefaultTimeout(5000); + page.setDefaultNavigationTimeout(60000); + const errors = []; + page.on("pageerror", (e) => errors.push(e.message)); + await page.route("**/*", serve(lang, [], [{ id: "otherco", name: "OtherCo", on: true, checkins: [] }])); + await watchSettingsReads(page); + await page.goto("http://magpie.test/?view=settings&tab=usage"); + await settingsDrawn(page); + const tab = page.locator("#warmTab-plugins"); + await tab.waitFor(); + assert.equal((await tab.textContent()).trim(), w.tab); + await tab.click(); + for (const id of ["fakeco", "otherco"]) await page.locator(`#pluginCheckinList .row[data-provider="${id}"]`).waitFor(); + assert.deepEqual(errors, []); + }); + test(`${engine} ${lang}: Settings has a Plugins check-in tab at 440px`, async (t) => { const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" })); t.after(() => browser.close()); @@ -188,7 +208,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", const tab = page.locator("#warmTab-plugins"); await tab.waitFor(); assert.equal(await tab.isHidden(), false); - assert.equal((await tab.textContent()).trim(), w.tab); + // one plugin checks in: the tab is its name (WorkBuddy's users looked for "WorkBuddy") + assert.equal((await tab.textContent()).trim(), "FakeCo"); assert.equal(await page.locator("#warmTab-qoder").isHidden(), true, "Qoder's tab with no Qoder account"); // at 440x900 the tabs are below the fold: the reader scrolls to them await page.mouse.move(220, 400);