Kiko03O1 on X asked for a better-looking Plugins › Discover page
("ui 设计能不能好看点"). Five things on it said one thing twice or said
it raw:
- A GitHub card had an "Unofficial" chip. A GitHub card is only ever
drawn in the 非官方插件 · GitHub section, so the chip repeated the
section's head on every card. It is gone from the card; the plugin's
page keeps its full warning.
- Sign in on a card and on an Installed row is tinted like Install,
not filled. It stays filled only in the plugin's sheet, so each level
of action has one look.
- The GitHub line said Go's English in the middle of a zh page ("no
answer in 8s"). internal/plugin's GitHub read now wraps its timeout in
ErrNoAnswer; /api/plugins/github passes `why`: "slow" for that or any
timeout, "limited" for GitHub's rate limit (ghtoken.Limited), and the page says "GitHub 响应超时" (zh, zh-TW, ja, de); the raw
error is the line's hover. The line is smaller and muted, and Retry
takes the accent colour.
- The second filter row's All had a count. It always equalled
Installed + Not installed and the first row's picked count, so
"全部 · N" showed twice side by side. It has no count now.
- Found on the way, same page: the filter box's placeholder was cut off
in en at 1280/1100/980 and in de at every width but 420. It fits at
every width now; the filter bar wraps where it did.
Looked at and left alone: the 8px inset on the borderless Signed in,
and the monospace version numbers.
plugins.js nets -25 bytes (the Unofficial chip's code went), so the
core script budget is unchanged: TestCoreScriptBudget passes at the
pushed head with no raise.
What was run, at this change on origin/main 4b9694c34, and again after
the last rebase onto 0df6a3aba: TestCoreScriptBudget, TestTaggedWhyKind,
gofmt, and the four changed GUI files with i18n-keys in both engines
(80 of 80):
- Red without the change: with the old assets, the four changed GUI
files (plugin-github, plugin-github-wait, plugin-github-filter,
plugin-market) went 37 red in Chromium; plugin-market expected the
tinted colour and got the filled one. TestTaggedWhyKind doesn't
compile without the change.
- Changed and nearby GUI files (those four, i18n-keys,
plugin-check-github-limit, plugin-kinds-discover, plugin-page), both
engines: 124 of 124 pass.
- gofmt clean. go vet clean on darwin, linux (-tags nogui) and windows;
all three build. go test internal/gui and internal/plugin: plugin ok;
gui ok on its own, one red in the package run,
TestMainWindowCorners/macOS_15_SDK killed at its 40s deadline at load
~85 (#2645), which passes alone.
- The whole GUI suite (858 files, both engines, concurrency 3) was
started at 628e18987 and ended early when the disk filled (ENOSPC):
~350 files ran, 3108 passed. Its five reds from before the disk
filled are off the Plugins page, pass alone, and are filed:
agent-models (#3468), cli-update (#3473), context-picks (#3483),
deprecated-subscriptions (#3484). The rest failed launching a browser
with ENOSPC.
- Rerun after space was freed, at d7ad3f2a3 plus this change: every
library-* file, every plugin-* file, login-import, menu-input-scroll,
mobile-web, name-suffix-saved and i18n-keys (94 files, both engines):
1414 of 1426 pass. The 12 reds are all red on an origin/main
118486258 worktree too, and filed: library-mcp-health-wsl ja (#3350),
menu-input-scroll (#3402, 0 of 4 on main), plugin-card-update webkit
(#3079, 0-1 of 3 on main over three runs, same Update-button wait),
plugin-github chromium de 440 scrolled 1px (#3218, 18 of 18 alone).
- The two files after name-suffix-saved outside plugin-* that open the
Plugins page, settings-tabs-stick and title-bar-tools, both engines:
42 of 42 pass.
- Not run: the other ~440 GUI files after name-suffix-saved, and
go test ./... .
Screenshots, before and after, zh dark and en light, were checked by
eye at 1280.
250 lines
17 KiB
JavaScript
250 lines
17 KiB
JavaScript
// Run with Node's test runner and Playwright on the module path; see README.md.
|
|
// GitHub answers after the rest of the plugins page, seconds after on a
|
|
// slow line, and the Unofficial section wasn't drawn until it did, so it
|
|
// read as there being no unofficial plugins (yetone: 当还没加载完的时候,
|
|
// 压根就不显示,会让那些网慢的用户以为没有非官方插件). While
|
|
// /api/plugins/github is held here, Discover shows the section in its
|
|
// place, before the field, with its head, a word that it is looking and
|
|
// cards still to come; let go, its cards come in where those were and the
|
|
// word goes. A search while it waits shows the same. When the ask fails,
|
|
// the section says so with Try again, which asks again. magpie answering
|
|
// with an error beside the list (GitHub unreachable from the reader's
|
|
// desktop: till on Discord, where the section just wasn't there) is said
|
|
// too: with no list, in the section's place with why and Try again, which
|
|
// has magpie ask GitHub at once (?again=1); with the cards it could give,
|
|
// a line over them saying how many more couldn't be read, and why. English, Chinese,
|
|
// Japanese and German, wide and 440px, in Chromium and WebKit; nothing
|
|
// scrolls on a click. MAGPIE_WAIT_ASSETS names an older assets directory,
|
|
// to see this fail on the code before it.
|
|
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(process.env.MAGPIE_WAIT_ASSETS || path.resolve(__dirname, "../assets"));
|
|
|
|
const REPOS = [
|
|
{ spec: "opencode-claude-auth", repo: "griffinmartin/opencode-claude-auth", url: "https://github.com/griffinmartin/opencode-claude-auth", owner: "griffinmartin", description: "OpenCode plugin that uses your existing Claude Code credentials — no separate login needed. ", stars: 1301, license: "MIT", pushed: "2026-09-22T23:47:15Z", package: "opencode-claude-auth", version: "2.2.1" },
|
|
{ spec: "github:keli-wen/agy-staff", repo: "keli-wen/agy-staff", url: "https://github.com/keli-wen/agy-staff", owner: "keli-wen", description: "Hire Google's Antigravity CLI (agy) as a fast Gemini staffer for Claude Code and OpenAI Codex.", stars: 723, license: "MIT", pushed: "2026-10-06T16:29:15Z", package: "agy-staff", version: "0.7.4" },
|
|
];
|
|
const LISTINGS = [
|
|
{ package: "@magpie-community/opencode-zed-auth", name: "Zed", community: true, kind: "pv", npm: { version: "0.1.8", weekly: 90, license: "MIT" } },
|
|
];
|
|
|
|
// gh: how /api/plugins/github answers each time it is asked, in turn: a
|
|
// promise held until let go, "fail", or { json } as magpie's answer;
|
|
// urls: each ask's URL
|
|
function server(lang, gh, urls = []) {
|
|
let asked = 0;
|
|
return async (route) => {
|
|
const url = new URL(route.request().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: { lang, theme: "light" } });
|
|
if (url.pathname === "/api/providers") return json({ providers: [], presets: [], excluded: [], gateway: { running: true, window: true }, plugins: [] });
|
|
if (url.pathname === "/api/groups") return json({ groups: [], pools: [] });
|
|
if (url.pathname === "/api/plugins") return json({ bun: true, bunVersion: "1.4.2", plugins: [], picker: false, movable: [] });
|
|
if (url.pathname === "/api/plugins/listings") return json({ listings: LISTINGS });
|
|
if (url.pathname === "/api/plugins/github") {
|
|
const next = gh[asked++] ?? gh.at(-1);
|
|
urls.push(url.pathname + url.search);
|
|
if (next?.json) return json(next.json);
|
|
if (next === "fail") return route.fulfill({ status: 502, contentType: "text/plain", body: "GitHub didn't answer" });
|
|
await next;
|
|
return json({ repos: REPOS, topic: "magpie-plugin" }).catch(() => {});
|
|
}
|
|
if (url.pathname === "/api/plugins/search") return json({ hits: [] });
|
|
if (url.pathname.startsWith("/api/")) return json({});
|
|
if (!/^\/[\w./-]*$/.test(url.pathname) || url.host !== "magpie.test") return route.fulfill({ status: 404, body: "" });
|
|
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)];
|
|
try { await route.fulfill({ body: await fs.readFile(file), contentType }); } catch { await route.fulfill({ status: 404, body: "" }); }
|
|
};
|
|
}
|
|
|
|
const L = {
|
|
en: { section: "Unofficial, on GitHub", look: "Looking on GitHub", failed: /Couldn't ask GitHub/, again: "Try again", none: /GitHub found 12 repositories, but none of them could be read/, more: /12 more on GitHub couldn't be read/, slow: /7 more on GitHub couldn't be read: GitHub didn't answer in time/ },
|
|
zh: { section: "非官方插件 · GitHub", look: "正在 GitHub 上查找", failed: /无法连接 GitHub/, again: "重试", none: /GitHub 找到了 12 个仓库,但一个都没能读取/, more: /GitHub 上还有 12 个插件没能读取/, slow: /GitHub 上还有 7 个插件没能读取:GitHub 响应超时/ },
|
|
ja: { section: "非公式 · GitHub", look: "GitHub を検索中", failed: /GitHub に接続できませんでした/, again: "再試行", none: /GitHub で 12 件のリポジトリが見つかりましたが/, more: /GitHub 上のほか 12 件を読み込めませんでした/, slow: /GitHub の応答がタイムアウトしました/ },
|
|
de: { section: "Inoffiziell, auf GitHub", look: "Suche auf GitHub", failed: /GitHub nicht erreichbar/, again: "Erneut versuchen", none: /GitHub hat 12 Repositories gefunden/, more: /12 weitere auf GitHub konnten nicht gelesen werden/, slow: /GitHub hat nicht rechtzeitig geantwortet/ },
|
|
};
|
|
|
|
const shot = async (loc, name) => {
|
|
if (!process.env.ARTIFACT_DIR) return;
|
|
await fs.mkdir(process.env.ARTIFACT_DIR, { recursive: true });
|
|
await loc.screenshot({ path: path.join(process.env.ARTIFACT_DIR, name + ".png") });
|
|
};
|
|
const held = () => { let go; const p = new Promise((r) => { go = r; }); p.go = go; return p; };
|
|
|
|
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
|
test(engine + ": the GitHub section while GitHub hasn't answered", async (t) => {
|
|
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: process.env.PLAYWRIGHT_CHANNEL || "chromium" }));
|
|
t.after(() => browser.close());
|
|
for (const lang of Object.keys(L)) {
|
|
for (const width of [980, 440]) {
|
|
await t.test(lang + " " + width, async () => {
|
|
const w = L[lang];
|
|
const open = async (gh, urls) => {
|
|
const ctx = await browser.newContext({ viewport: { width, height: 860 } });
|
|
const page = await ctx.newPage();
|
|
page.setDefaultTimeout(5000);
|
|
const errors = [];
|
|
page.on("pageerror", (e) => errors.push(e.message));
|
|
await page.route("**/*", server(lang, gh, urls));
|
|
await page.addInitScript(() => { try { localStorage.setItem("magpie.pluginTab", "discover"); } catch {} });
|
|
await page.goto("http://magpie.test/?view=plugins");
|
|
const view = page.locator("#view-plugins");
|
|
await view.waitFor({ state: "visible" });
|
|
await view.locator(".pm-card", { hasText: "Zed" }).waitFor();
|
|
const sec = view.locator(".pm-sec", { has: page.locator("h3", { hasText: w.section }) });
|
|
return { ctx, page, view, sec, errors };
|
|
};
|
|
|
|
// held: the section is there, before the field, looking
|
|
const wait = held();
|
|
const { ctx, page, view, sec, errors } = await open([wait]);
|
|
t.after(() => ctx.close());
|
|
await sec.waitFor();
|
|
const order = await view.locator(".pm-body > *").evaluateAll((es) => es.map((e) => e.className));
|
|
assert.ok(order.findIndex((c) => c.includes("pm-ghsec")) < order.findIndex((c) => c.includes("pm-manual")), "before the field: " + order);
|
|
assert.equal(await sec.getAttribute("aria-busy"), "true");
|
|
assert.match(await sec.locator(".pm-sechead > span").first().innerText(), /magpie-plugin/);
|
|
const look = sec.locator(".pm-ghlook");
|
|
assert.equal((await look.innerText()).trim(), w.look);
|
|
assert.equal(await look.getAttribute("role"), "status");
|
|
assert.equal(await sec.locator(".pm-card.ghost").count(), 3);
|
|
// the light moves: a ghost's bar is animated, and each card a beat after the last
|
|
const anim = await sec.locator(".pm-card.ghost .sk").evaluateAll((es) => es.map((e) => [getComputedStyle(e).animationName, getComputedStyle(e).animationDelay]));
|
|
assert.ok(anim.every(([n]) => n === "pm-sheen"), "sheen: " + JSON.stringify(anim));
|
|
assert.notEqual(anim[0][1], anim.at(-1)[1], "a beat apart");
|
|
// a ghost is laid out as a card: nothing spills at this width
|
|
for (const g of await sec.locator(".pm-card.ghost").all()) {
|
|
assert.ok(await g.evaluate((e) => e.scrollWidth <= e.clientWidth + 1 && e.getBoundingClientRect().height > 70), "ghost fits");
|
|
}
|
|
await shot(sec, `wait-${engine}-${lang}-${width}`);
|
|
|
|
// a search while it waits: the same section, waiting
|
|
const q = view.locator(".pm-head .pm-find input");
|
|
await q.fill("claude");
|
|
await sec.locator(".pm-ghlook").waitFor();
|
|
assert.equal(await sec.locator(".pm-card.ghost").count(), 3);
|
|
await q.fill("");
|
|
await sec.locator(".pm-ghlook").waitFor();
|
|
|
|
// let go: its cards in the ghosts' place, the word gone
|
|
wait.go();
|
|
await sec.locator(".pm-card:not(.ghost)").first().waitFor();
|
|
assert.equal(await sec.locator(".pm-card.ghost").count(), 0);
|
|
assert.equal(await sec.locator(".pm-ghlook").count(), 0);
|
|
assert.equal(await sec.getAttribute("aria-busy"), null);
|
|
assert.deepEqual(await sec.locator(".pm-card .pm-name b").allInnerTexts(), ["opencode-claude-auth", "agy-staff"]);
|
|
await page.waitForFunction(() => !document.querySelector(".pm-arrive"));
|
|
await shot(sec, `came-${engine}-${lang}-${width}`);
|
|
assert.deepEqual(errors, []);
|
|
|
|
// failed: said so, and Try again asks again
|
|
const again = held();
|
|
const f = await open(["fail", again]);
|
|
t.after(() => f.ctx.close());
|
|
await f.sec.locator(".pm-ghnone").waitFor();
|
|
assert.match(await f.sec.locator(".pm-ghnone").innerText(), w.failed);
|
|
assert.equal(await f.sec.locator(".pm-card").count(), 0);
|
|
await shot(f.sec, `failed-${engine}-${lang}-${width}`);
|
|
const before = await f.page.evaluate(() => [window.scrollY, ...[...document.querySelectorAll("*")].filter((e) => e.scrollTop > 0).map((e) => (e.id || e.className) + ":" + e.scrollTop)].join());
|
|
await f.sec.getByRole("button", { name: w.again }).click();
|
|
await f.sec.locator(".pm-ghlook").waitFor();
|
|
assert.equal(await f.page.evaluate(() => [window.scrollY, ...[...document.querySelectorAll("*")].filter((e) => e.scrollTop > 0).map((e) => (e.id || e.className) + ":" + e.scrollTop)].join()), before, "nothing scrolls on Try again");
|
|
again.go();
|
|
await f.sec.locator(".pm-card:not(.ghost)").first().waitFor();
|
|
assert.equal(await f.sec.locator(".pm-ghnone").count(), 0);
|
|
assert.deepEqual(f.errors, []);
|
|
|
|
// magpie answers, but GitHub couldn't give it the list: said in
|
|
// the section's place with why, never the section gone
|
|
const why = 'http://raw.githubusercontent.com/a/b/main/package.json: Get "https://raw.githubusercontent.com/a/b/main/package.json": dial tcp: i/o timeout';
|
|
const urls = [];
|
|
const later = held();
|
|
const e = await open([{ json: { repos: [], topic: "magpie-plugin", error: why, missing: 12 } }, later], urls);
|
|
t.after(() => e.ctx.close());
|
|
await e.sec.locator(".pm-ghnone").waitFor();
|
|
const said = await e.sec.locator(".pm-ghnone").innerText();
|
|
assert.match(said, w.none);
|
|
assert.ok(said.includes("i/o timeout"), said);
|
|
// its reason wraps: nothing spills at this width
|
|
assert.ok(await e.sec.evaluate((s) => s.scrollWidth <= s.clientWidth + 1), "the reason fits");
|
|
await shot(e.sec, `unread-${engine}-${lang}-${width}`);
|
|
// the search field's results say it too
|
|
const eq = e.view.locator(".pm-head .pm-find input");
|
|
await eq.fill("claude");
|
|
await e.sec.locator(".pm-ghnone").waitFor();
|
|
await eq.fill("");
|
|
await e.sec.locator(".pm-ghnone").waitFor();
|
|
// Try again has magpie ask GitHub at once (wheeled into sight
|
|
// first, clear of the window's footer, as a reader would)
|
|
const eAgain = e.sec.getByRole("button", { name: w.again });
|
|
await e.page.mouse.move(width / 2, 300);
|
|
for (let i = 0; i < 4; i++) await e.page.mouse.wheel(0, 400);
|
|
await eAgain.click();
|
|
await e.sec.locator(".pm-ghlook").waitFor();
|
|
later.go();
|
|
await e.sec.locator(".pm-card:not(.ghost)").first().waitFor();
|
|
assert.deepEqual(urls, ["/api/plugins/github", "/api/plugins/github?again=1"]);
|
|
assert.equal(await e.sec.locator(".pm-ghwarn, .pm-ghnone").count(), 0);
|
|
assert.deepEqual(e.errors, []);
|
|
|
|
// some came, some couldn't be read: the cards, and a line over
|
|
// them saying so with Try again, which keeps the cards meanwhile
|
|
const urls2 = [];
|
|
const later2 = held();
|
|
const m = await open([{ json: { repos: REPOS, topic: "magpie-plugin", error: why, missing: 12 } }, later2], urls2);
|
|
t.after(() => m.ctx.close());
|
|
await m.sec.locator(".pm-ghwarn").waitFor();
|
|
assert.match(await m.sec.locator(".pm-ghwarn").innerText(), w.more);
|
|
assert.equal(await m.sec.locator(".pm-card:not(.ghost)").count(), 2);
|
|
assert.ok(await m.sec.evaluate((s) => s.scrollWidth <= s.clientWidth + 1), "the line fits");
|
|
await shot(m.sec, `partial-${engine}-${lang}-${width}`);
|
|
const mAgain = m.sec.locator(".pm-ghwarn").getByRole("button", { name: w.again });
|
|
await m.page.mouse.move(width / 2, 300);
|
|
for (let i = 0; i < 4; i++) await m.page.mouse.wheel(0, 400);
|
|
await mAgain.click();
|
|
assert.equal(await m.sec.locator(".pm-card:not(.ghost)").count(), 2, "cards kept while asking");
|
|
later2.go();
|
|
await m.sec.locator(".pm-ghwarn").waitFor({ state: "detached" });
|
|
assert.equal(await m.sec.locator(".pm-card:not(.ghost)").count(), 2);
|
|
assert.deepEqual(urls2, ["/api/plugins/github", "/api/plugins/github?again=1"]);
|
|
assert.deepEqual(m.errors, []);
|
|
|
|
// GitHub too slow, as magpie tells it (why: "slow"): the line
|
|
// says so in the reader's language, not Go's "no answer in 8s"
|
|
// in the middle of the page, and the error as it came is its
|
|
// hover (the Kiko03O1 reply on X: ui 设计能不能好看点); Try
|
|
// again reads as a button, in the accent
|
|
const s = await open([{ json: { repos: REPOS, topic: "magpie-plugin", error: "no answer in 8s", why: "slow", missing: 7 } }]);
|
|
t.after(() => s.ctx.close());
|
|
const sLine = s.sec.locator(".pm-ghwarn");
|
|
await sLine.waitFor();
|
|
assert.match(await sLine.innerText(), w.slow);
|
|
assert.doesNotMatch(await sLine.innerText(), /no answer/);
|
|
assert.equal(await sLine.locator("span").first().getAttribute("title"), "no answer in 8s");
|
|
const tone = (v) => s.page.evaluate((v) => { const d = document.createElement("div"); d.style.color = `var(${v})`; document.body.append(d); const c = getComputedStyle(d).color; d.remove(); return c; }, v);
|
|
assert.equal(await sLine.getByRole("button", { name: w.again }).evaluate((b) => getComputedStyle(b).color), await tone("--accent"));
|
|
assert.deepEqual(s.errors, []);
|
|
|
|
// a failed ask after a list was had: the list stands, and the
|
|
// line says it is from before
|
|
const k = await open([{ json: { repos: REPOS, topic: "magpie-plugin" } }, { json: { repos: [], topic: "magpie-plugin", error: "GitHub's search: 403 rate limit" } }]);
|
|
t.after(() => k.ctx.close());
|
|
await k.sec.locator(".pm-card:not(.ghost)").first().waitFor();
|
|
await k.page.evaluate(() => window.loadPlugins());
|
|
await k.sec.locator(".pm-ghwarn").waitFor();
|
|
assert.match(await k.sec.locator(".pm-ghwarn").innerText(), /403 rate limit/);
|
|
assert.equal(await k.sec.locator(".pm-card:not(.ghost)").count(), 2);
|
|
assert.deepEqual(k.errors, []);
|
|
});
|
|
}
|
|
}
|
|
});
|
|
}
|