gui: a Plugins card's move button has a row of its own and says how many accounts it moves — on the Plugins tab, a card that offers a built-in's accounts put "Move my {name} accounts ({n})" in its top row beside the plugin's name; the button doesn't shrink (.pm-act is flex: none, nowrap), so in a two- or three-column window "Move my Grok (SuperGrok) accounts (1)" ran past the card's right edge, and Kiro's shorter one squeezed its name to "K…" and cut "magpie community". The move button (and its "Moving…") now has a row of its own at the card's foot, full width, wrapping if it must; Install, Sign in and the rest stay in the top row. Its words say what the number is: "Move my 1 Grok (SuperGrok) account", "Move my 2 Zed accounts", 「迁移我的 1 个 Grok (SuperGrok) 账号」. plugin-move-overflow.test.cjs (Chromium, WebKit, en/zh, 920/600/480px with the column count checked) fails without the change at 920 and 600px; plugin-move, plugin-market, market-have, old-webkit, plugin-moved-signin, plugin-release, plugin-signin pass (plugin-market's "typing keeps the field" fails now and then on main here too). Go not run: only CSS, JS and strings changed. (#398)
This commit is contained in:
@@ -392,7 +392,8 @@ const I18N = {
|
||||
"Move {name} here": "把 {name} 迁到这里",
|
||||
"{name}: on magpie's built-in": "{name}:使用 magpie 内置",
|
||||
"{name} runs on magpie's built-in, with your accounts; Move {name} here runs it on this plugin": "{name} 正由 magpie 内置运行,使用你的账号;「把 {name} 迁到这里」可改由这个插件运行",
|
||||
"Move my {name} accounts ({n})": "迁移我的 {name} 账号({n})",
|
||||
"Move my {n} {name} account": "迁移我的 {n} 个 {name} 账号",
|
||||
"Move my {n} {name} accounts": "迁移我的 {n} 个 {name} 账号",
|
||||
"Moving…": "正在迁移…",
|
||||
"Move": "迁移",
|
||||
"Runs {name} on this plugin in place of the built-in, with the same accounts; nothing changes if one doesn't work through it": "改由这个插件运行 {name},账号不变;有账号用不了时什么都不会改",
|
||||
|
||||
@@ -88,6 +88,7 @@
|
||||
.pm-act.done:hover:not(:disabled) { background: var(--green-soft); color: var(--green); }
|
||||
.pm-act.busy { color: var(--muted); font-weight: 500; }
|
||||
.pm-act:disabled:not(.busy):not(.done) { opacity: .55; }
|
||||
.pm-card > .pm-act.move { height: auto; min-height: 26px; padding: 4px 12px; white-space: normal; text-align: center; }
|
||||
.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 */
|
||||
|
||||
@@ -128,8 +128,8 @@
|
||||
}
|
||||
}
|
||||
const moveButton = (b, c, here) => {
|
||||
b.classList.add("go");
|
||||
b.textContent = here ? t("Move {name} here", { name: c.name }) : t("Move my {name} accounts ({n})", { name: c.name, n: c.accounts });
|
||||
b.classList.add("go", "move");
|
||||
b.textContent = here ? t("Move {name} here", { name: c.name }) : t(c.accounts === 1 ? "Move my {n} {name} account" : "Move my {n} {name} accounts", { name: c.name, n: c.accounts });
|
||||
b.title = t("Runs {name} on this plugin in place of the built-in, with the same accounts; nothing changes if one doesn't work through it", { name: c.name });
|
||||
b.disabled = busy.size > 0;
|
||||
b.onclick = (ev) => { ev.stopPropagation(); move(c); };
|
||||
@@ -147,6 +147,7 @@
|
||||
const op = busy.get(pkg);
|
||||
if (op === "add" || op === "upgrade" || op === "move") {
|
||||
b.classList.add("busy");
|
||||
if (op === "move") b.classList.add("move");
|
||||
b.append(el("span", "spin"), el("span", "", op === "move" ? t("Moving…") : op === "upgrade" ? t("Updating…") : market?.state.bun ? t("Installing…") : t("Getting Bun…")));
|
||||
b.disabled = true;
|
||||
if (!market?.state.bun) b.title = t("Plugins run on Bun {v}, downloaded once", { v: market?.state.bunVersion || "" });
|
||||
@@ -217,7 +218,11 @@
|
||||
by.append(v);
|
||||
} else by.append(el("span", "", l.npm?.publisher || l.package));
|
||||
who.append(by);
|
||||
top.append(logo(l.icon), who, actionFor(l.package, l.name, l));
|
||||
const act = actionFor(l.package, l.name, l);
|
||||
// a move says whose accounts: too long for the top row, it has one of its own
|
||||
const own = act.classList.contains("move");
|
||||
top.append(logo(l.icon), who);
|
||||
if (!own) top.append(act);
|
||||
const sum = el("p", "pm-sum", summary(l));
|
||||
const meta = el("div", "pm-meta");
|
||||
if (l.npm?.weekly) {
|
||||
@@ -236,6 +241,7 @@
|
||||
meta.append(b);
|
||||
}
|
||||
c.append(top, sum, meta);
|
||||
if (own) c.append(act);
|
||||
c.onclick = () => detail(l);
|
||||
c.onkeydown = (ev) => { if (ev.key === "Enter" || ev.key === " ") { ev.preventDefault(); detail(l); } };
|
||||
return c;
|
||||
|
||||
@@ -33,6 +33,13 @@ method's questions (a pick, then a text the plugin checks), then takes the
|
||||
code the browser page shows; an API-key way opens the account. English and
|
||||
Chinese, Chromium and WebKit, with the API faked.
|
||||
|
||||
`plugin-move-overflow.test.cjs` checks a Plugins card that offers a
|
||||
built-in's accounts ("Move my 1 Grok (SuperGrok) account"): the button has a
|
||||
row of its own at the card's foot, so it stays inside the card and the
|
||||
plugin's name and "magpie community" aren't cut, in a three-, two- and
|
||||
one-column window. English and Chinese, Chromium and WebKit, with the API
|
||||
faked.
|
||||
|
||||
`plugin-key-hint.test.cjs` checks a plugin's API-key way: its label titles
|
||||
the key's field and its placeholder is the field's hint, while a way labelled
|
||||
only "API key" keeps "<name> API key"; the provider's own icon shows on its
|
||||
@@ -640,7 +647,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-usage-asked.test.cjs internal/gui/tests/claude-risk.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 internal/gui/tests/tray-logos.test.cjs internal/gui/tests/routing-proxy.test.cjs internal/gui/tests/sse-body.test.cjs internal/gui/tests/remote-group-served.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-usage-asked.test.cjs internal/gui/tests/claude-risk.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 internal/gui/tests/tray-logos.test.cjs internal/gui/tests/routing-proxy.test.cjs internal/gui/tests/sse-body.test.cjs internal/gui/tests/remote-group-served.test.cjs internal/gui/tests/plugin-move-overflow.test.cjs
|
||||
```
|
||||
|
||||
If Playwright is installed outside the repository, set `NODE_PATH` to the
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// A Plugins card that offers a built-in's accounts keeps its button inside
|
||||
// the card: "Move my Grok (SuperGrok) accounts (1)" ran past the card's right
|
||||
// edge, and Kiro's shorter one squeezed its name to "K…" and cut "magpie
|
||||
// community". The button now has a row of its own at the card's foot and
|
||||
// says how many accounts it moves ("Move my 1 Grok (SuperGrok) account").
|
||||
// Every card stays whole, its name and byline uncut, in a three-, two- and
|
||||
// one-column window. In English and Chinese; the API is faked here.
|
||||
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 listing = (id, name, summary) => ({
|
||||
package: `@magpie-community/opencode-${id}-auth`, name, icon: id, providers: [id], community: true, replaces: id,
|
||||
summary: { en: summary, zh: summary }, npm: { version: "0.1.4" },
|
||||
});
|
||||
const listings = [
|
||||
listing("factory", "Factory", "Factory Droid subscriptions: Anthropic, OpenAI, xAI and open models."),
|
||||
listing("grok", "Grok", "Use SuperGrok and X Premium+ through the Grok Build CLI's sign-in."),
|
||||
listing("cursor", "Cursor", "Cursor Pro, Pro+, Ultra and Teams: every model of the plan."),
|
||||
listing("kiro", "Kiro", "Kiro Free, Pro, Pro+ and Power: Kiro sign-in, kiro-cli's, or an API key."),
|
||||
];
|
||||
const movable = [
|
||||
{ id: "grok", name: "Grok (SuperGrok)", package: listings[1].package, accounts: 1 },
|
||||
{ id: "kiro", name: "Kiro", package: listings[3].package, accounts: 1 },
|
||||
];
|
||||
|
||||
function serve(lang) {
|
||||
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:true};` });
|
||||
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: [], onPlugins: [] });
|
||||
if (url.pathname === "/api/groups") return json({ groups: [] });
|
||||
if (url.pathname === "/api/plugins/market") return json({ listings, state: { bun: true, bunVersion: "1.3.0", plugins: [], movable } });
|
||||
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)];
|
||||
try { await route.fulfill({ body: await fs.readFile(file), contentType }); } catch { await route.fulfill({ status: 404, body: "" }); }
|
||||
};
|
||||
}
|
||||
|
||||
const card = { en: "Move my 1 Grok (SuperGrok) account", zh: "迁移我的 1 个 Grok (SuperGrok) 账号" };
|
||||
const launch = (engine) => engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" });
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
for (const lang of ["en", "zh"]) {
|
||||
for (const [width, cols] of [[920, 3], [600, 2], [480, 1]]) {
|
||||
test(`${engine} ${lang} ${width}px: a card's move button stays inside it`, async (t) => {
|
||||
const browser = await launch(engine);
|
||||
t.after(() => browser.close());
|
||||
const page = await (await browser.newContext({ viewport: { width, height: 800 }, reducedMotion: "reduce" })).newPage();
|
||||
page.setDefaultTimeout(5000);
|
||||
const errors = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", serve(lang));
|
||||
await page.goto("http://magpie.test/?view=plugins");
|
||||
await page.locator("#view-plugins button", { hasText: card[lang] }).waitFor();
|
||||
if (process.env.ARTIFACT_DIR) await page.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `plugin-move-overflow-${engine}-${lang}-${width}.png`) });
|
||||
|
||||
const cards = await page.locator("#view-plugins .pm-card").evaluateAll((cs) => cs.map((c) => {
|
||||
const box = c.getBoundingClientRect();
|
||||
const out = [...c.querySelectorAll(".pm-top *")].filter((e) => {
|
||||
const r = e.getBoundingClientRect();
|
||||
return r.width && (r.left < box.left || r.right > box.right);
|
||||
}).map((e) => e.className || e.tagName);
|
||||
const cut = [...c.querySelectorAll(".pm-name b, .pm-by, .pm-by > span")].filter((e) => e.scrollWidth > e.clientWidth).map((e) => e.textContent);
|
||||
return { name: c.querySelector(".pm-name b")?.textContent, out, cut };
|
||||
}));
|
||||
assert.ok(cards.length >= listings.length, "the market's cards aren't there");
|
||||
const lefts = await page.locator("#view-plugins .pm-card").evaluateAll((cs) => new Set(cs.map((c) => Math.round(c.getBoundingClientRect().left))).size);
|
||||
assert.equal(lefts, cols, `not ${cols} columns at ${width}px`);
|
||||
const wrong = cards.flatMap((c) => [...(c.out.length ? [`${c.name}: runs past its card`] : []), ...c.cut.map((x) => `${c.name}: "${x}" is cut`)]);
|
||||
assert.deepEqual(wrong, []);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -73,12 +73,12 @@ const L = {
|
||||
move: "Move to the plugin", busy: "Installing the plugin and checking each account…", again: "Try again", back: "Use the built-in again",
|
||||
failed: "It stays built-in: magpie couldn't reach npm to install the plugin. Check the network or proxy, then try again.",
|
||||
onPlugin: "The community Zed plugin", builtin: "magpie's built-in · or the community Zed plugin", done: "Zed now runs on its plugin — 2 accounts, 1 model.",
|
||||
subs: "Subscriptions", card: "Move my Zed accounts (2)", own: "Zed itself stays signed in as it is." },
|
||||
subs: "Subscriptions", card: "Move my 2 Zed accounts", own: "Zed itself stays signed in as it is." },
|
||||
zh: { runs: "运行方式", line: "Zed 可以改由社区插件运行,账号不变。", look: "看看",
|
||||
move: "迁移到插件", busy: "正在安装插件并逐个检查账号…", again: "重试", back: "改回内置",
|
||||
failed: "仍使用内置:无法连接 npm 安装插件,请检查网络或代理后重试。",
|
||||
onPlugin: "社区 Zed 插件", builtin: "magpie 内置 · 也可改用社区 Zed 插件", done: "Zed 现在由插件运行——2 个账号,1 个模型。",
|
||||
subs: "订阅", card: "迁移我的 Zed 账号(2)", own: "Zed 本身的登录保持不变。" },
|
||||
subs: "订阅", card: "迁移我的 2 个 Zed 账号", own: "Zed 本身的登录保持不变。" },
|
||||
};
|
||||
|
||||
const launch = (engine) => engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" });
|
||||
|
||||
Reference in New Issue
Block a user