gui: old-webkit green again (#5919, #6030)

Both old-webkit reds had been on main for a week with no owner, and
commit after commit cited them as "red on origin/main, filed".

#5919: d374168d0 gave the sidebar foot `.side-foot:has(> .nav-sub)
{ max-height: 80% }`, and Safari before 15.4 can't parse :has(). The
foot is now .with-sub, set by navSubs when Settings' tabs go in and
cleared once the last one has folded away (navSubLeave's gone), so the
foot keeps its height through the fold as before.

#6030: the check that every script is loaded by index.html or on
demand kept a hand list, and headerpresets.js, navpages.js and
pasteread.js were each left out of it. A script some script imports
with import("./x.js") now counts as loaded on demand.

Budget: +103 bytes of app.js (and of the core) for the class. Nothing
small enough to pay for it could move out: modelInfo looked dead in
app.js but the gateway and routing plugins both call it.

Run, on mica at ae94571d7 plus this change:
- old-webkit, sidebar-settings-steady, nav-sub-fold, nav-sub-unroll,
  i18n-keys: 86/86;
- go test -run Budget ./internal/gui/: ok; gofmt -l internal/gui: clean;
- the sidebar and nav files (nav-*, side-*, sidebar-*, phone- and
  view-no-sideways, side-effort, nav-timeout): their only reds are the
  same at a clean ae94571d7: nav-timeout (#5425), phone-no-sideways
  (#5869), side-effort (#6353), view-no-sideways (#6669).
Broken by hand:
- without the line that adds .with-sub, sidebar-settings-steady's new
  "the foot grows for the tabs" is red, 40/40;
- an unimported zzorphan.js turns old-webkit red ("is not loaded by
  index.html, and no script imports it").
Not tried: the whole GUI suite; a real Safari 15.0.
This commit is contained in:
yetone
2026-11-18 00:03:26 +08:00
parent 6c6d3bc842
commit 4b8c5948e7
5 changed files with 22 additions and 8 deletions
+3 -2
View File
@@ -521,9 +521,10 @@ body.side-nav #nav button.has-dot.can-fold::after { right: 28px; }
.nav-sl:first-of-type { padding-top: 2px; }
/* Settings' tabs, over its button at the sidebar's foot (app.js navSubs),
close to the button they come from; the foot takes more of a short
sidebar while they show */
sidebar while they show (.with-sub, set by app.js: Safari before 15.4
can't parse :has()) */
.side-foot > .nav-sub { margin: 6px 0 2px 16px; }
.side-foot:has(> .nav-sub) { max-height: 80%; }
.side-foot.with-sub { max-height: 80%; }
.nav-sub::before { content: ""; position: absolute; left: 0; top: 3px; bottom: 3px; width: 1px; background: var(--line); }
/* rows keep their size while the list unrolls or folds: squeezed, a strip
drawn again then (Installed gets its count) marked the selection a third
+6 -2
View File
@@ -24019,6 +24019,7 @@ function navSubs() {
all[(to + all.length) % all.length].focus();
};
if (above) at.before(box); else at.after(box);
box.parentElement.classList.add("with-sub");
}
box.setAttribute("aria-label", (at.querySelector("span[data-t]") || at.querySelector("span"))?.textContent || "");
for (const s of box.querySelectorAll(".nav-s, .nav-sl")) s.remove();
@@ -24182,16 +24183,19 @@ function navSubEnter(box) {
}
// a folding list is out of reach at once
function navSubLeave(box) {
// the foot holding Settings' tabs is .with-sub, not :has(), which Safari
// before 15.4 can't parse (#5919)
const p = box.parentElement, gone = () => { box.remove(); p.classList.toggle("with-sub", !!p.querySelector(":scope>.nav-sub")); };
box.classList.add("leaving");
box.removeAttribute("role");
box.inert = true;
for (const s of box.querySelectorAll(".nav-s")) s.classList.replace("nav-s", "nav-s-gone");
if (navCalm() || navSubs.quiet) { box.remove(); return; }
if (navCalm() || navSubs.quiet) { gone(); return; }
const cs = getComputedStyle(box);
box.classList.add("moving");
box.animate([{ height: box.offsetHeight + "px", marginTop: cs.marginTop, marginBottom: cs.marginBottom, opacity: 1 },
{ height: "0px", marginTop: "0px", marginBottom: "0px", opacity: 0 }], { duration: 240, easing: NAV_EASE, fill: "forwards" })
.finished.then(() => box.remove(), () => box.remove());
.finished.then(gone, gone);
}
// the header beside the sidebar: the group, the page, and its tab
function renderCrumb(items) {
File diff suppressed because one or more lines are too long
+6 -2
View File
@@ -189,8 +189,12 @@ test("compat.js is the first of the page's own scripts", async () => {
// appearance.js when Settings draws General or the look changes;
// navorder.js once a page order is kept, or Settings › Sidebar pages draws;
// the checks above
// still read them
for (const f of await scripts()) if (!["webfonts.js", "cfgblocked.js", "signsheets.js", "ruleedit.js", "ratewindows.js", "traywindows.js", "autoresetown.js", "registry.js", "navlamp.js", "whatsnew.js", "claudemode.js", "ctxtext.js", "resetask.js", "quotaall.js", "quotatable.js", "quitask.js", "checkinnow.js", "proxies.js", "autobackup.js", "scrollends.js", "profilerename.js", "settingshints.js", "keyspend.js", "syncfiles.js", "agentcompact.js", "agentwindow.js", "balfound.js", "passerrors.js", "tlscerts.js", "keybalance.js", "modellimits.js", "notices.js", "videogen.js", "provlinks.js", "setfeats.js", "pageshare.js", "panelfirst.js", "panelarrange.js", "modelfind.js", "agentsmanager.js", "agentsuffix.js", "phonetabs.js", "pluginmd.js", "bark.js", "acctexport.js", "plugincounts.js", "navicons.js", "autoswitchtip.js", "codexprojects.js", "pipecheck.js", "relaycheck.js", "addfloat.js", "plugingrid.js", "plugininstalled.js", "rotfig.js", "ompadvisor.js", "kimisub.js", "agentspeed.js", "claudemagpie.js", "keyrates.js", "maximages.js", "qianwenplan.js", "qianfanplan.js", "agymove.js", "updatetrust.js", "currencyprefs.js", "appearance.js", "mirroredit.js", "navorder.js", "instancename.js"].includes(f)) assert(all.includes(f), f + " is not loaded by index.html");
// still read them. A file some script imports (import("./x.js")) is
// loaded on demand too: headerpresets.js, navpages.js and pasteread.js
// were each left out of this list and turned it red on main (#6030)
const lazy = new Set();
for (const f of await scripts()) for (const m of (await read(f)).matchAll(/import\(\s*["']\.\/([\w.-]+\.js)["']\s*\)/g)) lazy.add(m[1]);
for (const f of await scripts()) if (!lazy.has(f) && !["webfonts.js", "cfgblocked.js", "signsheets.js", "ruleedit.js", "ratewindows.js", "traywindows.js", "autoresetown.js", "registry.js", "navlamp.js", "whatsnew.js", "claudemode.js", "ctxtext.js", "resetask.js", "quotaall.js", "quotatable.js", "quitask.js", "checkinnow.js", "proxies.js", "autobackup.js", "scrollends.js", "profilerename.js", "settingshints.js", "keyspend.js", "syncfiles.js", "agentcompact.js", "agentwindow.js", "balfound.js", "passerrors.js", "tlscerts.js", "keybalance.js", "modellimits.js", "notices.js", "videogen.js", "provlinks.js", "setfeats.js", "pageshare.js", "panelfirst.js", "panelarrange.js", "modelfind.js", "agentsmanager.js", "agentsuffix.js", "phonetabs.js", "pluginmd.js", "bark.js", "acctexport.js", "plugincounts.js", "navicons.js", "autoswitchtip.js", "codexprojects.js", "pipecheck.js", "relaycheck.js", "addfloat.js", "plugingrid.js", "plugininstalled.js", "rotfig.js", "ompadvisor.js", "kimisub.js", "agentspeed.js", "claudemagpie.js", "keyrates.js", "maximages.js", "qianwenplan.js", "qianfanplan.js", "agymove.js", "updatetrust.js", "currencyprefs.js", "appearance.js", "mirroredit.js", "navorder.js", "instancename.js"].includes(f)) assert(all.includes(f), f + " is not loaded by index.html, and no script imports it");
});
test("the styles hold up in Safari 15.0", async () => {
@@ -90,6 +90,10 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
return r.top >= f.top - 0.5 && r.bottom <= f.bottom + 0.5;
});
assert.ok(await inSight("#prefs"), "the button is in sight");
// the foot takes more of the sidebar while the tabs show, through a
// class and not :has(), which Safari before 15.4 can't parse (#5919)
const footMax = () => page.locator(".side-foot").evaluate((f) => getComputedStyle(f).maxHeight);
assert.equal(await footMax(), "80%", "the foot grows for the tabs");
const over = await page.locator(".side-foot").evaluate((f) => f.scrollHeight > f.clientHeight + 1);
assert.equal(over, !!size.over, "the foot scrolls only when the list can't fit");
if (!size.over) assert.ok(await inSight(".nav-s.cur"), "the open tab is in sight");
@@ -104,6 +108,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await page.locator('#nav button[data-view="agents"]').click();
const closing = await drift(page, 600);
await page.waitForFunction(() => !document.querySelector(".nav-sub"));
assert.equal(await footMax(), "55%", "the foot goes back once they fold");
assert.ok(closing < 1, `the button moved ${closing}px while the list folded`);
assert.ok(Math.abs((await prefs.boundingBox()).y - before.y) < 1, "the button is where it began");