diff --git a/internal/gui/assets/plugins.css b/internal/gui/assets/plugins.css index a6da0db10..ef0eb6fe0 100644 --- a/internal/gui/assets/plugins.css +++ b/internal/gui/assets/plugins.css @@ -316,4 +316,3 @@ body.window .pm-manual { --bleed-l: 16px; } .pm-card.ghost .sk, .pm-ghlook, .pm-ghlook .dots i, .pm-arrive .pm-card { animation: none; } .pm-ghlook .dots i { opacity: .5; } } -.pm-tools > .pm-tools-flip { flex: none; margin-left: auto; padding: 0 2px; } diff --git a/internal/gui/assets/plugins.js b/internal/gui/assets/plugins.js index 2f0127cba..de984926e 100644 --- a/internal/gui/assets/plugins.js +++ b/internal/gui/assets/plugins.js @@ -1320,6 +1320,8 @@ r.append(val); return r; } + const flip = e.tools?.length && !e.off && toolsFlip(e); + if (flip) val.append(flip); if ((e.isGateway || (mw && !mw.error) || ownOpts) && !e.off && editing?.pkg !== pkg) { const o = el("button", "text", t("Options")); o.title = e.options ? t("The options it runs with") : t("It runs with no options; its package suggests some"); @@ -1479,17 +1481,21 @@ const b = copyBtn(url, t("MCP server address")); b.title = t("Copy the MCP server's address ({url}): add it to an agent as an MCP server (Streamable HTTP)", { url }); d.append(b); - if (sv && !gatewayMode && !featuresOff.has("library")) { - const f = el("button", "link pm-tools-flip", t(sv.on ? "Hide from agents" : "Give to agents")); - f.onclick = (ev) => { - ev.stopPropagation(); - f.disabled = true; - api("library/servers/plugin-on", { name: sv.plugin, on: !sv.on }).then(refresh, (err) => { f.disabled = false; statusErr(err); }); - }; - d.append(f); - } return d; } + // toolsFlip gives a plugin's tools to every agent or hides them, among + // the row's buttons (on the tools line it sat a line below them) + function toolsFlip(e) { + const sv = e.toolsServer; + if (!sv || gatewayMode || featuresOff.has("library")) return null; + const f = el("button", "text pm-tools-flip", t(sv.on ? "Hide from agents" : "Give to agents")); + f.onclick = (ev) => { + ev.stopPropagation(); + f.disabled = true; + api("library/servers/plugin-on", { name: sv.plugin, on: !sv.on }).then(refresh, (err) => { f.disabled = false; statusErr(err); }); + }; + return f; + } // what a plugin's page may read of magpie's: what its package.json's // magpie.permissions declares, each a read with no secret in it diff --git a/internal/gui/tests/plugin-tools.test.cjs b/internal/gui/tests/plugin-tools.test.cjs index 468d52215..ad785628d 100644 --- a/internal/gui/tests/plugin-tools.test.cjs +++ b/internal/gui/tests/plugin-tools.test.cjs @@ -110,18 +110,23 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", shown.length = 0; const vline = row("video").locator(".pm-tools"); assert.equal((await vline.locator("span").first().innerText()).trim(), w.given); - const flip = vline.locator(".pm-tools-flip"); + const vval = row("video").locator(".val"); + const flip = vval.locator(".pm-tools-flip"); assert.equal((await flip.innerText()).trim(), w.hide); await flip.click(); - await vline.locator(".pm-tools-flip", { hasText: w.give }).waitFor(); + await vval.locator(".pm-tools-flip", { hasText: w.give }).waitFor(); assert.equal((await vline.locator("span").first().innerText()).trim(), w.hidden); assert.deepEqual(shown, [{ name: VIDEO, on: false }]); assert.ok(!(await row("video").innerText()).includes("Off\n"), "the plugin itself stays on"); - await vline.locator(".pm-tools-flip").click(); - await vline.locator(".pm-tools-flip", { hasText: w.hide }).waitFor(); + await vval.locator(".pm-tools-flip").click(); + await vval.locator(".pm-tools-flip", { hasText: w.hide }).waitFor(); assert.deepEqual(shown, [{ name: VIDEO, on: false }, { name: VIDEO, on: true }]); - const [fb, vb] = await Promise.all([vline.locator(".pm-tools-flip").boundingBox(), row("video").boundingBox()]); - assert.ok(fb.x + fb.width <= vb.x + vb.width + 1, "the line's button overflows its row"); + assert.equal(await vline.locator("button.pm-tools-flip").count(), 0, "the flip sits with the row's buttons, not on the tools line"); + // on one line with Switch off and Remove (it sat a line below them, 11-08) + const [fb, vb] = await Promise.all([vval.locator(".pm-tools-flip").boundingBox(), row("video").boundingBox()]); + assert.ok(fb.x + fb.width <= vb.x + vb.width + 1, "the row's button overflows its row"); + const mids = await vval.locator("button").evaluateAll((bs) => bs.map((b) => { const r = b.getBoundingClientRect(); return r.top + r.height / 2; })); + for (const m of mids) assert.ok(Math.abs(m - mids[0]) <= 1, "row buttons off one line: " + mids.join(", ")); const over = await page.evaluate(() => document.scrollingElement.scrollWidth - document.scrollingElement.clientWidth); assert.ok(over <= 0, "page scrolls sideways by " + over);