gui: a provider kept for its usage alone is one click, Usage only, and its card says so (#2068, keleus)

keleus wanted a subscription's quota in the status bar without anything
routed to it. That has existed since #1818 (noModels), but getting there
took Picked only, then Select none, then Save, and the card then just said
"no models exposed". The models' serves control now has a third option,
Usage only: no picks, noModels on, nothing routed, balance and usage still
read, models the vendor lists later not added. The card's line says
"usage only" for such a provider. Picked only with none picked used to be
the same state under another name; it now starts from the models the
vendor's list serves (the dashed ones), so each of the three options is a
state of its own. Unpicking the last pick still leaves none (#1831),
which now reads as Usage only. Strings in en, zh, zh-TW, ja, de; the old
Picked only tooltip's second half moved to Usage only's.

Decision (owner delegated product calls): name the state rather than
document the path; the backend, CLI (`magpie provider models <id> none`)
and saved files are unchanged.

Run: provider-none-picked.test.cjs and i18n-keys.test.cjs, Chromium and
WebKit, 5 languages, 1100 and 420 wide: 33/33. With app.js put back,
provider-none-picked fails ("+ 'Picked only' - 'Usage only'"). The test's
saved-as-none fixture now has its models off, as /api/providers sends them
(Exposed is empty for it). No Go changed. Not run: the whole GUI suite
(no shared selector or API added).
This commit is contained in:
yetone
2026-10-14 16:42:39 +08:00
parent 1a5128747b
commit 54a2b0d05f
4 changed files with 59 additions and 26 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ keys and accounts per request is in [Gateway routing and fallback](gateway-routi
| Extra body | `ExtraBody` (`extraBody` in providers.json, the editor's *Extra body*, #1604) is a JSON object whose fields `WithExtraBody` adds at the top level of every JSON body sent to the provider: Messages, Chat, Responses and Gemini, relayed as they came or translated, in the gateway's `forwardOnce` and in Test and Detect (`tested`). A field the body has already is kept; a name written `"!name"` replaces it. Values are put in as written, objects whole, not merged. `${sessionId}` in any string, at any depth, becomes the request's session: the agent's session header (`sessionOf`), else the id `conversationID` derives from the first user message (`magpie-` and its hash), so it stays the same through one conversation; Test and Detect send `magpie-test-` and 12 random letters, a new one each time. `model`, `stream` and the conversation (`messages`, `input`, `contents`, `system`, `systemInstruction`, `system_instruction`, `instructions`, `tools`, `ExtraBodyReserved`) are magpie's: Save refuses them with or without `!` (`ExtraBodyOK`), the editor says so as they are typed, and one written into providers.json by hand is dropped on read (`cleanExtraBody`). Not sent with it: `count_tokens`, embeddings, images, video and System One's decision model (other APIs), and a signed-in account's requests. One object goes to every API; fields for one API alone are not a thing yet. | [`extrabody.go`](../../internal/provider/extrabody.go), [`gateway.go`](../../internal/gateway/gateway.go) |
| providers.json | `Path` is `providers.json` in magpie's config folder. A read that fails returns `ErrUnreadable` and is never treated as empty. `store` writes atomically through a rename and drops the cached catalog (`catalog.Touched`). | [`provider.go`](../../internal/provider/provider.go) |
| The list | `All` merges stored providers with `Accounts()`. An entry with no URL stores the user's picks for an account. The order is `file.Order`. Reads within one request share one build (`Hold`, #746). | [`provider.go`](../../internal/provider/provider.go) |
| Model picks | `Models` are the models the user picked for agents; none means the vendor's list, up to 24 (`Exposed`), unless the user chose Select none (`NoModels`, `magpie provider models <id> none`): then none of its models is served, not to agents, not to any routing group (auto groups included), not by a `provider/model` id, not as a classifier, while its balance and usage are still read (`ServesNone`, #1818). A file without `noModels` reads as before, and a pick clears it. `Save` keeps beside new picks the models listed then (`PickedFrom`, `listedWith`), and the same picks saved again keep it. When the picks held every model listed then, one the vendor lists since is served first beside them (`withNewlyListed`, `Picks`); one listed then and left unpicked stays out. Picks saved before `PickedFrom` was kept are taken to hold every model when they hold every one released up to the newest of them (models.dev's `release_date`), so a Claude account whose user picked them all is served Haiku 5.5 (wakaka). The editor and the TUI start from `Picks`, so a later Save keeps the new model. | [`models.go`](../../internal/provider/models.go), [`provider.go`](../../internal/provider/provider.go) |
| Model picks | `Models` are the models the user picked for agents; none means the vendor's list, up to 24 (`Exposed`), unless the user chose Select none (`NoModels`, `magpie provider models <id> none`): then none of its models is served, not to agents, not to any routing group (auto groups included), not by a `provider/model` id, not as a classifier, while its balance and usage are still read (`ServesNone`, #1818). The editor's serves control names it Usage only, beside Vendor's list and Picked only, and the card says "usage only" (#2068); Picked only from there picks the models the vendor's list serves, to unpick from. A file without `noModels` reads as before, and a pick clears it. `Save` keeps beside new picks the models listed then (`PickedFrom`, `listedWith`), and the same picks saved again keep it. When the picks held every model listed then, one the vendor lists since is served first beside them (`withNewlyListed`, `Picks`); one listed then and left unpicked stays out. Picks saved before `PickedFrom` was kept are taken to hold every model when they hold every one released up to the newest of them (models.dev's `release_date`), so a Claude account whose user picked them all is served Haiku 5.5 (wakaka). The editor and the TUI start from `Picks`, so a later Save keeps the new model. | [`models.go`](../../internal/provider/models.go), [`provider.go`](../../internal/provider/provider.go) |
| List schedule and rules | A provider of the user's own (not an account, a plugin's or a decision-only one) can set `RefreshEvery` (`magpie provider refresh-every <id> 6h`, or 1d, or off, at least 10m) and `AutoInclude` (`magpie provider auto-include <id> 'gpt-*' 're:claude-.*'`, or none; a glob with `*`, any case, or `re:` matching the whole id; a plain id is refused) (#2135). The gateway (`magpie serve` or the app) looks each minute and fetches a list once `Fetched` is that old, through the same `Refetch` as Fetch models (`KeepListsFresh`); a failed fetch waits `min(every, 15m)`. `RefetchTaking` adds to the picks a model the fetch newly lists that a rule matches (`takeMatching`), starting from what is served now (`Exposed`), so nothing served is taken away and a model the user unticks stays out (it is not new to the next fetch). Setting the rules takes the current list's matches. Every save that doesn't set them keeps them, the window's editor among them; the editor has no fields for them yet. | [`autolist.go`](../../internal/provider/autolist.go), [`models.go`](../../internal/provider/models.go), [`providers_cli.go`](../../internal/cli/providers_cli.go) |
| Keys | Several keys per provider. Requests go to the first key that is on; the gateway moves on when it is out or rate limited. `Key` stays the first, so other code reads it as before. A key can be made for one protocol (`KeyProtocol`). A key made for a protocol its provider has no URL for is skipped (`perKeyBarred`); when every key is, the provider is still tried whole on the URLs it has, and the candidate carries `noURL` so it isn't quiet: Routing's row (`Weighed.NoURL`) says "key set to {api} only, no {api} URL · sent on the others", and the editor's key row shows a "No {api} URL" chip (`keyLacksURL`; #1702, `TestKeyForAProtocolWithNoURLIsSaid`, `key-nourl.test.cjs`). A key's value can be replaced in place (`ReplaceKey`, #1869: a key rotated at the vendor): it keeps its name, place, protocol, weight and on or off, and what was set for it by its fingerprint (`AccountModels`, `AccountProxies`, `AccountConcurrency`) and the gateway keys held to it (`access.ReplaceAccount`) move to the new one; the GUI's `keys/replace` also lifts its rests (`UnrestAll`). Its past requests stay under the old fingerprint, by the same name. | [`keys.go`](../../internal/provider/keys.go) |
| Google Vertex AI | `google-vertex` (`VertexPreset`, `IsVertex`) is a provider of the user's own with no key. `Provider.Vertex` holds `project`, `location` (`global`, `us`, `eu` or a region; `global` when empty), `credentials` (a file; empty for Application Default Credentials) and `impersonate` (a service account's email). Save refuses a key given it, then normalizes them (`Normal`) and checks each (`check`); `normalize` clears the four URLs and any key put in `providers.json` by hand, which stands in for neither a token nor a project and leaves the provider as found savable, so the provider's one address is `vertexBase`, `https://<host>/v1/projects/<project>/locations/<location>`, its host following the location (`vertexHost`). It speaks Gemini alone (`Speaks`, `Base`). It is `Ready` once that address can be made, never from a key or an account; until then the app, `magpie providers` and the TUI say it needs a project, and `magpie provider <id>` says how to give it one. `hasEndpoint` counts it as a provider of the user's own, not a subscription's picks. An import link naming it is refused (`ParseImport`): its project and credentials are the user's own, which no link hands over. `Sign` refuses any other address and sets the bearer token before the user's `Headers`; `AuthHeaders` gives it no key header. Its models are its location's (`vertexModels`, in `planModels`): the preset has `NoList`, because Vertex AI has no list that says what a location serves. The lists are in the [reference](../reference.md#google-vertex-ai). | [`vertex.go`](../../internal/provider/vertex.go), [`provider.go`](../../internal/provider/provider.go), [`account.go`](../../internal/provider/account.go), [`rename.go`](../../internal/provider/rename.go), [`models.go`](../../internal/provider/models.go), [`importurl.go`](../../internal/provider/importurl.go) |
+11 -5
View File
@@ -5584,7 +5584,7 @@ function renderProviders() {
const n = p.models.filter((m) => m.on).length;
// a provider that only draws images (Settings → Image generation) says so
const models = n ? t(n === 1 ? "{n} model" : "{n} models", { n })
: p.draws ? t(p.draws === 1 ? "{n} image model" : "{n} image models", { n: p.draws }) : t("no models exposed");
: p.draws ? t(p.draws === 1 ? "{n} image model" : "{n} image models", { n: p.draws }) : t(p.noModels ? "usage only" : "no models exposed");
// every account in use refused by its vendor: signed out, as the
// accounts list says of each, not a green "signed in"
const inUse = (p.account?.logins || []).filter((l) => l.on || l.active);
@@ -10703,21 +10703,27 @@ function renderModels(p) {
// that one unpicked every model again, while Select none served none and
// looked nearly the same): the vendor's list, or the models picked, none
// when none are. A click on a model, Select all or Select none is
// "Picked"; only "Vendor's list" goes back to the vendor's list
// "Picked"; only "Vendor's list" goes back to the vendor's list. None
// picked is Usage only, its own option (#2068, keleus: a subscription
// kept for its usage alone took Picked only, then Select none, then Save
// to find): nothing routed to it, its balance and usage still shown.
// Picked only with none picked starts from what the vendor's list serves
// (the dashed ones), to unpick from
const serves = el("div", "segs mserves");
const servesOpts = [["list", "Vendor's list", "Serve the vendor's list, up to {n} of it (dashed), models it lists later too"], ["picked", "Picked only", "Serve only the models picked: none while none are, its balance and usage still shown"]].map(([v, name, tip]) => {
const servesOpts = [["list", "Vendor's list", "Serve the vendor's list, up to {n} of it (dashed), models it lists later too"], ["picked", "Picked only", "Serve only the models picked"], ["none", "Usage only", "Route nothing to it: no agent or routing group uses its models, and those it lists later aren't added. Its balance and usage still show."]].map(([v, name, tip]) => {
const b = el("button", "opt", t(name));
b.dataset.serves = v;
b.title = t(tip, { n: 24 });
b.onclick = () => {
if (v === "list") { draft.chosen = []; draft.typed = ""; draft.none = false; }
else if (!draft.chosen.length) draft.none = true;
else if (v === "none") { draft.chosen = []; draft.typed = ""; draft.none = true; }
else if (!draft.chosen.length) { draft.chosen = p.models.filter((m) => !noAPI(m)).slice(0, 24).map((m) => m.id); draft.none = true; }
draw();
};
serves.append(b);
return b;
});
const servesMode = () => draft.chosen.length || draft.none ? "picked" : "list";
const servesMode = () => draft.chosen.length ? "picked" : draft.none ? "none" : "list";
const drawServes = () => {
const now = servesMode();
for (const b of servesOpts) { b.classList.toggle("on", b.dataset.serves === now); b.setAttribute("aria-pressed", b.dataset.serves === now); }
+16 -4
View File
@@ -3902,7 +3902,10 @@ const I18N = {
"Vendor's list": "供应商列表",
"Picked only": "仅所选",
"Serve the vendor's list, up to {n} of it (dashed), models it lists later too": "提供供应商的列表,最多 {n} 个(虚线框),之后新上的模型也包括在内",
"Serve only the models picked: none while none are, its balance and usage still shown": "只提供勾选的模型:一个都没勾时不提供任何模型,余额和用量照常显示",
"Serve only the models picked": "只提供勾选的模型",
"Usage only": "仅看用量",
"Route nothing to it: no agent or routing group uses its models, and those it lists later aren't added. Its balance and usage still show.": "不往它路由:Agent 和路由分组都不使用它的模型,之后新上的模型也不会加进来。余额和用量照常显示。",
"usage only": "仅看用量",
"Vendor's list: agents don't see it, the routing groups its models are in use up to {n} of it (dashed). Click a model to pick just it.": "供应商列表:Agent 看不到,模型所在的路由分组最多使用其中 {n} 个(虚线框)。点击模型可单选。",
"Vendor's list: agents see up to {n} of its models (dashed), and those it lists later. Click a model to pick just it.": "供应商列表:Agent 看到最多 {n} 个模型(虚线框),之后新上的也会看到。点击模型可单选。",
"Free only": "只选免费",
@@ -8057,7 +8060,10 @@ const I18N = {
"Vendor's list": "供應商列表",
"Picked only": "僅所選",
"Serve the vendor's list, up to {n} of it (dashed), models it lists later too": "提供供應商的列表,最多 {n} 個(虛線框),之後新上的模型也包括在內",
"Serve only the models picked: none while none are, its balance and usage still shown": "只提供勾選的模型:一個都沒勾時不提供任何模型,餘額和用量照常顯示",
"Serve only the models picked": "只提供勾選的模型",
"Usage only": "僅看用量",
"Route nothing to it: no agent or routing group uses its models, and those it lists later aren't added. Its balance and usage still show.": "不往它路由:Agent 和路由分組都不使用它的模型,之後新上的模型也不會加進來。餘額和用量照常顯示。",
"usage only": "僅看用量",
"Vendor's list: agents don't see it, the routing groups its models are in use up to {n} of it (dashed). Click a model to pick just it.": "供應商列表:Agent 看不到,模型所在的路由分組最多使用其中 {n} 個(虛線框)。點選模型可單選。",
"Vendor's list: agents see up to {n} of its models (dashed), and those it lists later. Click a model to pick just it.": "供應商列表:Agent 看到最多 {n} 個模型(虛線框),之後新上的也會看到。點選模型可單選。",
"Free only": "只選免費",
@@ -12233,7 +12239,10 @@ const I18N = {
"Vendor's list": "ベンダーのリスト",
"Picked only": "選択したもののみ",
"Serve the vendor's list, up to {n} of it (dashed), models it lists later too": "ベンダーのリストを最大 {n} 件(破線)提供します。後から追加されたモデルも含みます",
"Serve only the models picked: none while none are, its balance and usage still shown": "選択したモデルだけを提供します。何も選択していなければ何も提供せず、残高と使用量は引き続き表示されます",
"Serve only the models picked": "選択したモデルだけを提供します",
"Usage only": "使用量のみ",
"Route nothing to it: no agent or routing group uses its models, and those it lists later aren't added. Its balance and usage still show.": "何もルーティングしません。エージェントもルーティンググループもモデルを使わず、後から追加されたモデルも加わりません。残高と使用量は引き続き表示されます。",
"usage only": "使用量のみ",
"Vendor's list: agents don't see it, the routing groups its models are in use up to {n} of it (dashed). Click a model to pick just it.": "ベンダーのリスト:エージェントには表示されず、モデルが属するルーティンググループが最大 {n} 件(破線)を使います。モデルをクリックするとそれだけを選択します。",
"Vendor's list: agents see up to {n} of its models (dashed), and those it lists later. Click a model to pick just it.": "ベンダーのリスト:エージェントにはモデルが最大 {n} 件(破線)表示され、後から追加されたものも表示されます。モデルをクリックするとそれだけを選択します。",
"Free only": "無料のみ",
@@ -16420,7 +16429,10 @@ const I18N = {
"Vendor's list": "Liste des Anbieters",
"Picked only": "Nur gewählte",
"Serve the vendor's list, up to {n} of it (dashed), models it lists later too": "Die Liste des Anbieters anbieten, bis zu {n} Modelle (gestrichelt), auch später hinzukommende",
"Serve only the models picked: none while none are, its balance and usage still shown": "Nur die gewählten Modelle anbieten: keines, solange keines gewählt ist; Guthaben und Nutzung werden weiter angezeigt",
"Serve only the models picked": "Nur die gewählten Modelle anbieten",
"Usage only": "Nur Nutzung",
"Route nothing to it: no agent or routing group uses its models, and those it lists later aren't added. Its balance and usage still show.": "Nichts dorthin leiten: Weder Agenten noch Weiterleitungsgruppen nutzen seine Modelle, auch später gelistete nicht. Guthaben und Nutzung werden weiter angezeigt.",
"usage only": "nur Nutzung",
"Vendor's list: agents don't see it, the routing groups its models are in use up to {n} of it (dashed). Click a model to pick just it.": "Liste des Anbieters: Agenten sehen sie nicht, die Weiterleitungsgruppen seiner Modelle nutzen bis zu {n} davon (gestrichelt). Klicken Sie auf ein Modell, um nur dieses zu wählen.",
"Vendor's list: agents see up to {n} of its models (dashed), and those it lists later. Click a model to pick just it.": "Liste des Anbieters: Agenten sehen bis zu {n} seiner Modelle (gestrichelt), auch später hinzukommende. Klicken Sie auf ein Modell, um nur dieses zu wählen.",
"Free only": "Nur kostenlose",
@@ -10,10 +10,12 @@
// and the auto groups all served 17). Kept for routing groups alone with
// none picked, the models the groups use are drawn dashed too (#1818: drawn
// as none while the groups used them). What it serves is said by a
// two-way control, Vendor's list or Picked only, and the last pick
// unpicked leaves none, as Select none does, not the vendor's list again
// (#1831, kchen0x). In every language, Chromium and WebKit, at 1100 and
// 420 wide.
// control, Vendor's list or Picked only, and the last pick unpicked leaves
// none, as Select none does, not the vendor's list again (#1831, kchen0x).
// None is the control's third option, Usage only, one click away, and the
// card says it (#2068, keleus: it took Picked only, then Select none, then
// Save); Picked only from there starts from what the vendor's list serves.
// In every language, Chromium and WebKit, at 1100 and 420 wide.
const assert = require("node:assert/strict");
const fs = require("node:fs/promises");
const path = require("node:path");
@@ -28,7 +30,8 @@ const base = {
key: { set: true, masked: "sk-…one" }, keyList: [], balanceToken: { takes: false, set: false }, proxy: "",
};
const relay = { ...base, id: "router", name: "Router", host: "router.example.com", chat: "https://router.example.com/v1" };
const watched = { ...base, id: "watched", name: "Watched", host: "watched.example.com", chat: "https://watched.example.com/v1", noModels: true, exposed: 0 };
// as /api/providers sends one saved as none: none of its models on (Exposed)
const watched = { ...base, id: "watched", name: "Watched", host: "watched.example.com", chat: "https://watched.example.com/v1", noModels: true, exposed: 0, models: base.models.map((m) => ({ ...m, on: false })) };
const grouped = { ...base, id: "grouped", name: "Grouped", host: "grouped.example.com", chat: "https://grouped.example.com/v1", unlisted: true, groups: { "glm-5.2": ["group/auto-glm-5-2"], "glm-5.3-free": ["group/auto-glm-5-3-free"] } };
function serve(lang, saves) {
@@ -55,11 +58,11 @@ function serve(lang, saves) {
// hint after Select none; groupsWhy, groupsHint: those kept for routing
// groups alone
const words = {
en: { save: "Save", selectNone: "Select none", list: "Vendor's list", picked: "Picked only", why: "Agents see it: none are picked", hint: "Vendor's list: agents see up to 24 of its models", none: "None selected: no agent or routing group uses its models", groupsWhy: "Routing groups use it: none are picked", groupsHint: "the routing groups its models are in use up to 24" },
zh: { save: "保存", selectNone: "全不选", list: "供应商列表", picked: "仅所选", why: "Agent 能看到它:没有勾选任何模型时", hint: "供应商列表:Agent 看到最多 24 个模型", none: "全不选:Agent 和路由分组都不使用它的模型", groupsWhy: "路由分组会用到它", groupsHint: "模型所在的路由分组最多使用其中 24 个" },
"zh-TW": { save: "儲存", selectNone: "全不選", list: "供應商列表", picked: "僅所選", why: "Agent 能看到它:沒有勾選任何模型時", hint: "供應商列表:Agent 看到最多 24 個模型", none: "全不選:Agent 和路由分組都不使用它的模型", groupsWhy: "路由分組會用到它", groupsHint: "模型所在的路由分組最多使用其中 24 個" },
ja: { save: "保存", selectNone: "選択をすべて解除", list: "ベンダーのリスト", picked: "選択したもののみ", why: "エージェントに表示されます:何も選択されていない", hint: "エージェントにはモデルが最大 24 件", none: "選択なし:エージェントもルーティンググループも", groupsWhy: "ルーティンググループが使います", groupsHint: "ルーティンググループが最大 24 件" },
de: { save: "Speichern", selectNone: "Keine auswählen", list: "Liste des Anbieters", picked: "Nur gewählte", why: "Agenten sehen es: Nichts ist gewählt", hint: "Agenten sehen bis zu 24 seiner Modelle", none: "Keine ausgewählt: Weder Agenten noch Weiterleitungsgruppen", groupsWhy: "Weiterleitungsgruppen nutzen es", groupsHint: "Weiterleitungsgruppen seiner Modelle nutzen bis zu 24" },
en: { save: "Save", selectNone: "Select none", list: "Vendor's list", picked: "Picked only", usage: "Usage only", card: "usage only", why: "Agents see it: none are picked", hint: "Vendor's list: agents see up to 24 of its models", none: "None selected: no agent or routing group uses its models", groupsWhy: "Routing groups use it: none are picked", groupsHint: "the routing groups its models are in use up to 24" },
zh: { save: "保存", selectNone: "全不选", list: "供应商列表", picked: "仅所选", usage: "仅看用量", card: "仅看用量", why: "Agent 能看到它:没有勾选任何模型时", hint: "供应商列表:Agent 看到最多 24 个模型", none: "全不选:Agent 和路由分组都不使用它的模型", groupsWhy: "路由分组会用到它", groupsHint: "模型所在的路由分组最多使用其中 24 个" },
"zh-TW": { save: "儲存", selectNone: "全不選", list: "供應商列表", picked: "僅所選", usage: "僅看用量", card: "僅看用量", why: "Agent 能看到它:沒有勾選任何模型時", hint: "供應商列表:Agent 看到最多 24 個模型", none: "全不選:Agent 和路由分組都不使用它的模型", groupsWhy: "路由分組會用到它", groupsHint: "模型所在的路由分組最多使用其中 24 個" },
ja: { save: "保存", selectNone: "選択をすべて解除", list: "ベンダーのリスト", picked: "選択したもののみ", usage: "使用量のみ", card: "使用量のみ", why: "エージェントに表示されます:何も選択されていない", hint: "エージェントにはモデルが最大 24 件", none: "選択なし:エージェントもルーティンググループも", groupsWhy: "ルーティンググループが使います", groupsHint: "ルーティンググループが最大 24 件" },
de: { save: "Speichern", selectNone: "Keine auswählen", list: "Liste des Anbieters", picked: "Nur gewählte", usage: "Nur Nutzung", card: "nur Nutzung", why: "Agenten sehen es: Nichts ist gewählt", hint: "Agenten sehen bis zu 24 seiner Modelle", none: "Keine ausgewählt: Weder Agenten noch Weiterleitungsgruppen", groupsWhy: "Weiterleitungsgruppen nutzen es", groupsHint: "Weiterleitungsgruppen seiner Modelle nutzen bis zu 24" },
};
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
@@ -87,7 +90,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const chip = (id) => editor.locator(".mchips .mchip", { hasText: id });
await chip("glm-5.2").waitFor();
const cls = (id) => chip(id).evaluate((c) => [c.classList.contains("on"), c.classList.contains("auto")]);
// which of Vendor's list / Picked only is on, and the control fits
// which of Vendor's list / Picked only / Usage only is on, and the
// control fits
const serves = async () => {
const seg = editor.locator(".mserves");
const box = await seg.boundingBox(), ed = await editor.boundingBox();
@@ -116,15 +120,22 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await chip("glm-5.2").click();
for (const id of ["glm-5.3-free", "glm-5.2"]) assert.deepEqual(await cls(id), [false, false], id + " after the last pick unpicked");
await editor.getByText(w.none, { exact: false }).waitFor();
assert.equal(await serves(), w.picked);
assert.equal(await serves(), w.usage);
// Vendor's list goes back to it
await editor.locator(".mserves .opt", { hasText: w.list }).click();
await editor.locator(".mserves .opt[data-serves=list]").click();
for (const id of ["glm-5.3-free", "glm-5.2"]) assert.deepEqual(await cls(id), [false, true], id + " vendor's list again");
await editor.getByText(w.hint, { exact: false }).waitFor();
assert.equal(await serves(), w.list);
// Picked only with none picked is none
await editor.locator(".mserves .opt", { hasText: w.picked }).click();
// Usage only is none, at a click (#2068)
await editor.locator(".mserves .opt[data-serves=none]").click();
for (const id of ["glm-5.3-free", "glm-5.2"]) assert.deepEqual(await cls(id), [false, false], id + " usage only");
await editor.getByText(w.none, { exact: false }).waitFor();
assert.equal(await serves(), w.usage);
// Picked only from there picks what the vendor's list serves
await editor.locator(".mserves .opt[data-serves=picked]").click();
for (const id of ["glm-5.3-free", "glm-5.2"]) assert.deepEqual(await cls(id), [true, false], id + " picked from the vendor's list");
assert.equal(await serves(), w.picked);
await editor.locator(".mserves .opt[data-serves=none]").click();
await chip("glm-5.2").click();
// and another clicked joins it
await chip("glm-5.3-free").click();
@@ -136,6 +147,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await editor.getByRole("button", { name: w.selectNone, exact: true }).click();
for (const id of ["glm-5.3-free", "glm-5.2"]) assert.deepEqual(await cls(id), [false, false], id + " after Select none");
await editor.getByText(w.none, { exact: false }).waitFor();
assert.equal(await serves(), w.usage);
await editor.locator(".bar").getByRole("button", { name: w.save, exact: true }).click();
for (let i = 0; i < 60 && !saves.length; i++) await page.waitForTimeout(50);
assert.equal(saves.length, 1, "saved");
@@ -143,9 +155,12 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.deepEqual(saves[0].models || [], [], "no picks sent");
await page.locator("#modal:not([hidden]) .editor").waitFor({ state: "detached" }).catch(() => {});
// one saved so opens as none, and a pick then clears it
// one saved so says so on its card, opens as none, and a pick then
// clears it
assert.ok((await page.locator(".row.provider", { hasText: "Watched" }).locator(".sub").innerText()).endsWith(w.card), "the card says usage only");
await page.locator(".row.provider", { hasText: "Watched" }).click();
await chip("glm-5.2").waitFor();
assert.equal(await serves(), w.usage);
for (const id of ["glm-5.3-free", "glm-5.2"]) assert.deepEqual(await cls(id), [false, false], id + " saved as none");
await editor.getByText(w.none, { exact: false }).waitFor();
await chip("glm-5.2").click();