Files
magpie/internal/gui/assets/provlinks.js
T
yetone b03a374763 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.
2026-11-10 07:08:02 +08:00

51 lines
2.4 KiB
JavaScript

// Settings' search finds a provider's own settings (Codex's reset and
// warm-up, Claude's warm-up, a plugin's check-in) by these rows, each
// opening the provider's editor. They show only while searching, so
// app.js imports this when a search first wants them, and it weighs
// nothing on the core. A row goes with its list's plugin (warm-ups), and
// with no such provider to open (findSettings, by its agents).
window.provPrefLinksDraw = function () {
const box = $("#provPrefLinks");
box.replaceChildren();
const ids = [...new Set(Object.values(PROV_PREFS).flat())];
const by = (list) => list.classList.contains("ci-plugin") ? [list.dataset.provider] : Object.keys(PROV_PREFS).filter((k) => PROV_PREFS[k].includes(list.id));
for (const list of [...ids.map((id) => $("#" + id)), ...$("#pluginCheckinList").children]) {
if (!list || list.hidden) continue;
const agents = by(list);
for (const r of list.querySelectorAll(":scope > .row.pref:not(.ci-acct):not(.ci-now-row):not(.warm-now):not([hidden])")) {
const name = r.querySelector(".who > .name");
if (!name) continue;
const row = el("div", "row pref agent-pref-link");
const f = list.closest("[data-feature]")?.dataset.feature;
if (f) row.dataset.feature = f;
row.agents = agents;
const who = el("div", "who");
const n = el("div", "name", name.textContent);
n.dataset.en = name.dataset.en || name.textContent;
who.append(n, el("div", "sub", t("In {provider}'s editor, on the Providers page", { provider: subNames(agents.slice(0, 1)) })));
const sub = r.querySelector(".sub:not(.err)");
if (sub) {
const says = el("span", "", sub.textContent);
says.hidden = true;
says.dataset.en = sub.dataset.en || sub.textContent;
who.append(says);
}
const go = el("button", "text", t("Open"));
go.type = "button";
go.onclick = async () => {
if (!await show("providers")) return;
const p = providers?.providers.find((x) => agents.includes(x.account?.agent));
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);
}
}
};