gui: a page left out of the sidebar still opens from a link, ?view= or a search hit

Settings › General › Sidebar pages (magpie.navHidden) took a page out of
the sidebar, and offView then sent every way to it (a link, ?view=, a
Settings search hit, a plugin's show()) to Agents or Providers with
nothing said, so the page was unreachable. offView now redirects only a
page gateway mode or a switched-off built-in plugin leaves out. Hiding
stays a sidebar choice: the window's own kept page (magpie.lastView)
isn't reopened when it is hidden, so a fresh window still opens on the
first page, or Providers when Agents is hidden too (keptView in
start.js).

nav-pages-hidden: with Library hidden, show("library") and ?view=library
open Library; a kept lastView of library opens Providers.

Run (mica, at this tree; mote at load 27):
- nav-pages-hidden, nav-pages-order, last-page, gateway-mode, Chromium
  and WebKit: 19 pass, 1 red, last-page WebKit, red the same on
  origin/main and filed (#7033).
- go test ./internal/gui -run 'TestCoreScriptBudget|TestI18n|TestCSS': ok.

Broken by hand, each red, then put back:
- the new test on origin/main's app.js and start.js: 2 of 2 red (line
  69, Library not opened), both engines.
- keptView without the navMine check: Chromium red at line 76 (the
  window reopened the hidden page).

Not tried: the real app window, the full GUI suite.
This commit is contained in:
yetone
2026-11-18 12:31:23 +08:00
parent 3c44ed92bb
commit b0c2b5e261
4 changed files with 19 additions and 4 deletions
File diff suppressed because one or more lines are too long
+2 -1
View File
@@ -23407,7 +23407,8 @@ function setGatewayMode(on) {
}
// offView: v, or the page a plugin switched off sends it to (yyddbds)
function offView(v) {
const gone = (x) => featureHides($(`#nav button[data-view="${x}"]`)) || navMine().includes(x);
// a page left out of the sidebar (navMine) still opens when asked for
const gone = (x) => featureHides($(`#nav button[data-view="${x}"]`));
if (!gone(v)) return v;
if (v === "groups" && !gone("routing")) return "routing";
return gatewayMode || gone("agents") ? "providers" : "agents";
+2 -1
View File
@@ -15,7 +15,8 @@ function keptView() {
if (asked === "agents" || OPEN_VIEWS.includes(asked)) return asked;
let v = "";
try { v = localStorage.getItem("magpie.lastView") || ""; } catch { /* none kept */ }
return OPEN_VIEWS.includes(v) ? v : ""; // one gateway mode leaves out, show() makes Providers
// one gateway mode leaves out, show() makes Providers; one left out of the sidebar isn't reopened
return OPEN_VIEWS.includes(v) && !navMine().includes(v) ? v : "";
}
const firstView = mode === "window" ? keptView() || (navMine().includes("agents") ? "providers" : "") : "";
// from the tray panel's More in Plugins (q): Discover, once show() picked the tab (#3579)
+14 -1
View File
@@ -2,7 +2,7 @@
// Settings › General › Sidebar pages (youimark on X: a docker gateway has no
// use for Agents or Library): the pages ticked off leave the sidebar, are
// kept for this browser (localStorage magpie.navHidden), and the window
// that would open on one opens Providers. Chromium and WebKit. No backend:
// that would open on one opens Providers. A link to one still opens it. Chromium and WebKit. No backend:
// the API is faked.
const assert = require("node:assert/strict");
const fs = require("node:fs/promises");
@@ -62,6 +62,19 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await page.waitForSelector("#nav button.on");
assert.deepEqual((await hidden()).sort(), ["agents", "library"]);
assert.equal(await page.evaluate(() => document.querySelector("#nav button.on").dataset.view), "providers");
// still reachable: a link or ?view= to a page left out opens it, not Agents
// or Providers; only the window's own kept page gives way
const on = () => page.evaluate(() => [...document.querySelectorAll(".view")].find((v) => !v.hidden)?.id);
await page.evaluate(() => show("library"));
await page.waitForFunction(() => !document.querySelector("#view-library").hidden);
assert.equal(await on(), "view-library");
await page.goto(BASE + "?view=library");
await page.waitForFunction(() => !document.querySelector("#view-library")?.hidden);
assert.equal(await on(), "view-library");
await page.evaluate(() => localStorage.setItem("magpie.lastView", "library"));
await page.goto(BASE);
await page.waitForSelector("#nav button.on");
assert.equal(await page.evaluate(() => document.querySelector("#nav button.on").dataset.view), "providers");
// and put back
await page.goto(BASE + "?view=settings");
await page.waitForSelector(".nav-pages-pick");