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.
142 lines
8.8 KiB
JavaScript
142 lines
8.8 KiB
JavaScript
// Run with Node's test runner and Playwright on the module path; see README.md.
|
|
// Where Codex and Claude Code compact a long conversation (#876, hisiling:
|
|
// 272K was the only size, and only for every model at once). A provider's
|
|
// editor has Compact at beside Context window and Max output, in the same
|
|
// form: one size for all its models, model=size for one, shown as set,
|
|
// sent with the Save, a value that isn't a number of tokens refused before
|
|
// anything is sent. Long conversations, in Codex's and Claude Code's
|
|
// settings on their opened rows (here Claude Code's), takes a size of its own
|
|
// beside Compact at / Full window; a typed size posts settings/full-context
|
|
// with it, and no click or typing scrolls the page.
|
|
// English and Chinese, 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");
|
|
|
|
function serve(lang, posts) {
|
|
let settings = { theme: "light", lang, tray: "panel", currency: "usd", version: "0.1.900", dir: "~/.config/magpie", gateway: "http://127.0.0.1:3425", proxyNow: "none", proxySource: "none", visionModels: [], imageGenModels: [], titleModels: [], workbuddyCheckins: [], lanURLs: [], redactWords: [], trayUsageEvery: 3 };
|
|
const models = ["deepseek-v4-flash", "deepseek-v4-pro"].map((id) => ({ id, name: id, on: true, context: 1000000 }));
|
|
const provider = { id: "deepseek", name: "DeepSeek", icon: "generic", chat: "https://api.deepseek.example/v1", responses: "", anthropic: "", models, agents: [], key: { set: true, masked: "sk-…1234" }, ready: true, compacts: { "*": 500000, "deepseek-v4-flash": 272000 } };
|
|
const providers = { providers: [provider], presets: [], excluded: [], gateway: { running: true, window: true } };
|
|
return async (route) => {
|
|
const req = route.request(), 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:${JSON.stringify(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: [agentRow("claude", "Claude Code")], profiles: [], settings: { lang, theme: "light" } });
|
|
if (url.pathname === "/api/providers") return json(providers);
|
|
if (url.pathname === "/api/groups") return json({ groups: [], models: [] });
|
|
if (url.pathname.startsWith("/api/provider/")) {
|
|
posts.push({ path: url.pathname, body: req.postDataJSON() });
|
|
return json(providers);
|
|
}
|
|
if (url.pathname === "/api/settings/full-context") {
|
|
const body = req.postDataJSON();
|
|
posts.push({ path: url.pathname, body });
|
|
settings = { ...settings, fullContext: body.on, ...(body.at !== undefined ? { compactAt: body.at === 272000 ? 0 : body.at } : {}) };
|
|
return json(settings);
|
|
}
|
|
if (url.pathname === "/api/settings") {
|
|
if (req.method() === "POST") posts.push({ path: url.pathname, body: req.postDataJSON() });
|
|
return json(settings);
|
|
}
|
|
if (url.pathname === "/api/plugins") return json({ plugins: [] });
|
|
if (url.pathname === "/api/usage/quotas") return json([]);
|
|
if (url.pathname.startsWith("/api/")) return json({});
|
|
const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
|
|
try {
|
|
await route.fulfill({ body: await fs.readFile(file), contentType: { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)] });
|
|
} catch {
|
|
await route.fulfill({ status: 404, body: "" });
|
|
}
|
|
};
|
|
}
|
|
|
|
const words = {
|
|
en: { field: "Compact at", save: "Save", bad: "Compact at: lots is not a number of tokens like 272k", at: (n) => `Compact at ${n}`, full: "Full window" },
|
|
zh: { field: "压缩阈值", save: "保存", bad: "压缩阈值:lots 不是 272k 这样的 token 数", at: (n) => `${n} 时压缩`, full: "完整窗口" },
|
|
};
|
|
|
|
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
|
for (const lang of ["en", "zh"]) {
|
|
const w = words[lang];
|
|
const open = async (t, view, height = 720) => {
|
|
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: process.env.PLAYWRIGHT_CHANNEL || "chromium" }));
|
|
t.after(() => browser.close());
|
|
const page = await (await browser.newContext({ viewport: { width: 900, height }, reducedMotion: "reduce" })).newPage();
|
|
page.setDefaultTimeout(5000);
|
|
const errors = [], posts = [];
|
|
page.on("pageerror", (e) => errors.push(e.message));
|
|
await page.route("**/*", serve(lang, posts));
|
|
await watchSettingsReads(page);
|
|
await page.goto(`http://magpie.test/?view=${view}`);
|
|
return { page, errors, posts };
|
|
};
|
|
|
|
test(`${engine} ${lang}: a provider's compaction threshold is set in its editor`, async (t) => {
|
|
const { page, errors, posts } = await open(t, "providers");
|
|
await page.locator('.row.provider[data-id="deepseek"]').click();
|
|
assert(await page.getByText(w.field, { exact: true }).isVisible(), "the field is there");
|
|
const box = page.locator("input.compacts");
|
|
assert.equal(await box.inputValue(), "500k, deepseek-v4-flash=272k", "what is set is shown");
|
|
// not a number of tokens: refused, nothing sent
|
|
await box.fill("lots");
|
|
await page.getByRole("button", { name: w.save, exact: true }).click();
|
|
await page.getByText(w.bad).waitFor();
|
|
assert.deepEqual(posts, []);
|
|
// a size's chip fills the field for every model
|
|
const picks = page.locator("input.compacts + .cxpicks .cxpick");
|
|
assert.deepEqual(await picks.allTextContents(), ["128K", "200K", "272K", "500K", "1M"]);
|
|
const top = await page.evaluate(() => document.scrollingElement.scrollTop);
|
|
await picks.filter({ hasText: "1M" }).click();
|
|
assert.equal(await box.inputValue(), "1m");
|
|
assert.equal(await picks.filter({ hasText: "1M" }).evaluate((b) => b.classList.contains("on")), true);
|
|
assert.equal(await page.evaluate(() => document.scrollingElement.scrollTop), top, "a chip scrolled the page");
|
|
await box.fill("1m, deepseek-v4-pro=400k");
|
|
await page.getByRole("button", { name: w.save, exact: true }).click();
|
|
await page.waitForFunction(() => !document.querySelector("input.compacts"));
|
|
assert.deepEqual(posts.map((p) => p.path), ["/api/provider/save"]);
|
|
assert.deepEqual(posts[0].body.compacts, { "*": 1000000, "deepseek-v4-pro": 400000 });
|
|
assert.deepEqual(errors, []);
|
|
});
|
|
|
|
test(`${engine} ${lang}: Long conversations compacts at a size the user types`, async (t) => {
|
|
const { page, errors, posts } = await open(t, "agents");
|
|
await openAgentSettings(page, "claude");
|
|
const row = page.locator("#fullContextSegs");
|
|
const num = row.locator("input.compact-num");
|
|
await num.waitFor();
|
|
assert.equal(await num.getAttribute("aria-label"), w.field);
|
|
assert.equal(await row.locator("select").count(), 0, "no native select");
|
|
assert(await row.getByText(w.at("272K"), { exact: true }).isVisible(), "272K by default");
|
|
assert.equal(await num.inputValue(), "");
|
|
const view = () => page.locator("#view-agents").evaluate((v) => v.scrollTop);
|
|
const before = await view();
|
|
await num.fill("lots");
|
|
await num.press("Enter");
|
|
await page.getByText(w.bad).waitFor();
|
|
assert.deepEqual(posts, []);
|
|
await num.fill("500k");
|
|
await num.press("Enter");
|
|
await row.getByText(w.at("500K"), { exact: true }).waitFor();
|
|
assert.deepEqual(posts.map((p) => [p.path, p.body]), [["/api/settings/full-context", { on: false, at: 500000 }]]);
|
|
assert.equal(await row.locator("input.compact-num").inputValue(), "500k");
|
|
// the whole window hides the size; back to it shows it again
|
|
await row.getByText(w.full, { exact: true }).click();
|
|
await page.waitForFunction(() => document.querySelector("#fullContextSegs input.compact-num")?.hidden);
|
|
assert.deepEqual(posts.at(-1).body, { on: true });
|
|
await row.getByText(w.at("500K"), { exact: true }).click();
|
|
await page.waitForFunction(() => document.querySelector("#fullContextSegs input.compact-num")?.hidden === false);
|
|
assert.deepEqual(posts.at(-1).body, { on: false });
|
|
assert.equal(await view(), before, "the row scrolled the page");
|
|
assert(!posts.some((p) => p.path === "/api/settings"), "set on its own, not with the other preferences");
|
|
assert.deepEqual(errors, []);
|
|
});
|
|
}
|
|
}
|