An agent's model picker (Pi and every agent with own-provider groups)
lists the providers the agent is signed in to itself below magpie's
models. Their section header was only the vendor's name, e.g. "OPENCODE
GO", the same as the user's magpie provider of that name, so maxleebeta
read Pi's own OpenCode Go list as magpie ignoring the one model picked
for magpie's OpenCode Go.
A section of direct options (Option.Direct) not already named for the
agent now reads "OpenCode Go · Pi's own sign-in" ("OpenCode Go · Pi 自己的
登录"), in sentence case, faint like the header, no accent. Its key is
distinct, so magpie's and the agent's own groups of one vendor are two
headers. Claude Code's "Claude Code" groups (named for the agent)
are unchanged. New string in zh, zh-TW, ja, de.
Run (mote, playwright chromium + webkit):
- agent-own-direct.test.cjs, extended: headings are exactly
["OpenCode Go", "OpenCode Go · <own sign-in>"], the own one between
magpie's and Pi's models, no text-transform, same height as magpie's
header, no left border or background image; 20/20 (both engines x
en/zh/zh-TW/ja/de x 980/420). i18n-keys, claude-picker-fold,
claude-picker-magpie-first, rail-tip green.
- Broken by hand (chromium en 980): suffix never added -> red; header
key not distinct -> red (headings ["DeepSeek","OpenCode Go"]).
- Whole GUI suite on WSL magpie-desktop (mote was at load ~600):
19,997 tests, 538 fail across 125 files. Those 125 files rerun at
main f177c36a9 and at this head: 490 vs 481 fail, the same files; the
names differing either way are scattered timing tests (Routing rules,
thumbs, scroll) on a loaded Linux box, none in the picker. The
picker files that fail (zero-priced-free etc.) fail alike on main.
- go test ./internal/gui: TestCoreScriptBudget red on main too (#5139):
main 1,533,907, this head 1,533,906 (one byte less; comments trimmed,
no raise). TestMainWindowCorners/macOS_26_SDK red on main (#3949).
Not tried: the real app or a real Pi sign-in; Linux WebKitGTK and the
Windows webview.
159 lines
11 KiB
JavaScript
159 lines
11 KiB
JavaScript
// Run with Node's test runner and Playwright on the module path; see README.md.
|
|
// maxleebeta in #feedback: Pi 1.5.0 connected to magpie, picking one of
|
|
// Pi's own OpenCode Go models (opencode-go/<model>, the OPENCODE GO section
|
|
// of its model list) turned 「接入」 off at once, with nothing said, while
|
|
// magpie's DeepSeek V4.1 Flash kept it on. The own model is asked of
|
|
// OpenCode Go by Pi itself, so the pick does take Pi off magpie; now the
|
|
// list says so (direct, not via magpie, listed after magpie's), and the
|
|
// pick is asked first, Cancel leaving Pi connected, as Claude Code's own
|
|
// models are (#726). The options are what /api/state sends since the fix:
|
|
// an own model carries direct. Every language, wide and narrow.
|
|
// Its section's heading was OPENCODE GO alone, the name of the user's own
|
|
// OpenCode Go provider in magpie, read as magpie's section that ignored
|
|
// the one model picked there (maxleebeta); it now says it is Pi's own
|
|
// sign-in, below magpie's OpenCode Go.
|
|
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 DS = "magpie/deepseek/deepseek-v4.1-flash";
|
|
const options = [
|
|
{ value: "opencode-go/glm-5.1", note: "GLM-5.1", group: "OpenCode Go", direct: "OpenCode Go" },
|
|
{ value: "opencode-go/kimi-k2.6", note: "Kimi K2.6", group: "OpenCode Go", direct: "OpenCode Go" },
|
|
{ value: DS, label: "DeepSeek V4.1 Flash", ref: "deepseek/deepseek-v4.1-flash", group: "DeepSeek", note: "DeepSeek · via magpie" },
|
|
{ value: "magpie/deepseek/deepseek-v4.1-pro", label: "DeepSeek V4.1 Pro", ref: "deepseek/deepseek-v4.1-pro", group: "DeepSeek", note: "DeepSeek · via magpie" },
|
|
{ value: "magpie/opencode-go/minimax-m2.7", label: "MiniMax M2.7", ref: "minimax/minimax-m2.7", group: "OpenCode Go", note: "OpenCode Go · via magpie" },
|
|
];
|
|
|
|
function server(lang, posts) {
|
|
let cur = { agents: [{ id: "pi", name: "Pi", icon: "generic", path: "/fixture/pi", wired: true, fields: [{ key: "model", label: "model", value: DS, options }] }], profiles: [] };
|
|
const reply = (route) => route.fulfill({ json: { ...cur, settings: { lang, theme: "light" } } });
|
|
return async (route) => {
|
|
const req = route.request(), url = new URL(req.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 reply(route);
|
|
if (url.pathname === "/api/set") {
|
|
const body = JSON.parse(req.postData());
|
|
posts.push(body);
|
|
cur = JSON.parse(JSON.stringify(cur));
|
|
const a = cur.agents[0];
|
|
a.fields[0].value = body.value;
|
|
a.wired = body.value.startsWith("magpie/");
|
|
return reply(route);
|
|
}
|
|
if (url.pathname.startsWith("/api/agents/preview/")) return json({ changes: [] });
|
|
if (url.pathname === "/api/usage/quotas") return json([]);
|
|
if (url.pathname === "/api/groups") return json({ groups: [] });
|
|
if (url.pathname === "/api/plugins") return json({ plugins: [] });
|
|
if (url.pathname === "/api/agents/cli") return json({ agents: {}, pending: false });
|
|
if (url.pathname === "/api/providers") return json({ providers: [], presets: [], excluded: [], gateway: { running: true, window: true } });
|
|
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 row = '.row.agent[data-id="pi"]';
|
|
const KEYS = ["{agent}'s own sign-in", "direct, not via magpie", "via magpie", "Take {agent} off magpie?", "Cancel", "Use {model}",
|
|
"{model} is {agent}'s own model: {agent} asks {vendor} for it itself, with its own sign-in, not through magpie. Picking it takes {agent} off magpie, and it starts on {model}."];
|
|
|
|
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
|
for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
|
|
for (const width of [980, 420]) {
|
|
test(`${engine} ${lang} ${width}: Pi's own OpenCode Go model says it goes direct and is asked before 接入 goes off`, 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, height: 700 }, reducedMotion: "reduce" })).newPage();
|
|
page.setDefaultTimeout(5000);
|
|
page.setDefaultNavigationTimeout(60000);
|
|
const errors = [], posts = [], dialogs = [];
|
|
page.on("pageerror", (e) => errors.push(e.message));
|
|
page.on("dialog", (d) => { dialogs.push(d.message()); d.dismiss(); });
|
|
await page.route("**/*", server(lang, posts));
|
|
await page.goto("http://magpie.test/?view=agents");
|
|
await page.locator(`${row} .ag-conn`).waitFor();
|
|
const tr = (k, v) => page.evaluate(([k, v]) => t(k, v), [k, v]);
|
|
const missing = await page.evaluate(([keys, lang]) => lang === "en" ? [] : keys.filter((k) => !I18N[lang]?.[k]), [KEYS, lang]);
|
|
assert.deepEqual(missing, [], `every string has its ${lang}`);
|
|
const tops = () => page.evaluate(() => [document.scrollingElement.scrollTop, document.querySelector("#view-agents")?.scrollTop]);
|
|
const top = await tops();
|
|
const start = page.locator(`${row} > .field.ag-start`);
|
|
const item = (text) => page.locator("#pop #list li", { hasText: text }).first();
|
|
const open = async () => { await start.click(); await page.locator("#pop:not([hidden]) #list li").first().waitFor(); };
|
|
const on = () => page.locator(`${row} .ag-conn`).getAttribute("aria-checked");
|
|
|
|
// each says which way it goes; magpie's are listed first
|
|
await open();
|
|
const tag = (li) => li.locator(".badge.path").textContent();
|
|
assert.equal(await tag(item("GLM-5.1")), await tr("direct, not via magpie"));
|
|
assert.equal(await tag(item("DeepSeek V4.1 Pro")), await tr("via magpie"));
|
|
const order = await page.locator("#pop #list li").allTextContents();
|
|
const at = (s) => order.findIndex((x) => x.includes(s));
|
|
assert.ok(at("DeepSeek V4.1 Pro") >= 0 && at("DeepSeek V4.1 Pro") < at("GLM-5.1"), `magpie's first: ${JSON.stringify(order)}`);
|
|
|
|
// magpie's OpenCode Go section is OpenCode Go; Pi's own says whose
|
|
// sign-in it is, in the page's language, quiet and on one line
|
|
const heads = (await page.locator("#pop #list li.group").allTextContents()).map((s) => s.trim());
|
|
const own = "OpenCode Go · " + await tr("{agent}'s own sign-in", { agent: "Pi" });
|
|
assert.deepEqual(heads.filter((h) => h.startsWith("OpenCode Go")), ["OpenCode Go", own], JSON.stringify(heads));
|
|
const ownHead = order.findIndex((x) => x.trim() === own);
|
|
assert.ok(at("MiniMax M2.7") < ownHead && ownHead < at("GLM-5.1"), `Pi's own heading over its own models: ${JSON.stringify(order)}`);
|
|
const head = page.locator("#pop #list li.group.own");
|
|
const look = await head.evaluate((li) => {
|
|
const s = li.querySelector(".own-sign"), cs = getComputedStyle(s), r = li.getBoundingClientRect(), list = li.closest("#pop").getBoundingClientRect();
|
|
return { transform: cs.textTransform, height: r.height, inside: r.right <= list.right + 0.5, border: getComputedStyle(li).borderLeftWidth, image: getComputedStyle(li).backgroundImage };
|
|
});
|
|
assert.equal(look.transform, "none", "the words read as written");
|
|
const plain = await page.locator("#pop #list li.group:not(.own)", { hasText: "OpenCode Go" }).evaluate((li) => li.getBoundingClientRect().height);
|
|
assert.equal(look.height, plain, "one line, as tall as magpie's OpenCode Go heading");
|
|
assert.ok(look.inside, `inside the picker at ${width}px`);
|
|
assert.equal(look.border, "0px", "no stripe");
|
|
assert.equal(look.image, "none", "no gradient");
|
|
|
|
// the OpenCode Go model is asked first; Cancel leaves Pi connected
|
|
await item("GLM-5.1").click();
|
|
const ask = page.locator("#modal .leave-ask");
|
|
await ask.waitFor();
|
|
assert.equal((await ask.locator(".ehead b").textContent()).trim(), await tr("Take {agent} off magpie?", { agent: "Pi" }));
|
|
assert.ok((await ask.textContent()).includes("OpenCode Go"), "says who Pi asks instead");
|
|
assert.deepEqual(posts, [], "nothing written before it is confirmed");
|
|
const box = await ask.boundingBox();
|
|
assert.ok(box.x >= 0 && box.x + box.width <= width, `the ask fits at ${width}px`);
|
|
await ask.locator("button", { hasText: await tr("Cancel") }).click();
|
|
await ask.waitFor({ state: "detached" });
|
|
assert.deepEqual(posts, []);
|
|
assert.equal(await on(), "true");
|
|
|
|
// magpie's other model isn't asked, and Pi stays on
|
|
await open();
|
|
await item("DeepSeek V4.1 Pro").click();
|
|
await page.waitForFunction((r) => document.querySelector(r + " > .field.ag-start")?.textContent.includes("Pro"), row);
|
|
assert.equal(await page.locator("#modal:not([hidden]) .leave-ask").count(), 0);
|
|
assert.deepEqual(posts, [{ agent: "pi", field: "model", value: "magpie/deepseek/deepseek-v4.1-pro" }]);
|
|
assert.equal(await on(), "true");
|
|
|
|
// confirmed, it is written, and 「接入」 goes off as it said
|
|
await open();
|
|
await item("GLM-5.1").click();
|
|
await ask.waitFor();
|
|
await ask.locator("button", { hasText: await tr("Use {model}", { model: "opencode-go/glm-5.1" }) }).click();
|
|
await page.waitForFunction(() => document.querySelector("#modal").hidden);
|
|
await page.waitForFunction((r) => document.querySelector(r + " .ag-conn")?.getAttribute("aria-checked") === "false", row);
|
|
assert.deepEqual(posts.at(-1), { agent: "pi", field: "model", value: "opencode-go/glm-5.1" });
|
|
|
|
assert.equal(await page.locator("select").count(), 0, "no native select");
|
|
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth), 0, `no sideways scroll at ${width}px`);
|
|
assert.deepEqual(await tops(), top, "no click moved the page");
|
|
assert.deepEqual(dialogs, [], "no native dialog");
|
|
assert.deepEqual(errors, []);
|
|
});
|
|
}
|
|
}
|
|
}
|