From 8607a7a029079bcee1eb5577871fc697788a6896 Mon Sep 17 00:00:00 2001 From: yetone Date: Mon, 9 Nov 2026 23:57:40 +0800 Subject: [PATCH] library: a skill GitHub's limit left unchecked leads to the token's row MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A skill check that ran into GitHub's 60-an-hour limit says "Add a GitHub token in Settings → Network and sharing", in a status line that fades and a tag's tooltip, and nothing there went to Settings (the scattered settings audit after netube99 on X). The Not checked tag is now a link when the limit was the one without a token: it opens Settings › Network and sharing and lights the GitHub token's row. A token's own limit has nothing to add there, so its tag stays plain. github-token.test.cjs swaps its route between rounds with unrouteAll({ behavior: "ignoreErrors" }): the click leaves Settings' lazy files being served, and the old unroute made the next round's handler fulfil a route already handled. Run (mote, through mote-run): github-token.test.cjs, Chromium and WebKit, en and zh, 8 of 8; github-token plus every library-*.test.cjs before the route fix: 1211 pass, the one red that route race. Broken by hand: the tag never a link, 4 of 8 red (each limited case). Not tried: the real app's window; the whole GUI suite runs after the last of these changes. --- internal/gui/assets/plugins/library/client.js | 9 ++++++++- internal/gui/assets/plugins/library/library.css | 2 ++ internal/gui/tests/github-token.test.cjs | 11 +++++++++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/internal/gui/assets/plugins/library/client.js b/internal/gui/assets/plugins/library/client.js index f89a37ae1..f6390de78 100644 --- a/internal/gui/assets/plugins/library/client.js +++ b/internal/gui/assets/plugins/library/client.js @@ -5791,7 +5791,14 @@ magpie.plugin("library", (ctx) => { } nm.append(b); } else if (c?.status === "unknown") { - nm.append(tag(t("Not checked"), "lib-unchecked", checkError(c))); + const b = tag(t("Not checked"), "lib-unchecked", checkError(c)); + // GitHub's limit without a token: the tag leads to where one is + // added, Settings › Network and sharing's GitHub row + if (c.limited && !c.limited.token) { + b.classList.add("link"); + b.onclick = (e) => { e.stopPropagation(); openSettingsAt(e, "network", "#githubList .row"); }; + } + nm.append(b); } // changed here since it was fetched from GitHub (#1449): an update asks // before it replaces that diff --git a/internal/gui/assets/plugins/library/library.css b/internal/gui/assets/plugins/library/library.css index d8712d4a3..b229ebb7f 100644 --- a/internal/gui/assets/plugins/library/library.css +++ b/internal/gui/assets/plugins/library/library.css @@ -234,6 +234,8 @@ button.row.lib-hubfolded:hover { background: var(--pill); } .lib-tag.lib-new.link { cursor: pointer; } .lib-tag.lib-new.link:hover { background: color-mix(in srgb, var(--accent) 22%, var(--accent-soft)); } .lib-tag.lib-unchecked { color: var(--faint); font-weight: 400; } +.lib-tag.lib-unchecked.link { cursor: pointer; } +.lib-tag.lib-unchecked.link:hover { color: var(--fg-2); } .lib-tag.lib-signed { color: var(--green); background: var(--green-soft); } .lib-tag.lib-signed::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; } diff --git a/internal/gui/tests/github-token.test.cjs b/internal/gui/tests/github-token.test.cjs index f3b962311..393372ea5 100644 --- a/internal/gui/tests/github-token.test.cjs +++ b/internal/gui/tests/github-token.test.cjs @@ -4,7 +4,8 @@ // row: a token typed is saved on its own and shown masked, with Remove; one // GITHUB_TOKEN / GH_TOKEN gives is said; one refused is said in the row, // what was typed kept; nothing scrolls. And a check GitHub limited says so -// in the page's words: until when, and that a token in Settings raises it. +// in the page's words: until when, and that a token in Settings raises it, +// and its tag opens the token's row there. // In English and Chinese, with the API faked. const assert = require("node:assert/strict"); const fs = require("node:fs/promises"); @@ -134,7 +135,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", const errors = []; page.on("pageerror", (e) => errors.push(e.message)); for (const st of [{ mask: "", from: "" }, { mask: "ghp_…0123", from: "settings" }]) { - await page.unroute("**/*"); + // a click before can leave a file being served: let it go + await page.unrouteAll({ behavior: "ignoreErrors" }); await page.route("**/*", serve(lang, [], st)); await watchSettingsReads(page); await page.goto("http://magpie.test/?view=library"); @@ -149,6 +151,11 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", const want = (st.from ? w.withToken : w.limited).replace("{time}", time); assert((await page.locator("#status").textContent()).includes(want), `status: ${await page.locator("#status").textContent()}`); assert.equal(await page.locator("#view-library .lib-unchecked").getAttribute("title"), want); + // without a token the tag leads to the GitHub token's row + if (!st.from) { + await page.locator("#view-library .lib-unchecked").click(); + await page.locator("#view-settings #githubList .row.flash").waitFor(); + } else assert.equal(await page.locator("#view-library .lib-unchecked.link").count(), 0, "a token's own limit has nothing to add"); } assert.deepEqual(errors, []); });