gui: Settings opens after Codex's row on the Agents page was opened and shut (ysm119)

ysm119 on Discord (v0.1.2519, macOS): opening Settings showed
"null is not an object (evaluating '$(row + ".who").title = t(en)')".

Cause: an opened agent row borrows its settings rows (AGENT_PREFS,
f1e4516da) from #agentPrefRows. Shutting the row, or any redraw that
leaves no row open, drew the list again with replaceChildren(), and
the borrowed rows went out of the page with the old row. Nothing put
them back until something called homeAgentPrefRows, so renderSettings'
tooltip loop found no #codexTitlesRow, and translateStatic (a language
change) missed their text too.

Fix: renderAgents and renderAgentsLoading put the rows home right after
clearing the list, so they are never out of the page; a row opened
again takes them as before. Codex's rows' tooltips are set in
renderAgentPrefs, which homes them first and owns them; Settings sets
only Open at login's. Siblings checked: every other reader of these
rows (renderAgentPrefs, renderAgentPrefLinks, renderCodexMemories,
renderCodexSubagentModel, agentPrefsButton, connectPanel,
openAgentPrefs and its MutationObserver) already homes first.

Test: agent-prefs.test.cjs "Settings opens after Codex's row was opened
and shut", Chromium and WebKit, en/zh/zh-TW/ja/de, 1100 and 440: open
Codex's row, shut it, the rows are in the page, Settings opens from its
button with no error and the titles row's tooltip in the language.

Run (mote):
- On origin/main da0005df8 without the fix: 20/20 red, "codexAgentsV1Row
  in the page once shut"; with that check off, WebKit fails with the
  reporter's exact text and Chromium with "Cannot set properties of
  null (setting 'title')".
- Broken by hand (renderAgents' homing taken out): red again, same
  message, both engines.
- Before rebase, 89 files (agent-*, codex-*, settings-*, i18n-keys,
  gui-de/ja/zh-tw, menu-scroll, text-size), concurrency 4: 1465 tests,
  1432 pass, 33 fail: agent-panel-name-width's 32 (red on pristine
  origin/main f435aadbf too, 0/32; #4203, commented) and gui-ja's
  ja-has-every-zh-string (red on main, #4580).
- At the pushed head (rebased on fb3942ee6): agent-prefs, codex-titles,
  codex-memories-settings, settings-general, settings-search,
  i18n-keys, gui-zh-tw/de/ja: 125 tests, 124 pass, 1 fail (#4580).
  go test -run TestCoreScriptBudget ./internal/gui: ok (app.js
  1,311,806, core 1,532,895, no budget raised; comments kept short).

Not run: the whole GUI suite and go test ./... (JS-only change;
another session's full GUI suite was on mote); the real app.
This commit is contained in:
yetone
2026-11-01 11:14:22 +08:00
parent fb3942ee67
commit 784b66366f
2 changed files with 42 additions and 13 deletions
+14 -13
View File
@@ -428,6 +428,7 @@ function renderAgentsLoading() {
page.setAttribute("aria-busy", "true");
const list = $("#agents");
list.replaceChildren();
homeAgentPrefRows();
for (let i = 0; i < 5; i++) {
const row = el("div", "row agent ag-sk-row");
const who = el("div", "who");
@@ -454,6 +455,7 @@ function renderAgents() {
page.removeAttribute("aria-busy");
const list = $("#agents");
list.replaceChildren();
homeAgentPrefRows(); // an opened row's, back in the page (ysm119)
agentsLead(list);
if (!state.agents.length) {
const e = el("div", "empty-state");
@@ -19713,19 +19715,10 @@ function renderSettings() {
(v) => savePrefs({ ...keep, noWSLAgents: v === "off" })));
renderSessionTerminal(s, keep);
renderBarIcon();
// what each row does, kept in its tooltip, the row saying its name
// alone as Settings › General does (#2120); Open at login's says where
// the Mac lists it: a launch agent, under App Background Activity
for (const [row, en] of [
["#codexTitlesRow", "Names each thread in a hidden request of its own; same as the session, it goes on the session’s model, as Codex sends it when that is one of Codex’s own"],
["#codexDescriptionsRow", "Writes each thread’s short description in a hidden request of its own; same as the session, it goes on the session’s model, as Codex sends it when that is one of Codex’s own"],
["#codexPredictionsRow", "Guesses your next message for the composer, reading the whole conversation again each time; same as the session, it goes on the session’s model"],
["#codexAutoReviewRow", "Decides an approval in your place when Codex’s approvals are on auto-review; Codex’s own pick is codex-auto-review, else the conversation’s model at low effort; on a ChatGPT Free plan, where codex-auto-review isn’t free, unset follows the session"],
["#codexMemoriesRow", "Writes Codex’s memories of past threads, in the background; same as the session, on the session’s model, or on gpt-5.6-terra and gpt-5.6-luna when that is one of Codex’s own"],
["#loginRow", document.body.classList.contains("mac")
? "Opens in the menu bar with no window. System Settings › General › Login Items lists it under App Background Activity, not Open at Login"
: "Opens in the tray with no window"],
]) $(row + " .who").title = t(en);
// what it does in its tooltip (#2120), and where the Mac lists it
$("#loginRow .who").title = t(document.body.classList.contains("mac")
? "Opens in the menu bar with no window. System Settings › General › Login Items lists it under App Background Activity, not Open at Login"
: "Opens in the tray with no window");
// the system's record, set on its own, not with the other choices
$("#loginSegs").replaceChildren(segs([["off", t("Off")], ["on", t("On")]], s.login ? "on" : "off", (v) =>
prefWrite(api("settings/login", { on: v === "on" }))));
@@ -21163,6 +21156,14 @@ function renderAgentPrefs() {
const s = prefs;
if (!s) return;
homeAgentPrefRows();
// what each row does, in its tooltip (#2120)
for (const [row, en] of [
["#codexTitlesRow", "Names each thread in a hidden request of its own; same as the session, it goes on the session’s model, as Codex sends it when that is one of Codex’s own"],
["#codexDescriptionsRow", "Writes each thread’s short description in a hidden request of its own; same as the session, it goes on the session’s model, as Codex sends it when that is one of Codex’s own"],
["#codexPredictionsRow", "Guesses your next message for the composer, reading the whole conversation again each time; same as the session, it goes on the session’s model"],
["#codexAutoReviewRow", "Decides an approval in your place when Codex’s approvals are on auto-review; Codex’s own pick is codex-auto-review, else the conversation’s model at low effort; on a ChatGPT Free plan, where codex-auto-review isn’t free, unset follows the session"],
["#codexMemoriesRow", "Writes Codex’s memories of past threads, in the background; same as the session, on the session’s model, or on gpt-5.6-terra and gpt-5.6-luna when that is one of Codex’s own"],
]) $(row + " .who").title = t(en);
// Codex's own models in multi-agent V1 (their subagents' tasks go as text),
// so a GPT lead can run a subagent on magpie's other models (#141). Where
// Codex's own multi_agent_v2 is on in the config magpie routes it wins, and
+28
View File
@@ -138,6 +138,34 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
});
}
// ysm119 on Discord (v0.1.2519, WebKit): Codex's row opened and shut
// again, then Settings, threw "null is not an object (evaluating
// '$(row + ".who").title = t(en)')". Shut, the row was drawn again
// without its opened part, and Codex's settings rows went with that
// part, out of the page, where Settings and a language change look
// for them. Shut, they are back in it; Settings opens on its own
// button, with no reload, and says what each row does.
for (const width of [1100, 440]) {
test(`${engine} ${lang} ${width}: Settings opens after Codex's row was opened and shut`, async (t) => {
const { page, errors } = await newPage(engine, t, width, lang);
await page.goto("http://magpie.test/?view=agents");
await openAgentSettings(page, "codex");
await page.locator('.row.agent[data-id="codex"] .ag-link').click();
await page.locator('.row.agent[data-id="codex"] .ag-prefs').waitFor({ state: "detached" });
await page.locator('.row.agent[data-id="codex"] .ag-link[aria-expanded="false"]').waitFor();
for (const id of CODEX) assert(await page.evaluate((id) => document.getElementById(id)?.isConnected === true, id), `${lang} ${width}: ${id} in the page once shut`);
await page.locator("#prefs").click();
await page.locator("#view-settings").waitFor();
await page.waitForFunction(() => __settingsReads.asked > 0 && __settingsReads.asked === __settingsReads.drawn);
assert.deepEqual(errors, [], `${lang} ${width}: no error opening Settings`);
assert.equal(await page.locator("#status.err").textContent().catch(() => ""), "", `${lang} ${width}: no red error line`);
const tip = await page.evaluate(() => document.querySelector("#codexTitlesRow .who")?.title);
assert.equal(tip, await page.evaluate(() => t("Names each thread in a hidden request of its own; same as the session, it goes on the session’s model, as Codex sends it when that is one of Codex’s own")), `${lang}: the titles row says what it does`);
if (lang !== "en") assert(!/^Names each/.test(tip), `${lang}: in the language`);
await noSideScroll(page, `${lang} ${width} Settings`);
});
}
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];