library: a repository's heading folds an agent's profiles into one chip, and a row's profiles chip lines up with the hand (Yanzhongixuy on X)
0.1.3926, several Hermes profiles: the Skills page's source headings (anthropics/skills ...) drew one icon per profile, a long strip, and the one chip2a1111cbamade on a row sat out of line. That commit said "Rows only": groupChips never set change.rows, so headings kept every profile. The row's chip had data-members, not data-agent, so the fan/stack translate rules in library.css never reached it. groupChips now sets change.rows, and its profiles chip is half lit when a profile has some of the skills. library.css applies the fan rules to [data-members] chips too. docs/subsystems/library.md says so. Files: plugins/library/client.js, plugins/library/library.css, tests/library-profile-group.test.cjs (new), docs/subsystems/library.md. Run on mote: library-profile-group.test.cjs (new; chromium + webkit, en/zh/ zh-TW/ja/de, 420 and 980px, 22 cases): 22 of 22 green; broken by hand (old client.js and library.css) 22 of 22 red (13 Hermes chips, not 1); old library.css alone 22 of 22 red (chips out of line). The Library GUI files, group-skill-chips and i18n-keys ran in both engines: the only reds are library-loading's chromium and webkit cases, red on origin/main8c7328f3a6too (run there alone, 2 of 6 red), filed as #6204. Not run: the full Go suite and the 113-file GUI run's final tally (still running when pushed), Linux WebKitGTK, a real Hermes install with many profiles.
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -5616,7 +5616,7 @@ magpie.plugin("library", (ctx) => {
|
||||
for (const g of by.values()) v = await api("library/" + kind + "/agents-some", { names: g.names, agents: g.agents, on });
|
||||
return v;
|
||||
};
|
||||
const box = agentChips(all, full, async (next) => {
|
||||
const change = async (next) => {
|
||||
const on = next.filter((id) => !full.includes(id)), off = full.filter((id) => !next.includes(id));
|
||||
box.classList.add("busy");
|
||||
try {
|
||||
@@ -5640,11 +5640,20 @@ magpie.plugin("library", (ctx) => {
|
||||
status(e.message, "err", 6000);
|
||||
}
|
||||
render();
|
||||
}, { all: true, blocked: servers ? (a) => (reach(a) ? "" : n === 1 ? sseBlocked(skills[0])(a) : t("{agent} can reach none of these servers", { agent: a.name }))
|
||||
};
|
||||
// an agent's profiles are one chip here too (Yanzhongixuy on X: a
|
||||
// repository's heading drew an icon for each of twenty Hermes profiles)
|
||||
change.rows = true;
|
||||
const box = agentChips(all, full, change, { all: true, blocked: servers ? (a) => (reach(a) ? "" : n === 1 ? sseBlocked(skills[0])(a) : t("{agent} can reach none of these servers", { agent: a.name }))
|
||||
: hooks ? (a) => (reach(a) ? "" : n === 1 ? hookBlocked(skills[0])(a) : t("{agent} can run none of these hooks", { agent: a.name })) : null,
|
||||
always: servers || hooks || !n ? null : (a) => (reach(a) ? "" : n === 1 ? alwaysFor(skills[0])(a)
|
||||
: t("{agent} reads ~/.agents/skills itself, where all of these are kept — it has them whatever is ticked here", { agent: a.name })) });
|
||||
box.classList.add("lib-groupchips");
|
||||
// a profiles chip is half lit when a profile of it has some of the skills
|
||||
for (const c of box.querySelectorAll(".lib-ag[data-members]")) {
|
||||
const ms = idsOf(c).map((id) => all.find((x) => x.id === id)).filter((a) => a && reach(a));
|
||||
if (ms.some((a) => count(a) && count(a) < reach(a)) || (ms.some((a) => count(a)) && !c.classList.contains("on"))) c.classList.add("some");
|
||||
}
|
||||
for (const c of box.querySelectorAll(".lib-ag[data-agent]")) {
|
||||
const a = all.find((x) => x.id === c.dataset.agent), k = count(a), m = reach(a);
|
||||
if (!m) continue;
|
||||
|
||||
@@ -358,13 +358,13 @@ input.lib-setname:focus { border-color: var(--accent); box-shadow: 0 0 0 3px col
|
||||
it never move. The cards are dealt out one after another, the one with
|
||||
the furthest to go first, so none passes over another, and go back
|
||||
together, quicker. Transform stays free for the press. */
|
||||
.lib-row > .lib-agents .lib-ag[data-agent] { translate: calc(var(--k, 0) * (var(--lib-fan) - var(--lib-stack))) 0; }
|
||||
.lib-row > .lib-agents:hover .lib-ag[data-agent], .lib-row > .lib-agents:focus-within .lib-ag[data-agent] { translate: 0 0; transition-delay: 0s, 0s, 0s, 0s, 0s, calc((var(--lib-agent-count, 1) - 1 - var(--k, 0)) * var(--lib-step)); }
|
||||
.lib-row > .lib-agents .lib-ag[data-agent], .lib-row > .lib-agents .lib-ag[data-members] { translate: calc(var(--k, 0) * (var(--lib-fan) - var(--lib-stack))) 0; }
|
||||
.lib-row > .lib-agents:hover .lib-ag[data-agent], .lib-row > .lib-agents:focus-within .lib-ag[data-agent], .lib-row > .lib-agents:hover .lib-ag[data-members], .lib-row > .lib-agents:focus-within .lib-ag[data-members] { translate: 0 0; transition-delay: 0s, 0s, 0s, 0s, 0s, calc((var(--lib-agent-count, 1) - 1 - var(--k, 0)) * var(--lib-step)); }
|
||||
.lib-row > .lib-agents .lib-ag { flex: none; width: 24px; min-width: 0; height: 24px; padding: 0 0 0 4px; justify-content: flex-start; background: var(--card); border-color: var(--line-2); box-shadow: none; transition: background .14s, border-color .14s, transform .14s var(--ease), outline-color .2s, box-shadow .2s, translate .22s cubic-bezier(.32, .72, 0, 1); }
|
||||
.lib-row > .lib-agents:hover .lib-ag, .lib-row > .lib-agents:focus-within .lib-ag { transition-duration: .14s, .14s, .14s, .2s, .2s, .3s; transition-timing-function: ease, ease, var(--ease), ease, ease, cubic-bezier(.23, 1, .32, 1); }
|
||||
.lib-row > .lib-agents { --lib-step: min(16ms, calc(120ms / max(1, var(--lib-agent-count, 1) - 1))); }
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.lib-row > .lib-agents .lib-ag[data-agent], .lib-row > .lib-agents:hover .lib-ag[data-agent], .lib-row > .lib-agents:focus-within .lib-ag[data-agent] { transition-duration: .14s, .14s, .14s, .2s, .2s, 0s; transition-delay: 0s; }
|
||||
.lib-row > .lib-agents .lib-ag[data-agent], .lib-row > .lib-agents:hover .lib-ag[data-agent], .lib-row > .lib-agents:focus-within .lib-ag[data-agent], .lib-row > .lib-agents .lib-ag[data-members], .lib-row > .lib-agents:hover .lib-ag[data-members], .lib-row > .lib-agents:focus-within .lib-ag[data-members] { transition-duration: .14s, .14s, .14s, .2s, .2s, 0s; transition-delay: 0s; }
|
||||
}
|
||||
.lib-row > .lib-agents .lib-ag .ic { width: 14px; height: 14px; }
|
||||
/* the ring in the card's colour that cuts each chip out of the one under
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// With several Hermes profiles a repository's heading in the Library's
|
||||
// skills drew an icon for each of them, and the one chip a row made of them
|
||||
// sat out of line with the others (Yanzhongixuy on X, 0.1.3926: "显示很长且
|
||||
// 错位"). Both are one chip with a count that opens a menu of the profiles,
|
||||
// in line with the hand of chips. A tick in the menu gives the repository's
|
||||
// skills to that profile alone. 420px and 980px, English, Chinese,
|
||||
// Traditional Chinese, Japanese and German; the API is faked.
|
||||
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 HOME = "/Users/me";
|
||||
const agent = (id, name, icon) => ({ id, name, icon, skills: `${HOME}/.${id}/skills`, mcp: `${HOME}/.${id}/mcp.json` });
|
||||
const gh = (repo, name, agents) => ({ name, kind: "github", source: `https://github.com/${repo}/tree/main/skills/${name}`, description: "d", agents });
|
||||
|
||||
function server(lang, state, posts) {
|
||||
return async (route) => {
|
||||
const req = route.request();
|
||||
const 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 json({ agents: [], profiles: [], settings: { lang, theme: "light" } });
|
||||
if (url.pathname === "/api/library") return json(state.lib);
|
||||
if (url.pathname === "/api/library/skills/agents-some") {
|
||||
const b = req.postDataJSON();
|
||||
posts.push(b);
|
||||
for (const s of state.lib.skills) {
|
||||
if (!b.names.includes(s.name)) continue;
|
||||
const kept = s.agents.filter((a) => !b.agents.includes(a));
|
||||
s.agents = (b.on ? [...kept, ...b.agents] : kept).sort();
|
||||
}
|
||||
return json({ ...state.lib, result: { changed: b.agents } });
|
||||
}
|
||||
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/usage/quotas") return json([]);
|
||||
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 NAMES = ["coder", "work", "play", "ops", "docs", "a", "b", "c", "d", "e", "f", "g"];
|
||||
const PROFILES = NAMES.map((n) => agent("hermes#" + n, "Hermes · " + n, "hermes"));
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
test(engine + ": a repository's heading folds an agent's profiles into one chip", async (t) => {
|
||||
assert(["chromium", "webkit"].includes(engine), "BROWSER must be chromium or webkit");
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: process.env.PLAYWRIGHT_CHANNEL || "chromium" }));
|
||||
t.after(() => browser.close());
|
||||
for (const width of [420, 980]) for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
|
||||
await t.test(lang + " " + width, async () => {
|
||||
const state = {
|
||||
lib: {
|
||||
dir: `${HOME}/.magpie/library`, backups: `${HOME}/.magpie/backups`, home: HOME,
|
||||
agents: [agent("claude", "Claude Code", "claudecode-color"), agent("hermes", "Hermes Agent", "hermes"), ...PROFILES, agent("codex", "Codex", "openai")],
|
||||
instructions: { agents: [], sets: [] }, servers: [], foundServers: [], projects: [], foundSkills: [], problems: [],
|
||||
skills: [gh("acme/kit", "mango", ["claude", "hermes", "hermes#coder"]), gh("acme/kit", "cherry", ["claude", "hermes", "hermes#coder", "hermes#work"]), gh("zed/tools", "pear", [])],
|
||||
},
|
||||
};
|
||||
const posts = [];
|
||||
const ctx = await browser.newContext({ viewport: { width, height: 760 }, reducedMotion: "reduce" });
|
||||
await ctx.addInitScript(() => { try { localStorage.setItem("magpie.libTab", "skills"); } catch {} });
|
||||
const page = await ctx.newPage();
|
||||
page.setDefaultTimeout(5000);
|
||||
page.setDefaultNavigationTimeout(60000);
|
||||
const errors = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", server(lang, state, posts));
|
||||
await page.goto("http://magpie.test/");
|
||||
await page.locator('button[data-view="library"]').click();
|
||||
const head = page.locator("#view-library .lib-grouphead").filter({ has: page.locator(".name", { hasText: /^acme\/kit$/ }) });
|
||||
await head.waitFor();
|
||||
if (!(await head.evaluate((h) => h.classList.contains("open")))) await head.locator(".name").click();
|
||||
const row = page.locator("#view-library .lib-skill > .lib-agents").first();
|
||||
await row.waitFor();
|
||||
const strip = head.locator(".lib-groupchips");
|
||||
|
||||
// the heading: claude, one Hermes chip, codex; not a chip per profile
|
||||
assert.equal(await strip.locator('.lib-ag[data-agent^="hermes"]').count(), 0);
|
||||
assert.equal(await strip.locator(".lib-ag.profiles").count(), 1);
|
||||
assert.equal(await strip.locator(".lib-ag[data-agent]").count(), 2);
|
||||
const chip = strip.locator(".lib-ag.profiles");
|
||||
// hermes and #coder have both skills; #work has one
|
||||
assert.equal(await chip.locator(".cnt").textContent(), "2");
|
||||
assert(await chip.evaluate((c) => c.classList.contains("some")));
|
||||
|
||||
// a row's chips are one hand: each the same step from the last
|
||||
for (const box of [strip, row]) {
|
||||
await page.mouse.move(2, 2);
|
||||
await page.waitForTimeout(400);
|
||||
const lefts = await box.locator(".lib-ag:not(.all)").evaluateAll((cs) => cs.map((c) => c.getBoundingClientRect().left));
|
||||
const steps = lefts.slice(1).map((x, i) => Math.round((x - lefts[i]) * 2) / 2);
|
||||
assert(steps.length >= 2);
|
||||
assert(steps.every((d) => Math.abs(d - steps[0]) <= 0.5), "chips are out of line: " + steps);
|
||||
}
|
||||
|
||||
// a tick gives that profile every skill of the repository
|
||||
await chip.click();
|
||||
const menu = page.locator(".proto-menu");
|
||||
await menu.waitFor();
|
||||
await menu.locator(".pm-item", { hasText: "play" }).click();
|
||||
await page.waitForTimeout(150);
|
||||
assert.deepEqual(posts.shift(), { names: ["cherry", "mango"], agents: ["hermes#play"], on: true });
|
||||
assert.deepEqual(errors, []);
|
||||
await ctx.close();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user