gui: a subscription's resets, warm-up, check-in and Claude run are its editor's own fields under Advanced

The owner (11-09): the block of cards these lists made under Routing took
most of the provider editor. Each list is now a field of the editor's
Advanced, beside its own label (Resets, Warm up, Check in, Claude Code),
first in it, and a field with nothing to show is hidden from the first
draw, before the prefs have loaded. Settings' search still finds them:
the hit opens the editor with Advanced open, brings the row into sight
and lights it.

In the editor's narrower column a row's name and control share the first
line and its description goes under both (a grid), so a description that
grows after a click moves nothing under the pointer. An account's own
warm-up time goes under its Same/Own/Off picks, not before them, so
picking Own at 440 wide no longer pushes the picks a line down.

Tests:
- In the editor a click holds what was pressed where it was (modalHold),
  and the editor may scroll to do it, so checkin-account, warm-at-own and
  codex-reset-lead check the pressed row's place on the screen, and that
  the page itself never scrolls, instead of every scrollTop. Each target
  is brought into sight first, so Playwright's own scroll before a click
  isn't counted.
- reader.cjs's inEditor scrolls the editor's body with the wheel until
  the element is inside it and not covered, and checks again after the
  editor draws anew.
- settings-groups: Claude's editor has Claude Code's run row too; the
  Usage part names alertHead and alertList (missed by 7d177985f).
- codex-reset-lead's "lead set outside the choices" brings the pick into
  sight before opening it (red on origin/main too, #5054).

Paid for in the core budget by seven long comments cut to two lines each,
no raise.

Run (mote, at this tree):
- the 42 GUI files this reaches, plus settings-back, i18n-keys and gui-de,
  Chromium and WebKit: 855 pass, 8 red, each red on origin/main too and
  filed: plugin-move-unserved "Try again takes the models unticked"
  (#4392, #4410) and tencent-cloud's region strip (#4321, #4399).
- go test ./internal/gui -run 'TestCoreScriptBudget|TestI18n': ok.
Seen red on origin/main 53b2773d7 while checking and filed:
claude-tui-setting's "Route is already handled" (#5836) and
claude-lean-prompt-setting's WebKit page error (#5832).

Again after the rebase onto da8480326, at this commit: TestCoreScriptBudget
and TestI18n ok; provider-prefs, warm-at-own, checkin-account,
codex-reset-lead, settings-groups and i18n-keys 120 of 120.

Broken by hand, each red, then put back:
- the editor rows' grid rule removed: 16 red, warm-at-own 11 (both
  engines) and checkin-account 5 (WebKit), the pressed control moved.
- the own time's wrap-reverse removed: warm-at-own 8 red at 440 (Chromium
  and WebKit, a pick moved a line down).
- the search hit not opening Advanced: provider-prefs and settings-search
  32 of 38 red.
- the fields put before Advanced instead of in it: provider-prefs
  20 of 20 red.

Not tried: the real app window.
This commit is contained in:
yetone
2026-11-10 07:08:02 +08:00
parent da8480326f
commit b03a374763
11 changed files with 181 additions and 107 deletions
+21 -10
View File
@@ -4963,19 +4963,30 @@ body .row.agent .ag-prefs .row.pref .who { display: block; }
:is(.ag-prefs, .agent-prefs) .row.pref { flex-wrap: wrap; row-gap: 8px; }
:is(.ag-prefs, .agent-prefs) .row.pref .who { flex: 1 1 240px; min-width: 0; }
:is(.ag-prefs, .agent-prefs) .compact-at { flex: 0 1 auto; min-width: 0; flex-wrap: wrap; row-gap: 6px; }
/* a subscription's warm-ups, check-in and resets (PROV_PREFS), in its
provider's editor across both columns from where the fields start, a
card each, their lines wrapped as an agent's are */
.editor .prov-prefs { grid-column: 1 / -1; margin-left: var(--ed-at, 86px); display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.editor .prov-prefs[hidden] { display: none; }
.prov-prefs .list.prefs { margin: 0; }
.prov-prefs .list.prefs[hidden] { display: none; }
/* a subscription's warm-ups, check-in and resets (PROV_PREFS): fields of
its provider's editor under Advanced, drawn as the editor's own rows
(a name, its line as a hint, the control at the end), not Settings'
cards */
.editor .prov-prefs { display: flex; flex-direction: column; gap: 10px; min-width: 0; padding-top: 2px; }
.editor .prov-prefs .list.prefs { margin: 0; background: none; border: 0; border-radius: 0; overflow: visible; display: flex; flex-direction: column; gap: 10px; }
/* the name and its control on the first line, its line under both: a line
that grows (a check-in's outcome, a longer state) never moves the
control just pressed, which the editor can't scroll back as a view does */
.editor .prov-prefs .row.pref { display: grid; grid-template-columns: minmax(min(40%, 9em), 1fr) auto; align-items: start; min-height: 0; padding: 0; gap: 2px 12px; border: 0; }
.editor .prov-prefs .row.pref[hidden] { display: none; }
.editor .prov-prefs .row.pref > .who { display: contents; }
.editor .prov-prefs .row.pref > .who > * { grid-column: 1 / -1; }
.editor .prov-prefs .row.pref > .who > .name { grid-column: 1; grid-row: 1; }
.editor .prov-prefs .row.pref > :not(.who) { grid-column: 2; grid-row: 1; justify-self: end; min-width: 0; margin-left: 0; }
.editor .prov-prefs .row.pref .name { font-size: 12.5px; font-weight: 400; line-height: 24px; white-space: normal; }
.editor .prov-prefs .row.pref .sub { font-size: 11px; line-height: 16px; color: var(--fg-2); margin-top: 0; white-space: normal; }
/* a time and its picks fit the editor's narrower column: they wrap, at its end */
.editor .prov-prefs .warm-at { flex: 0 1 auto; min-width: 0; max-width: 100%; flex-wrap: wrap; justify-content: flex-end; row-gap: 6px; }
/* an account's own time goes under its picks, not above them: a pick pressed stays where it was */
.editor .prov-prefs .warm-at:not(.times) { flex-wrap: wrap-reverse; }
/* the editor's Claude Code runs as row switches it; magpie web as a
gateway has that row's switch off, so this one shows there */
.prov-prefs #claudeRunList:not(.gw) #claudeTuiRow { display: none; }
.prov-prefs .row.pref .sub { white-space: normal; }
.prov-prefs .row.pref { flex-wrap: wrap; row-gap: 8px; }
.prov-prefs .row.pref .who { flex: 1 1 240px; min-width: 0; }
/* Settings' search finds them; not searching, the links stay out */
#view-settings:not(.set-searching) :is(#agentPrefLinks, #provPrefLinks) { display: none; }
+47 -60
View File
@@ -4623,13 +4623,8 @@ function updateStuck(u) {
// that one's notes first.
const ISSUES = "https://github.com/yetone/magpie/issues/";
let whatsNewAsked = false;
// cliBehindOnce: the terminal's magpie is a copied file rather than the
// installer's link, so it can't follow the app's updates (#531's lesson: a
// stale command wedged the WebDAV sync). The window can't tell a stale copy
// from a current one — that would mean running the old binary, whose
// start-up migrates settings — so this is advice, shown once per load, only
// in the window (the panel is too small), and dismissable until the next
// version.
// cliBehindOnce: the terminal's magpie is a copy, not the installer's
// link, so it can't follow updates (#531); advice once per load, window only
let cliBehindAsked = false;
function cliBehindOnce() {
if (cliBehindAsked || mode === "panel" || !$("#modal").hidden) return; // another dialog owns the screen: the advice waits for the next load
@@ -4670,13 +4665,8 @@ async function whatsNewOnce() {
showWhatsNew(w.releases, true, { total: w.total });
}
// openWhatsNew is Settings' way back to the notes: the current version's (or
// those since the last update), after those of every release up to the
// waiting update (pending), which the app puts first. The notes that
// couldn't be had (the site failing, #661) say so, with a retry and the
// release page, apart from a version that has none.
// last: the range picked (wnRange), "" since the last update; a failed ask
// keeps the notes last shown (wnKept).
// openWhatsNew: Settings' way back to the notes, up to the waiting update;
// last: the range picked (wnRange); a failed ask keeps the last shown
let wnKept = null;
async function openWhatsNew(b, last = "") {
if (b) { b.disabled = true; b.classList.add("busy"); }
@@ -9568,7 +9558,6 @@ function drawEditor(p, presetID) {
ed.append(...pluginOptionsField(subOf(a.agent), true));
if ((a.logins || []).filter((l) => l.active || l.on).length > 1) ed.append(...renderRouting(p));
if (p.move) ed.append(...renderMove(p));
ed.append(...provPrefsField(a.agent));
} else {
const acct = el("div", "acct");
acct.append(icon(a.agentIcon), el("span", "n", a.user), hideAccounts.eye(a.user, p.id), el("span", "plan", accountPlan(a)));
@@ -9577,6 +9566,8 @@ function drawEditor(p, presetID) {
ed.append(...field(t("Models"), renderModels(p), pluginFilterNote(subOf(a.agent))));
if (p.drawIds?.length) ed.append(...renderDrawers(p));
if (p.filmIds?.length) ed.append(...renderVideomakers(p));
// the subscription's own warm-up, check-in and resets first
if (subOf(a.agent)) advIn.append(...provPrefsField(a.agent));
// a subscription's window too: Codex's backend says 272K for models
// that take 872K (#120)
const cx = input(draft.contexts || "", t("e.g. 128k · or gpt-6=1m, comma separated"));
@@ -14429,13 +14420,8 @@ function quotaText(w) {
const count = quotaCount(w);
return count ? count + " · " + pct : pct;
}
// quotaPace: how far a window is from an even pace through it, as a
// number (fflake33 on Discord): the figure the meter shows less what an
// even pace would show by now, in points of the window, rounded — used
// 60% halfway through is +10, and left it is −10; null where the window's
// start or reset isn't known (startsAt is the gateway's,
// provider.WithWindowStarts). over says more is used than an even pace
// would have, whichever way the meter reads.
// quotaPace: a window's distance from an even pace, in points (fflake33);
// null with no known start or reset; over: more used than even
function quotaPace(w, now = Date.now()) {
if (w.unlimited || quotaNoShare(w) || w.historyMissing || !w.startsAt || !w.resetsAt) return null;
const s = Date.parse(w.startsAt), e = Date.parse(w.resetsAt);
@@ -15642,13 +15628,8 @@ function localAddress(s) {
return u.protocol + "//" + u.host;
} catch { return null; }
}
// hostSite is the page the editor's head links to for a provider with no
// website: the origin of the base its host is shown from, under that base's
// own scheme, so a local server at http://127.0.0.1:7863/v1 opens over http
// (#2377). https only when no base of its own spells the host (a moved
// subscription shows the host it had). A plugin's provider has
// plugin://<id> for its base, and its id is no address to open: only a host
// with a dot or a port makes a link.
// hostSite: the head's link for a provider with no website, its base's
// origin and scheme (#2377); only a host with a dot or a port links
function hostSite(p) {
const h = (p?.host || "").toLowerCase();
if (!/[.:]/.test(h)) return "";
@@ -17005,13 +16986,8 @@ function quotaWindowLine(q, w) {
if (!w) return null;
return quotaLines({ ...q, windows: [w.window ? { ...w, name: w.window } : w] })[0] || null;
}
// quotaSpark: the tray card's line of a window's current cycle, the even
// burn faint under it; none while the curves are off. In a card's width a
// month drawn in a few pixels' height read as one straight line, its dashes
// all but on it (#2079): it is taller, and the gap between what was left and
// the even burn is shaded, green where it is above (it lasts) and amber
// where it is below (it runs out first), so which side it is on shows
// without reading an angle.
// quotaSpark: the tray card's line of a window's cycle over the even burn,
// the gap shaded green above, amber below (#2079); none while curves are off
let sparkClips = 0;
function quotaSpark(q, w) {
if (quotaRange === "off") return null;
@@ -19642,6 +19618,9 @@ const PROV_PREFS = {
"minimax-code": ["minimaxList"], "minimax-code-global": ["minimaxList"],
qoder: ["qoderList"], "qoder-cn": ["qoderList"],
};
// each list's label in the editor's Advanced, the plugins' check-ins
// under Check in
const PROV_PREF_LABEL = { codexResetList: "Resets", codexWarmList: "Warm up", claudeWarmList: "Warm up" };
let provPrefListEls = null, provPrefMount = null;
// homeProvPrefRows: an editor's lists back in the page
function homeProvPrefRows() {
@@ -19655,29 +19634,44 @@ function provPrefsOf(agent) {
const g = [...$("#pluginCheckinList").children].find((x) => x.dataset.provider === agent);
return g ? [...lists, g] : lists;
}
// mountProvPrefs: the agent's into an editor's box, again after a draw
function mountProvPrefs(box, agent) {
const provPrefKey = (x) => x.classList.contains("ci-plugin") ? "ci-plugin" : x.id;
// mountProvPrefs: the agent's lists into an editor's fields, each beside
// its label, again after a draw; a field with nothing shown goes
function mountProvPrefs(slots, agent) {
homeProvPrefRows();
const own = provPrefsOf(agent);
provPrefMount = { box, agent, own };
box.replaceChildren(...own);
box.hidden = !own.some((x) => !x.hidden);
provPrefMount = { slots, agent, own };
for (const slot of slots) {
const mine = own.filter((x) => provPrefKey(x) === slot.dataset.list);
slot.replaceChildren(...mine);
const off = !mine.some((x) => !x.hidden);
slot.hidden = off;
for (const n of slot.fieldRow) n.hidden = off;
}
}
function remountProvPrefs() {
const m = provPrefMount;
if (m?.box.isConnected) return mountProvPrefs(m.box, m.agent);
if (m?.slots[0].isConnected) return mountProvPrefs(m.slots, m.agent);
homeProvPrefRows();
provPrefMount = null;
}
// provPrefsField: a subscription's warm-up, check-in and resets as the
// editor's own fields, under Advanced (the owner, 11-09: a block of cards
// under Routing took most of the editor)
function provPrefsField(agent) {
if (gatewayMode && agent != "claude" || !PROV_PREFS[agent] && !(prefs?.checkinPlugins || []).some((x) => x.id === agent) && prefs) return [];
const box = edAligned(el("div", "prov-prefs"));
if (prefs) mountProvPrefs(box, agent);
else {
box.hidden = true;
loadSettings().then(() => box.isConnected && mountProvPrefs(box, agent), () => {});
}
return [box];
const keys = [...(PROV_PREFS[agent] || []).filter((id) => !gatewayMode || id == "claudeRunList"), "ci-plugin"];
const slots = keys.map((k) => {
const slot = el("div", "prov-prefs");
slot.dataset.list = k;
slot.fieldRow = field(k == "claudeRunList" ? "Claude Code" : t(PROV_PREF_LABEL[k] || "Check in"), slot);
for (const n of slot.fieldRow) n.hidden = true;
slot.hidden = true;
return slot;
});
if (prefs) mountProvPrefs(slots, agent);
else loadSettings().then(() => slots[0].isConnected && mountProvPrefs(slots, agent), () => {});
return slots.flatMap((x) => x.fieldRow);
}
// a provider's settings found by Settings' search, drawn by provlinks.js
// once a search wants them
@@ -19915,13 +19909,8 @@ function renderCLI(r) {
cliAsk?.then((v) => { if (r.isConnected) paint(v); }, () => { if (!cliView) sub.textContent = t("Couldn't tell"); });
}
// Settings' Download source (#893): where an update's file is downloaded
// from — usemagpie.ai (R2), and github.com when that fails, or a GitHub
// download mirror put before github.com's URL, the same setting `magpie
// update mirror` writes. magpie names no mirror of its own; the feed and
// each file's SHA-256 still come from usemagpie.ai, and a file that doesn't
// match is never installed. A draft and its error are
// kept across the page being drawn again.
// Settings' Download source (#893): a GitHub mirror before github.com, as
// `magpie update mirror` writes; the feed and SHA-256 stay usemagpie.ai's
let mirrorEditing = false, mirrorDraft = "", mirrorErr = "";
function setUpdateMirror(mirror) {
return writingPrefs(api("settings/update-mirror", { mirror }))
@@ -20495,10 +20484,8 @@ const IN_USE = "|*";
// renderTrayUsage: the subscriptions and plans whose windows show beside
// the tray icon, side by side. The cards are the Usage page's, asked for
// when the menu opens; any number are ticked in it.
// suffixSegs: how the agents' lists name a model: with its provider's
// after it, all but the user's own (#92), or none (#335). Set on its own;
// drawn(mode) redraws where it was picked (#868). Read from the state's
// settings, not Settings' own read (#1433).
// suffixSegs: a model named with its provider's after it, but the user's
// own (#92), or none (#335); from the state's settings (#1433)
function suffixMode(s = state.settings || {}) { return s.plainNames ? "off" : s.plainOwnNames ? "own" : "on"; }
function suffixSegs(drawn) {
const mode = suffixMode();
+4
View File
@@ -1382,6 +1382,7 @@ const I18N = {
"Warm up now": "现在预热",
"Sends the warm-up's one tiny request to an account now": "现在给一个账号发出预热的那条极小请求",
"Warm up": "预热",
"Resets": "重置卡",
"The 5-hour window hasn't started: one tiny request starts it now": "5 小时窗口还没开始:发一个极小的请求,现在就开始计时",
"Warm up…": "预热…",
"Warm up which account": "预热哪个账号",
@@ -6183,6 +6184,7 @@ const I18N = {
"Warm up now": "現在預熱",
"Sends the warm-up's one tiny request to an account now": "現在給一個帳號發出預熱的那條極小請求",
"Warm up": "預熱",
"Resets": "重置卡",
"The 5-hour window hasn't started: one tiny request starts it now": "5 小時視窗還沒開始:發一個極小的請求,現在就開始計時",
"Warm up…": "預熱…",
"Warm up which account": "預熱哪個帳號",
@@ -10953,6 +10955,7 @@ const I18N = {
"Warm up now": "今すぐウォームアップ",
"Sends the warm-up's one tiny request to an account now": "ウォームアップのごく小さなリクエストを今すぐアカウントに送ります",
"Warm up": "ウォームアップ",
"Resets": "リセット",
"The 5-hour window hasn't started: one tiny request starts it now": "5 時間枠はまだ始まっていません。ごく小さなリクエストを 1 つ送って今すぐ始めます",
"Warm up…": "ウォームアップ…",
"Warm up which account": "ウォームアップするアカウント",
@@ -15754,6 +15757,7 @@ const I18N = {
"Warm up now": "Jetzt vorwärmen",
"Sends the warm-up's one tiny request to an account now": "Sendet die winzige Vorwärm-Anfrage jetzt an ein Konto",
"Warm up": "Vorwärmen",
"Resets": "Resets",
"The 5-hour window hasn't started: one tiny request starts it now": "Das 5-Stunden-Fenster hat noch nicht begonnen: eine winzige Anfrage startet es jetzt",
"Warm up…": "Vorwärmen…",
"Warm up which account": "Welches Konto vorwärmen",
+7 -1
View File
@@ -35,7 +35,13 @@ window.provPrefLinksDraw = function () {
go.onclick = async () => {
if (!await show("providers")) return;
const p = providers?.providers.find((x) => agents.includes(x.account?.agent));
if (p) openProvider(p.id);
if (!p) return;
// its field is under the editor's Advanced: opened, and the row lit
advanced = { of: p.id, open: true };
await openProvider(p.id);
if (!r.isConnected) return;
r.scrollIntoView({ block: "center" });
r.classList.add("flash");
};
row.append(who, go);
box.append(row);
+8 -3
View File
@@ -61,7 +61,6 @@ const words = {
de: { on: "Einmal täglich eingecheckt, solange der tägliche Check-in an ist", off: "Vom täglichen Check-in ausgenommen", card: "Automatischer Check-in ist für dieses Konto aus" },
};
const scrolls = (page) => page.evaluate(() => [scrollY, ...[...document.querySelectorAll("*")].filter((e) => e.scrollTop).map((e) => e.scrollTop)].join(","));
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
for (const width of [1100, 420]) {
@@ -96,13 +95,19 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const on = rows.nth(1).locator(".segs .opt").nth(1);
await inEditor(page, on);
const y = await scrolls(page);
// in the editor, what was pressed stays under the pointer: the
// editor scrolls to hold a row drawn again (modalHold)
const top = () => on.evaluate((e) => e.getBoundingClientRect().top);
const y = await top();
const saved = page.waitForResponse((r) => new URL(r.url()).pathname === "/api/settings/checkin-account");
await on.click();
await saved;
assert.deepEqual(asked, [{ key: "workbuddy|u2", on: true }]);
await page.waitForFunction((want) => document.querySelectorAll("#wbList .ci-acct .sub")[1]?.textContent.trim() === want, w.on);
assert.equal(await scrolls(page), y, "the switch moved the page");
await page.evaluate(() => new Promise((ok) => requestAnimationFrame(() => requestAnimationFrame(ok))));
const now = await top();
assert(Math.abs(now - y) <= 1, `the switch moved from ${y} to ${now}`);
assert.equal(await page.evaluate(() => scrollY), 0, "the page itself never scrolls");
assert.equal(await page.locator("select").count(), 0);
assert.deepEqual(errors, []);
});
@@ -129,7 +129,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
// every row fits: nothing runs past the editor
const over = await page.evaluate(() => {
const view = document.querySelector(".editor .prov-prefs").getBoundingClientRect();
const view = document.querySelector(".editor .prov-prefs[data-list=codexResetList]").getBoundingClientRect();
return [...document.querySelectorAll("#codexAutoResetRow, .ar-own, .ar-own-case, .ar-own-say, .ar-own .opt")]
.filter((e) => { const r = e.getBoundingClientRect(); return r.right > view.right + 1 || r.left < view.left - 1; })
.map((e) => e.className + " " + e.textContent.slice(0, 30));
+13 -6
View File
@@ -18,8 +18,10 @@ const { test } = require("node:test");
const { chromium, webkit } = require("playwright");
const { watchSettingsReads, settingsDrawn, provPrefsProviders, openProvPrefs, inEditor } = require("./reader.cjs");
// scrolls: where every box that scrolls is, so a click that moved one shows
const scrolls = (page) => page.evaluate(() => [scrollY, ...[...document.querySelectorAll("*")].filter((e) => e.scrollTop).map((e) => e.scrollTop)].join(","));
// scrolls: the page's scroll and where the lead's row is on the screen. In
// the editor a click holds what was pressed where it was (modalHold), so
// the editor's own scrollTop may change to keep the row still.
const scrolls = (page) => page.evaluate(() => [scrollY, Math.round(document.querySelector("#codexResetLeadRow .name").getBoundingClientRect().top)].join(","));
const assets = path.resolve(__dirname, "../assets");
@@ -171,7 +173,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await ownField();
assert.equal(await own.inputValue(), "3", "it starts at the lead");
assert.equal(await own.getAttribute("inputmode"), "numeric");
const r = await own.boundingBox(), v = await page.locator(".editor .prov-prefs").boundingBox();
const r = await own.boundingBox(), v = await page.locator(".editor .prov-prefs[data-list=codexResetList]").boundingBox();
assert(r.x >= v.x && r.x + r.width <= v.x + v.width + 1, "the field fits");
assert.equal(await scrolls(page), top, "opening the field moved nothing");
await own.fill("7");
@@ -197,15 +199,18 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
// leaving the field saves it
await ownField();
await own.fill("12");
await page.locator("#codexResetLeadRow .name").click();
const name = page.locator("#codexResetLeadRow .name");
await inEditor(page, name); // in sight first, so the click itself scrolls nothing
const before = await scrolls(page);
await name.click();
for (let i = 0; i < 100 && posts.length < 4; i++) await page.waitForTimeout(20);
assert.deepEqual(posts.at(-1), { minutes: 12 });
await page.waitForFunction((want) => document.querySelector("#codexResetLeadRow button.reset-lead .rl-say > .on")?.textContent.trim() === want, await say(page, lang, 12));
assert.equal(await scrolls(page), top, "no click moved the page");
assert.equal(await scrolls(page), before, "no click moved the page");
// fits, no sideways scroll, no native select, no left border
const over = await page.evaluate(() => {
const view = document.querySelector(".editor .prov-prefs").getBoundingClientRect();
const view = document.querySelector(".editor .prov-prefs[data-list=codexResetList]").getBoundingClientRect();
return [...document.querySelectorAll("#codexResetLeadRow, #codexResetLeadRow *")]
.filter((e) => { const r = e.getBoundingClientRect(); return r.width && (r.right > view.right + 1 || r.left < view.left - 1); })
.map((e) => e.className + " " + e.textContent.slice(0, 30));
@@ -224,7 +229,9 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const { page, errors } = await open(t, engine, "en", 900, 45, posts);
const pick = page.locator("#codexResetLeadRow button.reset-lead");
assert.equal((await pick.locator(".rl-say > .on").textContent()).trim(), "45 min before");
await inEditor(page, pick);
await pick.click();
await page.locator(".proto-menu .pm-item").first().waitFor();
assert.equal(await page.locator(".proto-menu .pm-item").count(), 13);
assert.equal(await page.locator(".proto-menu .pm-item.on .pm-name").textContent(), "45 min before");
await page.keyboard.press("Escape");
+6 -2
View File
@@ -70,9 +70,13 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const box = page.locator(".editor .prov-prefs");
await box.locator("#codexWarmList #warmSegs .opt").first().waitFor();
assert.equal(await box.locator("#codexResetList").count(), 1, "Codex's resets");
// the editor's own fields under Advanced, not cards over the
// editor's first fields (the owner, 11-09)
assert.equal(await page.locator(".editor details.advanced .prov-prefs #codexWarmList, .editor details.advanced .prov-prefs #codexResetList").count(), 2, "under Advanced");
assert.equal(await page.locator(".editor .prov-prefs").evaluateAll((bs) => bs.length > 0 && bs.every((b) => b.closest("details.advanced"))), true, "every field under Advanced");
assert.equal(await box.locator("#claudeWarmList, #wbList, .ci-plugin").count(), 0, "only Codex's own");
const fits = await box.evaluate((b) => { const r = b.getBoundingClientRect(); return r.width > 0 && r.right <= innerWidth; });
assert.equal(fits, true, "the box fits the window");
const fits = await box.evaluateAll((bs) => bs.filter((b) => b.offsetParent).every((b) => { const r = b.getBoundingClientRect(); return r.width > 0 && r.right <= innerWidth; }));
assert.equal(fits, true, "each field fits the window");
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth), true, "no sideways scroll");
if (process.env.ARTIFACT_DIR) await page.locator(".editor").first().screenshot({ path: path.join(process.env.ARTIFACT_DIR, `provider-prefs-${engine}-${width}-${lang}-codex.png`) });
// written from the editor as from Settings
+53 -12
View File
@@ -236,26 +236,57 @@ function provPrefsProviders(ids, names = {}) {
presets: [], excluded: [], gateway: { running: true, window: true },
};
}
// openProvPrefs: the provider's editor, open on its own settings
// openProvPrefs: the provider's editor, its Advanced opened on its own
// settings (fields there since the owner's 11-09)
async function openProvPrefs(page, id) {
await page.goto(`http://magpie.test/?view=providers&edit=${encodeURIComponent(id)}`);
await page.locator(".editor .prov-prefs:not([hidden])").waitFor({ timeout: 60000 });
const adv = page.locator(".editor details.advanced");
await adv.waitFor({ timeout: 60000 });
if (!(await adv.evaluate((d) => d.open))) await adv.locator(":scope > summary").click();
await page.locator(".editor .prov-prefs .row").filter({ visible: true }).first().waitFor({ timeout: 60000 });
}
// inEditor brings a control in a provider's editor into sight. The editor
// is in the modal, whose body isn't a view, so the app lets the scroll
// stand; then it waits till no box has scrolled for ten frames, so a check
// that a click left the page where it was reads it at rest.
async function inEditor(page, locator) {
// a save draws the lists again, so the element found can be replaced
// before it is scrolled to: found again then
for (let i = 0; ; i++) {
try {
await locator.waitFor({ state: "visible" });
await locator.scrollIntoViewIfNeeded();
break;
} catch (e) {
if (i >= 5 || !/not attached/.test(e.message)) throw e;
}
// a code scroll is put back (gui-shell.md, "A click never moves"): the
// wheel over the editor's body, as a reader, till the element is inside
// it, clear of the bar under it; a save draws the lists again, so the
// element is found again each time
for (let round = 0; round < 5; round++) {
await locator.waitFor({ state: "visible" });
let inside = false;
for (let i = 0; i < 200; i++) {
const at = await locator.evaluateAll((es) => {
const e = es.length === 1 ? es[0] : null, body = e?.closest(".ebody");
if (!e || !e.isConnected) return null;
if (!body) return { none: true };
const r = e.getBoundingClientRect(), v = body.getBoundingClientRect();
// a point whose nearest box that can scroll is the body: one inside
// it (a list of its own) takes the wheel first, even with nothing
// to scroll in Chromium, and the body never moves
const scrolls = (n) => /auto|scroll/.test(getComputedStyle(n).overflowY);
let px = v.left + v.width / 2, py = (v.top + v.bottom) / 2;
find: for (let fy = 0.5; fy < 1; fy += 0.1) for (const fx of [0.5, 0.15, 0.85, 0.02]) for (const s of [1, -1]) {
const x = v.left + v.width * fx, y = v.top + v.height * (s > 0 ? fy : 1 - fy);
let n = document.elementFromPoint(x, y);
if (!n || !body.contains(n)) continue;
while (n !== body && !scrolls(n)) n = n.parentElement;
if (n === body) { px = x; py = y; break find; }
}
// and nothing lies over it (a bar held at the editor's foot): a
// click there would be scrolled to by Playwright first
const h = document.elementFromPoint(r.left + r.width / 2, r.top + r.height / 2);
const over = !!h && h !== e && !e.contains(h);
return { top: r.top, bottom: r.bottom, vt: v.top, vb: v.bottom, px, py, over, low: r.top > (v.top + v.bottom) / 2 };
});
if (!at) { await page.waitForTimeout(40); continue; }
if (at.none) { await locator.scrollIntoViewIfNeeded(); inside = true; break; }
if (at.top >= at.vt + 8 && at.bottom <= at.vb - 8 && !at.over) { inside = true; break; }
await page.mouse.move(at.px, at.py);
await page.mouse.wheel(0, at.top < at.vt + 8 || at.over && !at.low ? -40 : 40);
await page.waitForTimeout(30);
}
await page.evaluate(() => new Promise((done) => {
let last = "", same = 0;
@@ -263,6 +294,16 @@ async function inEditor(page, locator) {
const f = () => { const now = at(); same = now === last ? same + 1 : 0; last = now; if (same >= 10) done(); else requestAnimationFrame(f); };
requestAnimationFrame(f);
}));
// the editor drawn again meanwhile (a load come in) starts at its top:
// reached again
if (inside && await locator.evaluateAll((es) => {
const e = es.length === 1 ? es[0] : null, body = e?.closest(".ebody");
if (!e || !body) return !!e;
const r = e.getBoundingClientRect(), v = body.getBoundingClientRect();
return r.top >= v.top && r.bottom <= v.bottom;
})) return;
}
throw new Error("not brought into the editor's sight: " + locator);
}
// The Usage page's Requests: a row's click opens that one request on a page
+7 -6
View File
@@ -61,11 +61,11 @@ function server(lang, posts, over) {
const L = {
en: {
reset: "Warm up on reset", daily: "Daily warm-up", checkin: "Daily check-in",
lean: "Short Claude system prompt", reset: "Warm up on reset", daily: "Daily warm-up", checkin: "Daily check-in",
on: "On", off: "Off", started: "last started", checked: "Ann checked in today +2, 3-day streak",
},
zh: {
reset: "窗口重置时预热", daily: "每日定时预热", checkin: "每日自动签到",
lean: "精简 Claude 系统提示词", reset: "窗口重置时预热", daily: "每日定时预热", checkin: "每日自动签到",
on: "开启", off: "关闭", started: "上次启动于", checked: "Ann 今日已签到 +2, 连续 3 天",
},
};
@@ -131,12 +131,12 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
workbuddyCheckins: [{ user: "Ann", day: today, at: new Date().toISOString(), outcome: "claimed", credit: 2, streak: 3 }],
});
// Settings' Usage part: its list alone, no service's rows in it
// Settings' Usage part: its list and the Alerts, no service's rows
await page.goto("http://magpie.test/?view=settings&tab=usage");
await page.locator("#setPage-usage #currencySegs .opt").first().waitFor();
const parts = await page.evaluate(() => [...document.querySelectorAll("#setPage-usage > *")]
.map((h) => h.querySelector("#currencySegs") ? "usage" : h.className));
assert.deepEqual(parts, ["usage"]);
.map((h) => h.querySelector("#currencySegs") ? "usage" : h.id));
assert.deepEqual(parts, ["usage", "alertHead", "alertList"]);
assert.equal(await page.locator("#warmTabs, .warm-panes").count(), 0, "no tabs left");
for (const id of ["#warmSegs", "#warmAtSegs", "#claudeWarmSegs", "#claudeWarmAtSegs", "#wbCheckinSegs", "#traeCheckinSegs"]) {
assert.equal(await page.locator("#setPage-usage").locator(id).count(), 0, id + " is out of Settings");
@@ -204,7 +204,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await edit("claude");
assert.deepEqual(await panes(page), ["claude"]);
assert.deepEqual(await visibleRows(), [w.reset, w.daily]);
// Claude Code's own run row is Claude's too
assert.deepEqual(await visibleRows(), [w.lean, w.reset, w.daily]);
await thumbsUnderPicks("claude");
await press(page.locator(".editor #claudeWarmSegs .opt").nth(2));
await last("claudeWarmup", "all");
+14 -6
View File
@@ -52,7 +52,6 @@ const W = {
de: { same: "Wie oben, 06:00", own: "Täglich zu seiner eigenen Uhrzeit", off: "Nicht zu einer Uhrzeit gestartet", segs: ["Gleich", "Eigene", "Aus"] },
};
const scrolls = (page) => page.evaluate(() => [scrollY, ...[...document.querySelectorAll("*")].filter((e) => e.scrollTop).map((e) => e.scrollTop)].join(","));
const sideways = (page) => page.evaluate(() => {
const out = [];
const de = document.documentElement, v = document.querySelector(".editor .ebody") || document.querySelector(".editor");
@@ -96,9 +95,16 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await inEditor(page, rows.last().locator(".segs"));
await inEditor(page, rows.first().locator(".segs"));
if (process.env.ARTIFACT_DIR) await page.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `warm-at-own-${engine}-${lang}-${width}.png`) });
const y = await scrolls(page);
await rows.first().locator(".segs .opt").nth(1).click();
// each pick stays under the pointer: the editor scrolls to hold a
// row drawn again (modalHold)
const top = (loc) => loc.evaluate((e) => e.getBoundingClientRect().top);
const settled = () => page.evaluate(() => new Promise((ok) => requestAnimationFrame(() => requestAnimationFrame(ok))));
let pressed, y;
const press = async (loc) => { await inEditor(page, loc); pressed = loc; y = await top(loc); await loc.click(); }; // in sight first, so the click itself scrolls nothing
const stayed = async () => { await settled(); const now = await top(pressed); assert(Math.abs(now - y) <= 1, `a click moved from ${y} to ${now}`); };
await press(rows.first().locator(".segs .opt").nth(1));
await page.locator('.warm-own[data-user="a@example.com"] input').waitFor();
await stayed();
assert.deepEqual(asked, [["a@example.com", "06:00"]]);
const a = page.locator('.warm-own[data-user="a@example.com"]');
assert.equal((await a.locator(".sub").innerText()).trim(), w.own);
@@ -108,16 +114,18 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.deepEqual(asked[1], ["a@example.com", "09:00"]);
// B off, by its name as it is; then back to the time above
const b = page.locator('.warm-own[data-user="B@Example.com"]');
await b.locator(".segs .opt").nth(2).click();
await press(b.locator(".segs .opt").nth(2));
for (let i = 0; i < 50 && asked.length < 3; i++) await page.waitForTimeout(40);
assert.deepEqual(asked[2], ["B@Example.com", "off"]);
await page.waitForFunction((s) => document.querySelector('.warm-own[data-user="B@Example.com"] .sub')?.textContent === s, w.off);
await b.locator(".segs .opt").nth(0).click();
await stayed();
await press(b.locator(".segs .opt").nth(0));
for (let i = 0; i < 50 && asked.length < 4; i++) await page.waitForTimeout(40);
assert.deepEqual(asked[3], ["B@Example.com", ""]);
await page.waitForFunction((s) => document.querySelector('.warm-own[data-user="B@Example.com"] .sub')?.textContent === s, w.same);
assert.equal(await page.locator('.warm-own[data-user="a@example.com"] input').inputValue(), "09:00");
assert.equal(await scrolls(page), y, "a click moved the page");
await stayed();
assert.equal(await page.evaluate(() => scrollY), 0, "the page itself never scrolls");
assert.deepEqual(await sideways(page), []);
assert.equal(await page.locator("select").count(), 0);
assert.deepEqual(errors, []);