Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
agents: a click anywhere on a connected agent's row opens or closes it (NG_shiyu on X)
yetone317aa54d9ccf
diff --git a/docs/subsystems/gui-shell.md b/docs/subsystems/gui-shell.mdindex 250544adb..a1fac5050 100644--- a/docs/subsystems/gui-shell.md+++ b/docs/subsystems/gui-shell.md@@ -433,6 +433,7 @@ covers it in both engines, every language and a narrow window.- The Providers page has a search box over its list (#1614, `findProviders` in [`app.js`](../../internal/gui/assets/app.js)): the words typed keep the rows, on and off, whose text or data say them all: name, id, preset, addresses, every model's id and name, the account's user and plan and each login's, account names and key names. The Turned off fold stays open while searching; Escape or clearing the box shows every row and the fold as it was. A row that is on reorders by dragging its logo, Alt+↑/↓, Alt+Shift+↑/↓ (top, bottom) or its right-click menu (`openProviderMenu`: Move to top, Move up, Move down, Move to bottom). While searching, a step or a drop moves it among the rows shown (it takes the place of the row it passes, `stepProvider`, `shownToOn`) and the hidden ones keep their order; Move to top and Move to bottom go to the ends of the whole list. Every move saves the whole order through `POST /api/providers/arrange`. See `provider-find.test.cjs` and `provider-order.test.cjs`.- Hide accounts (`window.hideAccounts` at the end of [`app.js`](../../internal/gui/assets/app.js), stored in `magpie.maskEmails`, which the panel follows) masks every account name and address in the page's text and tooltips. While it is on, an account's name on the provider editor's row (`accountNameButton`, and the one-account line) and on its Usage card (`quotaWho`), and on the tray panel's Usage card (`panelQuotaCard`'s `.pq-who`, in sight while the card is hovered), has an eye (`hideAccounts.eye`), in sight on hover or keyboard focus. A click shows that one account, its address and the name the user gave it together (`kin`), everywhere that page draws it, tooltips included, while the others stay hidden (yogurt36 on Discord, for a screen share). The accounts shown are a set held in memory that `hits()` skips; nothing stores them. The window and the panel are pages of their own, each with its own set: one shown in the window stays hidden in the panel and the other way round, so a screenshot of either shows only what was shown there. Closing the window hides them again: the page stays loaded while the window is hidden, so `hideMain` runs `mainClosedJS` (`hideAccounts.closed`) first. Putting the panel away hides the panel's again, from its `visibilitychange` (the one that drops `panelPeek`) (`account-eye.test.cjs`, `TestClosingHidesShownAccounts`).- A new user's Agents page (the window's first page and the panel's Agents tab) has a *Get started* card above the agents in the welcome's place (wangye1644294 on X, `guideCard` in [`app.js`](../../internal/gui/assets/app.js)). Its three steps are: add a model source; connect an agent, where the agents magpie found that can be connected are named and each is connected in one click (`agents/connect`); and, optional, a routing group, with the most harmless starter template that can be made from the user's models (`provider.Templates`, Never stuck first) added in one click through `POST /api/groups/template`. Every tick comes from the state: the models magpie serves (`served` in `/api/state`, groups left out), an agent wired, or a group that isn't automatic. None comes from the card having been seen. The card goes once the first two steps are done. Its close button saves `settings.GuideHidden` through `POST /api/settings/guide`, so the panel, the window and a reload agree, and the Settings save keeps it. See `getting-started.test.cjs`.+- A connected agent's row in the window opens and closes on a click anywhere on it that isn't one of its controls, as a disclosure row does on the Mac (NG_shiyu on X, `connectRow` in [`app.js`](../../internal/gui/assets/app.js)): the click is handed to the row's *Models {n}* link (`expandLink`), which stays the control the keyboard and a screen reader use and keeps `aria-expanded`. Buttons, links, inputs, anything with a role, the grip and the opened sheet (`.ag-exp`) keep their own clicks, and a click that ends a text selection does nothing. The panel's rows did this already (`agent-row-disclose.test.cjs`).- Every page of the window keeps to one width, at most 1200px of content centred, with a 16px gutter in a narrow window (`padding: max(16px, calc(50% - 600px))` on each `#view-…`, #860). Routing, Usage and Sessions are in that rule too (面条 on Discord), so a large screen doesn't stretch them edge to edge while the others sit in the middle; their columns follow the room they get (`byWidth`). See `page-width.test.cjs`.- The page must work in Chromium (Windows' WebView2) and WebKit (macOS, and WebKitGTK on Linux). GUI tests run in both engines.- In the design of macOS 26 the main window has the corners of a window with a plain title bar, and its lights stay where the toolbar had them. `TestMainWindowCorners` ([`titlebar_darwin_test.go`](../../internal/gui/titlebar_darwin_test.go)) measures this in a process of its own, with package `windowshape`: after a new title and size and a new system appearance, as AppKit draws that appearance, where a first press with another app in front begins a window drag, and where a sheet begins. It runs that process as linked against the macOS 26 SDK and against macOS 15's, whatever SDK the toolchain has (`runAppKitSDK` and `stampSDK` give the copy it runs that SDK, and sign it again). In the earlier design, on an older macOS or with macOS 15's SDK, it checks that the window keeps its toolbar; `TestMainWindowRightToLeft` checks that it keeps it with the lights on the right. Both run in CI's macOS job. No test covers `UIDesignRequiresCompatibility`: AppKit reads it from an app bundle's Info.plist, LaunchServices registers each bundle that runs, and a press sent within a process run from one doesn't always begin a window drag.diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.jsindex c62c04931..497cfa9fb 100644--- a/internal/gui/assets/app.js+++ b/internal/gui/assets/app.js@@ -1519,7 +1519,20 @@ function connectRow(a, row, who, { fields, extras, fieldBtn, sw, kind }) {const start = kind === "ok" && !listsMenu(a) ? startField(a) : null;if (start) fields.querySelector(`:scope > [data-key="${CSS.escape(start.key)}"]`)?.remove();if (kind === "ok") {- if (a.wired) row.append(expandLink(a));+ if (a.wired) {+ // a click anywhere on the row that isn't one of its controls opens or+ // closes it, as a disclosure row does on the Mac (NG_shiyu on X: the+ // space between the name and the model did nothing, only the small+ // link did); the link stays the control the keyboard and a screen+ // reader use, with its aria-expanded+ const link = expandLink(a);+ row.append(link);+ row.onclick = (ev) => {+ if (ev.target.closest("button, a, input, label, [role], .ag-exp, .ag-handle")) return;+ if (!getSelection()?.isCollapsed) return; // words being selected+ link.click();+ };+ }// the square copying the command that starts it on magpie (agy), the// only way it takes magpie: on the row, before the modelconst launch = a.wired && fields.querySelector(".field.launch");diff --git a/internal/gui/tests/agent-row-disclose.test.cjs b/internal/gui/tests/agent-row-disclose.test.cjsnew file mode 100644index 000000000..647039c14--- /dev/null+++ b/internal/gui/tests/agent-row-disclose.test.cjs@@ -0,0 +1,156 @@+// Run with Node's test runner and Playwright on the module path; see README.md.+// A connected agent's row in the window opens and closes on a click+// anywhere on it that isn't one of its controls, as a disclosure row does+// on the Mac (NG_shiyu on X: the space between the name and the model did+// nothing, only the small Models › link opened it, which is far to reach+// on a large screen). Its controls still do only their own thing: the+// model picker opens its menu, the grip its menu, the switch asks to+// disconnect, and a click inside the opened part leaves it open. The link+// stays the control the keyboard uses, its aria-expanded true while the+// row is open. A row that isn't connected has nothing to open. No click+// moves the page. Wide and narrow windows, every language, Chromium and+// WebKit. No backend: 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 assets = path.resolve(__dirname, "../assets");+const opts = [+ { value: "group/steady", label: "Never stuck", ref: "group/steady", group: "Routing groups", icons: ["deepseek"] },+ { value: "ds/pro", label: "DeepSeek Pro", ref: "ds/pro", note: "DeepSeek", group: "DeepSeek", icon: "deepseek" },+];+const models = { shown: 2, listed: 2, by: [{ name: "Routing groups", icons: ["deepseek"], n: 1 }, { name: "DeepSeek", icon: "deepseek", n: 1 }], names: ["Never stuck", "DeepSeek Pro"] };+// enough agents under them that the page scrolls+const more = Array.from({ length: 12 }, (_, i) => ({ id: "a" + i, name: "Agent " + i, icon: "generic", path: "/f/a" + i, wired: true, models, fields: [{ key: "model", label: "model", value: "ds/pro", options: opts }] }));+const state = (lang) => ({+ agents: [+ { id: "codex", name: "Codex", icon: "generic", path: "/f/codex", wired: true, models, fields: [{ key: "model", label: "model", value: "group/steady", options: opts }] },+ { id: "gemini", name: "Gemini CLI", icon: "generic", path: "/f/gemini", wired: false, fields: [{ key: "model", label: "model", value: "", options: opts }] },+ ...more,+ ],+ profiles: [], settings: { lang, theme: "light" },+});++const serve = (lang) => async (route) => {+ const url = new URL(route.request().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:false};` });+ if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });+ if (url.pathname === "/api/state") return json(state(lang));+ 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)];+ const body = await fs.readFile(file).catch(() => null);+ await route.fulfill(body ? { body, contentType } : { status: 404, body: "" });+};++const codex = '.row.agent[data-id="codex"]';+// the page's scroll, wherever the page scrolls+const scrolled = (page) => page.evaluate(() => [document.scrollingElement.scrollTop, ...[...document.querySelectorAll(".view")].map((v) => v.scrollTop)].join());+// the middle of the row's empty space between the name and the link, or,+// in a window too narrow for one, the end of the line under the name+const gap = (page, r) => page.evaluate((r) => {+ const row = document.querySelector(r), who = row.querySelector(":scope > .who").getBoundingClientRect();+ const next = row.querySelector(":scope > .ag-link, :scope > .field").getBoundingClientRect();+ const words = Math.max(...[...row.querySelectorAll(":scope > .who > *")].map((e) => { const g = document.createRange(); g.selectNodeContents(e); return g.getBoundingClientRect().right; }));+ if (next.left - words > 16 && Math.abs(next.top - who.top) < who.height) return { x: (words + next.left) / 2, y: next.top + next.height / 2, empty: true };+ const name = row.querySelector(".name").getBoundingClientRect();+ return { x: name.left + name.width / 2, y: name.top + name.height / 2, empty: false };+}, r);+const isOpen = (page, r = codex) => page.evaluate((r) => {+ const row = document.querySelector(r);+ return { open: row.classList.contains("expanded") && !!row.querySelector(":scope > .ag-exp"), aria: row.querySelector(":scope > .ag-link")?.getAttribute("aria-expanded") ?? null };+}, r);+const quiet = (page) => page.waitForTimeout(600); // the sheet slides++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 [1100, 560]) {+ test(`${engine} ${lang} ${width}px: a click on a connected row's empty space opens and closes it`, async (t) => {+ const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));+ t.after(() => browser.close());+ const page = await browser.newPage({ viewport: { width, height: 560 } });+ page.setDefaultTimeout(5000);+ const errors = [];+ page.on("pageerror", (e) => errors.push(e.message));+ await page.route("**/*", serve(lang));+ await page.goto("http://magpie.test/?view=agents");+ await page.locator(`${codex} .ag-link`).waitFor();+ const y = await scrolled(page);+ assert.deepEqual(await isOpen(page), { open: false, aria: "false" });++ // the row's empty space: open, and the link says so+ let at = await gap(page, codex);+ if (width === 1100) assert.ok(at.empty, "no empty space between the name and the link at 1100px");+ await page.mouse.click(at.x, at.y);+ await quiet(page);+ assert.deepEqual(await isOpen(page), { open: true, aria: "true" }, "the row didn't open");+ // a click inside what opened leaves it open+ const exp = await page.locator(`${codex} > .ag-exp`).boundingBox();+ await page.mouse.click(exp.x + exp.width - 6, exp.y + exp.height - 6);+ await quiet(page);+ assert.equal((await isOpen(page)).open, true, "a click inside the opened part closed it");+ // and again on the row: closed+ at = await gap(page, codex);+ await page.mouse.click(at.x, at.y);+ await quiet(page);+ assert.deepEqual(await isOpen(page), { open: false, aria: "false" }, "the row didn't close");++ // its name opens it too: the whole row is the disclosure+ await page.locator(`${codex} .name`).click();+ await quiet(page);+ assert.equal((await isOpen(page)).open, true, "a click on the name didn't open it");+ await page.locator(`${codex} > .ag-link`).click();+ await quiet(page);+ assert.equal((await isOpen(page)).open, false, "the link didn't close it");++ // its controls do only their own thing+ await page.locator(`${codex} > .field.ag-start`).click();+ await page.locator("#pop.model-picker").waitFor();+ assert.equal((await isOpen(page)).open, false, "the model picker opened the row");+ await page.keyboard.press("Escape");+ await page.locator("#pop.model-picker").waitFor({ state: "hidden" });+ await page.locator(`${codex} > .ag-handle`).click();+ await page.locator(".pop.row-menu").waitFor();+ assert.equal((await isOpen(page)).open, false, "the grip opened the row");+ await page.keyboard.press("Escape");+ await page.locator(".pop.row-menu").waitFor({ state: "detached" }).catch(() => page.locator(".pop.row-menu").waitFor({ state: "hidden" }));+ await page.locator(`${codex} > .ag-conn`).click();+ await page.locator("#modal .disconnect-ask").waitFor();+ assert.equal((await isOpen(page)).open, false, "the switch opened the row");+ await page.keyboard.press("Escape");+ await page.locator("#modal .disconnect-ask").waitFor({ state: "detached" });+ await quiet(page);+ assert.equal((await isOpen(page)).open, false);++ // the keyboard: the link, Enter+ await page.locator(`${codex} > .ag-link`).focus();+ await page.keyboard.press("Enter");+ await quiet(page);+ assert.deepEqual(await isOpen(page), { open: true, aria: "true" }, "Enter on the link didn't open it");+ await page.locator(`${codex} > .ag-link`).focus();+ await page.keyboard.press("Enter");+ await quiet(page);+ assert.deepEqual(await isOpen(page), { open: false, aria: "false" });++ // one not connected has nothing to open+ const g = await page.locator('.row.agent[data-id="gemini"] .name').boundingBox();+ await page.mouse.click(g.x + g.width / 2, g.y + g.height / 2);+ await quiet(page);+ assert.equal(await page.locator('.row.agent[data-id="gemini"] > .ag-exp').count(), 0);+ assert.equal(await page.locator(".row.agent.expanded").count(), 0);++ assert.equal(await scrolled(page), y, "a click moved the page");+ assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth), "the row runs past the window");+ assert.deepEqual(errors, []);+ });+ }+ }+}