routing: a model in a group at one reasoning can be added again at another (visamzh on X)

visamzh on X: in a Routing group, the same model can no longer be added a
second time at another reasoning effort (gpt-6.2-sol at xhigh and at high).
It used to work.

Cause: 74c67785c (#907, 10-05) ticked a model in the Add a model picker
when any member had its base, so sol showed ticked for sol:xhigh. A click
on sol then took sol:xhigh out instead of adding sol, so a second effort
could never be added from the GUI. Saving (SaveGroup's cleanList dedups
exact ids only), reading, the gateway's members() (each effort its own
member, internal/gateway/groupeffort_test.go) and the TUI picker were never
affected, so groups that already hold sol:xhigh and sol:high load and route
as they are.

Now a member held at a fixed reasoning or on one account is a row of its
own in the picker, ticked, its level/account in its note, and a click on
it takes that member out, as #907 asked. The model's own row under it is
unticked and adds the model again, to be set to another level in its row.

Tests:
- group-member-again.test.cjs (new): sol:xhigh in the group gives two sol
  rows (held one ticked, says "xhigh reasoning"), the plain one adds a
  third member, set to high it saves [sol:xhigh, terra:high, sol:high];
  a group already holding sol:xhigh and sol:high shows both and saves
  both. en/zh x chromium/webkit.
- group-pick-filter.test.cjs (#907) updated: the held row stays ticked and
  takes its member out; the plain row is not ticked; save keeps two:max.

Run (mote, mote-run, node --test):
- group-member-again + group-pick-filter at this head: 8/8 pass. At
  origin/main e1c186cfe with the new test: group-member-again 0/4
  ("sol at xhigh and sol itself are not two rows 1 !== 2").
- Every GUI file reaching ?view=groups or plugins/routing (104 files,
  concurrency 4): 1401/1473 pass. The 72 reds were in 10 files. The 9 files
  rerun at this head and at origin/main e1c186cfe (concurrency 2): the
  same 71 reds at both. routing-groups-page's one 420px red (quotas
  redrawn) passed in the rerun. Filed: #7016 (routing-provider-off,
  routing-rows-fit, win-fonts); the rest are in #6934
  (group-editor-selected, menu-input-scroll, mobile-web,
  name-suffix-where-named, zero-priced-free).
- Rebased onto 69233d6bc (Docker image only) after the runs.

Not tried: a click-through in the real app. No Go changed, so the Go
groupeffort tests were not run again. No new strings, so zh-TW/ja/de are
unaffected.
This commit is contained in:
yetone
2026-11-18 10:42:59 +08:00
parent 69233d6bcf
commit a265632dae
4 changed files with 164 additions and 16 deletions
+12 -10
View File
@@ -8174,17 +8174,19 @@ function routingPage(part) {
// the image models after them, said as such (jzw690 on X): a group
// of them is picked in Settings › Models › Images, or named at the images API
const drawRef = (x) => ({ ...ref(x), note: noted(`${x.providerName} · ${t("Image model")}`, x.id) });
const options = [...subs, ...(decides ? [] : groups.models.map(ref)), ...(decides ? [] : (groups.drawers || []).map(drawRef)), ...(chats ? [] : (groups.deciders || []).map(ref))];
// the member a model is in the group as: itself, or with its
// reasoning fixed (deepseek/x:max), which is ticked as it and taken
// out by it rather than added twice (#907)
const holding = (id) => d.members.includes(id) ? id : d.members.find((m) => splitMember(m)[0] === id);
openPicker({ id: "", name: "", fields: [] }, { key: "member", label: "model", value: "", options, multi: true, picked: (id) => !!holding(id), onPick: (id) => {
// a model in the group with its reasoning fixed (deepseek/x:max) or
// on one account is a row of its own, ticked, its level or account
// in its note, and a click takes that member out (#907); the model's
// own row under it adds it again, to be fixed at another level
// (visamzh on X: gpt-6.2-sol at high and at xhigh, #189)
const withHeld = (mk) => (x) => [...d.members.filter((m) => m !== x.id && !subOf(m) && splitMember(m)[0] === x.id)
.map((m) => { const o = mk(x); return { ...o, value: m, note: [fixedOf(m) && fixedWords(fixedOf(m)), memberAccount(m)?.name, o.note].filter(Boolean).join(" · ") }; }), mk(x)];
const options = [...subs, ...(decides ? [] : groups.models.flatMap(withHeld(ref))), ...(decides ? [] : (groups.drawers || []).flatMap(withHeld(drawRef))), ...(chats ? [] : (groups.deciders || []).flatMap(withHeld(ref)))];
openPicker({ id: "", name: "", fields: [] }, { key: "member", label: "model", value: "", options, multi: true, picked: (id) => d.members.includes(id), onPick: (id) => {
if (!id) return;
const m = holding(id);
if (!m) d.members.splice(d.members.findLastIndex((x) => !d.matched.includes(x)) + 1, 0, id); // after the last named
else if (d.matched.includes(m)) return status(t("In the group by a pattern: switch it off to send it nothing"), "warn");
else { d.members.splice(d.members.indexOf(m), 1); rematch(); }
if (!d.members.includes(id)) d.members.splice(d.members.findLastIndex((x) => !d.matched.includes(x)) + 1, 0, id); // after the last named
else if (d.matched.includes(id)) return status(t("In the group by a pattern: switch it off to send it nothing"), "warn");
else { d.members.splice(d.members.indexOf(id), 1); rematch(); }
draw(); drawRules();
} }, addBtn, ev);
};
+11 -2
View File
@@ -1128,14 +1128,23 @@ and 1000x700, in Chromium and WebKit, English and Chinese.
`group-pick-filter.test.cjs` covers a group's Add a model picker and the
filter over the routing groups (#907; PAMI on Discord). A model in the group
with its reasoning fixed (a/two:max) is ticked, and a click takes that member
out instead of adding it a second time. A model that is in other groups names
with its reasoning fixed (a/two:max) is a ticked row of its own, and a click
takes that member out; the model's own row under it is not ticked. A model
that is in other groups names
them, and the whole note shows on hover. The filter keeps the groups whose
name, id or models match every word typed, and the keyboard stays in it.
When nothing matches it says so, and Escape clears it. The page never moves,
and there is no select or left border. In Chromium and WebKit, English and
Chinese.
`group-member-again.test.cjs` covers adding a model to a group a second
time at another reasoning (visamzh on X: gpt-6.2-sol at high and at xhigh).
With sol in the group at xhigh, the picker lists that member ticked and sol
itself not; a click on sol adds it again, its reasoning is fixed at high, and
the save sends both members. A group read with sol at two levels keeps both
rows and sends both back. It fails on the picker that took the model as its
member at a level. In Chromium and WebKit, English and Chinese.
`old-webkit.test.cjs` holds the page to Safari 15.0, the WebKit macOS 12 can
have (#220: a regex lookbehind in app.js, a syntax error before Safari 16.4,
left the panel with its headings and nothing working). Every script in
@@ -0,0 +1,133 @@
// Run with Node's test runner and Playwright on the module path; see README.md.
// visamzh on X: a routing group held gpt-6.2-sol at high and at xhigh, two
// members of one model (#189), but the Add a model picker took a model in
// the group at a fixed level as that member (#907): clicking it took the
// member out, so the model could not be added a second time.
// - The picker lists the member at its level as a ticked row of its own
// and the model's own row under it, not ticked; a click there adds the
// model again, whose reasoning is then fixed at another level, and a
// save sends both members.
// - A group read with the same model at two levels keeps both, in the
// editor and in what it saves.
// In English and Chinese, Chromium and WebKit.
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 assets = path.resolve(__dirname, "../assets");
const efforts = ["low", "medium", "high", "xhigh"];
const models = [
{ id: "cx/sol", name: "sol", providerName: "Codex", icon: "generic", efforts },
{ id: "cx/terra", name: "terra", providerName: "Codex", icon: "generic", efforts },
];
const words = {
en: { edit: "Edit", save: "Save", add: "Add another model", xhigh: "xhigh reasoning", high: "high reasoning" },
zh: { edit: "编辑", save: "保存", add: "再添加一个模型", xhigh: "xhigh 推理强度", high: "high 推理强度" },
};
function serve(lang, posts) {
const info = (ids) => ids.map((id) => ({ id, ready: true }));
const groups = () => ({
models, pools: [],
groups: [
{ id: "g", name: "G", members: ["cx/sol:xhigh", "cx/terra:high"], off: [], routing: "order", ready: true, memberInfo: info(["cx/sol:xhigh", "cx/terra:high"]) },
{ id: "pair", name: "Pair", members: ["cx/sol:xhigh", "cx/sol:high"], off: [], routing: "order", ready: true, memberInfo: info(["cx/sol:xhigh", "cx/sol:high"]) },
],
});
const state = { agents: [{ id: "codex", name: "Codex", path: "/test/codex", fields: [] }], profiles: [], settings: { lang, theme: "light" } };
return async (r) => {
const url = new URL(r.request().url());
const json = (data) => r.fulfill({ json: data });
if (url.pathname === "/boot.js") return r.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true};` });
if (url.pathname === "/wails/runtime.js") return r.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
if (url.pathname === "/api/state") return json(state);
if (url.pathname === "/api/plugins") return json({ plugins: [] });
if (url.pathname === "/api/gateway/trace") {
if (url.searchParams.get("wait")) return new Promise(() => {}); // nothing more comes
return json({ mine: true, now: new Date().toISOString(), seq: 1, totals: { requests: 0, rerouted: 0, errors: 0 }, routes: [] });
}
if (url.pathname === "/api/gateway/history") return json({ cut: false, days: [], routes: [] });
if (url.pathname === "/api/groups") return json(groups());
if (url.pathname.startsWith("/api/groups/")) {
posts.push({ path: url.pathname, body: JSON.parse(r.request().postData() || "{}") });
return json(groups());
}
if (url.pathname === "/api/providers") return json({ providers: [], presets: [], excluded: [], gateway: { running: true, window: true, url: "http://127.0.0.1:3999" } });
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)];
await r.fulfill({ body: await fs.readFile(file), contentType });
};
}
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
for (const lang of ["en", "zh"]) {
const w = words[lang];
test(`${engine} ${lang}: a model in a group at one reasoning is added again at another`, async (t) => {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
const page = await (await browser.newContext({ viewport: { width: 1100, height: 1400 }, reducedMotion: "reduce" })).newPage();
t.after(() => browser.close());
page.setDefaultTimeout(5000);
page.setDefaultNavigationTimeout(60000);
const errors = [], posts = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang, posts));
await page.goto("http://magpie.test/?view=groups");
const card = (id) => page.locator(`.rt-group[data-id="${id}"]`);
await card("g").waitFor();
const pop = page.locator("#pop");
const save = async (ed) => {
const b = ed.locator("button.primary", { hasText: w.save });
await page.mouse.move(550, 600);
for (let i = 0; i < 10 && (await b.boundingBox()).y > 1400 - 160; i++) {
await page.mouse.wheel(0, 300);
await page.waitForTimeout(150);
}
const bb = await b.boundingBox();
await page.mouse.click(bb.x + bb.width / 2, bb.y + bb.height / 2);
await page.waitForFunction(() => !document.querySelector(".rt-gedit"));
return posts.filter((p) => p.path === "/api/groups/save").at(-1).body;
};
// G holds sol at xhigh: the picker adds sol again
await card("g").locator("button", { hasText: w.edit }).click();
let ed = page.locator(".rt-gedit");
const rows = () => ed.locator(".fbl").first().locator(".fbrow");
assert.equal(await rows().count(), 2);
await ed.locator("button.rt-gadd", { hasText: w.add }).click();
const sols = pop.locator("li", { has: page.locator(".v", { hasText: /^sol$/ }) });
await sols.first().waitFor();
assert.equal(await sols.count(), 2, "sol at xhigh and sol itself are not two rows");
const cur = (li) => li.evaluate((x) => x.classList.contains("cur"));
assert.equal(await cur(sols.nth(0)), true, "sol at xhigh is not ticked");
assert((await sols.nth(0).locator(".n").textContent()).includes(w.xhigh), "the held row doesn't say its level");
assert.equal(await cur(sols.nth(1)), false, "sol itself is ticked while it is in at xhigh only");
await sols.nth(1).click();
assert.equal(await rows().count(), 3, "sol was not added again");
assert.equal(await cur(sols.nth(0)), true, "adding sol again took sol at xhigh out");
assert.equal(await cur(sols.nth(1)), true);
await page.keyboard.press("Escape");
await pop.waitFor({ state: "hidden" });
// the new row fixed at high
await rows().nth(2).locator("button.rt-fixed:not(.rt-fast)").click();
await pop.locator("li", { has: page.locator(".v", { hasText: new RegExp(`^${w.high}$`) }) }).first().click();
await pop.waitFor({ state: "hidden" });
assert.equal((await rows().nth(2).locator("button.rt-fixed:not(.rt-fast)").textContent()).trim(), w.high);
assert.equal((await rows().nth(0).locator("button.rt-fixed:not(.rt-fast)").textContent()).trim(), w.xhigh);
let sent = await save(ed);
assert.deepEqual(sent.members, ["cx/sol:xhigh", "cx/terra:high", "cx/sol:high"], "both of sol's members are not sent");
// Pair, read with sol at two levels, keeps both
await card("pair").locator("button", { hasText: w.edit }).click();
ed = page.locator(".rt-gedit");
assert.equal(await rows().count(), 2, "a member of the same model was dropped on read");
sent = await save(ed);
assert.deepEqual(sent.members, ["cx/sol:xhigh", "cx/sol:high"]);
assert.deepEqual(errors, []);
});
}
}
@@ -3,9 +3,11 @@
// with its reasoning fixed (a/two:max) was neither ticked nor taken out by
// a click: it was added a second time. PAMI on Discord: with many groups,
// one was hard to find.
// - The picker ticks a model in the group as itself or with an effort, and
// a click takes that member out (its effort with it), not adds it twice;
// a model in other groups says them, the whole note on hover.
// - The picker ticks a model in the group as itself or with an effort (a
// row of its own, saying its level), and a click takes that member out
// (its effort with it); the model's own row under it is not ticked and
// adds it again (visamzh on X, group-member-again.test.cjs). A model in
// other groups says them, the whole note on hover.
// - Over the groups, a filter keeps those whose name, id or models match
// every word typed; the keyboard stays in it as the list is drawn, none
// matching says so, Escape clears it. Not one <select>, no left border.
@@ -118,6 +120,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await opt("two").waitFor();
const cur = (name) => opt(name).evaluate((li) => li.classList.contains("cur"));
assert.equal(await cur("two"), true, "a member with its effort is not ticked");
const plain = pop.locator("li", { has: page.locator(".v", { hasText: /^two$/ }) }).nth(1);
assert.equal(await plain.evaluate((li) => li.classList.contains("cur")), false, "the model's own row is ticked while it is in at max only");
assert.equal(await cur("one"), true);
assert.equal(await cur("three"), false);
const note = opt("two").locator(".n");
@@ -144,7 +148,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await page.mouse.click(bb.x + bb.width / 2, bb.y + bb.height / 2);
await page.waitForFunction(() => !document.querySelector(".rt-gedit"));
const sent = posts.find((p) => p.path === "/api/groups/save");
assert.deepEqual(sent.body.members, ["a/one", "a/two"], "a member added twice, or its effort kept");
assert.deepEqual(sent.body.members, ["a/one", "a/two:max"], "a member added twice, or its effort lost");
assert.equal(await page.locator("select").count(), 0, "a native select");
const missing = await page.evaluate(() => ["Filter groups and models", "No group or model matches “{q}”"]