Skip to content

Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.

gui: Settings has Loading bird, which keeps magpie's bird off skeletons and stops looking for them

yetonef463a8aaf783
diff --git a/internal/gui/api.go b/internal/gui/api.go
index e807be7ac..21dc67db9 100644
--- a/internal/gui/api.go
+++ b/internal/gui/api.go
@@ -864,6 +864,9 @@ func Handler(w Windows, gw *gateway.Server) http.Handler {
if s.ReduceMotion {
boot["reduceMotion"] = true
}
+ if s.NoBird {
+ boot["noBird"] = true
+ }
// a browser tab keeps its own font choice (fonts.js)
if !isWeb(w) {
boot["uiFont"], boot["codeFont"] = s.UIFont, s.CodeFont
@@ -1305,6 +1308,10 @@ func Handler(w Windows, gw *gateway.Server) http.Handler {
if _, sent := fields["reduceMotion"]; !sent {
in.ReduceMotion = cur.ReduceMotion
}
+ // nor whether the loading bird is kept off
+ if _, sent := fields["noBird"]; !sent {
+ in.NoBird = cur.NoBird
+ }
// nor whether a value masked for the first time is told (Must2333)
if _, sent := fields["maskAlert"]; !sent {
in.MaskAlert = cur.MaskAlert
diff --git a/internal/gui/api_settings_test.go b/internal/gui/api_settings_test.go
index a51cd5c11..326680132 100644
--- a/internal/gui/api_settings_test.go
+++ b/internal/gui/api_settings_test.go
@@ -395,3 +395,47 @@ func TestSettingsReduceMotion(t *testing.T) {
}
}
}
+
+// The loading bird's switch (Yayoi_no_yume on X) is on unless turned off:
+// boot.js says noBird only when it is, a save that leaves it out keeps it,
+// and false brings the bird back.
+func TestSettingsNoBird(t *testing.T) {
+ h := t.TempDir()
+ t.Setenv("HOME", h)
+ t.Setenv("USERPROFILE", h)
+ t.Setenv("XDG_CONFIG_HOME", filepath.Join(h, ".config"))
+ t.Setenv("XDG_CACHE_HOME", filepath.Join(h, ".cache"))
+ handler := Handler(nil, nil)
+
+ getBoot := func() string {
+ rec := httptest.NewRecorder()
+ handler.ServeHTTP(rec, httptest.NewRequest("GET", "/boot.js", nil))
+ if rec.Code != http.StatusOK {
+ t.Fatalf("GET /boot.js: %d %s", rec.Code, rec.Body)
+ }
+ return rec.Body.String()
+ }
+ if boot := getBoot(); strings.Contains(boot, `"noBird"`) {
+ t.Fatalf("the bird is on by default, got boot.js: %s", boot)
+ }
+ for _, tc := range []struct {
+ body string
+ want bool
+ }{
+ {`{"theme":"dark","noBird":true}`, true},
+ {`{"theme":"light"}`, true},
+ {`{"theme":"dark","noBird":false}`, false},
+ } {
+ rec := httptest.NewRecorder()
+ handler.ServeHTTP(rec, httptest.NewRequest("POST", "/api/settings", strings.NewReader(tc.body)))
+ if rec.Code != http.StatusOK {
+ t.Fatalf("%s: %d %s", tc.body, rec.Code, rec.Body)
+ }
+ if got := settings.Load().NoBird; got != tc.want {
+ t.Fatalf("%s: NoBird = %v, want %v", tc.body, got, tc.want)
+ }
+ if boot := getBoot(); strings.Contains(boot, `"noBird":true`) != tc.want {
+ t.Fatalf("%s: boot.js = %s, want noBird=%v", tc.body, boot, tc.want)
+ }
+ }
+}
diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js
index d957a9aab..877af6749 100644
--- a/internal/gui/assets/app.js
+++ b/internal/gui/assets/app.js
@@ -8366,6 +8366,8 @@ const IOS_EASE = "cubic-bezier(.32, .72, 0, 1)";
// a declaration, so code above it can ask too
// the system's Reduce Motion, or Settings' (#3813)
function calm() { return document.documentElement.dataset.motion === "reduce" || matchMedia("(prefers-reduced-motion: reduce)").matches; }
+// Settings' Loading bird turned off: no bird on a skeleton or a README
+function birdOff() { return document.documentElement.dataset.bird === "off"; }
// magpie's bird in parts, its wing and tail free to move (the header's logo
// holds the shapes)
const BIRD = `<svg viewBox="0 0 44 44"><use href="#bird" clip-path="url(#bird-body)"/><g class="tail"><use href="#bird" clip-path="url(#bird-tail)"/></g><g class="wing"><use href="#bird" clip-path="url(#bird-wing)"/></g></svg>`;
@@ -8389,12 +8391,31 @@ function skelSeen() {
}
return out;
}
-let skelSince = 0, skelFlying = false;
-setInterval(() => {
- if (skelFlying || document.hidden || calm() || !document.querySelector(SKEL)) return (skelSince = 0);
- if (!skelSince) return (skelSince = Date.now());
- if (Date.now() - skelSince >= 450 && skelSeen().length) skelBird();
-}, 250);
+// It looks every 250ms only while a skeleton is in the page: an observer
+// starts the look when one is added, the look stops itself once none is
+// left, and with the bird turned off neither runs (a 1-core server:
+// Yayoi_no_yume on X).
+let skelSince = 0, skelFlying = false, skelTick = 0;
+const skelAdded = new MutationObserver((recs) => {
+ for (const r of recs) for (const n of r.addedNodes) if (n.nodeType === 1 && (n.matches(SKEL) || n.querySelector(SKEL))) return skelWatch();
+});
+function skelWatch() {
+ if (birdOff()) {
+ clearInterval(skelTick);
+ skelTick = skelSince = 0;
+ return skelAdded.disconnect();
+ }
+ if (skelTick) return;
+ if (!document.querySelector(SKEL)) return skelAdded.observe(document.body, { childList: true, subtree: true });
+ skelAdded.disconnect();
+ skelTick = setInterval(() => {
+ if (!skelFlying && !document.querySelector(SKEL)) return (skelSince = 0, clearInterval(skelTick), skelTick = 0, skelWatch());
+ if (skelFlying || document.hidden || calm()) return (skelSince = 0);
+ if (!skelSince) return (skelSince = Date.now());
+ if (Date.now() - skelSince >= 450 && skelSeen().length) skelBird();
+ }, 250);
+}
+skelWatch();
async function skelBird() {
skelFlying = true;
const b = el("div", "sk-bird roam");
@@ -8428,7 +8449,7 @@ async function skelBird() {
s.animate([{ transform: "none" }, { transform: "translateY(3px)", offset: .3 }, { transform: "translateY(-1.2px)", offset: .6 }, { transform: "translateY(.4px)", offset: .8 }, { transform: "none" }], { duration: 560, easing: "ease-out" });
await tween(130, (e) => put({ y: at.y + 3 * e, sx: 1 + .14 * e, sy: 1 - .18 * e }), easeOut);
await tween(90, (e) => put({ y: at.y + 3 * (1 - e), sx: 1.14 - .14 * e, sy: .82 + .18 * e }), easeIn);
- const to = next(s);
+ const to = birdOff() ? null : next(s);
if (!to) break;
const from = { x, y }, go = spot(to), h = 16 + Math.min(40, Math.hypot(go.x - from.x, go.y - from.y) * .15);
put({ f: go.x >= from.x ? 1 : -1 });
@@ -19026,6 +19047,10 @@ function applyPrefs(s, rate) {
}
}
if (!!s.reduceMotion !== (root.dataset.motion === "reduce")) window.holdStill(!!s.reduceMotion);
+ if (!!s.noBird !== birdOff()) {
+ if (s.noBird) root.dataset.bird = "off"; else delete root.dataset.bird;
+ skelWatch();
+ }
if (!!s.colorblind !== !!root.dataset.colorblind) {
if (s.colorblind) root.dataset.colorblind = "1";
else delete root.dataset.colorblind;
@@ -19471,6 +19496,8 @@ function renderSettings() {
$("#colorblindSegs").replaceChildren(segs([["off", t("Off")], ["on", t("On")]], s.colorblind ? "on" : "off", (v) => savePrefs({ ...keep, colorblind: v === "on" })));
$("#reduceMotionSegs").title = t("Animations stand still, as with the system's Reduce Motion, so magpie keeps the computer less busy");
$("#reduceMotionSegs").replaceChildren(segs([["off", t("Off")], ["on", t("On")]], s.reduceMotion ? "on" : "off", (v) => savePrefs({ ...keep, reduceMotion: v === "on" })));
+ $("#birdSegs").title = t("magpie's bird hops on what is still loading; Off keeps it away, and magpie stops looking for it");
+ $("#birdSegs").replaceChildren(segs([["off", t("Off")], ["on", t("On")]], s.noBird ? "off" : "on", (v) => savePrefs({ ...keep, noBird: v === "off" })));
renderLangPick(s, keep);
renderGatewayMode(s);
// a browser tab has its own zoom, and magpie leaves it to it
@@ -22408,7 +22435,7 @@ function wbCheckinLine(r) {
// prefsKeep is what the settings page sends of s, all of it each time.
function prefsKeep(s) {
- return { theme: s.theme, colorblind: !!s.colorblind, reduceMotion: !!s.reduceMotion, lang: s.lang, tray: s.tray, dock: !!s.dock, dockWindow: !!s.dockWindow, lightweight: s.lightweight, keepAwake: !!s.keepAwake, keepAwakeDisplay: !!s.keepAwakeDisplay, noWSLAgents: !!s.noWSLAgents, proxy: s.proxy || "",
+ return { theme: s.theme, colorblind: !!s.colorblind, reduceMotion: !!s.reduceMotion, noBird: !!s.noBird, lang: s.lang, tray: s.tray, dock: !!s.dock, dockWindow: !!s.dockWindow, lightweight: s.lightweight, keepAwake: !!s.keepAwake, keepAwakeDisplay: !!s.keepAwakeDisplay, noWSLAgents: !!s.noWSLAgents, proxy: s.proxy || "",
sessionTerminal: s.sessionTerminal || "",
uiFont: s.uiFont || null, codeFont: s.codeFont || null,
otel: s.otel || {},
diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.js
index 034433f1c..17588d2c7 100644
--- a/internal/gui/assets/i18n.js
+++ b/internal/gui/assets/i18n.js
@@ -3046,6 +3046,8 @@ const I18N = {
"Appearance": "外观",
"Colorblind mode": "色盲模式",
"Reduce motion": "减弱动态效果",
+ "Loading bird": "加载时的喜鹊",
+ "magpie's bird hops on what is still loading; Off keeps it away, and magpie stops looking for it": "magpie 的喜鹊会在还在加载的内容上跳来跳去;关闭后它不再出现,magpie 也不再为它盯着页面",
"Animations stand still, as with the system's Reduce Motion, so magpie keeps the computer less busy": "动画静止不动,如同系统的「减弱动态效果」,让 magpie 少占用电脑",
"Colorblind-safe chart colors, and each allowance window's line in a dash of its own": "图表改用色盲友好配色,每个额度窗口的走势线使用各自的线型",
"Follows the Omarchy theme, as picked in Omarchy's menu": "跟随 Omarchy 主题,在 Omarchy 菜单里切换",
@@ -7094,6 +7096,8 @@ const I18N = {
"Appearance": "外觀",
"Colorblind mode": "色盲模式",
"Reduce motion": "減少動態效果",
+ "Loading bird": "載入時的喜鵲",
+ "magpie's bird hops on what is still loading; Off keeps it away, and magpie stops looking for it": "magpie 的喜鵲會在還在載入的內容上跳來跳去;關閉後它不再出現,magpie 也不再為它盯著頁面",
"Animations stand still, as with the system's Reduce Motion, so magpie keeps the computer less busy": "動畫靜止不動,如同系統的「減少動態效果」,讓 magpie 少佔用電腦",
"Colorblind-safe chart colors, and each allowance window's line in a dash of its own": "圖表改用色盲友善配色,每個額度時段的走勢線使用各自的線型",
"Follows the Omarchy theme, as picked in Omarchy's menu": "跟隨 Omarchy 主題,在 Omarchy 選單裡切換",
@@ -11154,6 +11158,8 @@ const I18N = {
"Appearance": "外観",
"Colorblind mode": "色覚サポート",
"Reduce motion": "視差効果を減らす",
+ "Loading bird": "読み込み中のカササギ",
+ "magpie's bird hops on what is still loading; Off keeps it away, and magpie stops looking for it": "読み込み中の部分の上で magpie のカササギが跳ねます。オフにすると現れず、magpie もそのための監視をやめます",
"Animations stand still, as with the system's Reduce Motion, so magpie keeps the computer less busy": "システムの「視差効果を減らす」と同じくアニメーションを止め、コンピュータの負荷を減らします",
"Colorblind-safe chart colors, and each allowance window's line in a dash of its own": "グラフを色覚に配慮した配色にし、利用枠のウィンドウごとに推移線の線種を変えます",
"Follows the Omarchy theme, as picked in Omarchy's menu": "Omarchy のメニューで選んだ Omarchy テーマに従います",
@@ -15224,6 +15230,8 @@ const I18N = {
"Appearance": "Darstellung",
"Colorblind mode": "Farbenblind-Modus",
"Reduce motion": "Bewegung reduzieren",
+ "Loading bird": "Elster beim Laden",
+ "magpie's bird hops on what is still loading; Off keeps it away, and magpie stops looking for it": "magpies Elster hüpft über das, was noch lädt; Aus hält sie fern, und magpie hört auf, danach Ausschau zu halten",
"Animations stand still, as with the system's Reduce Motion, so magpie keeps the computer less busy": "Animationen stehen still wie bei „Bewegung reduzieren“ des Systems, damit magpie den Computer weniger beansprucht",
"Colorblind-safe chart colors, and each allowance window's line in a dash of its own": "Farbenblind-taugliche Diagrammfarben, und jedes Zeitfenster eines Kontingents mit eigenem Strichmuster",
"Follows the Omarchy theme, as picked in Omarchy's menu": "Folgt dem im Omarchy-Menü gewählten Omarchy-Theme",
diff --git a/internal/gui/assets/index.html b/internal/gui/assets/index.html
index 33c1cb326..ff8414fe1 100644
--- a/internal/gui/assets/index.html
+++ b/internal/gui/assets/index.html
@@ -176,6 +176,10 @@
<div class="who"><div class="name" data-t>Reduce motion</div></div>
<div id="reduceMotionSegs"></div>
</div>
+ <div class="row pref" id="birdRow">
+ <div class="who"><div class="name" data-t>Loading bird</div></div>
+ <div id="birdSegs"></div>
+ </div>
<div class="row pref">
<div class="who"><div class="name" data-t>Language</div></div>
<button type="button" id="langPick" class="sess-pick pref-pick" aria-label="Language" aria-haspopup="menu" aria-expanded="false"></button>
diff --git a/internal/gui/assets/plugins.js b/internal/gui/assets/plugins.js
index cb1b7a10a..69827bb2d 100644
--- a/internal/gui/assets/plugins.js
+++ b/internal/gui/assets/plugins.js
@@ -1527,7 +1527,10 @@
const box = el("div", "pm-bounce"), s = document.createElementNS("http://www.w3.org/2000/svg", "svg"), b = el("div", "sk-bird");
s.innerHTML = "<path/><path/><path/><path/>";
b.innerHTML = BIRD;
- box.append(s, b);
+ // with Settings' Loading bird off, the strings stand still, birdless
+ const off = birdOff();
+ box.append(s);
+ if (!off) box.append(b);
const ps = [...s.children], ws = [1, .94, .6, .82], at = [.16, .44, .3, .58];
const L = ws.map((w, i) => ({ y: 31 + i * 22, d: 0, v: 0, bx: 0, hold: false }));
// the bird is placed by its feet: f faces it, r leans it, sx/sy squash it
@@ -1553,6 +1556,7 @@
await new Promise(requestAnimationFrame);
if (!box.isConnected || gone) return;
W = box.clientWidth;
+ if (off) return draw();
if (calm()) return draw(), put({ x: at[0] * W, y: L[0].y - 5 });
// each string a damped spring, let go of when the bird leaves it
(async () => {
@@ -1595,6 +1599,7 @@
}
})().catch(() => {});
box.leave = () => {
+ if (off) return box.remove();
gone = true;
box.dataset.gone = b.dataset.flap = "";
const xa = x, ya = y;
diff --git a/internal/gui/assets/theme.js b/internal/gui/assets/theme.js
index 217d06a08..21504d167 100644
--- a/internal/gui/assets/theme.js
+++ b/internal/gui/assets/theme.js
@@ -10,6 +10,7 @@
if (theme) document.documentElement.dataset.theme = theme;
if (prefs && prefs.colorblind) document.documentElement.dataset.colorblind = "1";
if (prefs && prefs.reduceMotion) document.documentElement.dataset.motion = "reduce";
+ if (prefs && prefs.noBird) document.documentElement.dataset.bird = "off";
if (prefs) document.documentElement.style.setProperty("--zoom", prefs.web ? 1 : (prefs.textSize || 100) / 100);
})();
diff --git a/internal/gui/tests/plugin-readme-bird.test.cjs b/internal/gui/tests/plugin-readme-bird.test.cjs
index 104b4e35e..ddcd085ea 100644
--- a/internal/gui/tests/plugin-readme-bird.test.cjs
+++ b/internal/gui/tests/plugin-readme-bird.test.cjs
@@ -2,7 +2,8 @@
// A plugin's README loads under magpie's bird: it drops onto the skeleton's
// lines, each one bending under it as it bounces down them. When the README
// comes the bird flies off and the box goes. With reduced motion the lines
-// stay straight and the bird sits still on the first.
+// stay straight and the bird sits still on the first. With Settings'
+// Loading bird off the lines stay straight and no bird comes.
const assert = require("node:assert/strict");
const fs = require("node:fs/promises");
const path = require("node:path");
@@ -14,13 +15,13 @@ const listings = [{ package: "opencode-copilot-auth", name: "GitHub Copilot", ic
summary: { en: "Your GitHub Copilot plan." }, npm: { version: "0.0.9", weekly: 48213, publisher: "thdxr" } }];
const readme = (n) => ["# opencode-copilot-auth", ...Array.from({ length: n }, (_, i) => "\nParagraph " + i + ".")].join("\n");
-function server(reply) {
+function server(reply, noBird) {
return async (route) => {
const url = new URL(route.request().url());
const json = (data) => route.fulfill({ json: data });
- if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"en",theme:"light",web:false};` });
+ if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"en",theme:"light",web:false${noBird ? ",noBird:true" : ""}};` });
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
- if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings: { lang: "en", theme: "light" } });
+ if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings: { lang: "en", theme: "light", ...(noBird ? { noBird: true } : {}) } });
if (url.pathname === "/api/providers") return json({ providers: [], presets: [], excluded: [], gateway: { running: true, window: true }, plugins: [] });
if (url.pathname === "/api/groups") return json({ groups: [], pools: [] });
const state = { bun: true, bunVersion: "1.3.0", plugins: [] };
@@ -47,14 +48,14 @@ const look = (page) => page.evaluate(() => {
// how far a line's middle bends below its ends
const bend = (d) => { const n = (d || "").match(/-?[\d.]+/g)?.map(Number) || []; return n.length < 14 ? 0 : n[7] - n[1]; };
-async function open(browser, reduced) {
+async function open(browser, reduced, noBird) {
const page = await (await browser.newContext({ viewport: { width: 980, height: 820 }, reducedMotion: reduced ? "reduce" : "no-preference" })).newPage();
page.setDefaultTimeout(5000);
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
let release;
const next = new Promise((r) => { release = r; });
- await page.route("**/*", server(() => next));
+ await page.route("**/*", server(() => next, noBird));
await page.goto("http://magpie.test/?view=plugins");
await page.locator("#view-plugins .pm-find input").fill("copilot");
const card = page.locator('.pm-card[data-pkg="opencode-copilot-auth"]');
@@ -133,4 +134,21 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.equal(await page.locator("#modal .pm-bounce").count(), 0, "the box goes at once");
assert.deepEqual(errors, []);
});
+
+ test(engine + ": with Settings' Loading bird off the lines stay straight and no bird comes", async (t) => {
+ const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
+ t.after(() => browser.close());
+ const { page, errors, release } = await open(browser, false, true);
+ await page.waitForFunction(() => document.querySelector("#modal .pm-bounce path").getAttribute("d"));
+ const read = () => page.evaluate(() => [...document.querySelectorAll("#modal .pm-bounce path")].map((p) => p.getAttribute("d")));
+ const a = await read();
+ await page.waitForTimeout(400);
+ assert.deepEqual(await read(), a, "nothing moves");
+ for (const d of a) assert.equal(bend(d), 0, `straight: ${d}`);
+ assert.equal(await page.locator(".sk-bird").count(), 0, "no bird");
+ release({ readme: readme(3), updated: "2026-09-01T00:00:00Z" });
+ await page.locator("#modal .pm-md p", { hasText: "Paragraph 2." }).waitFor();
+ assert.equal(await page.locator("#modal .pm-bounce").count(), 0, "the box goes at once");
+ assert.deepEqual(errors, []);
+ });
}
diff --git a/internal/gui/tests/settings-general.test.cjs b/internal/gui/tests/settings-general.test.cjs
index 7def87157..d082de244 100644
--- a/internal/gui/tests/settings-general.test.cjs
+++ b/internal/gui/tests/settings-general.test.cjs
@@ -30,7 +30,7 @@ const names = { en: "English", zh: "简体中文", "zh-TW": "繁體中文", ja:
const appearance = { en: "Appearance", zh: "外观", "zh-TW": "外觀", ja: "外観", de: "Darstellung" };
const system = { en: "System", zh: "跟随系统", "zh-TW": "跟隨系統", ja: "システム", de: "System" };
// the rows whose name says enough, found by the control they hold
-const bare = ["#themeSegs", "#colorblindSegs", "#reduceMotionSegs", "#langPick", "#textSizeSegs", "#traySegs", "#plainNamesSegs", "#loginSegs", "#dockSegs"];
+const bare = ["#themeSegs", "#colorblindSegs", "#reduceMotionSegs", "#birdSegs", "#langPick", "#textSizeSegs", "#traySegs", "#plainNamesSegs", "#loginSegs", "#dockSegs"];
// the rows that keep a line, one each
const kept = ["#lightweightSegs", "#keepAwakeSegs", "#sessionTerminalRow .sess-pick"];
diff --git a/internal/gui/tests/skeleton-bird.test.cjs b/internal/gui/tests/skeleton-bird.test.cjs
index 9f87cb7b8..5e32d7926 100644
--- a/internal/gui/tests/skeleton-bird.test.cjs
+++ b/internal/gui/tests/skeleton-bird.test.cjs
@@ -3,6 +3,9 @@
// still up after a moment, as on a slow page, get the bird, which hops from
// bar to bar, each bar dipping under it, and flies off once they are gone.
// A quick load never sees it, and with reduced motion no bird comes.
+// Settings' Loading bird (Yayoi_no_yume on X, a 1-core server) turns it
+// off: no bird comes and nothing looks for skeletons. With it on, the look
+// every 250ms runs only while a skeleton is in the page.
const assert = require("node:assert/strict");
const fs = require("node:fs/promises");
const path = require("node:path");
@@ -13,13 +16,18 @@ const assets = path.resolve(__dirname, "../assets");
const listings = [{ package: "opencode-copilot-auth", name: "GitHub Copilot", icon: "githubcopilot", providers: ["github-copilot"],
summary: { en: "Your GitHub Copilot plan." }, npm: { version: "0.0.9", weekly: 48213, publisher: "thdxr" } }];
-function server(market) {
+function server(market, prefs = {}, posted = []) {
return async (route) => {
const url = new URL(route.request().url());
const json = (data) => route.fulfill({ json: data });
- if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"en",theme:"light",web:false};` });
+ if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = ${JSON.stringify({ lang: "en", theme: "light", web: false, ...(prefs.noBird ? { noBird: true } : {}) })};` });
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
- if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings: { lang: "en", theme: "light" } });
+ const settings = () => ({ lang: "en", theme: "light", searchVendors: [], searchAPIs: [], ...prefs });
+ if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings: settings() });
+ if (url.pathname === "/api/settings") {
+ if (route.request().method() === "POST") { const b = JSON.parse(route.request().postData()); posted.push(b); Object.assign(prefs, b); }
+ return json(settings());
+ }
if (url.pathname === "/api/providers") return json({ providers: [], presets: [], excluded: [], gateway: { running: true, window: true }, plugins: [] });
if (url.pathname === "/api/groups") return json({ groups: [], pools: [] });
const state = { bun: true, bunVersion: "1.3.0", plugins: [] };
@@ -34,7 +42,7 @@ function server(market) {
};
}
-async function open(browser, reduced, market) {
+async function open(browser, reduced, market, prefs, posted, view = "plugins") {
const page = await (await browser.newContext({ viewport: { width: 980, height: 820 }, reducedMotion: reduced ? "reduce" : "no-preference" })).newPage();
page.setDefaultTimeout(5000);
const errors = [];
@@ -42,6 +50,15 @@ async function open(browser, reduced, market) {
await page.addInitScript(() => {
// every bird that came, and every bar that dipped
window.seen = { birds: 0, places: new Set(), dips: 0 };
+ // the skeletons' look every 250ms: how many were started, how many run
+ window.looks = { made: 0, live: new Set() };
+ const si = window.setInterval, ci = window.clearInterval;
+ window.setInterval = function (fn, ms, ...a) {
+ const id = si.call(window, fn, ms, ...a);
+ if (typeof fn === "function" && /skelSeen/.test(String(fn))) looks.made++, looks.live.add(id);
+ return id;
+ };
+ window.clearInterval = function (id) { looks.live.delete(id); return ci.call(window, id); };
new MutationObserver((ms) => { for (const m of ms) for (const n of m.addedNodes) if (n.classList?.contains("sk-bird")) seen.birds++; })
.observe(document, { childList: true, subtree: true });
const step = () => {
@@ -53,8 +70,8 @@ async function open(browser, reduced, market) {
};
requestAnimationFrame(step);
});
- await page.route("**/*", server(market));
- await page.goto("http://magpie.test/?view=plugins");
+ await page.route("**/*", server(market, prefs, posted));
+ await page.goto("http://magpie.test/?view=" + view);
return { page, errors };
}
@@ -104,4 +121,63 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await page.waitForFunction(() => !document.querySelector("#view-plugins .pm-card.ghost"));
assert.deepEqual(errors, []);
});
+
+ test(engine + ": with no skeleton left, nothing looks for one every 250ms", async (t) => {
+ const browser = await launch();
+ t.after(() => browser.close());
+ let release;
+ const held = new Promise((r) => { release = r; });
+ const { page, errors } = await open(browser, false, () => held);
+ await page.locator("#view-plugins .pm-card.ghost").first().waitFor();
+ await page.waitForFunction(() => looks.live.size === 1);
+ release();
+ await page.waitForFunction(() => !document.querySelector("#view-plugins .pm-card.ghost"));
+ await page.waitForFunction(() => !document.querySelector(".sk-bird") && looks.live.size === 0, null, { timeout: 3000 });
+ // a skeleton added later starts it again
+ const made = await page.evaluate(() => looks.made);
+ await page.evaluate(() => { const s = document.createElement("span"); s.className = "skeleton"; s.id = "late-sk"; document.body.append(s); });
+ await page.waitForFunction((n) => looks.made === n + 1 && looks.live.size === 1, made);
+ await page.evaluate(() => document.getElementById("late-sk").remove());
+ await page.waitForFunction(() => looks.live.size === 0);
+ assert.deepEqual(errors, []);
+ });
+
+ test(engine + ": with Settings' Loading bird off, no bird comes, no bar moves and nothing looks for skeletons", async (t) => {
+ const browser = await launch();
+ t.after(() => browser.close());
+ let release;
+ const held = new Promise((r) => { release = r; });
+ const { page, errors } = await open(browser, false, () => held, { noBird: true });
+ await page.locator("#view-plugins .pm-card.ghost").first().waitFor();
+ await page.waitForTimeout(1500);
+ assert.deepEqual(await page.evaluate(() => [seen.birds, seen.dips, looks.made, looks.live.size]), [0, 0, 0, 0]);
+ release();
+ await page.waitForFunction(() => !document.querySelector("#view-plugins .pm-card.ghost"));
+ assert.deepEqual(errors, []);
+ });
+
+ test(engine + ": Settings' Loading bird is On by default, and Off saves noBird and stops the look", async (t) => {
+ const browser = await launch();
+ t.after(() => browser.close());
+ const prefs = {}, posted = [];
+ const { page, errors } = await open(browser, false, async () => {}, prefs, posted, "settings");
+ const on = page.locator("#birdSegs .opt", { hasText: /^On$/ }), off = page.locator("#birdSegs .opt", { hasText: /^Off$/ });
+ await on.waitFor();
+ assert.match(await on.getAttribute("class"), /\bon\b/);
+ // a skeleton up while it is turned off: the look stops, and one added
+ // after never starts it
+ await page.evaluate(() => { const s = document.createElement("span"); s.className = "skeleton"; document.body.append(s); });
+ await page.waitForFunction(() => looks.live.size === 1);
+ await off.click();
+ await page.waitForFunction(() => document.documentElement.dataset.bird === "off" && looks.live.size === 0);
+ assert.equal(posted.at(-1).noBird, true);
+ const made = await page.evaluate(() => looks.made);
+ await page.evaluate(() => { const s = document.createElement("span"); s.className = "skeleton"; document.body.append(s); });
+ await page.waitForTimeout(600);
+ assert.equal(await page.evaluate(() => looks.made), made, "nothing starts looking with it off");
+ await on.click();
+ await page.waitForFunction(() => !document.documentElement.dataset.bird && looks.live.size === 1);
+ assert.equal(posted.at(-1).noBird, false);
+ assert.deepEqual(errors, []);
+ });
}
diff --git a/internal/settings/settings.go b/internal/settings/settings.go
index 97e26ffa1..468fda624 100644
--- a/internal/settings/settings.go
+++ b/internal/settings/settings.go
@@ -49,9 +49,13 @@ type Settings struct {
// ReduceMotion stills magpie's animations as the system's Reduce
// Motion does, for a computer or phone that the moving Routing page
// keeps busy (#3813).
- ReduceMotion bool `json:"reduceMotion,omitempty"`
- Lang string `json:"lang,omitempty"` // system | en | zh
- Tray string `json:"tray,omitempty"` // what clicking the tray icon opens: panel | window
+ ReduceMotion bool `json:"reduceMotion,omitempty"`
+ // NoBird keeps magpie's bird off the loading skeletons and the
+ // Plugins page's README, for a small server where its watch for them
+ // is work enough to matter (Yayoi_no_yume on X). Off means shown.
+ NoBird bool `json:"noBird,omitempty"`
+ Lang string `json:"lang,omitempty"` // system | en | zh
+ Tray string `json:"tray,omitempty"` // what clicking the tray icon opens: panel | window
// SessionTerminal is the Mac app that opens a resumed session, by bundle
// id. "" and "system" follow the .command file association. This
// computer's own (KeepOwn): another Mac may not have that app.