plugins: the Unofficial, on GitHub section shows while GitHub hasn't answered, looking, with cards still to come

On a slow line the section wasn't drawn until /api/plugins/github
answered, so Discover read as having no unofficial plugins (yetone:
当还没加载完的时候,压根就不显示,会让那些网慢的用户以为没有非官方插件).

While it waits, the section stands in its place before the field: its
head and hint, a quiet "Looking on GitHub" with three breathing dots
(role=status, aria-busy on the section), and three card-shaped ghosts
(logo, name, author, button, two lines, two chips) a soft light passes
over, each card a beat after the last. When GitHub answers, its cards
come in where the ghosts were with a short staggered fade-up. A search
while it waits shows the same. When the ask fails (and nothing was
loaded before) the section says "Couldn't ask GitHub: <error>" with Try
again, instead of disappearing. prefers-reduced-motion stops all of it.
Strings in zh, zh-TW, ja and de.

Run:
- new internal/gui/tests/plugin-github-wait.test.cjs: 18/18 on this tree
  (Chromium and WebKit; en, zh, ja, de; 980 and 440 wide; held, search
  while held, let go, 502 then Try again, no scroll on the click).
  With MAGPIE_WAIT_ASSETS at origin/main's assets: 9/9 red (Chromium).
  Screenshots of each state looked at.
- GUI files around it (plugin-*, i18n-*, builtins, nav-sub*,
  click-scroll, old-webkit, mobile-web): 602/620 under load. The reds,
  rerun one file at a time here and on origin/main a751f5282: the same
  31 pass / 6 fail on both; the fails are plugin-other-ways, filed as
  #2590. i18n-keys' plugins/routing duplicates and the nav-sub-unroll /
  plugin-market timeouts passed on the one-at-a-time rerun.
- go test ./internal/gui: TestMainWindowCorners killed at 40s at load
  ~140-200 (#1936, sighting added); alone it passes here and on main.
- node --check on plugins.js and i18n.js.
Not tried: the real app on Linux WebKitGTK (CSS animation of
background-position and opacity only, no view transition).
This commit is contained in:
yetone
2026-10-16 22:50:26 +08:00
parent a751f5282e
commit 1d6f461a99
4 changed files with 270 additions and 11 deletions
+8
View File
@@ -3463,6 +3463,8 @@ const I18N = {
"Tagged {topic} on GitHub by its author. Nobody at magpie has read it: read its code before you install it": "作者在 GitHub 上给它打了 {topic} 标签,magpie 没有审阅过:安装前请先看看它的代码",
"{n} stars on GitHub": "GitHub 上 {n} 个 Star",
"Unofficial, on GitHub": "非官方插件 · GitHub",
"Looking on GitHub": "正在 GitHub 上查找",
"Couldn't ask GitHub: {error}": "无法连接 GitHub:{error}",
"Kind of plugin": "插件类型",
"Installed or not": "是否已安装",
"Not installed": "未安装",
@@ -7120,6 +7122,8 @@ const I18N = {
"Tagged {topic} on GitHub by its author. Nobody at magpie has read it: read its code before you install it": "作者在 GitHub 上給它打了 {topic} 標籤,magpie 沒有審閱過:安裝前請先看看它的程式碼",
"{n} stars on GitHub": "GitHub 上 {n} 個 Star",
"Unofficial, on GitHub": "非官方外掛 · GitHub",
"Looking on GitHub": "正在 GitHub 上尋找",
"Couldn't ask GitHub: {error}": "無法連線 GitHub:{error}",
"Kind of plugin": "外掛類型",
"Installed or not": "是否已安裝",
"Not installed": "未安裝",
@@ -10799,6 +10803,8 @@ const I18N = {
"Tagged {topic} on GitHub by its author. Nobody at magpie has read it: read its code before you install it": "作者が GitHub で {topic} タグを付けたものです。magpie はレビューしていません。インストール前にコードを確認してください",
"{n} stars on GitHub": "GitHub のスター {n}",
"Unofficial, on GitHub": "非公式 · GitHub",
"Looking on GitHub": "GitHub を検索中",
"Couldn't ask GitHub: {error}": "GitHub に接続できませんでした:{error}",
"Kind of plugin": "プラグインの種類",
"Installed or not": "インストール済みかどうか",
"Not installed": "未インストール",
@@ -14491,6 +14497,8 @@ const I18N = {
"Tagged {topic} on GitHub by its author. Nobody at magpie has read it: read its code before you install it": "Vom Autor auf GitHub mit {topic} getaggt. Niemand bei magpie hat es geprüft: Lies den Code, bevor du es installierst",
"{n} stars on GitHub": "{n} Sterne auf GitHub",
"Unofficial, on GitHub": "Inoffiziell, auf GitHub",
"Looking on GitHub": "Suche auf GitHub",
"Couldn't ask GitHub: {error}": "GitHub nicht erreichbar: {error}",
"Kind of plugin": "Art des Plugins",
"Installed or not": "Installiert oder nicht",
"Not installed": "Nicht installiert",
+35 -7
View File
@@ -136,13 +136,40 @@ button.pm-chip:disabled { cursor: default; opacity: .6; }
.pm-act:disabled:not(.busy):not(.done) { opacity: .55; }
.pm-act .spin { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
/* loading: cards drawn as grey bars */
.pm-card.ghost { gap: 10px; pointer-events: none; }
.pm-card.ghost > div { border-radius: 6px; background: var(--pill); animation: pm-pulse 1.3s ease-in-out infinite; }
.pm-card.ghost .g1 { height: 36px; width: 60%; }
.pm-card.ghost .g2 { height: 11px; }
.pm-card.ghost .g3 { height: 11px; width: 40%; }
/* loading: cards laid out as a card is, in soft bars a light passes
over, one card a beat after the one before it */
.pm-card.ghost { gap: 9px; pointer-events: none; border-color: color-mix(in srgb, var(--line) 70%, transparent); }
.pm-card.ghost .sk {
border-radius: 5px;
background: linear-gradient(100deg, var(--pill) 30%, color-mix(in srgb, var(--pill-hover) 70%, var(--card)) 50%, var(--pill) 70%);
background-size: 300% 100%;
animation: pm-sheen 1.8s cubic-bezier(.45, 0, .25, 1) infinite;
animation-delay: calc(var(--i, 0) * 120ms);
}
.pm-card.ghost .gtop { display: flex; align-items: center; gap: 10px; }
.pm-card.ghost .gwho { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.pm-card.ghost .glogo { flex: none; width: 36px; height: 36px; border-radius: 10px; }
.pm-card.ghost .gname { height: 11px; width: 52%; }
.pm-card.ghost .gby { height: 8px; width: 30%; opacity: .7; }
.pm-card.ghost .gact { flex: none; width: 56px; height: 26px; border-radius: 13px; opacity: .8; }
.pm-card.ghost .gline { height: 8px; margin-top: 6px; }
.pm-card.ghost .gline.short { width: 68%; margin-top: 0; }
.pm-card.ghost .gmeta { display: flex; gap: 8px; margin-top: 7px; }
.pm-card.ghost .gchip { height: 8px; width: 46px; opacity: .8; }
.pm-card.ghost .gchip.short { width: 30px; }
@keyframes pm-pulse { 50% { opacity: .5; } }
@keyframes pm-sheen { from { background-position: 100% 0; } to { background-position: 0 0; } }
/* the GitHub section looking: three dots breathing in turn, and the word */
.pm-sechead .pm-ghlook { display: inline-flex; align-items: center; gap: 7px; margin-left: auto; font-size: 11px; color: var(--faint); animation: pm-fade .4s var(--ease) both .15s; }
.pm-ghlook .dots { display: inline-flex; gap: 3px; }
.pm-ghlook .dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); opacity: .25; animation: pm-breathe 1.2s ease-in-out infinite; }
.pm-ghlook .dots i:nth-child(2) { animation-delay: .16s; }
.pm-ghlook .dots i:nth-child(3) { animation-delay: .32s; }
@keyframes pm-breathe { 0%, 70%, 100% { opacity: .25; transform: none; } 35% { opacity: .9; transform: translateY(-1.5px); } }
@keyframes pm-fade { from { opacity: 0; } }
/* its cards when they come: in where the ghosts were, one after another */
.pm-arrive .pm-card { animation: pm-arrive .42s cubic-bezier(.2, .7, .2, 1) both; animation-delay: calc(var(--i, 0) * 40ms); }
@keyframes pm-arrive { from { opacity: 0; transform: translateY(4px); } }
.pm-note { margin: 0; padding: 4px 2px; font-size: 12px; color: var(--muted); }
.pm-note.bad { color: var(--red); }
@@ -246,5 +273,6 @@ button.pm-chip:disabled { cursor: default; opacity: .6; }
}
@media (prefers-reduced-motion: reduce) {
.pm-card { transition: none; }
.pm-card.ghost > div, .pm-rskel { animation: none; }
.pm-card.ghost .sk, .pm-rskel, .pm-ghlook, .pm-ghlook .dots i, .pm-arrive .pm-card { animation: none; }
.pm-ghlook .dots i { opacity: .5; }
}
+68 -4
View File
@@ -14,6 +14,7 @@
let mine = null; // /api/plugins: what's installed
let listings = null; // /api/plugins/listings: the plugins suggested
let tagged = null; // /api/plugins/github: repositories their authors tagged magpie-plugin, as listings
let taggedErr = ""; // why they couldn't be asked for, while none were had
let topic = "magpie-plugin";
const npm = {}; // /api/plugins/npm: package → what npm says of it
const heads = {}; // /api/plugins/git: a git plugin's spec → the commit its repository is at
@@ -171,8 +172,12 @@
try {
const r = await api("plugins/github");
tagged = (r.repos || []).map(ghListing);
taggedErr = "";
if (r.topic) topic = r.topic;
} catch { tagged = tagged || []; }
} catch (e) {
if (!tagged) taggedErr = e.message || String(e);
tagged = tagged || [];
}
}
async function loadListings() {
try {
@@ -547,11 +552,22 @@
return d;
}
// cards still to come, drawn as a card is laid out (its picture, name
// and author, two lines of summary, its facts) for a light to pass over,
// one card after the other
function skeleton(n) {
const g = el("div", "pm-grid");
g.setAttribute("aria-hidden", "true");
const bar = (c) => el("div", "sk " + c);
for (let i = 0; i < n; i++) {
const c = el("div", "pm-card ghost");
c.append(el("div", "g1"), el("div", "g2"), el("div", "g3"));
c.style.setProperty("--i", i);
const top = el("div", "gtop"), who = el("div", "gwho");
who.append(bar("gname"), bar("gby"));
top.append(bar("glogo"), who, bar("gact"));
const meta = el("div", "gmeta");
meta.append(bar("gchip"), bar("gchip short"));
c.append(top, bar("gline"), bar("gline short"), meta);
g.append(c);
}
return g;
@@ -603,11 +619,56 @@
const f = ghQuery.trim().toLowerCase();
return !f || [l.name, l.github.repo, l.github.owner, l.package, summary(l)].join(" ").toLowerCase().includes(f);
};
const ghTitle = () => [el("h3", "", t("Unofficial, on GitHub")), el("span", "", t("repositories their authors tagged {topic} — nobody has reviewed them; read the code before you install one", { topic }))];
// GitHub answers after the rest, seconds after on a slow line, and a
// section that wasn't there read as there being no such plugins (the
// owner: 网慢的用户以为没有非官方插件). Until it answers the section
// stands in its place with its head, a word that it is looking and
// cards still to come; its cards then come in where those were.
let ghArrive = false;
function ghWaiting() {
const look = el("span", "pm-ghlook");
look.setAttribute("role", "status");
const dots = el("span", "dots");
dots.setAttribute("aria-hidden", "true");
dots.append(el("i"), el("i"), el("i"));
look.append(dots, el("span", "", t("Looking on GitHub")));
ghHead.replaceChildren(...ghTitle(), look);
ghSec.setAttribute("aria-busy", "true");
ghArrive = true;
replaceKeeping(ghSec, [ghHead, skeleton(3)]);
return ghSec;
}
// and one GitHub couldn't be asked of says so, with another go
function ghFailed() {
ghHead.replaceChildren(...ghTitle());
ghSec.removeAttribute("aria-busy");
const box = el("div", "pm-ghnone");
const again = el("button", "text", t("Try again"));
again.type = "button";
again.onclick = () => {
tagged = null;
taggedErr = "";
drawBody();
loadTagged().then(drawBody);
};
box.append(el("span", "", t("Couldn't ask GitHub: {error}", { error: taggedErr })), again);
replaceKeeping(ghSec, [ghHead, box]);
return ghSec;
}
function ghSection(list) {
ghList = list;
const h = [el("h3", "", t("Unofficial, on GitHub")), el("span", "", t("repositories their authors tagged {topic} — nobody has reviewed them; read the code before you install one", { topic }))];
ghHead.replaceChildren(...h);
ghHead.replaceChildren(...ghTitle());
ghSec.removeAttribute("aria-busy");
drawGh();
// the first cards after the wait come in, one after the other; the
// grid drawn again for a pick doesn't
if (ghArrive) {
ghArrive = false;
ghSec.classList.add("pm-arrive");
[...ghGrid.children].forEach((c, i) => c.style.setProperty("--i", Math.min(i, 9)));
setTimeout(() => ghSec.classList.remove("pm-arrive"), 900);
}
return ghSec;
}
function drawGh() {
@@ -817,12 +878,15 @@
if (tls.length) out.push(section(t("Tools for agents"), t("tools every agent can call, through magpie's MCP server"), tls));
if (pgs.length) out.push(section(t("Pages"), t("pages of their own in magpie's window, each shut off from the rest and reading only what it lists"), pgs));
if (gh.length) out.push(ghSection(gh));
else if (!tagged) out.push(ghWaiting());
else if (taggedErr) out.push(ghFailed());
out.push(manual());
replaceKeeping(body, out);
return;
}
if (ls.length) out.push(section(t("Suggested"), "", ls));
if (gh.length) out.push(ghSection(gh));
else if (!tagged) out.push(ghWaiting());
const known = new Set([...listings.map((l) => l.package), ...(tagged || []).map((l) => l.github.package).filter(Boolean)]);
const box = el("section", "pm-sec");
const h = el("div", "pm-sechead");
@@ -0,0 +1,159 @@
// 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. 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, or "fail"
function server(lang, gh) {
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);
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" },
zh: { section: "非官方插件 · GitHub", look: "正在 GitHub 上查找", failed: /无法连接 GitHub/, again: "重试" },
ja: { section: "非公式 · GitHub", look: "GitHub を検索中", failed: /GitHub に接続できませんでした/, again: "再試行" },
de: { section: "Inoffiziell, auf GitHub", look: "Suche auf GitHub", failed: /GitHub nicht erreichbar/, again: "Erneut versuchen" },
};
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) => {
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));
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, []);
});
}
}
});
}