gui: an agent's settings sheet opens from the panel again (#6139)
22f2759d7(11-11, Settings › General › Sidebar pages) added renderNavPages, which read $("#nav").querySelectorAll before it looked at the mode. The panel has no #nav (app.js removes it), so every Settings draw in the panel threw once navpages.js had loaded. The second draw is the one openAgentPrefs waits on (loadSettings), so in the panel the "Claude Code settings" and "Grok Build settings" menu items opened nothing. #6139 was filed 46 minutes after22f2759d7and was seen again twice with no owner (#6311 its duplicate). renderNavPages now hides its row and returns before it reads #nav outside a window. Its siblings (navHides, markNav, show) already check mode === "window". Found with a pageerror stack: "Cannot read properties of null (reading 'querySelectorAll') at window.renderNavPages (navpages.js:9)". agent-prefs' "in the panel a Settings line and the agent's menu open its sheet" was red in both engines and all five languages at 35aaaa4b9^,35aaaa4b9,8c7328f3aand origin/main 5f1a642b4^ (timeout at agent-prefs.test.cjs:192). Run (mica, at this tree): node --test agent-prefs.test.cjs pass 56 fail 0 (both engines, every language), nav-pages-hidden pass 2, i18n-keys pass 4.
This commit is contained in:
@@ -4,12 +4,14 @@
|
||||
// (navMine in app.js reads it). app.js imports this when Settings draws,
|
||||
// so it weighs nothing on the core.
|
||||
window.renderNavPages = function () {
|
||||
const row = $("#navPagesRow");
|
||||
const row = $("#navPagesRow"), nav = $("#nav");
|
||||
if (!row) return;
|
||||
const pages = [...$("#nav").querySelectorAll("button[data-view]")]
|
||||
// only a window has a sidebar: the panel has no #nav (#6139)
|
||||
if (mode !== "window" || !nav) { row.hidden = true; return; }
|
||||
const pages = [...nav.querySelectorAll("button[data-view]")]
|
||||
.filter((b) => b.dataset.view !== "providers" && !(gatewayMode && GATEWAY_HIDES.includes(b.dataset.view)) && !featureHides(b))
|
||||
.map((b) => ({ v: b.dataset.view, name: b.querySelector("[data-t]")?.dataset.en || b.textContent.trim() }));
|
||||
row.hidden = mode !== "window" || !pages.length;
|
||||
row.hidden = !pages.length;
|
||||
if (row.hidden) return;
|
||||
const mine = navMine();
|
||||
const n = pages.filter((p) => mine.includes(p.v)).length;
|
||||
|
||||
Reference in New Issue
Block a user