library: Magpie Browser's "which agents may use it" is a line of its own under its row
tao0194 on Discord (v0.1.2828, zh, panel-width window): in Library > MCP servers the magpie-browser row showed the connected ask (green dot, the question, a button per agent) inside the name's column, wrapped into a narrow strip between the command and the row's Scope and agent chips, three lines tall beside every other server's two. browserAsk's element was appended to the row's .who. It is now the row's own child: the row gets lib-asking while it shows, wraps, and the ask takes a line under the name, command and chips, from the name's left edge (the picture plus the row's gap, 37px, 38px in the window's rows) to the row's right edge. The first line keeps the name, command and chips as the other rows have them (.who flex-basis 0 above 560px). At 560px and under, where rows already wrap, a long command now ellipsizes beside the row's picture instead of taking the name to a line of its own under it; that was so for any server with a long command, and the ask's left edge follows the name. docs/subsystems/library.md says where the ask sits. library-browser-ask.test.cjs now has three agents (Codex, Zed among them) and a context7 row beside it, runs at 1100, 600, the panel's 440 and 360, and checks the ask starts under the first line, at the name's left edge, reaches the chips' right edge, that the first line is as tall as another server's, and that the name sits beside the picture. Run (mote, Playwright 1.62.0, Chromium and WebKit, en/zh/zh-TW/ja/de): - library-browser-ask.test.cjs on the old client.js/library.css: 42 of 44 red (every layout subtest; the two not-connected/given ones pass). With the change: 44 of 44 green. - The 84 GUI files that open the Library, name lib-row/lib-server or library.css, or check budgets and i18n keys: 1480 of 1480 ok, before the rebase ontoc3593dc49(no upstream change touches these files); library-browser-ask, i18n-keys and builtins again after it: 52 of 52 ok. go test ./internal/gui at the rebased head: TestMainWindowCorners red only (an AppKit window test, the same on origin/main78cd4e6dd, #3949); everything else ok. Not tried: the real app's panel (WKWebView) with a connected extension; the full GUI suite.
This commit is contained in:
@@ -64,7 +64,7 @@ agents RTK, a CLI that cuts shell output down before the model reads it.
|
||||
- With the MCP router on (`MCPHub`), an agent that takes a Streamable HTTP server is given magpie's one `magpie` entry in place of the Library servers ticked for it, and each server's own entry again when it is turned off. One that can't, or has an entry called magpie of its own, or whose library has a server called magpie, keeps each server's own entry, and the page says why ([MCP router](mcp-router.md)).
|
||||
- magpie's own MCP servers (`magpie-image`, `magpie-browser`, `magpie-web-search`, `magpie-vision`, and any `mcp …` run by a program named magpie) run this computer's magpie (#1439). `InstallServer` gives it magpie by full path (`update.Program`: the AppImage, not its mount; Homebrew's opt link, not the Cellar), and that path is right only on this computer. When the library is read, and after every change, `heal` points such a server whose program isn't on this computer (another system's path, a magpie moved out of Downloads, a bare `magpie`) at this magpie, so the agents and `CheckServers` get it; a magpie program that is here (another build) and a server run by any other program stay as they are. A carried library (`Collect`, for a backup or a WebDAV or S3 sync) names it as plain `magpie`, so two computers carry the same bundle and a sync doesn't write one's path over the other's; `Put` then reads it as that computer's magpie. [`self_here.go`](../../internal/library/self_here.go)
|
||||
- Magpie Web Search (`magpie-web-search`, `searchServer` in [`market.go`](../../internal/library/market.go)) is the featured, opt-in server for magpie's web search: `magpie mcp search` (`RunSearch` in [`browsermcp.go`](../../internal/browsermcp/browsermcp.go)) passes each stdio message to the gateway's `/mcp/magpie/web-search`, as `magpie mcp browser` does to its own path, with no browser session. Its sheet says each search goes where Settings › Models › Web search sends it. That page's MCP server row (`#searchMcpRow`) keeps the address to copy, and under its words Give agents Magpie Web Search… opens the sheet in the Library (`magpie.call("library", "server", "magpie-web-search")`), Turn on the Library when the Library is off, and nothing in gateway mode, as Settings › Images does for Magpie Image (lutra_fs on Discord: the search was in Settings and not in the Library; `search-mcp-library.test.cjs`). Each agent is given a 120-second tool timeout for it (`selfTimeout`). An agent in WSL is not given it directly, as with Magpie Browser; the MCP router serves it there.
|
||||
- Magpie Browser (`magpie-browser`) is opt-in, added with no agents, so the router offers it to none until one is ticked (an agent asked to use the browser reached for AppleScript instead). While its extension is connected (`GET /api/library/browser`, read again every 3 seconds while the row is shown) and no agent has it, its row in the MCP list asks which agents may use it, a button per agent whose chip can be clicked; a button clicks that chip, so the choice goes through `servers/agents` as a chip's does, and the row asks nothing more (`browserAsk` in [`client.js`](../../internal/gui/assets/plugins/library/client.js); `library-browser-ask.test.cjs`).
|
||||
- Magpie Browser (`magpie-browser`) is opt-in, added with no agents, so the router offers it to none until one is ticked (an agent asked to use the browser reached for AppleScript instead). While its extension is connected (`GET /api/library/browser`, read again every 3 seconds while the row is shown) and no agent has it, its row in the MCP list asks which agents may use it, on a line of its own under the row's name, command and chips (from the name's left edge to the row's right one, the row's `lib-asking`), a button per agent whose chip can be clicked; a button clicks that chip, so the choice goes through `servers/agents` as a chip's does, and the row asks nothing more (`browserAsk` in [`client.js`](../../internal/gui/assets/plugins/library/client.js); `library-browser-ask.test.cjs`).
|
||||
- Magpie Image Recognition (`magpie-vision`, `visionServer` in [`market.go`](../../internal/library/market.go)) is the featured, opt-in server for image recognition, beside Magpie Image and Magpie Web Search (matrix0487 on Discord: Discover had two of magpie's three): `magpie mcp vision` (`RunVision` in [`browsermcp.go`](../../internal/browsermcp/browsermcp.go)) passes each stdio message to the gateway's `/mcp/magpie/vision`, and makes `analyze_image`'s relative `image` path one in the agent's own folder on the way (`imageFrom`), since the gateway can't know where the agent runs; an absolute path, `~`, a URL or a drive goes as written. Its sheet says each image goes to Settings › Models › Images › Image recognition's model. That row has Give agents Magpie Image Recognition… (`libWay` in app.js, shared with Images' and Web search's links), Turn on the Library with the Library off, and nothing with recognition off or in gateway mode (`vision-mcp-library.test.cjs`). It gets the same 120-second tool timeout and the same WSL rule as Magpie Web Search.
|
||||
- Discover's featured list is the same with nothing set up: one of magpie's own whose model or search isn't there yet, or which Settings turned off, carries `unready` (`gateway.OwnUnready`, set by the GUI's `/api/library/market/servers`), shown as a Not set up yet badge on its card and the full reason in its sheet. It can still be added, since it answers once that is set up, and until then its tools answer with the same reason, so no agent is given a tool that fails without a word.
|
||||
- A carried library (`Collect`) has every file of each skill, its templates and other binaries included, up to `maxCarried` (16 MiB) a file and `maxCarriedAll` (32 MiB) in all, chosen smallest first across the skills (`readSkills`), so every skill's text goes before any big file. The total keeps a sealed backup under the 64 MiB a sync reads: the files are base64 twice in it. What is left out is named in `Left`, and `Put` keeps this computer's copy of such a file in the skill it puts (`keepLeft`). [`carry.go`](../../internal/library/carry.go)
|
||||
|
||||
@@ -2055,7 +2055,8 @@ magpie.plugin("library", (ctx) => {
|
||||
row.append(mark(s.icon, s.transport === "stdio" ? GLYPH.cmd : GLYPH.web), who, ...removeAct(() => confirmRemoveServer(s)),
|
||||
agentChips(withGone(all, s.agents), s.agents, chipsChange("servers/agents", s.name, "servers", (x) => serverRow(x, all)), { problems: s.problems, blocked: sseBlocked(s), all: true }));
|
||||
if (picking) return pickRow(row, s.name);
|
||||
if (s.name === "magpie-browser" && !s.agents?.length) who.append(browserAsk(row));
|
||||
// a line of its own under the row, not in the name's column (tao0194)
|
||||
if (s.name === "magpie-browser" && !s.agents?.length) row.append(browserAsk(row));
|
||||
row.onclick = () => editServer(s);
|
||||
row.title = t("Edit {name}", { name: s.name });
|
||||
return row;
|
||||
@@ -2096,6 +2097,7 @@ magpie.plugin("library", (ctx) => {
|
||||
const on = await browserLink();
|
||||
if (on && ask.hidden) draw();
|
||||
ask.hidden = !on;
|
||||
row.classList.toggle("lib-asking", on);
|
||||
setTimeout(look, 3000);
|
||||
};
|
||||
requestAnimationFrame(look);
|
||||
|
||||
@@ -497,6 +497,9 @@ input.lib-setname:focus { border-color: var(--accent); box-shadow: 0 0 0 3px col
|
||||
|
||||
@media (max-width: 560px) {
|
||||
.lib-list .row { flex-wrap: wrap; }
|
||||
/* a long command ellipsizes beside the row's picture rather than taking
|
||||
the name to a line under it (tao0194) */
|
||||
.lib-list .lib-row > .lib-glyph + .who, .lib-list .lib-row > .lib-logo + .who { max-width: calc(100% - var(--lib-indent)); }
|
||||
.lib-skillfile .bar { flex-wrap: wrap; }
|
||||
.lib-skillfile .bar .lib-reaches { flex-basis: 100%; }
|
||||
.lib-agents { max-width: 100%; }
|
||||
@@ -794,7 +797,16 @@ input.lib-setname:focus { border-color: var(--accent); box-shadow: 0 0 0 3px col
|
||||
.mk-sheet .mk-browser-folder > svg { grid-row: span 2; color: var(--fg-2); }
|
||||
.mk-sheet .mk-browser-folder-name { font-size: 12.5px; font-weight: 500; }
|
||||
.mk-sheet .mk-browser-folder-path { font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }
|
||||
.lib-browserask { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 6px; min-width: 0; font-size: 12px; color: var(--fg-2); cursor: default; }
|
||||
/* the ask is a line of its own under the row, from the name's left edge
|
||||
to the row's right one (tao0194: in the name's column it was squeezed
|
||||
between the command and the agents' chips); the line above keeps its
|
||||
name, command and chips as every other server's row has them */
|
||||
.lib-row.lib-asking { flex-wrap: wrap; row-gap: 6px; }
|
||||
/* where a row's name starts: its picture (26px) and the row's gap, 12px in the window */
|
||||
.lib-list .lib-row { --lib-indent: 37px; }
|
||||
body.window .lib-list .lib-row { --lib-indent: 38px; }
|
||||
@media not all and (max-width: 560px) { .lib-row.lib-asking > .who { flex-basis: 0; } }
|
||||
.lib-browserask { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; order: 1; flex: 0 0 calc(100% - var(--lib-indent)); margin-left: var(--lib-indent); min-width: 0; font-size: 12px; color: var(--fg-2); cursor: default; }
|
||||
.lib-browserask[hidden] { display: none; }
|
||||
.lib-browserask-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex: none; }
|
||||
.lib-browserask-q { min-width: 0; flex: 1 1 220px; overflow-wrap: anywhere; }
|
||||
|
||||
@@ -6,9 +6,13 @@
|
||||
// connected (read again while the row is shown, no reload), each agent a
|
||||
// button that gives it the server through servers/agents; once one has
|
||||
// it, the row asks nothing more. Not connected, or given to an agent
|
||||
// already, it asks nothing. Every language, Chromium and WebKit, at 1100
|
||||
// and 420 wide, nothing running off to the side; no backend, the API is
|
||||
// faked here.
|
||||
// already, it asks nothing. The ask is a line of its own under the row's
|
||||
// first line, as wide as the row past its picture, and that first line
|
||||
// is the name and command alone, as tall as any other server's (tao0194
|
||||
// on Discord: in the panel it sat inside the name's column, squeezed to
|
||||
// a few characters between the command and the agents' chips). Every
|
||||
// language, Chromium and WebKit, at 1100, 600, the panel's 440 and 360 wide,
|
||||
// nothing running off to the side; no backend, the API is faked here.
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
@@ -31,10 +35,12 @@ function fixture(lang, st) {
|
||||
agents: [
|
||||
{ id: "claude", name: "Claude Code", icon: "claudecode-color", mcp: `${HOME}/.claude.json`, skills: `${HOME}/.claude/skills`, hub: "on" },
|
||||
{ id: "codex", name: "Codex", icon: "codex-color", mcp: `${HOME}/.codex/config.toml`, hub: "on" },
|
||||
{ id: "zed", name: "Zed", icon: "zed", mcp: `${HOME}/.config/zed/settings.json`, hub: "on" },
|
||||
],
|
||||
servers: [
|
||||
{ name: "magpie-browser", transport: "stdio", command: "/Applications/magpie.app/Contents/MacOS/magpie", args: ["mcp", "browser"], agents: st.agents },
|
||||
{ name: "notes", transport: "stdio", command: "uvx", args: ["notes-mcp"], agents: [] },
|
||||
{ name: "context7", transport: "http", url: "https://mcp.context7.com/mcp", agents: ["claude", "codex", "zed"] },
|
||||
],
|
||||
instructions: { agents: [], sets: [] }, foundServers: [], projects: [], foundSkills: [], skills: [], problems: [],
|
||||
});
|
||||
@@ -98,7 +104,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
};
|
||||
for (const lang of LANGS) {
|
||||
const w = (s) => tr(lang, s);
|
||||
for (const width of [1100, 420]) {
|
||||
for (const width of [1100, 600, 440, 360]) {
|
||||
await t.test(`${lang} at ${width}px: asks once connected, a pick gives it, then asks nothing`, async () => {
|
||||
const st = { connected: false, agents: [] };
|
||||
const { f, context, page, errors, row } = await open(lang, width, st);
|
||||
@@ -110,12 +116,25 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
const ask = row.locator(".lib-browserask");
|
||||
await ask.waitFor({ state: "visible", timeout: 10000 });
|
||||
assert.equal(await ask.locator(".lib-browserask-q").textContent(), w(ASK));
|
||||
assert.deepEqual(await ask.locator(".lib-browserask-pick").allTextContents(), ["Claude Code", "Codex"]);
|
||||
assert.deepEqual(await ask.locator(".lib-browserask-pick").allTextContents(), ["Claude Code", "Codex", "Zed"]);
|
||||
// the other server, given to no agent either, asks nothing
|
||||
assert.equal(await page.locator("#view-library .lib-browserask:visible").count(), 1);
|
||||
assert.equal(await wide(page), 0);
|
||||
assert.equal(await row.evaluate((e) => e.scrollWidth - e.clientWidth), 0);
|
||||
shots.push([`${lang}-${width}-ask`, await row.screenshot()]);
|
||||
// its own line: under the name, the command and the chips, from
|
||||
// the name's left edge to the chips' right edge, and the first
|
||||
// line no taller than the server's beside it
|
||||
const box = (l) => l.evaluate((e) => { const r = e.getBoundingClientRect(); return { top: r.top, bottom: r.bottom, left: r.left, right: r.right, height: r.height }; });
|
||||
const [a, who, chips, nm] = await Promise.all([box(ask), box(row.locator(":scope > .who")), box(row.locator(":scope > .lib-agents")), box(row.locator(".name"))]);
|
||||
const other = await box(page.locator("#view-library .lib-server").filter({ has: page.locator(".name", { hasText: "notes" }) }).locator(":scope > .who"));
|
||||
assert(a.top >= who.bottom - 0.5 && a.top >= chips.bottom - 0.5, `ask starts under the first line: ${JSON.stringify({ a, who, chips })}`);
|
||||
assert(Math.abs(a.left - nm.left) <= 1, `ask starts under the name: ${a.left} vs ${nm.left}`);
|
||||
// and the name beside the row's picture, however long the command
|
||||
const pic = await box(row.locator(":scope > .lib-glyph, :scope > .lib-logo"));
|
||||
assert(nm.left >= pic.right && nm.top < pic.bottom, `name beside the picture: ${JSON.stringify({ nm, pic })}`);
|
||||
assert(a.right >= chips.right - 1, `ask reaches the chips' right edge: ${a.right} vs ${chips.right}`);
|
||||
assert(Math.abs(who.height - other.height) <= 1, `first line as tall as another server's: ${who.height} vs ${other.height}`);
|
||||
|
||||
await ask.locator('.lib-browserask-pick[data-agent="codex"]').click();
|
||||
await page.waitForFunction(() => document.querySelector('#view-library .lib-server .lib-agents .lib-ag[data-agent="codex"]')?.getAttribute("aria-pressed") === "true");
|
||||
|
||||
Reference in New Issue
Block a user