While a WSL distro runs, the Subagents page lists its agents that take subagents here (Claude Code, Codex and the rest of SubagentAgents) with a greyed chip that says magpie gives subagents only to agents on this computer, not yet to it in WSL. With the distro stopped, they were gone from the page: subagentsView built its agents from the targets only, and an agent in a stopped distro is no target (#3896). As the commit before did for the Hooks page: subagentsView now also lists each stopped agent of those kinds that the MCP and Skills pages list from its shape (asleepView), with the reason it has while the distro runs (wslNoSubagents, which subagentSpecOf now shares), so its chip, a subagent's problem for it and the "magpie can't give subagents to ... yet" line are the same, stopped or running. Nothing of the distro is opened. One magpie never saw (unseen) isn't listed. No WSL agent can be given a subagent yet, so there is nothing to keep for Woken. No change to the page; nothing new to translate. The line in library.md that named the pages leaving a stopped distro's agents out (#4182, #4237, #4238) is gone with this. What was run (tree e03c52f0, on origin/mainec5571d6, go1.26.8, linux/amd64, Linux 5.15, umask 077): - TestWSLStoppedSubagents (new): the Subagents page's WSL agents read while a FakeWSL distro runs (Claude Code and Codex, the kinds it lists, each with the reason), then with it stopped and its folder moved away: the same two, field for field. A subagent given the stopped Claude Code has the same problem for it. Nothing was written into the distro and FakeWSLRuns didn't move. - Broken by hand, each alone: subagentsView skipping the stopped agents ("... while it is stopped: map[], while it ran: map[claude@wsl:...]", and the subagent with no problem for Claude Code); the stopped agents listed with no reason ("No:" empty against the running ones', the same problem missing). - library-wsl-asleep, its new Subagents case beside the Hooks one, Chromium and WebKit, en, zh, zh-TW, ja and de at 1100 and 390px: a subagent's chips are Claude Code and the stopped Codex, Codex's blocked, asleep, aria-disabled, with the WSL reason as its tooltip, the line names it, a click on it sends nothing. As for Hooks, the page isn't changed, so only TestWSLStoppedSubagents catches the gap. - GUI files, each alone, Chromium and WebKit, Node 22.22.1, Playwright 1.62.1, DISPLAY unset: library-wsl-asleep 44/44 each, i18n-keys 4/4, library-subagents 6/6, library-hooks 6/6, library-gone-agents 11/11: 142 of 142. - go test -tags nogui -count=1 ./internal/library ./internal/agent ./internal/cli: library and cli ok; agent red in TestInstalledVersion, TestCursorFolderFromTheEditorIsNotTheCLI, TestQoderSettingsFromAnIDEPluginIsNotTheCLI and TestOmpDetectedWithPiDir (#3141). go test -race -run TestWSL ./internal/library: ok. - gofmt -l clean. go vet -tags nogui for linux, windows and darwin, go vet for windows, go build -tags nogui for linux and darwin and go build for windows: exit 0 each. go vet and go build without the tag on linux: exit 1 (no GTK headers here). - go test -tags nogui -count=1 -timeout 45m ./... (Bun 1.4.2; 9m49s, load 20 at its start): 78 packages ok, and 8 tests red in 3 packages, each filed: agent TestInstalledVersion, TestCursorFolderFromTheEditorIsNotTheCLI, TestQoderSettingsFromAnIDEPluginIsNotTheCLI, TestOmpDetectedWithPiDir and TestZedAppPath (#3141); gui TestGatewayHeldByAContainer and TestGatewayFixQuitsOnlyAMagpie (#3649); plugin TestGatewayHookMixedPiPackage ("starting plugins: context deadline exceeded", #2865, under load). The same suite on an origin/mainec5571d6worktree right after (10m01s): the same agent and gui reds, test for test, and plugin ok there. Not tried: a real distro, and the real app; FakeWSL counts the wsl.exe -d commands run in the stopped distro (none). Reviewed and run again by the maintainer at the stack's tree 45994757c (this commit and the six beside it, on origin/main90518de26), go1.26.8: - mote (macOS, arm64): gofmt -l clean; go vet and go build for darwin, GOOS=linux -tags nogui and GOOS=windows (library, plugin, gui): exit 0. go test -tags nogui -count=1 -timeout 45m ./...: every package ok but internal/gui TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and internal/proc TestNoCommandBypassesProc (#4491), both red on main fromb09349d17andc59c547c5, in files this stack doesn't touch. go test -race -run 'TestWSL|TestTagged|TestPinnedPiCache' for library and plugin: ok. - magpie-desktop (Linux, wsl-run; WebKit hangs on mote), Chromium and WebKit: every library-*, sync-*, s3-sync, github-sync and i18n-keys file, 4 at a time: 1003 of 1020. The 17 reds are in 6 files no commit here touches: i18n-keys ("Unmarked", #4524), library-chip-fan, -items, -mcp-health, -mcp-hub (#4483) and -mcp-tools. Those 6 alone, one at a time, at load ~60: 74 of 92 here, 77 of 92 at90518de26itself. Red in both: i18n-keys, -chip-fan and -items in WebKit, -mcp-tools in Chromium ja 420; -mcp-health green in both; -mcp-hub's WebKit case red here only, the case #4483 has red on main. -chip-fan and -items are #3072's and #4501's kind, WebKit under load. - Broken by hand on mote: subagentsView skipping the stopped distro's agents turns TestWSLStoppedSubagents red.
318 lines
21 KiB
JavaScript
318 lines
21 KiB
JavaScript
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||
// cybercaius on Discord: with WSL not started, the Library's MCP page
|
||
// didn't list the agents installed in it. A stopped distro's agents
|
||
// (asleep) are listed by what magpie last saw there: a chip is lit as the
|
||
// library has it, quietly greyer, and says the distro isn't running; a
|
||
// click is sent as any is, and magpie writes it there when the distro
|
||
// next runs. One whose places magpie never saw (unseen) is only on the
|
||
// rows that name it, greyed out, kept by every click on the row, and a
|
||
// click on it says why. One line under the list names the distro. Nothing
|
||
// here starts WSL (#3896): the page only reads /api/library. The
|
||
// Instructions page lists them the same way (#4182), and the Hooks and
|
||
// Subagents pages as while the distro runs (#4237, #4238). Chromium and
|
||
// WebKit, 1100px and 390px, in en, zh, zh-TW, ja and de. No backend: 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 { strings } = require("./strings.cjs");
|
||
|
||
const assets = path.resolve(__dirname, "../assets");
|
||
const HOME = "/Users/me", D = "Ubuntu-24.04";
|
||
const CX = "codex@wsl:" + D, PI = "pi@wsl:" + D;
|
||
const srv = (name, agents, more = {}) => ({ name, transport: "stdio", command: "uvx", args: [name], agents, ...more });
|
||
const lib = (servers, instructions = { agents: [] }) => ({
|
||
dir: `${HOME}/.magpie/library`, backups: `${HOME}/.magpie/backups`, home: HOME,
|
||
agents: [
|
||
{ id: "claude", name: "Claude Code", icon: "", instructions: `${HOME}/.claude/CLAUDE.md`, mcp: `${HOME}/.claude.json`, skills: `${HOME}/.claude/skills` },
|
||
{ id: CX, name: "Codex · WSL " + D, icon: "", mcp: "\\\\wsl.localhost\\" + D + "\\home\\me\\.codex\\config.toml", skills: "\\\\wsl.localhost\\" + D + "\\home\\me\\.codex\\skills", noSSE: true, mustCopy: true, how: "copy", asleep: D },
|
||
{ id: PI, name: "Pi · WSL " + D, icon: "", asleep: D, unseen: true },
|
||
],
|
||
instructions, servers, skills: [], foundServers: [], projects: [], foundSkills: [], problems: [],
|
||
});
|
||
// the Instructions page's rows: Claude Code here, Codex in the stopped
|
||
// distro at the file magpie last saw, and Pi on there, its file never seen
|
||
const instr = (on) => ({
|
||
shared: "Be brief.", sets: [{ id: "default", name: "", active: true, text: "Be brief." }],
|
||
agents: [
|
||
{ agent: "claude", name: "Claude Code", icon: "", path: `${HOME}/.claude/CLAUDE.md`, on: on.includes("claude"), extra: "" },
|
||
{ agent: CX, name: "Codex · WSL " + D, icon: "", path: "\\\\wsl.localhost\\" + D + "\\home\\me\\.codex\\AGENTS.md", on: on.includes(CX), extra: "", asleep: D },
|
||
{ agent: PI, name: "Pi · WSL " + D, icon: "", path: "", on: on.includes(PI), extra: "", asleep: D, unseen: true },
|
||
],
|
||
});
|
||
|
||
let I18N;
|
||
function tr(lang, key, vars = {}) {
|
||
let s = key;
|
||
if (lang !== "en") {
|
||
assert.equal(typeof I18N[lang][key], "string", `${lang} has no ${JSON.stringify(key)}`);
|
||
s = I18N[lang][key];
|
||
}
|
||
return s.replace(/\{(\w+)\}/g, (m, k) => (k in vars ? String(vars[k]) : m));
|
||
}
|
||
|
||
function server(lang, state, posts) {
|
||
return async (route) => {
|
||
const req = route.request(), url = new URL(req.url());
|
||
const json = (data, status = 200) => route.fulfill({ status, 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/library") return json({ ...lib(state.servers, state.instr), ...state.more });
|
||
if (url.pathname === "/api/library/reveal") { (state.reveals ||= []).push(req.postDataJSON()); return json({}); }
|
||
if (url.pathname.startsWith("/api/library/") && req.method() === "POST" && !url.pathname.includes("/check")) {
|
||
const body = req.postDataJSON(), what = url.pathname.replace("/api/library/", "");
|
||
posts.push({ what, body });
|
||
if (what === "instructions/save" && state.instr) {
|
||
state.instr = instr(body.agents);
|
||
return json({ part: "instructions", instructions: state.instr, result: { changed: [] } });
|
||
}
|
||
if (what === "servers/agents") {
|
||
state.servers = state.servers.map((s) => (s.name === body.name ? { ...s, agents: [...body.agents].sort() } : s));
|
||
return json({ ...lib(state.servers), result: { changed: [] } });
|
||
}
|
||
return json(lib(state.servers));
|
||
}
|
||
if (url.pathname === "/api/plugins") return json({ plugins: [] });
|
||
if (url.pathname === "/api/usage/quotas") return json([]);
|
||
if (url.pathname === "/api/groups") return json({ groups: [] });
|
||
if (url.pathname === "/api/providers") return json({ providers: [], gateway: { running: true } });
|
||
if (url.pathname.startsWith("/api/")) return json({});
|
||
if (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 sideways = (page) => page.evaluate(() => {
|
||
const over = [];
|
||
const w = document.documentElement.clientWidth;
|
||
if (document.documentElement.scrollWidth > w) over.push("page " + document.documentElement.scrollWidth);
|
||
for (const e of document.querySelectorAll("#view-library .lib-server, #view-library .lib-agents, #view-library .lib-asleep")) {
|
||
const r = e.getBoundingClientRect();
|
||
if (r.width && (r.right > w + 0.5 || r.left < -0.5)) over.push((e.className || e.tagName) + " " + Math.round(r.left) + "–" + Math.round(r.right));
|
||
}
|
||
return over;
|
||
});
|
||
|
||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||
test(engine + ": a stopped WSL distro's agents are on the MCP page as last seen", async (t) => {
|
||
assert(["chromium", "webkit"].includes(engine), "BROWSER must be chromium or webkit");
|
||
I18N = strings().I18N;
|
||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: process.env.PLAYWRIGHT_CHANNEL || "chromium" }));
|
||
t.after(() => browser.close());
|
||
for (const width of [1100, 390]) for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
|
||
await t.test(`${lang} at ${width}px`, async () => {
|
||
const w = (key, vars) => tr(lang, key, vars);
|
||
const state = { servers: [srv("fetch", [CX, PI]), srv("git", ["claude"]), srv("events", [], { transport: "sse", command: "", url: "https://example.invalid/sse" })] };
|
||
const posts = [], errors = [];
|
||
const ctx = await browser.newContext({ viewport: { width, height: 900 }, reducedMotion: "reduce" });
|
||
await ctx.addInitScript(() => { try { localStorage.setItem("magpie.libTab", "mcp"); } catch {} });
|
||
const page = await ctx.newPage();
|
||
page.setDefaultTimeout(5000);
|
||
page.setDefaultNavigationTimeout(60000);
|
||
page.on("pageerror", (e) => errors.push(e.message));
|
||
page.on("dialog", (d) => { errors.push("a browser dialog: " + d.message()); d.dismiss(); });
|
||
await page.route("**/*", server(lang, state, posts));
|
||
await page.goto("http://magpie.test/");
|
||
await page.locator('button[data-view="library"]').click();
|
||
const v = page.locator("#view-library");
|
||
const row = (name) => v.locator(".lib-server").filter({ has: page.locator(".name", { hasText: new RegExp("^" + name) }) });
|
||
const chips = (name) => row(name).locator(":scope > .lib-agents > .lib-ag[data-agent]").evaluateAll((cs) => cs.map((c) => c.dataset.agent));
|
||
const chip = (name, id) => row(name).locator(`.lib-ag[data-agent="${id}"]`);
|
||
await row("git").waitFor();
|
||
|
||
// Codex in the stopped distro is on every row, Pi only on fetch's
|
||
assert.deepEqual(await chips("fetch"), ["claude", CX, PI]);
|
||
assert.deepEqual(await chips("git"), ["claude", CX]);
|
||
assert.deepEqual(await chips("events"), ["claude", CX]);
|
||
const cx = chip("fetch", CX);
|
||
assert.match(await cx.getAttribute("class"), /\basleep\b/);
|
||
assert.equal(await cx.getAttribute("aria-pressed"), "true");
|
||
assert.equal(await cx.getAttribute("aria-disabled"), null);
|
||
assert.equal(await cx.getAttribute("title"), w("WSL {distro} isn't running: {agent} has it — click to take it away, and magpie writes the change there the next time it runs", { distro: D, agent: "Codex · WSL " + D }));
|
||
assert.equal(await chip("git", CX).getAttribute("title"), w("WSL {distro} isn't running: a click gives it to {agent} the next time the distro runs", { distro: D, agent: "Codex · WSL " + D }));
|
||
// what it can't take says so, as on any chip: no SSE for Codex
|
||
assert.match(await chip("events", CX).getAttribute("class"), /\bblocked\b/);
|
||
assert.notEqual(await chip("events", CX).getAttribute("title"), await chip("git", CX).getAttribute("title"));
|
||
const pi = chip("fetch", PI);
|
||
assert.match(await pi.getAttribute("class"), /\bunseen\b/);
|
||
assert.equal(await pi.getAttribute("aria-disabled"), "true");
|
||
assert.equal(await pi.getAttribute("aria-pressed"), "true");
|
||
const unseen = w("WSL {distro} isn't running, and magpie hasn't seen {agent}'s files there yet: start the distro to change this", { distro: D, agent: "Pi · WSL " + D });
|
||
assert.equal(await pi.getAttribute("title"), unseen);
|
||
// one line for the distro, naming Pi; the line of agents with no
|
||
// MCP servers doesn't
|
||
const aside = v.locator(".lib-asleep");
|
||
assert.equal(await aside.count(), 1);
|
||
assert.equal(await aside.textContent(), w("WSL {distro} isn't running: its agents show what magpie last saw there, and what you change is written there the next time it runs.", { distro: D }) + " " + w("{agents} can be changed once it runs.", { agents: "Pi · WSL " + D }));
|
||
assert.equal(await v.locator(".lib-aside").filter({ hasText: w("{agents} has no MCP servers magpie can write.", { agents: "Pi · WSL " + D }) }).count(), 0);
|
||
assert.deepEqual(await sideways(page), [], "sideways with the rows");
|
||
|
||
// Pi's chip clicked: nothing sent, the reason shown
|
||
await row("fetch").locator(":scope > .lib-agents").hover();
|
||
await pi.click({ force: true });
|
||
await page.waitForTimeout(200);
|
||
assert.deepEqual(posts, []);
|
||
// Claude Code given fetch: Pi keeps it, as Codex does
|
||
await chip("fetch", "claude").click();
|
||
await page.waitForTimeout(300);
|
||
assert.deepEqual(posts.map((p) => p.what), ["servers/agents"]);
|
||
assert.deepEqual([...posts[0].body.agents].sort(), ["claude", CX, PI]);
|
||
// Codex given git while its distro is stopped: sent, kept
|
||
await row("git").locator(":scope > .lib-agents").hover();
|
||
await chip("git", CX).click();
|
||
await page.waitForTimeout(300);
|
||
assert.deepEqual(posts[1], { what: "servers/agents", body: { name: "git", agents: ["claude", CX] } });
|
||
assert.deepEqual(errors, []);
|
||
await ctx.close();
|
||
});
|
||
}
|
||
});
|
||
}
|
||
|
||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||
// #4182: the Instructions page leaves them out no more. Codex's row is
|
||
// at the file magpie last saw, greyer, its path no button (the file
|
||
// manager would start WSL); its switch says the distro isn't running and
|
||
// is sent as any is. Pi, on, whose file magpie never saw, is greyed out
|
||
// and kept on by every switch: before, a switch sent the agents without
|
||
// the stopped distro's, which took them off.
|
||
test(engine + ": a stopped WSL distro's agents are on the Instructions page as last seen", async (t) => {
|
||
assert(["chromium", "webkit"].includes(engine), "BROWSER must be chromium or webkit");
|
||
I18N = strings().I18N;
|
||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: process.env.PLAYWRIGHT_CHANNEL || "chromium" }));
|
||
t.after(() => browser.close());
|
||
for (const width of [1100, 390]) for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
|
||
await t.test(`${lang} at ${width}px`, async () => {
|
||
const w = (key, vars) => tr(lang, key, vars);
|
||
const state = { servers: [], instr: instr(["claude", PI]) };
|
||
const posts = [], errors = [];
|
||
const ctx = await browser.newContext({ viewport: { width, height: 900 }, reducedMotion: "reduce" });
|
||
await ctx.addInitScript(() => { try { localStorage.setItem("magpie.libTab", "instructions"); } catch {} });
|
||
const page = await ctx.newPage();
|
||
page.setDefaultTimeout(5000);
|
||
page.on("pageerror", (e) => errors.push(e.message));
|
||
page.on("dialog", (d) => { errors.push("a browser dialog: " + d.message()); d.dismiss(); });
|
||
await page.route("**/*", server(lang, state, posts));
|
||
await page.goto("http://magpie.test/");
|
||
await page.locator('button[data-view="library"]').click();
|
||
const v = page.locator("#view-library");
|
||
const row = (name) => v.locator(".lib-row:not(.lib-set)").filter({ has: page.locator(".name", { hasText: new RegExp("^" + name) }) });
|
||
const sw = (name) => row(name).locator(".lib-switch");
|
||
const asleep = w("WSL {distro} isn't running: its agents show what magpie last saw there, and what you change is written there the next time it runs.", { distro: D });
|
||
await row("Codex").waitFor();
|
||
|
||
assert.doesNotMatch(await row("Claude Code").getAttribute("class"), /\basleep\b/);
|
||
assert.match(await row("Codex").getAttribute("class"), /\basleep\b/);
|
||
assert.equal(await row("Codex").locator(".lib-path").evaluate((e) => e.tagName), "SPAN");
|
||
assert.equal(await sw("Codex").getAttribute("aria-checked"), "false");
|
||
assert.equal(await sw("Codex").getAttribute("aria-disabled"), null);
|
||
assert.equal(await sw("Codex").getAttribute("title"), asleep);
|
||
assert.match(await row("Pi").getAttribute("class"), /\basleep\b/);
|
||
assert.equal(await row("Pi").locator(".lib-path").count(), 0);
|
||
assert.equal(await sw("Pi").getAttribute("aria-checked"), "true");
|
||
assert.equal(await sw("Pi").getAttribute("aria-disabled"), "true");
|
||
assert.equal(await sw("Pi").getAttribute("title"), w("WSL {distro} isn't running, and magpie hasn't seen {agent}'s files there yet: start the distro to change this", { distro: D, agent: "Pi · WSL " + D }));
|
||
// one line for the distro, naming Pi; neither is said to keep no
|
||
// instructions file
|
||
const aside = v.locator(".lib-asleep");
|
||
assert.equal(await aside.count(), 1);
|
||
assert.equal(await aside.textContent(), asleep + " " + w("{agents} can be changed once it runs.", { agents: "Pi · WSL " + D }));
|
||
for (const x of await v.locator(".lib-aside:not(.lib-asleep)").allTextContents()) assert.doesNotMatch(x, /WSL/);
|
||
assert.deepEqual(await sideways(page), [], "sideways with the rows");
|
||
|
||
// Codex's path clicked: no file manager asked for
|
||
await row("Codex").locator(".lib-path").click();
|
||
await page.waitForTimeout(200);
|
||
assert.deepEqual(state.reveals || [], []);
|
||
// Pi's switch clicked: nothing sent
|
||
await sw("Pi").click({ force: true });
|
||
await page.waitForTimeout(200);
|
||
assert.deepEqual(posts, []);
|
||
// Codex switched on while its distro is stopped: sent, Pi kept on,
|
||
// and the status says when it is written
|
||
await sw("Codex").click();
|
||
await page.waitForFunction((want) => document.querySelector("#status").textContent === want, asleep).catch(() => {});
|
||
assert.deepEqual(posts.map((p) => p.what), ["instructions/save"]);
|
||
assert.deepEqual(posts[0].body, { agents: ["claude", CX, PI] });
|
||
assert.equal(await page.locator("#status").textContent(), asleep);
|
||
assert.equal(await sw("Codex").getAttribute("aria-checked"), "true");
|
||
// Claude Code switched off: both of the stopped distro's stay on
|
||
await sw("Claude Code").click();
|
||
await page.waitForTimeout(300);
|
||
assert.deepEqual(posts[1], { what: "instructions/save", body: { agents: [CX, PI] } });
|
||
assert.deepEqual(errors, []);
|
||
await ctx.close();
|
||
});
|
||
}
|
||
});
|
||
}
|
||
|
||
// #4237, #4238: the Hooks and Subagents pages list the stopped distro's
|
||
// Codex as they do while the distro runs: its chip greyed, saying magpie
|
||
// gives no agent in WSL any yet, named in the line under the list, and a
|
||
// click on it sends nothing. Pi, whose places magpie never saw, isn't on
|
||
// a row that doesn't name it. The page draws what /api/library says
|
||
// (hooksView and subagentsView list the stopped agents); this holds it to
|
||
// that.
|
||
const GREYED = {
|
||
hooks: {
|
||
lib: { hooks: [{ name: "notify", event: "turn-end", command: "notify-send done", agents: ["claude"] }], hookAgents: [{ id: "claude", file: `${HOME}/.claude/settings.json`, events: ["Stop"] }, { id: CX, no: "magpie gives hooks only to agents on this computer, not yet to Codex · WSL " + D + " in WSL", wsl: true }] },
|
||
row: ".lib-hook", name: "notify",
|
||
tip: "magpie gives hooks only to agents on this computer, not yet to {agent} in WSL",
|
||
line: [".lib-hooks-no", "magpie can't give hooks to {agents} yet: their chips are greyed, and say why."],
|
||
},
|
||
subagents: {
|
||
lib: { subagents: [{ name: "reviewer", description: "Reviews a diff", prompt: "Review it.", skills: [], mcp: [], agents: ["claude"] }], subagentAgents: [{ id: "claude", dir: `${HOME}/.claude/agents`, skills: true, mcp: true }, { id: CX, no: "magpie gives no subagents to an agent in WSL yet", wsl: true }] },
|
||
row: ".lib-subagent", name: "reviewer",
|
||
tip: "magpie gives subagents only to agents on this computer, not yet to {agent} in WSL",
|
||
line: [".lib-subagents-no", "magpie can't give subagents to {agents} yet: their chips are greyed, and say why."],
|
||
},
|
||
};
|
||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) for (const [tab, g] of Object.entries(GREYED)) {
|
||
test(engine + `: a stopped WSL distro's agents are on the ${tab} page, greyed as while it runs`, async (t) => {
|
||
assert(["chromium", "webkit"].includes(engine), "BROWSER must be chromium or webkit");
|
||
I18N = strings().I18N;
|
||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: process.env.PLAYWRIGHT_CHANNEL || "chromium" }));
|
||
t.after(() => browser.close());
|
||
for (const width of [1100, 390]) for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
|
||
await t.test(`${lang} at ${width}px`, async () => {
|
||
const w = (key, vars) => tr(lang, key, vars);
|
||
const state = { servers: [], more: g.lib };
|
||
const posts = [], errors = [];
|
||
const ctx = await browser.newContext({ viewport: { width, height: 900 }, reducedMotion: "reduce" });
|
||
await ctx.addInitScript((tab) => { try { localStorage.setItem("magpie.libTab", tab); } catch {} }, tab);
|
||
const page = await ctx.newPage();
|
||
page.setDefaultTimeout(5000);
|
||
page.on("pageerror", (e) => errors.push(e.message));
|
||
page.on("dialog", (d) => { errors.push("a browser dialog: " + d.message()); d.dismiss(); });
|
||
await page.route("**/*", server(lang, state, posts));
|
||
await page.goto("http://magpie.test/");
|
||
await page.locator('button[data-view="library"]').click();
|
||
const v = page.locator("#view-library");
|
||
const row = v.locator(g.row).filter({ has: page.locator(".name", { hasText: new RegExp("^" + g.name) }) });
|
||
await row.waitFor();
|
||
assert.deepEqual(await row.locator(":scope > .lib-agents > .lib-ag[data-agent]").evaluateAll((cs) => cs.map((c) => c.dataset.agent)), ["claude", CX]);
|
||
const cx = row.locator(`.lib-ag[data-agent="${CX}"]`);
|
||
assert.match(await cx.getAttribute("class"), /\bblocked\b/);
|
||
assert.match(await cx.getAttribute("class"), /\basleep\b/);
|
||
assert.equal(await cx.getAttribute("aria-disabled"), "true");
|
||
assert.equal(await cx.getAttribute("aria-pressed"), "false");
|
||
assert.equal(await cx.getAttribute("title"), w(g.tip, { agent: "Codex · WSL " + D }));
|
||
assert.equal(await v.locator(g.line[0]).textContent(), w(g.line[1], { agents: "Codex · WSL " + D }));
|
||
assert.deepEqual(await sideways(page), [], "sideways with the rows");
|
||
await row.locator(":scope > .lib-agents").hover();
|
||
await cx.click({ force: true });
|
||
await page.waitForTimeout(200);
|
||
assert.deepEqual(posts, []);
|
||
assert.deepEqual(errors, []);
|
||
await ctx.close();
|
||
});
|
||
}
|
||
});
|
||
}
|