The owner, 10-20: Settings › General held Codex subagents, Long
conversations, Codex background compaction, thread titles, thread
descriptions, composer predictions, the auto-review model and the
memories model, apart from the agents they set; "很割裂、很分散,不直观".
They now sit with their agent (AGENT_PREFS): in its opened row on the
Agents page (a Settings list in connectPanel), in a sheet from the
tray panel's row ("Settings" line, openAgentPrefs) and from the agent's
menu ("{agent} settings"). Each row is the one element moved between
those places, so its handlers and state go with it. Settings' search
still finds them, with a row that opens the agent's sheet
(#agentPrefLinks). A gateway has no Agents page and none of them.
Strings for zh, zh-TW, ja and de; docs (reference, agent-wiring,
gui-shell) point at the new place. app.js 1,277,298 bytes and the core
scripts 1,469,058, so both budgets rise.
Run on 6416d639c (the dialog morph, on origin/main 75e769a9f), macOS,
playwright 1.62.0:
- agent-prefs.test.cjs (new) plus the 10 migrated files (codex-titles,
codex-descriptions, codex-auto-review, codex-predictions,
codex-memories-settings, codex-async-compact, compact-at,
settings-general, bare-ids, gateway-mode) and modal-morph: 152/152,
chromium and webkit, every language, wide and 420px.
- go test ./internal/gui/: ok after the budget rise.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
Two GUI tests leaned on the Agents page's old height and are moved with it:
agent-models-loading clicked "elsewhere" at (900, 650), which is now
Codex's Disconnect button in its opened row, so it clicks the page's lead
line; agent-expand-steady clicked Goose's row while Codex's opened row
(~554px with its settings) pushed it out of a 560px view, so it wheels
Goose's link into sight first (reader.cjs reach). codex-subagents-lead
and agent-models-redraw clicked controls below Codex's opened row and
timed out in WebKit ("outside of the viewport"); they wait for the row to
finish sliding open, then wheel the control into sight. With Settings ›
General shorter, segs-press-redraw's sweep left Usage's warm-up tabs
above the view in WebKit; it wheels them back when they are. panel-effort
opened Kimi's row below Codex's opened one the same way. login-allow's
wheel loop read the shorter General page's button 50ms after each wheel and
clicked beside it (de, 440px); it uses reach. mobile-web shut each agent
picker by tapping the Agents tab, which a picker opened low in Codex's
taller row covers on a phone; it taps the header's name (the lead line
can sit under the header's tabs, and a tap there opened Library), wheels
each row and field into sight before tapping it, and says which agent and
field a step timed out on. All seven pass in Chromium and WebKit.
After the rebase onto main (32 commits on), with the test fixes above:
- go test ./internal/gui/ ./internal/plugin/ ./internal/agent/ ok;
gofmt -l clean; go vet GOOS=linux -tags nogui and GOOS=windows.
- 95 GUI files (every agent-, codex-, claude-, settings- and modal- file,
and every file either side changed): 1375 pass; the 8 reds were
segs-press-redraw, fixed above. The 16 other files that click an
Agents row: 369/370, rail-tip red on main too (#3091).
- The full suite's reds are listed in the dialog morph's commit; each was
run alone on this head and on origin/main.
- mobile-web's "desktop matches origin/main" compares Settings and the
Agents page with main's assets, so it is red until this is on main; its
phone checks pass in Chromium and WebKit.
165 lines
10 KiB
JavaScript
165 lines
10 KiB
JavaScript
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||
// An agent's own settings are where the agent is (the owner, 10-20: Codex's
|
||
// and Claude Code's rows sat in Settings › General, apart from the agents
|
||
// they set). In the window, Codex's opened row holds its eight and Claude
|
||
// Code's its one, Long conversations; Settings has none of them, but its
|
||
// search still finds them, as a row saying where they are whose Open shows
|
||
// the agent's sheet. In the panel a "Settings" line opens the sheet, and so
|
||
// does the agent's menu; shut, the rows are back where they were. Gateway
|
||
// mode writes no agent's files, so none of it shows. Five languages, wide
|
||
// and narrow, Chromium and WebKit; 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 { watchSettingsReads, agentRow, openAgentSettings } = require("./reader.cjs");
|
||
|
||
const assets = path.resolve(__dirname, "../assets");
|
||
const CODEX = ["codexAgentsV1Row", "fullContextRow", "codexAsyncRow", "codexTitlesRow", "codexDescriptionsRow", "codexPredictionsRow", "codexAutoReviewRow", "codexMemoriesRow"];
|
||
|
||
function settingsPayload(over) {
|
||
return {
|
||
theme: "light", lang: "en", tray: "panel", quotaLeft: false, currency: "usd",
|
||
dock: false, dockWindow: false, proxy: "", redact: false, redactPersonal: false, redactWords: [],
|
||
codexWarmup: "", claudeWarmup: "", codexWarmAt: "", claudeWarmAt: "", workbuddyCheckin: false, noStats: false,
|
||
trayUsage: "", trayUsageEvery: 3, vision: "", imageGen: "",
|
||
version: "0.1.400", dir: "~/.config/magpie", gateway: "http://127.0.0.1:3425",
|
||
proxyNow: "none", proxySource: "none", login: false,
|
||
visionModels: [], imageGenModels: [], workbuddyCheckins: [], lanURLs: [], titleModels: [],
|
||
fx: { rate: 7.2, at: new Date().toISOString(), stale: false },
|
||
...over,
|
||
};
|
||
}
|
||
|
||
function server(lang, { gateway = false } = {}) {
|
||
const settings = settingsPayload({ lang, ...(gateway ? { web: true, gatewayMode: "", gatewayOn: true } : {}) });
|
||
// Codex with a memories field, so its memories row is there to show
|
||
const codex = agentRow("codex", "Codex");
|
||
codex.fields.push({ key: "memories", label: "memories", value: "", options: [{ value: "relay/m1", label: "m1", ref: "relay/m1" }] });
|
||
return 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:${gateway}${gateway ? ",gateway: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: [codex, agentRow("claude", "Claude Code"), agentRow("pi", "Pi")], profiles: [], settings: { lang, theme: "light" }, fx: settings.fx });
|
||
if (url.pathname === "/api/settings") return json(settings);
|
||
if (url.pathname === "/api/plugins") return json({ plugins: [] });
|
||
if (url.pathname === "/api/usage/quotas") return json([]);
|
||
if (url.pathname === "/api/groups") return json({ groups: [], models: [] });
|
||
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)];
|
||
try {
|
||
await route.fulfill({ body: await fs.readFile(file), contentType });
|
||
} catch {
|
||
await route.fulfill({ status: 404, body: "" });
|
||
}
|
||
};
|
||
}
|
||
|
||
const want = {
|
||
en: { titles: "Codex thread titles", sheet: "Codex settings", open: "Open" },
|
||
zh: { titles: "Codex 会话标题", sheet: "Codex 设置", open: "打开" },
|
||
"zh-TW": { titles: "Codex 會話標題", sheet: "Codex 設定", open: "開啟" },
|
||
ja: { titles: "Codex のスレッドタイトル", sheet: "Codex の設定", open: "開く" },
|
||
de: { titles: "Codex-Thread-Titel", sheet: "Einstellungen von Codex", open: "Öffnen" },
|
||
};
|
||
// the ids of an agent's settings rows shown in `box`, in order
|
||
const shownIn = (page, box) => page.locator(box).evaluate((b) => [...b.querySelectorAll(":scope [id$=Row]")].filter((r) => r.checkVisibility()).map((r) => r.id));
|
||
const sheet = (page) => page.locator("#modal:not([hidden]) .editor.agent-prefs");
|
||
const noSideScroll = (page, what) => page.evaluate(() => [document.documentElement.scrollWidth, innerWidth]).then(([w, iw]) => assert(w <= iw, `${what}: no sideways scroll: ${w} > ${iw}`));
|
||
|
||
async function newPage(engine, t, width, lang, opts) {
|
||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||
t.after(() => browser.close());
|
||
const page = await browser.newPage({ viewport: { width, height: 760 }, reducedMotion: "reduce" });
|
||
page.setDefaultTimeout(8000);
|
||
const errors = [];
|
||
page.on("pageerror", (e) => errors.push(e.message));
|
||
await page.route("**/*", server(lang, opts));
|
||
await watchSettingsReads(page);
|
||
return { page, errors };
|
||
}
|
||
|
||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||
for (const lang of Object.keys(want)) {
|
||
for (const width of [1100, 440]) {
|
||
test(`${engine} ${lang} ${width}: an agent's own settings are in its opened row, and Settings' search finds them there`, async (t) => {
|
||
const { page, errors } = await newPage(engine, t, width, lang);
|
||
const w = want[lang];
|
||
await page.goto("http://magpie.test/?view=agents");
|
||
await openAgentSettings(page, "codex");
|
||
const codexBox = '.row.agent[data-id="codex"] .ag-prefs';
|
||
assert.deepEqual(await shownIn(page, codexBox), CODEX, `${lang} ${width}: Codex's eight`);
|
||
assert(await page.locator(codexBox).evaluate((b) => b.scrollWidth <= b.clientWidth + 1), `${lang} ${width}: the rows fit the opened row`);
|
||
await noSideScroll(page, `${lang} ${width} Codex`);
|
||
await openAgentSettings(page, "claude");
|
||
assert.deepEqual(await shownIn(page, '.row.agent[data-id="claude"] .ag-prefs'), ["fullContextRow"], `${lang} ${width}: Claude Code's one`);
|
||
|
||
// none in Settings; its search says where they are
|
||
await page.goto("http://magpie.test/?view=settings");
|
||
await page.locator("#setQ").waitFor();
|
||
for (const id of CODEX) assert.equal(await page.locator(`#view-settings #${id}`).count(), 0, `${lang}: ${id} not in Settings`);
|
||
assert.equal(await page.locator(".agent-pref-link").first().isVisible(), false, "no link rows till searching");
|
||
await page.locator("#setQ").fill(w.titles);
|
||
const link = page.locator(".agent-pref-link").filter({ hasText: w.titles });
|
||
await link.waitFor();
|
||
await noSideScroll(page, `${lang} ${width} search`);
|
||
await link.getByRole("button", { name: w.open, exact: true }).click();
|
||
await sheet(page).waitFor();
|
||
assert.equal(await sheet(page).locator(".ehead").textContent(), w.sheet);
|
||
assert.deepEqual(await shownIn(page, "#modal .editor.agent-prefs"), CODEX, `${lang} ${width}: the sheet has Codex's eight`);
|
||
assert(await page.locator("#view-agents").isVisible(), "Open goes to the Agents page");
|
||
await page.keyboard.press("Escape");
|
||
await page.locator("#modal").waitFor({ state: "hidden" });
|
||
// shut, every row is back in the page, none lost with the sheet
|
||
for (const id of CODEX) assert.equal(await page.locator(`#${id}`).count(), 1, `${lang}: ${id} back`);
|
||
assert.deepEqual(errors, []);
|
||
});
|
||
}
|
||
|
||
test(`${engine} ${lang}: in the panel a Settings line and the agent's menu open its sheet`, async (t) => {
|
||
const { page, errors } = await newPage(engine, t, 360, lang);
|
||
const w = want[lang];
|
||
await page.goto("http://magpie.test/?mode=panel&view=agents");
|
||
// the panel shows a row's controls once it's opened
|
||
await page.locator('.row.agent[data-id="codex"] .ag-sum').click();
|
||
const line = page.locator('.row.agent[data-id="codex"] .agent-prefs-open');
|
||
await line.waitFor();
|
||
assert.equal(await line.getAttribute("aria-label"), w.sheet);
|
||
assert.equal(await page.locator('.row.agent[data-id="pi"] .agent-prefs-open').count(), 0, "Pi has none");
|
||
await noSideScroll(page, `${lang} panel`);
|
||
await line.click();
|
||
await sheet(page).waitFor();
|
||
assert.deepEqual(await shownIn(page, "#modal .editor.agent-prefs"), CODEX);
|
||
assert(await page.locator("#modal .dialog").evaluate((d) => d.scrollWidth <= d.clientWidth + 1), `${lang}: the sheet fits 360`);
|
||
await page.keyboard.press("Escape");
|
||
await page.locator("#modal").waitFor({ state: "hidden" });
|
||
|
||
await page.locator('.row.agent[data-id="claude"] .ag-handle').click();
|
||
await page.getByRole("menuitem", { name: w.sheet.replace("Codex", "Claude Code") }).click();
|
||
await sheet(page).waitFor();
|
||
assert.deepEqual(await shownIn(page, "#modal .editor.agent-prefs"), ["fullContextRow"]);
|
||
await page.keyboard.press("Escape");
|
||
await page.locator("#modal").waitFor({ state: "hidden" });
|
||
for (const id of CODEX) assert.equal(await page.locator(`#${id}`).count(), 1, `${lang}: ${id} back`);
|
||
assert.deepEqual(errors, []);
|
||
});
|
||
}
|
||
|
||
test(`${engine}: gateway mode shows none of an agent's settings`, async (t) => {
|
||
const { page, errors } = await newPage(engine, t, 1100, "en", { gateway: true });
|
||
// it has no Agents page: asked for, the Providers page shows
|
||
await page.goto("http://magpie.test/?view=agents");
|
||
await page.locator("#view-providers").waitFor();
|
||
assert.equal(await page.locator("#view-agents").isVisible(), false, "no Agents page");
|
||
assert.equal(await page.locator(".ag-prefs, .agent-prefs-open").count(), 0, "no rows, no line");
|
||
await page.goto("http://magpie.test/?view=settings");
|
||
await page.locator("#setQ").fill("Codex");
|
||
assert.equal(await page.locator(".agent-pref-link").count(), 0, "no link rows");
|
||
assert.deepEqual(errors, []);
|
||
});
|
||
}
|