gui: the loading bird lands three times before the page fills, and a stray read never sends it off

v0.1.2095 (8cbd0a9c9) held a read for the bird's first landing and then
flew it off whenever any read was waiting. Every GET through api() counts,
so a poll landing then sent the bird away over skeletons still up; it came
back after 450ms and did it again. The owner saw it fly off twice and hop
only the third time (10-30), and asked for a longer minimum: two or three
hops, not one.

Now a read back before the bird's third landing (drop 300ms, two hops,
~1.6s) waits for it. At that landing the held reads go in, the bird stands
160ms while the page fills, and then carries on as before: it hops to the
next bar while there is one and flies off only when none is left. The cap
for a window that draws no frames is 3s, up from 1.5s. Comments cut so
app.js stays inside both budgets (app.js 1,311,561 of 1,311,735).

Run on mote (macOS 27), at this tree on origin/main f5dd4e142:
- skeleton-bird, tray-bird, plugin-readme-bird, both engines: 28 pass,
  0 fail. New: "a read of something else, as the bird lands, doesn't send
  it off while skeletons are up" (four api("/api/state") reads during the
  drop; one bird, still hopping 2.5s later). Changed: a load done as the
  bird comes waits for three landings, more than 1.3s and less than 3.5s.
- Broken by hand on v0.1.2095's app.js: the stray-read test fails in both
  engines (the bird flew off and came again), and the three-landings test
  fails in both (363ms, 444ms).
- 20 GUI files around loading pages (modal-centred-late,
  plugin-github-wait, plugin-progressive, usage-focus-steady,
  usage-stale-answer, routing-js, routing-day-window, routing-time,
  usage-refresh, library-loading, sessions-overview, plugin-market,
  providers-fetching, gateway-card, panel-usage, agent-models-loading,
  plugin-page, i18n-keys, reduce-motion, held-animations): 209 pass, 0
  fail.
- go test -run Budget ./internal/gui/: ok. gofmt -l: clean.

Not run: the full GUI suite (another session's full suite holds mote),
Linux and Windows.
This commit is contained in:
yetone
2026-10-30 02:14:36 +08:00
parent 6e55914b6d
commit 9b4d0bda82
2 changed files with 39 additions and 13 deletions
+11 -10
View File
@@ -8508,10 +8508,8 @@ function skelSeen() {
// 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;
// Once the bird has come it lands at least once (the owner, 10-30: a load
// done as it came had it streak off over no skeleton): a read back before
// then waits for it, and is let go as it leaves. At most 1.5s, for a frame
// a hidden window never draws.
// Once come, the bird lands three times (~1.6s) before a read goes in (the
// owner, 10-30). At most 3s: a hidden window draws no frames.
let skelGate = null, skelWaiting = 0;
async function skelHold() {
if (!skelGate) return;
@@ -8542,7 +8540,7 @@ async function skelBird() {
skelFlying = true;
let release;
const gate = skelGate = new Promise((ok) => { release = () => { if (skelGate === gate) skelGate = null; ok(); }; });
setTimeout(release, 1500);
setTimeout(release, 3000);
const b = el("div", "sk-bird roam");
b.innerHTML = BIRD;
document.body.append(b);
@@ -8570,17 +8568,20 @@ async function skelBird() {
put({ x: at.x - 24, y: at.y - 40, f: 1 });
b.animate([{ opacity: 0 }, { opacity: 1 }], 120);
await tween(300, (e, t) => put({ x: at.x - 24 + 24 * t, y: at.y - 40 + 40 * e, sx: 1 - .05 * t, sy: 1 + .08 * t }), easeIn);
// its bar gone before it landed: it fades where it is, never flying
// over what came instead
// its bar gone mid-drop: it fades, never flying over the content
if (!s.isConnected) return void (quiet = true);
for (let hops = 0; hops < 400; hops++) {
// it lands: the bar dips under it and springs back
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);
// landed once: a read held for it means the load is done
if (!hops && skelWaiting) break;
if (!hops) release();
// third landing: held reads go in; it stands while the page fills,
// and leaves only when no bar is left
if (hops === 2) {
const held = skelWaiting;
release();
if (held) await new Promise((ok) => setTimeout(ok, 160));
}
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);
+28 -3
View File
@@ -3,7 +3,8 @@
// 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. Once
// it has come it lands once before the page fills (the owner, 10-30).
// it has come it lands three times before the page fills (the owner,
// 10-30), and a read of something else never sends it off early.
// 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.
@@ -99,7 +100,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.deepEqual(errors, []);
});
test(engine + ": a load done as the bird comes keeps its skeletons until the bird has landed once", async (t) => {
test(engine + ": a load done as the bird comes keeps its skeletons until the bird has landed three times", async (t) => {
const browser = await launch();
t.after(() => browser.close());
let release;
@@ -117,11 +118,35 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await page.waitForFunction(() => seen.goneAt, null, { timeout: 3000 });
const { dipsAtGone, goneAt } = await page.evaluate(() => seen);
assert.ok(dipsAtGone > 0, "the bird landed on a bar before the skeletons went");
assert.ok(goneAt - at < 1500, `the load waited at most for one landing (${Math.round(goneAt - at)}ms)`);
// drop 300ms, three landings 220ms each, two hops 340ms each: ~1.64s
assert.ok(goneAt - at > 1300, `the load waited for three landings (${Math.round(goneAt - at)}ms)`);
assert.ok(goneAt - at < 3500, `and no longer (${Math.round(goneAt - at)}ms)`);
await page.waitForFunction(() => !document.querySelector(".sk-bird"), null, { timeout: 2000 });
assert.deepEqual(errors, []);
});
test(engine + ": a read of something else, as the bird lands, doesn't send it off while skeletons are up", 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.locator(".sk-bird.roam").waitFor({ state: "attached", timeout: 3000 });
// reads the page makes as the bird drops and lands, none of them the
// one the skeletons wait for
await page.evaluate(() => { for (const ms of [0, 100, 250, 400]) setTimeout(() => api("/api/state"), ms); });
await page.waitForTimeout(2500);
assert.equal(await page.evaluate(() => seen.birds), 1, "one bird, still on the skeletons");
assert.ok(await page.locator(".sk-bird.roam").count(), "it is still there");
assert.ok(await page.evaluate(() => seen.places.size > 30 && seen.dips > 0), "it hops bar to bar");
release();
await page.waitForFunction(() => !document.querySelector("#view-plugins .pm-card.ghost"));
await page.waitForFunction(() => !document.querySelector(".sk-bird"), null, { timeout: 2000 });
assert.equal(await page.evaluate(() => seen.birds), 1);
assert.deepEqual(errors, []);
});
test(engine + ": a quick load never sees the bird", async (t) => {
const browser = await launch();
t.after(() => browser.close());