gui: Picked only with nothing picked picks nothing, and its Save is refused (yuancjun)

yuancjun (#help on Discord) found the provider editor's Picked only,
with no model picked, ticked the first 24 models the vendor's list
serves (draft.chosen = dashed(), #1818). On a 42-model relay that reads
as Select all, and the next Save wrote those 24 down as the picks.
Ported from their fork (yuancjun/magpie, fix/legacy-picks-serve-all,
321dfd5c9), with two siblings added.

- Picked only with nothing picked now picks nothing (draft.picking),
  says "Pick a model first." (the words Names & levels already uses, in
  every language), and draws nothing as served.
- Its Save is refused with the same words, in a provider of keys'
  editor (yuancjun's) and in a subscription's account editor, which
  draws the same models box (renderModels) and would have saved the
  vendor's list the same way.
- Select none from there is Usage only, and once a model is picked the
  last unpicked leaves none as before (#1831).
- Picks set aside by Vendor's list or Usage only are still given back by
  Picked only.

app.js's comments around the models box were cut to pay for it: the
core stays in its budget with no raise.

provider-none-picked now checks that Picked only from Usage only ticks
nothing, says to pick a model first, refuses the Save (no save request)
and that Select none from there is Usage only. provider-best-in-family
says Picked only ticks nothing.

Run on mote at this commit (rebased on a3768cdd1): provider-none-picked,
provider-best-in-family, provider-picked-only-shows-picks and i18n-keys,
both engines, 74/74 pass; TestCoreScriptBudget ok (main's growth took it
17 bytes over after the rebase; the pickingNone comment was cut, no
raise). Broken by hand: dashed() restored, provider-none-picked is red;
the Save guard removed, it times out waiting for .editor-error.
Whole GUI suite on WSL (magpie-desktop): about 214 not ok, run beside
three other sessions' full suites there; every red I checked fails the
same alone at base ed978e560 (balance-fix, click-scroll, codex-auto-reset,
codex-credits-first, codex-predictions, editor-advanced-align,
gateway-key-limit, gateway-key-models, icon-url; #4683, #4908, #4790,
#4385). Not a clean whole-suite record.
Not tried: the real app with a real relay.
This commit is contained in:
yetone
2026-11-03 02:07:02 +08:00
parent 952309abcf
commit 2c90922b06
3 changed files with 45 additions and 31 deletions
+21 -21
View File
@@ -9377,6 +9377,7 @@ function drawEditor(p, presetID) {
cancel.onclick = cancelEdit;
const saveBtn = el("button", "text primary", t("Save"));
saveBtn.onclick = () => {
if (pickingNone()) return editorError(t("Pick a model first."), "warn");
const cx = parseContexts(draft.contexts || "");
if (cx.error) return contextError(ed, cx.error);
const ox = parseContexts(draft.outputs || "");
@@ -9976,6 +9977,7 @@ function drawEditor(p, presetID) {
cancel.onclick = cancelEdit;
const saveBtn = el("button", "text primary", t(isNew ? "Add" : "Save"));
const save = () => {
if (p && pickingNone()) return editorError(t("Pick a model first."), "warn");
// a typed icon address first; one that fails stays (hoobnn)
const waiting = custom && ed.iconFlush?.();
if (waiting) return waiting.then((ok) => ok && save());
@@ -10986,12 +10988,14 @@ function chosenIds() {
// provider's models served, not to agents, not to routing groups, while its
// balance and usage still show. Without it no picks is the vendor's list.
const noneChosen = () => !!draft.none && !chosenIds().length;
// Picked only, none picked: Save is refused (yuancjun)
const pickingNone = () => !!draft.picking && !chosenIds().length;
// bestChosen: Best in family kept, with nothing picked
const bestChosen = () => !!draft.best && !draft.none && !chosenIds().length;
// servedIds: the models the provider serves as the editor has it: the
// picks; none after Select none; else those the vendor's list serves
const servedIds = (p) => draft.chosen.length ? draft.chosen : draft.none ? [] : p.models.filter((m) => draft.best ? m.best : m.on).map((m) => m.id);
const servedIds = (p) => draft.chosen.length ? draft.chosen : draft.none || draft.picking ? [] : p.models.filter((m) => draft.best ? m.best : m.on).map((m) => m.id);
// modelsOpen: a provider editor's models let out to their full height
// (#833), kept for the next editor. MCHIPS_MAX: the box's height held, as
@@ -11143,11 +11147,9 @@ function renderModels(p) {
names.dataset.provider = p.id;
const q = p.models.length > 24 ? input("", t("filter {n} models…", { n: p.models.length })) : null;
let showAll = false;
// the chips are held to a few lines, scrolled within; a long list can be
// let out to its full height and folded back (#833: 模型区域像 Agent 页面
// 一样支持展开 / 收起), as the Agents page's Show more is. Offered only
// while the list is taller than those lines; kept open from one editor to
// the next till folded
// the chips are held to a few lines, scrolled within, and let out to
// their full height and folded back (#833), while taller than those lines;
// kept open from one editor to the next till folded
const fold = el("button", "agent-more mchips-fold");
fold.dataset.unrolls = ""; // it goes down with the models it lets out
const foldLabel = el("span", "", "");
@@ -11170,6 +11172,7 @@ function renderModels(p) {
};
const draw = () => {
if (agentMenu && chips.contains(agentMenu.anchor)) closeAgentMenu();
if (draft.chosen.length) draft.picking = false;
chips.replaceChildren();
const f = (q?.value || "").trim().toLowerCase();
let shown = 0, hidden = 0, unpicked = 0;
@@ -11177,10 +11180,10 @@ function renderModels(p) {
const picksOnly = draft.chosen.length && !f && unpickedShown !== p.id && !decideOnly(p);
// none picked: what the vendor's list serves is drawn as served (#614,
// #1818), none after Select none
const served = draft.chosen.length || decideOnly(p) || draft.none ? new Set() : new Set(dashed());
const served = draft.chosen.length || draft.picking || decideOnly(p) || draft.none ? new Set() : new Set(dashed());
// models that would read alike say what tells them apart (modelTells)
const tells = modelTells(p.models);
// a filter is a search: what it doesn't match is left out, picked or not
// a filter is a search: what it doesn't match is left out
for (const m of p.models) {
const on = draft.chosen.includes(m.id);
if (f && !m.id.toLowerCase().includes(f) && !(m.name || "").toLowerCase().includes(f) && !(m.default || "").toLowerCase().includes(f)) continue;
@@ -11221,12 +11224,8 @@ function renderModels(p) {
tested(c, m.id);
menu(c, m.id);
// a click picks the model, a served one too: with none picked it
// becomes the only pick. A served one clicked used to be left out,
// the rest of what was served picked in its place, so a click on
// the one model wanted ticked every other (#681)
// once one is picked the provider serves its picks, so the last
// unpicked leaves none, not the vendor's list again (#1831, kchen0x:
// unpicking it went back to exposing every model)
// becomes the only pick (#681). The last unpicked leaves none, not
// the vendor's list again (#1831, kchen0x)
c.onclick = () => {
draft.chosen = on ? draft.chosen.filter((x) => x !== m.id) : [...draft.chosen, m.id];
draft.none = true;
@@ -11256,6 +11255,7 @@ function renderModels(p) {
drawWorkOn();
drawServes();
why.textContent = decideOnly(p) ? t("Agents never see them: a routing group picks one as its classifier.")
: !draft.chosen.length && draft.picking ? t("Pick a model first.")
: !draft.chosen.length && draft.none ? t("None selected: no agent or routing group uses its models. Its balance and usage still show. Click a model to pick it.")
: bestChosen() && !draft.unlisted ? t("Best in family: agents see the newest model of each family it lists (dashed), up to {n}. A newer one it lists later takes the old one's place.", { n: 24 })
: draft.unlisted ? t(draft.chosen.length ? "Agents don't see them: only the routing groups they are in use them." : "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: 24 })
@@ -11661,9 +11661,8 @@ function renderModels(p) {
names.style.minHeight = "";
names.scrollTop = top;
};
// what the provider serves, in words (#1831): the vendor's list, the
// picks (a click on a model, Select all or none), the newest of each
// family, or Usage only (#2068). Picked only starts from the dashed ones
// what the provider serves, in words (#1831, #2068): the vendor's list,
// the picks, the newest of each family, or Usage only
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"], ["best", "Best in family", "Best in family: agents see the newest model of each family it lists (dashed), up to {n}. A newer one it lists later takes the old one's place."], ["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));
@@ -11671,10 +11670,11 @@ function renderModels(p) {
b.title = t(tip, { n: 24 });
b.onclick = () => {
if (v !== "picked" && draft.chosen.length) picksLeft = { id: p.id, picks: [...draft.chosen] };
if (v !== "picked") { draft.chosen = []; draft.typed = ""; draft.none = v === "none"; draft.best = v === "best"; }
if (v !== "picked") { draft.chosen = []; draft.typed = ""; draft.none = v === "none"; draft.best = v === "best"; draft.picking = false; }
else {
if (!draft.chosen.length && picksLeft?.id === p.id) { draft.chosen = picksLeft.picks; draft.none = true; }
if (!draft.chosen.length) { draft.chosen = dashed(); draft.none = true; }
// none picked: it picks none, not the first 24 (yuancjun)
draft.picking = !draft.chosen.length;
unpickedShown = null; draft.best = false;
}
draw();
@@ -11682,7 +11682,7 @@ function renderModels(p) {
serves.append(b);
return b;
});
const servesMode = () => draft.chosen.length ? "picked" : draft.none ? "none" : draft.best ? "best" : "list";
const servesMode = () => draft.chosen.length || draft.picking ? "picked" : draft.none ? "none" : draft.best ? "best" : "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); }
@@ -11701,7 +11701,7 @@ function renderModels(p) {
};
const allOff = el("button", "text action", t("Select none"));
allOff.title = t("Unpick every model");
allOff.onclick = () => { draft.chosen = []; draft.none = true; draw(); };
allOff.onclick = () => { draft.chosen = []; draft.none = true; draft.picking = false; draw(); };
bulk.append(allOn, allOff);
// just the free ones (Discord: 是否可以支持只选择免费模型), offered only
// when the list has both free and paid models: with none free it would
@@ -121,7 +121,9 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await editor.getByText(w.hint, { exact: false }).waitFor();
await editor.locator(".mserves .opt[data-serves=picked]").click();
assert.equal(await serves(), w.picked);
for (const id of newest) assert.deepEqual(await cls(id), [true, false], id + " picked");
// nothing picked yet: Picked only ticks nothing, rather than the
// newest of each family the list serves
for (const id of newest) assert.deepEqual(await cls(id), [false, false], id + " not picked yet");
// the older ones aren't picked (Picked only folds unpicked ones away)
for (const id of older) assert.equal(await editor.locator(".mchips .mchip.on", { hasText: id }).count(), 0, id + " not picked");
// Usage only, then Vendor's list: neither keeps it
@@ -14,7 +14,10 @@
// 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.
// Save). Picked only from there picks nothing (yuancjun: it ticked the
// first 24 the vendor's list serves, which read as Select all and was saved
// as picks): it says to pick a model first, and a Save is refused until one
// is picked; Select none from there is Usage only.
// In every language, Chromium and WebKit, at 1100 and 420 wide.
const assert = require("node:assert/strict");
const fs = require("node:fs/promises");
@@ -58,11 +61,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", 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" },
en: { pickFirst: "Pick a model first.", 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: { pickFirst: "请先选择模型。", save: "保存", selectNone: "全不选", list: "供应商列表", picked: "仅所选", usage: "仅看用量", card: "仅看用量", why: "Agent 能看到它:没有勾选任何模型时", hint: "供应商列表:Agent 看到最多 24 个模型", none: "全不选:Agent 和路由分组都不使用它的模型", groupsWhy: "路由分组会用到它", groupsHint: "模型所在的路由分组最多使用其中 24 个" },
"zh-TW": { pickFirst: "請先選擇模型。", save: "儲存", selectNone: "全不選", list: "供應商列表", picked: "僅所選", usage: "僅看用量", card: "僅看用量", why: "Agent 能看到它:沒有勾選任何模型時", hint: "供應商列表:Agent 看到最多 24 個模型", none: "全不選:Agent 和路由分組都不使用它的模型", groupsWhy: "路由分組會用到它", groupsHint: "模型所在的路由分組最多使用其中 24 個" },
ja: { pickFirst: "先にモデルを選んでください。", save: "保存", selectNone: "選択をすべて解除", list: "ベンダーのリスト", picked: "選択したもののみ", usage: "使用量のみ", card: "使用量のみ", why: "エージェントに表示されます:何も選択されていない", hint: "エージェントにはモデルが最大 24 件", none: "選択なし:エージェントもルーティンググループも", groupsWhy: "ルーティンググループが使います", groupsHint: "ルーティンググループが最大 24 件" },
de: { pickFirst: "Wählen Sie zuerst ein Modell.", 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"])) {
@@ -132,11 +135,20 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
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
// Picked only from there picks nothing: the vendor's list served
// ticking them all, which read as Select all and was saved as picks
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");
for (const id of ["glm-5.3-free", "glm-5.2"]) assert.deepEqual(await cls(id), [false, false], id + " not picked by Picked only");
assert.equal(await serves(), w.picked);
await editor.locator(".mserves .opt[data-serves=none]").click();
await editor.getByText(w.pickFirst, { exact: true }).first().waitFor();
// and a Save is refused, rather than serving the vendor's list
await editor.locator(".bar").getByRole("button", { name: w.save, exact: true }).click();
await editor.locator(".editor-error", { hasText: w.pickFirst }).waitFor();
assert.equal(saves.length, 0, "nothing saved with nothing picked");
// Select none from there is Usage only
await editor.getByRole("button", { name: w.selectNone, exact: true }).click();
await editor.getByText(w.none, { exact: false }).waitFor();
assert.equal(await serves(), w.usage);
await chip("glm-5.2").click();
// and another clicked joins it
await chip("glm-5.3-free").click();