settings search: built-ins are found too, off or on, and Open goes to their row

A built-in's switch and the settings it keeps in Plugins › Built-in or on
its own page (Gateway's Recent calls at a time) were found by nothing in
Settings' search, and one switched off took its Settings tab and rows
with it, so searching "Observability" with it off said no setting
matched (the scattered settings audit after netube99 on X). The search
now lists, after Settings' own rows and under "Plugins › Built-in", each
built-in whose name, line or schema setting has the words, in the
language shown or English, one off saying Off. Open goes to Plugins ›
Built-in and lights that row, again when the list is drawn a second time
as the plugins are read.

The list is drawn by a lazy setfeats.js the first time a search runs,
and only when what it finds changes, as Settings' observer runs the
search again on each change under the view.

Run (mote, at f98e954ce's tree plus this): settings-search,
old-webkit, builtin-places, provider-prefs, i18n-keys: 170 pass, 0 fail,
Chromium and WebKit, every language; TestCoreScriptBudget ok. Broken by
hand: without the row's light, and with the match always false, the new
case went red in Chromium (7 pass, 2 fail each).
This commit is contained in:
yetone
2026-11-09 22:11:00 +08:00
parent 07a06617e1
commit be9dbce02c
5 changed files with 124 additions and 5 deletions
File diff suppressed because one or more lines are too long
+4
View File
@@ -19796,6 +19796,9 @@ function findSettings() {
page.hidden = !hits;
any ||= hits > 0;
}
// the built-ins that match (setfeats.js)
if (window.setFeatsFind) any = setFeatsFind(words) > 0 || any;
else import("./setfeats.js").then(() => setQuery && findSettings(), () => {});
const none = $("#setNone");
none.hidden = any;
none.textContent = t("No setting matches “{q}”", { q: $("#setQ").value.trim() });
@@ -19807,6 +19810,7 @@ function searchSettings(q) {
v.classList.remove("set-searching");
for (const n of v.querySelectorAll(".set-miss")) n.classList.remove("set-miss");
$("#setNone").hidden = true;
window.setFeatsFind?.([]);
setSetTab(setTab);
}
{
+68
View File
@@ -0,0 +1,68 @@
// Settings' search, through Plugins › Built-in too: a built-in's switch,
// and the settings it has there or on its own page (Gateway's Recent calls
// at a time), were found by nothing in Settings, and one switched off took
// its Settings rows away with it, so a search for it said no setting
// matched (the scattered settings audit after netube99 on X). Each built-in
// whose name, words or settings match is listed after Settings' own rows,
// off ones too, and Open goes to its row in Plugins › Built-in. Loaded by
// app.js the first time a search runs, as provlinks.js is.
// the built-in an Open is for: its row is lit (and scrolled to once) each
// time Plugins › Built-in draws it in the next few seconds, as the list is
// drawn again when the plugins are read
let featAt = null, featAtEnd = 0;
{
const draw = window.renderBuiltins;
window.renderBuiltins = (box, list, done) => {
draw(box, list, done);
const row = featAt && box.querySelector(`.feat-row[data-id="${featAt.id}"]`);
if (!row) return;
if (!featAt.scrolled) row.scrollIntoView({ block: "center" });
featAt.scrolled = true;
row.classList.add("flash");
};
}
window.setFeatsFind = function (words) {
let box = document.getElementById("setFeats");
if (!box) {
box = el("section", "set-page set-feats");
box.id = "setFeats";
box.append(el("div", "list prefs"));
$("#view-settings").append(box);
}
const list = box.firstChild;
const say = (s) => (s ? s + " " + t(s) : "");
const found = ((words.length && prefs?.builtins) || []).filter((f) => {
const props = Object.values(f.schema?.properties || {});
const text = [say(f.name), say(f.sub), ...props.map((p) => say(p.title) + " " + say(p.description))].join(" ").toLowerCase();
return words.every((w) => text.includes(w));
});
// drawn again only when it changes: a draw is a change Settings'
// observer runs the search again on
const key = document.documentElement.lang + " " + found.map((f) => f.id + (f.on ? "+" : "-")).join(" ");
if (box.dataset.key === key) return found.length;
box.dataset.key = key;
list.replaceChildren();
for (const f of found) {
const r = el("div", "row pref feat-find");
r.dataset.id = f.id;
const who = el("div", "who");
who.append(el("div", "name", t(f.name)));
const sub = [f.on ? "" : t("Off"), f.sub ? t(f.sub) : ""].filter(Boolean).join(" · ");
if (sub) who.append(el("div", "sub", sub));
const go = el("button", "text", t("Open"));
go.type = "button";
go.onclick = () => {
featAt = { id: f.id, scrolled: false };
clearTimeout(featAtEnd);
featAtEnd = setTimeout(() => { featAt = null; }, 3000);
window.pluginTabTo?.("builtin");
show("plugins");
};
r.append(who, go);
list.append(r);
}
box.dataset.part = t("Plugins") + " › " + t("Built-in");
box.hidden = !found.length;
return found.length;
};
+1 -1
View File
@@ -165,7 +165,7 @@ test("compat.js is the first of the page's own scripts", async () => {
// Image generation, provlinks.js when Settings' search first wants its
// provider links; 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", "quitask.js", "checkinnow.js", "autobackup.js", "scrollends.js", "profilerename.js", "settingshints.js", "keyspend.js", "syncfiles.js", "agentcompact.js", "balfound.js", "passerrors.js", "keybalance.js", "modellimits.js", "notices.js", "videogen.js", "provlinks.js"].includes(f)) assert(all.includes(f), f + " is not loaded by index.html");
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", "quitask.js", "checkinnow.js", "autobackup.js", "scrollends.js", "profilerename.js", "settingshints.js", "keyspend.js", "syncfiles.js", "agentcompact.js", "balfound.js", "passerrors.js", "keybalance.js", "modellimits.js", "notices.js", "videogen.js", "provlinks.js", "setfeats.js"].includes(f)) assert(all.includes(f), f + " is not loaded by index.html");
});
test("the styles hold up in Safari 15.0", async () => {
+50 -3
View File
@@ -6,7 +6,9 @@
// of it; a setting that moved to its provider's editor (the warm-ups, the
// owner on 11-07) is found as a link per provider, Codex's and Claude
// Code's alike, whose Open takes the reader to that editor; nothing found
// says so; a link needs its provider, and its plugin on. Escape, or clearing the box, brings back the part
// says so; a link needs its provider, and its plugin on; a built-in
// whose name, words or settings match is listed after them, off or on, and
// Open goes to its row in Plugins › Built-in. Escape, or clearing the box, brings back the part
// picked as it was. Nothing is posted and the page doesn't scroll. In the
// smallest window (560 x 420) and magpie web on a phone (390 wide), nothing
// runs off to the side. Every language; no backend, the API is faked here.
@@ -20,7 +22,7 @@ const { openPart, provPrefsProviders } = require("./reader.cjs");
const assets = path.resolve(__dirname, "../assets");
function server(lang, posts, web, { provs = ["codex", "claude"], off = [] } = {}) {
function server(lang, posts, web, { provs = ["codex", "claude"], off = [], builtins = undefined } = {}) {
const cur = {
theme: "light", lang, tray: "panel", quotaLeft: false, currency: "usd", textSize: 100,
dock: false, dockWindow: false, proxy: "", redact: false, redactPersonal: false, redactWords: [],
@@ -29,7 +31,7 @@ function server(lang, posts, web, { provs = ["codex", "claude"], off = [] } = {}
version: "0.1.400", dir: "~/.config/magpie", gateway: "http://127.0.0.1:3425",
proxyNow: "none", proxySource: "none", login: false,
visionModels: [], imageGenModels: [], workbuddyCheckins: [], lanURLs: [],
fx: { rate: 7.2, at: new Date().toISOString(), stale: false },
fx: { rate: 7.2, at: new Date().toISOString(), stale: false }, builtins,
};
return async (route) => {
const req = route.request(), url = new URL(req.url());
@@ -40,6 +42,7 @@ function server(lang, posts, web, { provs = ["codex", "claude"], off = [] } = {}
if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings: { lang, theme: "light", textSize: 100 }, fx: cur.fx });
if (url.pathname === "/api/settings") return json(cur);
if (url.pathname === "/api/plugins") return json({ plugins: [] });
if (url.pathname === "/api/plugins/builtin" && builtins) return json(builtins);
if (url.pathname === "/api/providers") return json(provPrefsProviders(provs, { codex: "ChatGPT", claude: "Claude" }));
if (url.pathname === "/api/usage/quotas") return json([]);
if (url.pathname === "/api/groups") return json({ groups: [], models: [] });
@@ -203,6 +206,50 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
}
});
// the built-ins are found too, with what they set on their own page or
// in Plugins › Built-in, and one switched off (its Settings tab gone
// with it), and Open goes to its row in Plugins › Built-in
await t.test("built-ins are found, and Open goes to their row", async () => {
const row = (id, name, sub, on, more) => ({ id, name, sub, on, chosen: on, source: "preset", state: on ? "active" : "off", inUse: 0, ...more });
const builtins = [
row("otel", "Observability", "Send each request's trace to an OpenTelemetry collector", false, { setAt: "otel #otelList" }),
row("gateway", "Gateway page", "", true, { page: "gateway", setAt: "network #portList", config: { callsPage: 20 },
schema: { type: "object", properties: { callsPage: { type: "integer", title: "Recent calls at a time", description: "How many of the gateway's recent calls the page shows, and how many more each Show more adds", enum: [10, 20, 50, 100], default: 20 } } } }),
];
for (const lang of LANGS) {
const posts = [];
const page = await open(lang, posts, { builtins, off: ["otel"] });
const tr = (s, vars) => page.evaluate(([s, vars]) => t(s, vars), [s, vars]);
const found = page.locator("#setFeats .feat-find:visible");
for (const [words, want] of [
[await tr("Recent calls at a time"), [[await tr("Gateway page"), ""]]],
["recent calls", [[await tr("Gateway page"), ""]]],
[await tr("Observability"), [[await tr("Observability"), await tr("Off") + " · " + await tr("Send each request's trace to an OpenTelemetry collector")]]],
["zzqqxx", []],
]) {
await type(page, words.toLowerCase());
await page.waitForFunction((n) => document.querySelectorAll("#setFeats .feat-find").length === n || (!n && !document.querySelector("#setFeats:not([hidden])")), want.length);
const got = [];
for (const r of await found.all()) got.push([(await r.locator(".name").textContent()).trim(), (await r.locator(".sub").count() ? (await r.locator(".sub").textContent()).trim() : "")]);
assert.deepEqual(got, want, lang + " " + words);
const s = await state(page);
assert.equal(s.none, want.length ? "" : await tr("No setting matches “{q}”", { q: words.toLowerCase() }), "no 'nothing matches' over a built-in found");
if (want.length) assert.equal(await page.locator("#setFeats").getAttribute("data-part"), await tr("Plugins") + " › " + await tr("Built-in"));
assert.deepEqual(await overflow(page), []);
}
await type(page, await tr("Observability"));
shots.push([lang + "-builtins", await page.screenshot()]);
await type(page, "");
assert.equal(await seen(page, "#setFeats"), false, "put away with the search");
await type(page, "recent calls");
await found.first().locator("button", { hasText: await tr("Open") }).click();
await page.locator('#builtinList .feat-row.flash[data-id="gateway"]').waitFor();
assert.deepEqual(posts, [], "finding and opening posts nothing");
assert.deepEqual(page.errors, []);
await page.context().close();
}
});
await t.test("magpie web on a phone", async () => {
const page = await open("zh", [], { width: 390, height: 760, web: true });
assert.deepEqual(await overflow(page), []);