agents: Codex's memories and subagent model rows name the provider, as the rows beside them do (nb5p)
nb5p on Discord: in Codex's sheet, "Codex composer predictions" and
"Codex auto-review model" showed "GPT-6 Luna · MyGateway" while "Codex
memories model" showed "GPT-6 Luna" alone.
Cause: the sheet's rows draw from two sources. Predictions, titles,
descriptions and auto-review pick from Settings' titleModels and say
`${name} · ${providerName}` (namedIn). Memories and the subagent model are
Codex's own agent fields; their rows said the option's label only
(opt?.label in renderCodexMemories, codexSubSaid's name in
renderCodexSubagentModel), and an option keeps its provider in `group`,
not in the label. The API already sends it (internal/agent route.go
viaMagpie and codex.go's subagent options set Group: e.Provider.Name);
nothing was missing server side.
Fix: optNamed(opt, value) says an agent field's pick as "Label · Group",
a routing group (Group "Routing groups") by its name alone, and a value
no option has as it is. Both field rows use it. The card's subagent
square tooltip keeps its wording (its pinned text in
codex-subagent-model is unchanged); the memories square was removed
earlier. Codex's own models say "· OpenAI" (their group).
app.js stays in its budget, no raise: the helper is one line and
renderCodexMemories' comment was cut to two lines (1,316,414 bytes at
5d955a4d4, budget 1,316,781).
Test: internal/gui/tests/codex-sheet-providers.test.cjs, Chromium and
WebKit, en/zh/zh-TW/ja/de, 440px and 1100px: all four model rows in
Codex's sheet read "GPT-6 Luna · MyGateway" and fit; a routing group
reads "cheap", a value with no option reads as is.
Run, at 5d955a4d4 plus this change:
- Chromium (mote-run, BROWSER=chromium): codex-sheet-providers,
codex-memories-settings, codex-memories, codex-subagent-model,
codex-auto-review, codex-subagents-lead, desktop-subagent-model,
codex-start-model-field, agent-prefs, codex-predictions, i18n-keys:
91 tests, 90 pass, 1 fail: i18n-keys "a plugin's words are its own"
("Unmarked" in search_calls_test.go), red on main, #4524.
- WebKit (wsl-run, magpie-desktop; WebKit launch times out on mote): the
same files, 91 tests, 83 pass, 8 fail, all red on an unmodified main
b1a1b950f too: agent-prefs en 440 "fullContextRow not in Settings"
(filed #4552), codex-predictions "picking a model scrolled the page"
(#2624, #4120), i18n-keys (#4524). codex-sheet-providers 11 of 11.
- Earlier, at d0a61b856, also gui-zh-tw, gui-ja, gui-de in Chromium:
green (their WebKit cases timed out launching on mote).
- go test -run TestCoreScriptBudget ./internal/gui (mote): ok.
- node --check app.js: ok.
Broken by hand: with app.js at main, codex-sheet-providers is red 10 of
11 in Chromium (codexMemoriesPick: 'GPT-6 Luna' !== 'GPT-6 Luna ·
MyGateway'); with only the subagent row put back, 10 of 11 red on
codexSubagentModelPick the same way. The routing-group case passes on
both, as it should.
Not run: the whole GUI suite (no new API, selector or breakpoint),
go vet / go test ./... (no Go change). Not tried in the real app with
nb5p's MyGateway provider.
This commit is contained in:
@@ -406,6 +406,9 @@ function optionFor(field, value) {
|
||||
return field.options.find((o) => o.value === value);
|
||||
}
|
||||
|
||||
// a pick as "Name · Provider", as namedIn says it (nb5p); a routing group by name
|
||||
const optNamed = (o, v) => o ? (o.label || o.value) + (o.group && o.group !== ROUTING_GROUPS ? " · " + o.group : "") : v;
|
||||
|
||||
// directSaid: a model the agent asks its own vendor for itself, magpie not
|
||||
// in the way (Claude Code on its own sign-in), so its config names no magpie
|
||||
// endpoint — which read as magpie having failed to set it up
|
||||
@@ -21514,13 +21517,8 @@ function renderCodexAutoReview(s) {
|
||||
$("#codexAutoReviewPick").replaceChildren(b);
|
||||
}
|
||||
|
||||
// renderCodexMemories: the model Codex writes its memories with (#985,
|
||||
// Hu9956: the notebook square on Codex's card was all there was, beside the
|
||||
// subagent squares, and wasn't found). It is the card's own field, picked
|
||||
// in the same picker and written the same way, so the row and the square
|
||||
// show one setting; renderAgents draws the row again after every pick.
|
||||
// The row is in Codex's sheet now (openAgentPrefs), not Settings.
|
||||
// No Codex with a memories field to pick: no row.
|
||||
// renderCodexMemories: Codex's memories model (#985), its card's field, in
|
||||
// Codex's sheet; drawn again after every pick. No such field: no row.
|
||||
function renderCodexMemories() {
|
||||
homeAgentPrefRows();
|
||||
const row = $("#codexMemoriesRow");
|
||||
@@ -21533,7 +21531,7 @@ function renderCodexMemories() {
|
||||
const b = el("button", "rt-cond on");
|
||||
b.type = "button";
|
||||
b.setAttribute("aria-label", t("Codex memories model"));
|
||||
if (f.value) b.append(icon(opt?.icon || "generic"), el("span", "", opt?.label || f.value));
|
||||
if (f.value) b.append(icon(opt?.icon || "generic"), el("span", "", optNamed(opt, f.value)));
|
||||
else b.append(icon("generic"), el("span", "", t(SAME_SESSION)));
|
||||
b.onclick = (ev) => openPicker(a, f, b, ev);
|
||||
$("#codexMemoriesPick").replaceChildren(b);
|
||||
@@ -21557,7 +21555,7 @@ function renderCodexSubagentModel() {
|
||||
const b = el("button", "rt-cond on");
|
||||
b.type = "button";
|
||||
b.setAttribute("aria-label", t("Codex subagent model"));
|
||||
b.append(icon((f.value ? optionFor(f, f.value)?.icon : main && optionFor(main, main.value)?.icon) || "generic"), el("span", "", said.name));
|
||||
b.append(icon((f.value ? optionFor(f, f.value)?.icon : main && optionFor(main, main.value)?.icon) || "generic"), el("span", "", f.value ? optNamed(optionFor(f, f.value), f.value) : said.name));
|
||||
b.onclick = (ev) => openPicker(a, f, b, ev);
|
||||
$("#codexSubagentModelPick").replaceChildren(b);
|
||||
b.title = said.line;
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// Codex's sheet says each picked model with its provider, "Name · Provider",
|
||||
// in every model row (nb5p on Discord): "Codex composer predictions" and
|
||||
// "Codex auto-review model" did, from Settings' model list, while "Codex
|
||||
// memories model" and "Codex subagent model", which are Codex's own fields
|
||||
// and pick from its options, said the name alone ("GPT-6 Luna", no
|
||||
// "· MyGateway"). A routing group is said by its name alone, and a value no
|
||||
// option has as it is. Chromium and WebKit, every language, 440px and wide;
|
||||
// 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, openAgentSettings } = require("./reader.cjs");
|
||||
|
||||
const assets = path.resolve(__dirname, "../assets");
|
||||
// Codex's field options as internal/agent builds them: a magpie model's
|
||||
// group is its provider's name, a routing group's "Routing groups"
|
||||
const opts = [
|
||||
{ value: "gpt-5.5", label: "GPT-5.5", note: "OpenAI · via magpie", group: "OpenAI", ref: "openai/gpt-5.5", icon: "openai" },
|
||||
{ value: "mygw/gpt-6-luna", label: "GPT-6 Luna", note: "MyGateway · via magpie", group: "MyGateway", ref: "mygw/gpt-6-luna", icon: "openai" },
|
||||
{ value: "group/cheap", label: "cheap", note: "routing group · via magpie", group: "Routing groups", ref: "group/cheap" },
|
||||
];
|
||||
const agents = (memories, sub) => [{
|
||||
id: "codex", name: "Codex", path: "/test/config.toml", icon: "codex-color", wired: true,
|
||||
fields: [
|
||||
{ key: "model", label: "model", value: "gpt-5.5", options: opts },
|
||||
{ key: "subagent_model", label: "subagent model", value: sub, options: opts },
|
||||
{ key: "memories", label: "memories", value: memories, options: opts },
|
||||
],
|
||||
}];
|
||||
// Settings' list, as /api/settings has it
|
||||
const titleModels = [{ id: "mygw/gpt-6-luna", name: "GPT-6 Luna", provider: "mygw", providerName: "MyGateway", icon: "openai" }];
|
||||
const settings = (lang) => ({
|
||||
theme: "light", lang, 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,
|
||||
codexPredictions: "mygw/gpt-6-luna", codexAutoReview: "mygw/gpt-6-luna",
|
||||
fx: { rate: 7.2, at: new Date().toISOString(), stale: false },
|
||||
});
|
||||
|
||||
function server(lang, memories, sub) {
|
||||
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:false};` });
|
||||
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
|
||||
if (url.pathname === "/api/state") return json({ agents: agents(memories, sub), profiles: [], settings: { lang, theme: "light" } });
|
||||
if (url.pathname === "/api/settings") return json(settings(lang));
|
||||
if (url.pathname === "/api/usage/quotas") return json([]);
|
||||
if (url.pathname === "/api/groups") return json({ groups: [], models: [] });
|
||||
if (url.pathname === "/api/agents/cli") return json({ agents: {}, pending: false });
|
||||
if (url.pathname === "/api/providers") return json({ providers: [], gateway: { running: true } });
|
||||
if (url.pathname === "/api/plugins") return json({ plugins: [] });
|
||||
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: "" });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// the rows' names as i18n.js has them
|
||||
const W = {
|
||||
en: { mem: "Codex memories model", pred: "Codex composer predictions" },
|
||||
zh: { mem: "Codex 记忆整理模型", pred: "Codex 输入框预测" },
|
||||
"zh-TW": { mem: "Codex 記憶整理模型", pred: null },
|
||||
ja: { mem: "Codex メモリ整理のモデル", pred: null },
|
||||
de: { mem: "Codex-Modell für Erinnerungen", pred: null },
|
||||
};
|
||||
|
||||
async function open(engine, width, lang, memories, sub, t) {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
const context = await browser.newContext({ viewport: { width, height: 700 }, reducedMotion: "reduce" });
|
||||
const page = await context.newPage();
|
||||
page.setDefaultTimeout(5000);
|
||||
page.setDefaultNavigationTimeout(60000);
|
||||
const errors = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", server(lang, memories, sub));
|
||||
t.after(async () => {
|
||||
if (process.env.ARTIFACT_DIR) {
|
||||
await fs.mkdir(process.env.ARTIFACT_DIR, { recursive: true });
|
||||
await page.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `${engine}-${width}-${lang}-codex-sheet-providers.png`) });
|
||||
}
|
||||
await browser.close();
|
||||
});
|
||||
await watchSettingsReads(page);
|
||||
await page.goto("http://magpie.test/?view=agents");
|
||||
await openAgentSettings(page);
|
||||
await page.locator("#codexMemoriesPick button").waitFor();
|
||||
return { page, errors };
|
||||
}
|
||||
const said = (page, id) => page.locator(`#${id} button`).evaluate((b) => b.textContent.trim());
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
for (const width of [440, 1100]) {
|
||||
for (const lang of Object.keys(W)) {
|
||||
test(`${engine} ${width}px ${lang}: every model row in Codex's sheet names its provider`, async (t) => {
|
||||
const { page, errors } = await open(engine, width, lang, "mygw/gpt-6-luna", "mygw/gpt-6-luna", t);
|
||||
assert.equal((await page.locator("#codexMemoriesRow .name").textContent()).trim(), W[lang].mem);
|
||||
if (W[lang].pred) assert.equal((await page.locator("#codexPredictionsRow .name").textContent()).trim(), W[lang].pred);
|
||||
for (const id of ["codexPredictionsPick", "codexAutoReviewPick", "codexMemoriesPick", "codexSubagentModelPick"])
|
||||
assert.equal(await said(page, id), "GPT-6 Luna · MyGateway", id);
|
||||
// each row's name and button fit it, the page no wider than the window
|
||||
const fit = await page.evaluate(() => ["#codexMemoriesRow", "#codexSubagentModelRow"].every((s) => {
|
||||
const r = document.querySelector(s), box = r.getBoundingClientRect();
|
||||
return [...r.querySelectorAll(".name, button")].every((e) => {
|
||||
const b = e.getBoundingClientRect();
|
||||
return b.width > 0 && b.left >= box.left - 1 && b.right <= box.right + 1;
|
||||
});
|
||||
}) && document.documentElement.scrollWidth <= innerWidth);
|
||||
assert(fit, "a row overflows");
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
test(`${engine}: a routing group by its name alone, a value with no option as it is`, async (t) => {
|
||||
const { page, errors } = await open(engine, 900, "en", "group/cheap", "gone/old-model", t);
|
||||
assert.equal(await said(page, "codexMemoriesPick"), "cheap");
|
||||
assert.equal(await said(page, "codexSubagentModelPick"), "gone/old-model");
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user