diff --git a/docs/subsystems/providers-accounts.md b/docs/subsystems/providers-accounts.md index 2db649adf..4f7d06a9c 100644 --- a/docs/subsystems/providers-accounts.md +++ b/docs/subsystems/providers-accounts.md @@ -449,7 +449,8 @@ and `TestHistoricalWindowHoldsUsesEachWindowsOwnReading`. - The account Codex or Claude Code is signed in to can be paused (`SetLoginOn` off, #263) only while another of its accounts is on. The gateway then sends it nothing: Codex's own-model turns go through routing, which passes over it (`OwnPaused`), and a native compaction (`/responses/compact`) goes to the first account on that isn't resting, signed as that account (`compactOn` in [codex_backend.go](../../internal/gateway/codex_backend.go)). The last other account off, the paused one is used again. A switched-off Codex provider is not a pause: Codex's own-model requests still relay on its sign-in as they came. - A switched-off provider (`Off`, #163) stays saved. The gateway says it is off instead of saying the model is unknown. - A subscription switched off (`Off`) or whose account was removed from magpie (`Hidden`) is left alone in the background (`leftAlone` in [`left_alone.go`](../../internal/provider/left_alone.go); Riko on Discord, whose Claude switched off still ran `claude auth status --json` every minute). No CLI is asked who is signed in (`claudeIdentity`, `cliIdentity.get` for Cursor and Devin): what it said last, in memory or `cli-identity.json`, is served, so the account stays listed to switch on again. Nor is its allowance read (`fetchSubscriptionUsage`, `loginUsageAt`), a saved ChatGPT sign-in renewed (`RenewLogins`), the agent's account switched (`NextLogin`), a window warmed (`keepWarm`), its model list fetched (`newDue`), a daily check-in made by the loop (`checkinNow` with `soon` false; a press still checks in), a plugin's idle sign-in renewed (`KeepPluginsSignedIn`, #5080), or a Codex reset about to run out read and spent (`SpendExpiringCodexResets`, #2226; `TestExpiringResetLeftAlone`). A Cursor switched off that was never asked who is signed in isn't listed until it is switched on. `TestLeftAloneRunsNoCLI` runs those paths with fake `claude`, `cursor-agent` and `devin` CLIs on PATH and checks none ran. Plugins' model lists (`KeepPluginsListed`, and every listing after a sign-in or a plugin changes) are asked of the plugin host all at once, and a plugin provider switched off in magpie is named in the call (`plugin.ListingOff`, `pluginsOff` in [`plugins.go`](../../internal/provider/plugins.go)): `host.js` runs no models hook for it, nor the sign-in renewal before one, and tells its list as fallen back, so the list told last is kept (ChangQiu on Discord: `TestOffPluginProviderAskedNoModels`, `TestPluginsOffNamesThePluginsOwnIDs`). Refreshing every list (the window's Refresh, `POST /api/sync`, and `magpie sync`) goes through `RefreshLists`, which asks no provider switched off, and a key added to one isn't given its own list (`PrefillNewKeys`), nor is a provider switched off asked for its list when it is saved or a key is switched on in its editor (`TestRefreshListsAsksNoProviderSwitchedOff`, `TestPrefillAsksNoProviderSwitchedOff`). -- *Warm up now*, the last row of Settings › Usage's Codex and Claude Code warm-up tabs (`renderWarmNow` in `app.js`, `POST /api/warm-now`), sends one account the request the scheduled warm-up sends, whatever the warm-up settings say ([`warm_now.go`](../../internal/provider/warm_now.go)): `warmCodexLogin` for a ChatGPT account, then `StaleAllowance`; for a Claude account Claude Code's own run, `warmClaudeLogin` over the gateway's `warmClaude` (`WarmClaudeVia`), in the saved account's directory, then `claudeWarmedNow`, which has the account read again on its next look while its last reading keeps its own time, so the old windows never show as just read (`TestClaudeWarmedReadAgain`). With several accounts the press opens the app's menu of them. An account whose sign-in lapsed is sent nothing and says so, and the vendor's refusal comes back as the row's line, in red. The scheduled warm-up's file (`codex-warmup.json`) isn't written: its next look reads the window as started. `TestWarmNowSendsTheScheduledWarmUp` checks the body and headers equal the scheduled warm-up's; `warm-now.test.cjs` covers the GUI. +- A subscription's warm-up and daily check-in are fields under its provider editor's Advanced (`provPrefsField` in `app.js`; Settings' search finds them too). Advanced opens on its own while that provider's warm-up (on reset or at times of day) or check-in is on (`provPrefsOn`), unless the reader opened or closed it by hand, so a user who set one finds it (ChrisYagao on X; `warm-advanced.test.cjs`). +- *Warm up now*, the last row of Codex's and Claude Code's warm-up in their provider editors (`renderWarmNow` in `app.js`, `POST /api/warm-now`), sends one account the request the scheduled warm-up sends, whatever the warm-up settings say ([`warm_now.go`](../../internal/provider/warm_now.go)): `warmCodexLogin` for a ChatGPT account, then `StaleAllowance`; for a Claude account Claude Code's own run, `warmClaudeLogin` over the gateway's `warmClaude` (`WarmClaudeVia`), in the saved account's directory, then `claudeWarmedNow`, which has the account read again on its next look while its last reading keeps its own time, so the old windows never show as just read (`TestClaudeWarmedReadAgain`). With several accounts the press opens the app's menu of them. An account whose sign-in lapsed is sent nothing and says so, and the vendor's refusal comes back as the row's line, in red. The scheduled warm-up's file (`codex-warmup.json`) isn't written: its next look reads the window as started. `TestWarmNowSendsTheScheduledWarmUp` checks the body and headers equal the scheduled warm-up's; `warm-now.test.cjs` covers the GUI. - *All accounts*, the first item of Warm up now's menu with several accounts (CoderMaurice on X, `POST /api/warm-all`, `WarmAll` in [`warm_now.go`](../../internal/provider/warm_now.go)), sends Warm up now to every account in use (the one the agent is on, or one turned on beside it) whose windows aren't all running, as the cached readings tell them (`windowsRunning`: one never read is warmed), three at a time. An account turned off or paused, and one already in its windows, is sent nothing; one whose sign-in lapsed is sent nothing and failed. The row's line says each account's result: the ones warmed, the ones already in a window, and each refusal with its reason, in red; one turned off goes unsaid. A gateway rest isn't read here (the provider package can't see it): an account rested for a used-up window is in that window, so it is left alone as running. `TestWarmAllWarmsEachIdleAccountInUse`; `warm-now.test.cjs` covers the GUI. - The scheduled warm-up warms each window a Claude account is expected to have (`withExpected`), the 5-hour and the week, also one its reading left out: Anthropic leaves a window out until the request that starts it. A window left out while a shorter one is running is one the account doesn't have, since any use starts every window it has (a Claude Enterprise account with only the 5-hour, koohoko5924 on Discord, whose week was warmed over and over and its state read Idle): the warmer marks it `Absent` in `codex-warmup.json` and sends it nothing, and `usageRead` doesn't count it as due (`windowAbsent`, `shorterRunning` in [`codex_warmup.go`](../../internal/provider/codex_warmup.go)). A week once seen running, or left out of a reading that is only part of the plan's, is still warmed; one never read before is not. `TestClaudeWarmLeavesAWeekTheAccountHasnt`, `TestClaudeWarmStartsAWeekThatReset`, `TestUsageReadLeavesAWeekTheAccountHasnt`. - A Copilot subscription offers the union of its On accounts' models too (`copilotPoolModels` in [`copilot_pool.go`](../../internal/provider/copilot_pool.go), merged by `poolModels` as Codex's ChatGPT accounts are): each GitHub account's plan lists its own (`/models`), kept under `accountModels` for `Account.Lists`. The first account's list is fetched as before (`FetchNew`, `KeepAccountsListed`, Refresh); each fetch of it also asks the other accounts on: one with no list at once, of the rest the one asked longest ago once its list is a day old (`copilotFetchSaved`). A model Copilot refused an account (`copilotRefuses`) goes to the others that list it, and stays in the provider's list while another account on lists it (`copilotOthersList`). Only a failed ask is remembered (`copilotSavedAsked`), so a list gone is asked for again at once. applemacssma on X; `TestCopilotAccountsWithOtherModels`, `TestCopilotRefusedModelGoesToTheAccountServedIt`. diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index e660aa20e..aa2f4e0ce 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -9701,7 +9701,9 @@ function drawEditor(p, presetID) { 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)); + // and Advanced opened when one is on, as for Routing: the user who set + // a warm-up finds it where it went (ChrisYagao on X: "我的预热去哪里了") + if (subOf(a.agent)) advIn.append(...provPrefsField(a.agent, () => !(advanced && advanced.of === of) && provPrefsOn(a.agent) && (adv.open = true))); // 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")); @@ -19805,10 +19807,14 @@ function remountProvPrefs() { homeProvPrefRows(); provPrefMount = null; } +// provPrefsOn: the agent's warm-up or daily check-in is on +const provPrefsOn = (a, s = prefs) => !!(a == "codex" ? s.codexWarmup || warmTimes(s.codexWarmAts, s.codexWarmAt).length + : a == "claude" ? s.claudeWarmup || warmTimes(s.claudeWarmAts, s.claudeWarmAt).length + : s.checkinPlugins?.find((p) => p.id == a)?.on ?? s[PLUGIN_CHECKIN_INHERITS[a]]); // 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) { +function provPrefsField(agent, opened) { // a gateway keeps them: they run on its own accounts (#1065) if (!PROV_PREFS[agent] && !(prefs?.checkinPlugins || []).some((x) => x.id === agent) && prefs) return []; const keys = [...(PROV_PREFS[agent] || []), "ci-plugin"]; @@ -19820,8 +19826,8 @@ function provPrefsField(agent) { slot.hidden = true; return slot; }); - if (prefs) mountProvPrefs(slots, agent); - else loadSettings().then(() => slots[0].isConnected && mountProvPrefs(slots, agent), () => {}); + if (prefs) mountProvPrefs(slots, agent), opened?.(); + else loadSettings().then(() => slots[0].isConnected && (mountProvPrefs(slots, agent), opened?.()), () => {}); return slots.flatMap((x) => x.fieldRow); } // a provider's settings found by Settings' search, drawn by provlinks.js @@ -20172,8 +20178,7 @@ function renderSettings() { (v) => savePrefs({ ...keep, codexWarmAts: v, codexWarmAt: v[0] || "" })); renderWarmAt($("#claudeWarmAtSegs"), $("#claudeWarmAtSub"), warmTimes(s.claudeWarmAts, s.claudeWarmAt), s.claudeWarmup, t("Sent through Claude Code."), (v) => savePrefs({ ...keep, claudeWarmAts: v, claudeWarmAt: v[0] || "" })); - renderWarmAtOwn(s); - renderAutoResetOwn(s); + renderAutoResetOwn(s); // and each account's own warm-up time renderWarmNow("codex", s.codexUsers, "#warmNowRow"); renderWarmNow("claude", s.claudeUsers, "#claudeWarmNowRow"); // each built-in vendor's daily check-in, shown while one of its @@ -21151,60 +21156,12 @@ function renderWarmAt(box, sub, ats, onReset, via, save) { box.append(segs([["off", t("Off")], ["on", t("On")]], ats.length ? "on" : "off", (v) => save(v === "on" ? (ats.length ? ats : ["06:00"]) : []))); } -// Settings › Usage's Codex auto-use rows, drawn by autoresetown.js +// Codex's auto-use rows and each account's own warm-up time, drawn by autoresetown.js function renderAutoResetOwn(s) { if (window.autoResetOwnPaint) return autoResetOwnPaint(s); import("./autoresetown.js").then(() => autoResetOwnPaint(s), statusErr); } -// renderWarmAtOwn: each ChatGPT account's own daily time (#957, -// codexWarmAtOf), shown with two accounts or one with its own -function renderWarmAtOwn(s) { - const list = $("#codexWarmList"); - list.querySelectorAll(".warm-own").forEach((r) => r.remove()); - const own = s.codexWarmAtOf || {}; - const users = [...(s.codexUsers || [])]; - for (const u of Object.keys(own)) if (!users.some((x) => x.toLowerCase() === u)) users.push(u); - if (users.length < 2 && !Object.keys(own).length) return; - const save = async (user, at) => { - try { - prefs = await writingPrefs(api("settings/codex-warm-at", { user, at })); - if (state) state.settings = prefs; - renderSettings(); - } catch (e) { - statusTErr(e); - renderSettings(); - } - }; - for (const user of users) { - const at = own[user.toLowerCase()]; - const mode = at === undefined ? "same" : at === "off" ? "off" : "own"; - const r = el("div", "row pref warm-own"); - r.dataset.user = user; - const who = el("div", "who"); - const name = el("div", "name", user); - name.title = user; - const sub = el("div", "sub", mode === "own" ? t("Its own time each day") - : mode === "off" ? t("Not started at a time of day") - : s.codexWarmAt ? t("Same as above, {at}", { at: warmTimes(s.codexWarmAts, s.codexWarmAt).join(", ") }) : t("Same as above, off")); - sub.title = t("Give accounts different times and one window starts as another runs out."); - who.append(name, sub); - const box = el("div", "warm-at"); - if (mode === "own") { - const i = input(at, "06:00", "time"); - i.className = "at"; - i.setAttribute("aria-label", t("{who}'s time of day", { who: user })); - blurOnEnter(i); - i.onchange = () => { if (i.value && i.value !== at) save(user, i.value); }; - box.append(i); - } - box.append(segs([["same", t("Same")], ["own", t("Own")], ["off", t("Off")]], mode, (v) => - save(user, v === "same" ? "" : v === "off" ? "off" : s.codexWarmAt || "06:00"))); - r.append(who, box); - $("#warmNowRow").before(r); // Warm up now stays last - } -} - // renderWarmNow is Warm up now: the scheduled warm-up's request to one account at once const warmNowSaid = {}; function renderWarmNow(agent, users, rowId) { diff --git a/internal/gui/assets/autoresetown.js b/internal/gui/assets/autoresetown.js index 30df8e533..0b468cb82 100644 --- a/internal/gui/assets/autoresetown.js +++ b/internal/gui/assets/autoresetown.js @@ -1,7 +1,8 @@ // Codex's auto-use rows, in its provider's editor (PROV_PREFS): each ChatGPT account's switches // and, under them, how early a reset about to expire is used. app.js // imports this when renderSettings draws them (renderAutoResetOwn), so it weighs -// nothing on the core. +// nothing on the core. Each ChatGPT account's own warm-up time is drawn here too +// (warmAtOwnPaint), moved out of app.js for its budget. // renderAutoResetOwn lists each ChatGPT account under // "Codex: auto-use resets", with its switch, the same say as on the @@ -10,6 +11,7 @@ // window's Settings. The row shows while a Codex // account is signed in, or one is still on. window.autoResetOwnPaint = function (s) { + warmAtOwnPaint(s); const head = $("#codexAutoResetRow"); const list = head.parentElement; list.querySelectorAll(".ar-own").forEach((r) => r.remove()); @@ -149,3 +151,51 @@ function resetLeadOwn(b, cur, set) { b.replaceWith(i); i.focus(NO_SCROLL); } + +// warmAtOwnPaint: each ChatGPT account's own daily time (#957, +// codexWarmAtOf), shown with two accounts or one with its own +function warmAtOwnPaint(s) { + const list = $("#codexWarmList"); + list.querySelectorAll(".warm-own").forEach((r) => r.remove()); + const own = s.codexWarmAtOf || {}; + const users = [...(s.codexUsers || [])]; + for (const u of Object.keys(own)) if (!users.some((x) => x.toLowerCase() === u)) users.push(u); + if (users.length < 2 && !Object.keys(own).length) return; + const save = async (user, at) => { + try { + prefs = await writingPrefs(api("settings/codex-warm-at", { user, at })); + if (state) state.settings = prefs; + renderSettings(); + } catch (e) { + statusTErr(e); + renderSettings(); + } + }; + for (const user of users) { + const at = own[user.toLowerCase()]; + const mode = at === undefined ? "same" : at === "off" ? "off" : "own"; + const r = el("div", "row pref warm-own"); + r.dataset.user = user; + const who = el("div", "who"); + const name = el("div", "name", user); + name.title = user; + const sub = el("div", "sub", mode === "own" ? t("Its own time each day") + : mode === "off" ? t("Not started at a time of day") + : s.codexWarmAt ? t("Same as above, {at}", { at: warmTimes(s.codexWarmAts, s.codexWarmAt).join(", ") }) : t("Same as above, off")); + sub.title = t("Give accounts different times and one window starts as another runs out."); + who.append(name, sub); + const box = el("div", "warm-at"); + if (mode === "own") { + const i = input(at, "06:00", "time"); + i.className = "at"; + i.setAttribute("aria-label", t("{who}'s time of day", { who: user })); + blurOnEnter(i); + i.onchange = () => { if (i.value && i.value !== at) save(user, i.value); }; + box.append(i); + } + box.append(segs([["same", t("Same")], ["own", t("Own")], ["off", t("Off")]], mode, (v) => + save(user, v === "same" ? "" : v === "off" ? "off" : s.codexWarmAt || "06:00"))); + r.append(who, box); + $("#warmNowRow").before(r); // Warm up now stays last + } +} diff --git a/internal/gui/core_budget_test.go b/internal/gui/core_budget_test.go index 16475a431..0f4b29a4e 100644 --- a/internal/gui/core_budget_test.go +++ b/internal/gui/core_budget_test.go @@ -17,8 +17,8 @@ import ( // never what pays for a change (#5918); the history of each number is in // `git log -L` of this file. const ( - appScriptBudget = 1_089_622 // app.js: 1,080,614 at 8016205e3, with the 5,653 of room it had; +123 for a sidebar list folded from its page's row (hkwok06 on X), its chevron and fold in navicons.js, imported with the first list; +57 for each account of a provider's Usage card in a card of its own (normalcoder_ on X), past the 24 of room left; +17 for an allowance card's wallet line under its rings (apple_test_src on X), the one filter shared with its text line; +338 for the Daily update channel (fishmagic80 on X): its segment, its line under Update channel and the version row's two Up to date on Daily words, packed to the shortest form (one t() per choice); Settings › About and renderUpdate draw them on every window, so there is no page to move them to; +35 for Baidu Qianfan's Token Plan sign-in (yuushabu_buyinn on X, #5860): its field in qianfanplan.js, imported when such a provider's editor opens, drawn by renderStepPlan now told whose sign-in it brings, and what is left is the import and two quotaError lines, past the room there was; quotaError reads every card's error, so there is no page to move it to; +27 for Windows' title bar (258a14 on X): the caption buttons, their clicks, the bar's double click and what keeps them over a dialog in wincap.js, imported in Windows' window alone, the header's room for them in app.css, and what is left is the one line that imports it, past the 29 of room there was; that window's frame is drawn on every start, so there is no page to move it to; +107 for the pages in the reader's own order (chet030714 on X): the order, the sidebar and tab bar put in it, and the menu's drag and keys in navorder.js and navpages.js, imported once an order is kept or Settings draws, and what is left is the one line in navHides that imports it; navHides runs on every start, so there is no page to move it to; +275 for the grants Alibaba's Token Plan asks of a RAM user's AccessKey in the reader's language (MetalHqa on X): one string (ALI_RAM) shown under the editor's AccessKey ID and on the card that names them, less the 48 of the wrong "a RAM user that may use Model Studio is enough" it replaces; the editor and quotaError draw them on every window, so there is no page to move them to; +135 for a model test its vendor queued shown queued and not green (sufeng1894 on X): queuedSaid, one string shared by the chip's title, Test models' and Test this model's status, and the chip's amber dot; renderModels draws the provider editor's chips, so there is no page to move it to; +66 for AstrLink Guard's row saying an x64 magpie runs it under Windows on Arm's emulation until the next update installs the Arm build (EV_John_Liu on X), the Rosetta line's sibling, one line in pmSub; the Privacy rows draw it, so there is no page to move it to; +864 for Use on a Claude setup-token account, which switches Claude Code itself to it in its settings.json, and Use back on its signed-in account (liukaybee on X): one swUse helper shared by both buttons, packed to the shortest form; renderAccounts draws every account row, so there is no page to move it to; +1 for the classifier timeout's unset default, 15 and not 8 (ESern29751 on X): its second digit in the Settings row's fallback, which renderReplies draws, so there is no page to move it to; +457 for Kimi Code's subagent pool and its effort (XiaoLing_Arisa on X): the Subagents line and its pool menu in kimisub.js, imported before a Kimi Code row's Details first slides open so it measures the line, and what is left is that import, the line's place, the three fields kept out of the row's squares and the picker's note that Kimi's subagents run on the lead's model, packed to the shortest form; renderAgents draws every row, so there is no page to move it to; +354 for Images per request (#6849, Yuu_jiang_ on X): its field and parse are in maximages.js, imported as the editor draws Max output, and what stays is the import, the two saves' lines and the check that the editor is still open when it and keyrates.js land, no page to move them to; +499 for Speed beside Model and Effort in an agent's opened row (Tengs999 on X): the line, its menu and what decides the speed in agentspeed.js, imported before a fast model's Details first slides open so it measures the line, and what is left is that import and the line's place in the panel's and the window's rows, packed to one helper; renderAgents draws every row, so there is no page to move it to - coreScriptBudget = 1_273_901 // every core script at 8016205e3, the old measure 682 over its cap there (#5918); +367 for the model test on a chosen account (tmr11235), no page left to move it to; +151 for the provider menu's "Only on this device" item and its four translations; +458 for Settings › About's Report a problem row and its translations; +113 for withScheme, the one rule every typed address goes through (eachg0 on X), cut to the shortest form that keeps it whole; +10 for the kept whole's tooltip (Musikrv77852 on X), the past-cycle line reused for it, no page left to move it to; +1,112 for Codex's Open button and its Open Codex with menu (Yink88564391 on X), packed to the shortest form, no page left to move them to; +168 for Discover's long lists drawn in part (the owner, 11-13), after the rest of its hook moved into plugingrid.js, imported when Plugins first draws; +296 for the cap toggle and Smart sentences that say what they do and the Sign in on another computer row (Wing8Aqua on X), packed to the shortest form, no page left to move them to; +333 for In turn's figure in a provider's editor and its words naming the message that goes round (Wing8Aqua on X), the figure itself in rotfig.js, imported when In turn is first shown, the hook packed to the shortest form; +236 for a lone capped Codex account's row saying its turns go to the fallbacks when Codex is connected (not_4O4 on X), the two helpers inlined, no page left to move it to; +717 for omp's advisor (Awad_Yoo on X, #6408): its three rows moved into ompadvisor.js, imported when an omp's settings show, and what is left is the import, the role's " · off" and the Settings line's name, packed to the shortest form; +468 for a plugin's own file import (auth.import) in the import sheet, in the plugin's words (marchen_cc on X), packed to one statement; importSay is read as the Providers rows draw, so it has no lazy page to go to, and nothing else was moved out; +180 for Claude Magpie's own Claude Code folder (xMopf7RF on X, #6459): its Advanced fold in claudemagpie.js, imported when it first shows, and what is left is the import and the fold's place in the Separate app line, 216 bytes packed to the shortest form, less the 36 of room there was; +81 for the Use Claude Magpie button on Claude Desktop's row (xMopf7RF on X), drawn by claudemagpie.js too, what is left the one line that places it (#2710); +225 for the Hermes row's Other profiles lines (Norethcy on X), which 1d60b165c took out while each profile had a row and c96f33d65 left with no place at all, packed to the shortest form; the dead hermes# Default note went with it, and the Agents rows draw it, so there is no page to move it to; +397 for a key's own price rate (tnt12231 on X): its lines, check and placeholder in keyrates.js, imported when a provider with two or more keys opens, and what is left is the import, the draft's copy, Advanced opening for it, the save's one line and proxyLines drawing another kind of line; +316 for an image or video model's chip saying what it makes from its right-click (iceloon on X): the chat chip's Makes… now shared with it, and the media chip's Copy model ID left out, packed to the shortest form; the provider's editor draws it, so there is no page to move it to; +67 for the Claude Code · Claude Magpie row saying it is on magpie through Claude Magpie (xMopf7RF on X), one line in connectLine with the shortest words that say it; the Agents rows draw it, so there is no page to move it to; +12 for AIGoCode's logo in pngIcons (MindfulReturn on X), the list every drawn icon is looked up in; +491 for each cost in the tray panel's and Requests' chart and ranking in its own provider's currency (onkashiko on X): ledProv and the provider passed through, packed to the shortest form; drawLedColumns and drawLedRank are shared by the panel, so there is no page to move it to; +326 for the Qwen AI platform's Token Plan sign-in (imthe99galaxy on X): its field, sign-in and wait in qianwenplan.js, imported when such a provider's editor opens, and what is left is the import and one quotaError line for its two refusals, packed to the shortest form; quotaError reads every card's error, so there is no page to move it to; +72 for Copy all keys (emilochen on X): its row in keyrates.js, imported when a provider with two or more keys opens through keyRateField, now told which of its parts to draw, and what is left is the one line that places it; +83 for the page saying it has gone from view, so what its Sessions and Usage pages keep goes in 30 s and not 7 minutes (P0 memory): folded into the visibilitychange listener every window has, packed to the shortest form, so there is no page to move it to; +270 for Providers' Select, to remove several at once (eiyuuzaki2333 on X): its rows, bar, removal and keys in pvpick.js, imported when Select is first clicked, and what is left is pvSel, the button's click and two lines in renderProviders, which draws the list, so there is no page to move it to; +81 for each account of a provider's Usage card in a card of its own (normalcoder_ on X): one line that makes the box, its brief look left to CSS, and renderQuotas, which draws every card, so there is no page to move it to; +17 for Kimi Code's booster balance under an allowance card's rings in the tray panel (apple_test_src on X): the card's text line and the wallet line share one filter, packed to the shortest form; panelQuotaCard draws every card, so there is no page to move it to; +51 for what a failed plugin install left in plugins/, listed under Installed with a Remove (CHENGJIAHEGOXIS on X): its section in plugininstalled.js as pmLeftovers, imported when Plugins first draws, and what is left is the one call after drawInstalled; draw is what draws the page, so there is no page to move it to; +123 for a sidebar list folded from its page's row (hkwok06 on X): the chevron, its click and the fold kept per page in navicons.js, imported with the first list, and what is left is the folded list read beside the hidden pages' (navList, which navMine now shares) and the two rows' clicks asking navFold first; navSubs draws every list, so there is no page to move it to; +338 for the Daily update channel (fishmagic80 on X): its segment, its line under Update channel and the version row's two Up to date on Daily words, packed to the shortest form (one t() per choice); Settings › About and renderUpdate draw them on every window, so there is no page to move them to; +35 for Baidu Qianfan's Token Plan sign-in (yuushabu_buyinn on X, #5860): its field in qianfanplan.js, imported when such a provider's editor opens, drawn by renderStepPlan now told whose sign-in it brings, and what is left is the import and two quotaError lines, past the room there was; quotaError reads every card's error, so there is no page to move it to; +27 for Windows' title bar (258a14 on X): the caption buttons, their clicks, the bar's double click and what keeps them over a dialog in wincap.js, imported in Windows' window alone, the header's room for them in app.css, and what is left is the one line that imports it, past the 29 of room there was; that window's frame is drawn on every start, so there is no page to move it to; +107 for the pages in the reader's own order (chet030714 on X): the order, the sidebar and tab bar put in it, and the menu's drag and keys in navorder.js and navpages.js, imported once an order is kept or Settings draws, and what is left is the one line in navHides that imports it; navHides runs on every start, so there is no page to move it to; +275 for the grants Alibaba's Token Plan asks of a RAM user's AccessKey in the reader's language (MetalHqa on X): one string (ALI_RAM) shown under the editor's AccessKey ID and on the card that names them, less the 48 of the wrong "a RAM user that may use Model Studio is enough" it replaces; the editor and quotaError draw them on every window, so there is no page to move them to; +135 for a model test its vendor queued shown queued and not green (sufeng1894 on X): queuedSaid, one string shared by the chip's title, Test models' and Test this model's status, and the chip's amber dot; renderModels draws the provider editor's chips, so there is no page to move it to; +66 for AstrLink Guard's row saying an x64 magpie runs it under Windows on Arm's emulation until the next update installs the Arm build (EV_John_Liu on X), the Rosetta line's sibling, one line in pmSub; the Privacy rows draw it, so there is no page to move it to; +189 for Let magpie set it on a Codex card locked by config.toml's own compact limit or background threshold (sufeng1894 on X), and Undo for a background share taken over: the shared send posts it, packed to the shortest form; adviceRow draws every card, so there is no page to move it to; +864 for Use on a Claude setup-token account, which switches Claude Code itself to it in its settings.json, and Use back on its signed-in account (liukaybee on X): one swUse helper shared by both buttons, packed to the shortest form; renderAccounts draws every account row, so there is no page to move it to; +1 for the classifier timeout's unset default, 15 and not 8 (ESern29751 on X): its second digit in the Settings row's fallback, which renderReplies draws, so there is no page to move it to; +457 for Kimi Code's subagent pool and its effort (XiaoLing_Arisa on X): the Subagents line and its pool menu in kimisub.js, imported before a Kimi Code row's Details first slides open so it measures the line, and what is left is that import, the line's place, the three fields kept out of the row's squares and the picker's note that Kimi's subagents run on the lead's model, packed to the shortest form; renderAgents draws every row, so there is no page to move it to; +354 for Images per request (#6849, Yuu_jiang_ on X): its field and parse are in maximages.js, imported as the editor draws Max output, and what stays is the import, the two saves' lines and the check that the editor is still open when it and keyrates.js land, no page to move them to; +499 for Speed beside Model and Effort in an agent's opened row (Tengs999 on X): the line, its menu and what decides the speed in agentspeed.js, imported before a fast model's Details first slides open so it measures the line, and what is left is that import and the line's place in the panel's and the window's rows, packed to one helper; renderAgents draws every row, so there is no page to move it to + appScriptBudget = 1_088_093 // app.js: 1,080,614 at 8016205e3, with the 5,653 of room it had; +123 for a sidebar list folded from its page's row (hkwok06 on X), its chevron and fold in navicons.js, imported with the first list; +57 for each account of a provider's Usage card in a card of its own (normalcoder_ on X), past the 24 of room left; +17 for an allowance card's wallet line under its rings (apple_test_src on X), the one filter shared with its text line; +338 for the Daily update channel (fishmagic80 on X): its segment, its line under Update channel and the version row's two Up to date on Daily words, packed to the shortest form (one t() per choice); Settings › About and renderUpdate draw them on every window, so there is no page to move them to; +35 for Baidu Qianfan's Token Plan sign-in (yuushabu_buyinn on X, #5860): its field in qianfanplan.js, imported when such a provider's editor opens, drawn by renderStepPlan now told whose sign-in it brings, and what is left is the import and two quotaError lines, past the room there was; quotaError reads every card's error, so there is no page to move it to; +27 for Windows' title bar (258a14 on X): the caption buttons, their clicks, the bar's double click and what keeps them over a dialog in wincap.js, imported in Windows' window alone, the header's room for them in app.css, and what is left is the one line that imports it, past the 29 of room there was; that window's frame is drawn on every start, so there is no page to move it to; +107 for the pages in the reader's own order (chet030714 on X): the order, the sidebar and tab bar put in it, and the menu's drag and keys in navorder.js and navpages.js, imported once an order is kept or Settings draws, and what is left is the one line in navHides that imports it; navHides runs on every start, so there is no page to move it to; +275 for the grants Alibaba's Token Plan asks of a RAM user's AccessKey in the reader's language (MetalHqa on X): one string (ALI_RAM) shown under the editor's AccessKey ID and on the card that names them, less the 48 of the wrong "a RAM user that may use Model Studio is enough" it replaces; the editor and quotaError draw them on every window, so there is no page to move them to; +135 for a model test its vendor queued shown queued and not green (sufeng1894 on X): queuedSaid, one string shared by the chip's title, Test models' and Test this model's status, and the chip's amber dot; renderModels draws the provider editor's chips, so there is no page to move it to; +66 for AstrLink Guard's row saying an x64 magpie runs it under Windows on Arm's emulation until the next update installs the Arm build (EV_John_Liu on X), the Rosetta line's sibling, one line in pmSub; the Privacy rows draw it, so there is no page to move it to; +864 for Use on a Claude setup-token account, which switches Claude Code itself to it in its settings.json, and Use back on its signed-in account (liukaybee on X): one swUse helper shared by both buttons, packed to the shortest form; renderAccounts draws every account row, so there is no page to move it to; +1 for the classifier timeout's unset default, 15 and not 8 (ESern29751 on X): its second digit in the Settings row's fallback, which renderReplies draws, so there is no page to move it to; +457 for Kimi Code's subagent pool and its effort (XiaoLing_Arisa on X): the Subagents line and its pool menu in kimisub.js, imported before a Kimi Code row's Details first slides open so it measures the line, and what is left is that import, the line's place, the three fields kept out of the row's squares and the picker's note that Kimi's subagents run on the lead's model, packed to the shortest form; renderAgents draws every row, so there is no page to move it to; +354 for Images per request (#6849, Yuu_jiang_ on X): its field and parse are in maximages.js, imported as the editor draws Max output, and what stays is the import, the two saves' lines and the check that the editor is still open when it and keyrates.js land, no page to move them to; +499 for Speed beside Model and Effort in an agent's opened row (Tengs999 on X): the line, its menu and what decides the speed in agentspeed.js, imported before a fast model's Details first slides open so it measures the line, and what is left is that import and the line's place in the panel's and the window's rows, packed to one helper; renderAgents draws every row, so there is no page to move it to; -1,529: each ChatGPT account's own warm-up time (renderWarmAtOwn) moved into autoresetown.js, imported when its rows first draw, paying for a provider's editor opening Advanced when its warm-up or check-in is on (ChrisYagao on X), and the room left over given back + coreScriptBudget = 1_272_372 // every core script at 8016205e3, the old measure 682 over its cap there (#5918); +367 for the model test on a chosen account (tmr11235), no page left to move it to; +151 for the provider menu's "Only on this device" item and its four translations; +458 for Settings › About's Report a problem row and its translations; +113 for withScheme, the one rule every typed address goes through (eachg0 on X), cut to the shortest form that keeps it whole; +10 for the kept whole's tooltip (Musikrv77852 on X), the past-cycle line reused for it, no page left to move it to; +1,112 for Codex's Open button and its Open Codex with menu (Yink88564391 on X), packed to the shortest form, no page left to move them to; +168 for Discover's long lists drawn in part (the owner, 11-13), after the rest of its hook moved into plugingrid.js, imported when Plugins first draws; +296 for the cap toggle and Smart sentences that say what they do and the Sign in on another computer row (Wing8Aqua on X), packed to the shortest form, no page left to move them to; +333 for In turn's figure in a provider's editor and its words naming the message that goes round (Wing8Aqua on X), the figure itself in rotfig.js, imported when In turn is first shown, the hook packed to the shortest form; +236 for a lone capped Codex account's row saying its turns go to the fallbacks when Codex is connected (not_4O4 on X), the two helpers inlined, no page left to move it to; +717 for omp's advisor (Awad_Yoo on X, #6408): its three rows moved into ompadvisor.js, imported when an omp's settings show, and what is left is the import, the role's " · off" and the Settings line's name, packed to the shortest form; +468 for a plugin's own file import (auth.import) in the import sheet, in the plugin's words (marchen_cc on X), packed to one statement; importSay is read as the Providers rows draw, so it has no lazy page to go to, and nothing else was moved out; +180 for Claude Magpie's own Claude Code folder (xMopf7RF on X, #6459): its Advanced fold in claudemagpie.js, imported when it first shows, and what is left is the import and the fold's place in the Separate app line, 216 bytes packed to the shortest form, less the 36 of room there was; +81 for the Use Claude Magpie button on Claude Desktop's row (xMopf7RF on X), drawn by claudemagpie.js too, what is left the one line that places it (#2710); +225 for the Hermes row's Other profiles lines (Norethcy on X), which 1d60b165c took out while each profile had a row and c96f33d65 left with no place at all, packed to the shortest form; the dead hermes# Default note went with it, and the Agents rows draw it, so there is no page to move it to; +397 for a key's own price rate (tnt12231 on X): its lines, check and placeholder in keyrates.js, imported when a provider with two or more keys opens, and what is left is the import, the draft's copy, Advanced opening for it, the save's one line and proxyLines drawing another kind of line; +316 for an image or video model's chip saying what it makes from its right-click (iceloon on X): the chat chip's Makes… now shared with it, and the media chip's Copy model ID left out, packed to the shortest form; the provider's editor draws it, so there is no page to move it to; +67 for the Claude Code · Claude Magpie row saying it is on magpie through Claude Magpie (xMopf7RF on X), one line in connectLine with the shortest words that say it; the Agents rows draw it, so there is no page to move it to; +12 for AIGoCode's logo in pngIcons (MindfulReturn on X), the list every drawn icon is looked up in; +491 for each cost in the tray panel's and Requests' chart and ranking in its own provider's currency (onkashiko on X): ledProv and the provider passed through, packed to the shortest form; drawLedColumns and drawLedRank are shared by the panel, so there is no page to move it to; +326 for the Qwen AI platform's Token Plan sign-in (imthe99galaxy on X): its field, sign-in and wait in qianwenplan.js, imported when such a provider's editor opens, and what is left is the import and one quotaError line for its two refusals, packed to the shortest form; quotaError reads every card's error, so there is no page to move it to; +72 for Copy all keys (emilochen on X): its row in keyrates.js, imported when a provider with two or more keys opens through keyRateField, now told which of its parts to draw, and what is left is the one line that places it; +83 for the page saying it has gone from view, so what its Sessions and Usage pages keep goes in 30 s and not 7 minutes (P0 memory): folded into the visibilitychange listener every window has, packed to the shortest form, so there is no page to move it to; +270 for Providers' Select, to remove several at once (eiyuuzaki2333 on X): its rows, bar, removal and keys in pvpick.js, imported when Select is first clicked, and what is left is pvSel, the button's click and two lines in renderProviders, which draws the list, so there is no page to move it to; +81 for each account of a provider's Usage card in a card of its own (normalcoder_ on X): one line that makes the box, its brief look left to CSS, and renderQuotas, which draws every card, so there is no page to move it to; +17 for Kimi Code's booster balance under an allowance card's rings in the tray panel (apple_test_src on X): the card's text line and the wallet line share one filter, packed to the shortest form; panelQuotaCard draws every card, so there is no page to move it to; +51 for what a failed plugin install left in plugins/, listed under Installed with a Remove (CHENGJIAHEGOXIS on X): its section in plugininstalled.js as pmLeftovers, imported when Plugins first draws, and what is left is the one call after drawInstalled; draw is what draws the page, so there is no page to move it to; +123 for a sidebar list folded from its page's row (hkwok06 on X): the chevron, its click and the fold kept per page in navicons.js, imported with the first list, and what is left is the folded list read beside the hidden pages' (navList, which navMine now shares) and the two rows' clicks asking navFold first; navSubs draws every list, so there is no page to move it to; +338 for the Daily update channel (fishmagic80 on X): its segment, its line under Update channel and the version row's two Up to date on Daily words, packed to the shortest form (one t() per choice); Settings › About and renderUpdate draw them on every window, so there is no page to move them to; +35 for Baidu Qianfan's Token Plan sign-in (yuushabu_buyinn on X, #5860): its field in qianfanplan.js, imported when such a provider's editor opens, drawn by renderStepPlan now told whose sign-in it brings, and what is left is the import and two quotaError lines, past the room there was; quotaError reads every card's error, so there is no page to move it to; +27 for Windows' title bar (258a14 on X): the caption buttons, their clicks, the bar's double click and what keeps them over a dialog in wincap.js, imported in Windows' window alone, the header's room for them in app.css, and what is left is the one line that imports it, past the 29 of room there was; that window's frame is drawn on every start, so there is no page to move it to; +107 for the pages in the reader's own order (chet030714 on X): the order, the sidebar and tab bar put in it, and the menu's drag and keys in navorder.js and navpages.js, imported once an order is kept or Settings draws, and what is left is the one line in navHides that imports it; navHides runs on every start, so there is no page to move it to; +275 for the grants Alibaba's Token Plan asks of a RAM user's AccessKey in the reader's language (MetalHqa on X): one string (ALI_RAM) shown under the editor's AccessKey ID and on the card that names them, less the 48 of the wrong "a RAM user that may use Model Studio is enough" it replaces; the editor and quotaError draw them on every window, so there is no page to move them to; +135 for a model test its vendor queued shown queued and not green (sufeng1894 on X): queuedSaid, one string shared by the chip's title, Test models' and Test this model's status, and the chip's amber dot; renderModels draws the provider editor's chips, so there is no page to move it to; +66 for AstrLink Guard's row saying an x64 magpie runs it under Windows on Arm's emulation until the next update installs the Arm build (EV_John_Liu on X), the Rosetta line's sibling, one line in pmSub; the Privacy rows draw it, so there is no page to move it to; +189 for Let magpie set it on a Codex card locked by config.toml's own compact limit or background threshold (sufeng1894 on X), and Undo for a background share taken over: the shared send posts it, packed to the shortest form; adviceRow draws every card, so there is no page to move it to; +864 for Use on a Claude setup-token account, which switches Claude Code itself to it in its settings.json, and Use back on its signed-in account (liukaybee on X): one swUse helper shared by both buttons, packed to the shortest form; renderAccounts draws every account row, so there is no page to move it to; +1 for the classifier timeout's unset default, 15 and not 8 (ESern29751 on X): its second digit in the Settings row's fallback, which renderReplies draws, so there is no page to move it to; +457 for Kimi Code's subagent pool and its effort (XiaoLing_Arisa on X): the Subagents line and its pool menu in kimisub.js, imported before a Kimi Code row's Details first slides open so it measures the line, and what is left is that import, the line's place, the three fields kept out of the row's squares and the picker's note that Kimi's subagents run on the lead's model, packed to the shortest form; renderAgents draws every row, so there is no page to move it to; +354 for Images per request (#6849, Yuu_jiang_ on X): its field and parse are in maximages.js, imported as the editor draws Max output, and what stays is the import, the two saves' lines and the check that the editor is still open when it and keyrates.js land, no page to move them to; +499 for Speed beside Model and Effort in an agent's opened row (Tengs999 on X): the line, its menu and what decides the speed in agentspeed.js, imported before a fast model's Details first slides open so it measures the line, and what is left is that import and the line's place in the panel's and the window's rows, packed to one helper; renderAgents draws every row, so there is no page to move it to; -1,529: each ChatGPT account's own warm-up time moved into autoresetown.js, paying for Advanced opening on a warm-up or check-in that is on (ChrisYagao on X), the room left over given back ) // codeBytes is how many bytes of b are code: its blank lines, its lines diff --git a/internal/gui/tests/reader.cjs b/internal/gui/tests/reader.cjs index 328c60766..9e7d14306 100644 --- a/internal/gui/tests/reader.cjs +++ b/internal/gui/tests/reader.cjs @@ -244,6 +244,11 @@ async function openProvPrefs(page, id) { 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 }); + // and the editor at rest: with a warm-up or check-in on, Advanced opens + // on its own, so no click waits out the modal's opening and a row read + // now is read mid-scale (warm-at-times, WebKit 900px, 0.66px over) + await page.waitForFunction(() => !document.querySelector("#modal").getAnimations({ subtree: true }) + .some((a) => a.playState === "running" && a.effect?.getComputedTiming().endTime !== Infinity), null, { 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 diff --git a/internal/gui/tests/warm-advanced.test.cjs b/internal/gui/tests/warm-advanced.test.cjs new file mode 100644 index 000000000..e3d2d9eb8 --- /dev/null +++ b/internal/gui/tests/warm-advanced.test.cjs @@ -0,0 +1,87 @@ +// Run with Node's test runner and Playwright on the module path; see README.md. +// "我的预热去哪里了??" (ChrisYagao on X): a subscription's warm-up and +// daily check-in moved from Settings into its provider's editor (11-09) and +// then under the editor's Advanced, folded (11-10), so a user who had one +// on opened the editor and saw nothing of it. Advanced now opens on its own +// when the provider's warm-up (on reset or at times of day) or its daily +// check-in is on, as it does for Routing; with them off it stays folded, +// and a fold the reader closed by hand stays closed. Codex, Claude Code and +// a plugin that checks in; en, zh, zh-TW, ja, de; both engines; the API is +// faked here. +const assert = require("node:assert/strict"); +const fs = require("node:fs/promises"); +const path = require("node:path"); +const { test } = require("node:test"); +const { chromium, webkit } = require("playwright"); +const { provPrefsProviders } = require("./reader.cjs"); + +const assets = path.resolve(__dirname, "../assets"); +const names = { codex: "Codex", claude: "Claude Code", "trae-cn": "Trae CN" }; + +function serve(lang, settings) { + const s = { theme: "light", lang, currency: "usd", codexWarmup: "", claudeWarmup: "", codexUsers: ["ann@example.test"], claudeUsers: ["ann@example.test"], + checkinPlugins: [{ id: "trae-cn", name: "Trae CN", on: false }], ...settings }; + 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:"${lang}",theme:"light",web: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: s }); + if (url.pathname === "/api/settings") return json(s); + if (url.pathname === "/api/providers") return json(provPrefsProviders(Object.keys(names), names)); + if (url.pathname === "/api/groups") return json({ groups: [], models: [] }); + if (url.pathname === "/api/plugins") return json({ plugins: [] }); + if (url.pathname.startsWith("/api/")) return json({}); + const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname); + const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)]; + try { await route.fulfill({ body: await fs.readFile(file), contentType }); } catch { await route.fulfill({ status: 404, body: "" }); } + }; +} + +// provider, what is set, whether Advanced opens and the list that shows +const CASES = [ + ["codex", "nothing", {}, false, "#codexWarmList"], + ["codex", "warm up on reset", { codexWarmup: "week" }, true, "#codexWarmList"], + ["codex", "daily warm-up", { codexWarmAts: ["06:00"], codexWarmAt: "06:00" }, true, "#codexWarmList"], + ["claude", "nothing", {}, false, "#claudeWarmList"], + ["claude", "warm up on reset", { claudeWarmup: "all" }, true, "#claudeWarmList"], + ["claude", "daily warm-up", { claudeWarmAts: ["07:30"], claudeWarmAt: "07:30" }, true, "#claudeWarmList"], + ["claude", "Codex's warm-up only", { codexWarmup: "week" }, false, "#claudeWarmList"], + ["trae-cn", "nothing", {}, false, ".ci-plugin"], + ["trae-cn", "daily check-in", { checkinPlugins: [{ id: "trae-cn", name: "Trae CN", on: true }] }, true, ".ci-plugin"], +]; + +for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) { + for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) { + test(`${engine} ${lang}: a provider's warm-up or check-in that is on opens its editor's Advanced (ChrisYagao)`, async (t) => { + const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" })); + t.after(() => browser.close()); + for (const [id, set, settings, opens, list] of CASES) { + const at = `${id}, ${set}`; + const page = await (await browser.newContext({ viewport: { width: 900, height: 760 }, reducedMotion: "reduce" })).newPage(); + page.setDefaultTimeout(5000); + page.setDefaultNavigationTimeout(60000); + const errors = []; + page.on("pageerror", (e) => { if (engine === "webkit" && /due to access control checks/.test(e.message)) return; errors.push(e.message); }); // #1350 + await page.route("**/*", serve(lang, settings)); + await page.goto(`http://magpie.test/?view=providers&edit=${encodeURIComponent(id)}`); + const adv = page.locator(".editor details.advanced"); + await adv.waitFor({ timeout: 60000 }); + // the lists are mounted once Settings are read + await page.waitForFunction((list) => !!document.querySelector(`.editor .prov-prefs ${list}`), list); + assert.equal(await adv.evaluate((d) => d.open), opens, `${at}: Advanced open`); + assert.equal(await page.locator(`.editor .prov-prefs ${list}`).first().isVisible(), opens, `${at}: its list shown`); + if (opens) { + // closed by hand, a redraw of Settings leaves it closed + await adv.locator(":scope > summary").click(); + await page.waitForFunction(() => !document.querySelector(".editor details.advanced").open); + await page.evaluate(() => renderSettings()); + await page.waitForTimeout(100); + assert.equal(await adv.evaluate((d) => d.open), false, `${at}: closed by hand stays closed`); + } + assert.deepEqual(errors, [], at); + await page.context().close(); + } + }); + } +}