Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
routing: a weighted group's editor sorts its members by weight once (Norcleeh)
yetonee1721d6404a4
diff --git a/internal/gui/assets/plugins/routing/client.js b/internal/gui/assets/plugins/routing/client.jsindex 22353cc82..0ac46d30d 100644--- a/internal/gui/assets/plugins/routing/client.js+++ b/internal/gui/assets/plugins/routing/client.js@@ -5698,6 +5698,14 @@ function routingPage(part) {const list = el("div", "fbl");const addBtn = el("button", "rt-gadd");addBtn.append(svg(PLUS, 11, 1.8), el("span", "", t("Add a model")));+ // By weight, the named members put heaviest first once (Norcleeh on+ // Discord): the order is the fallback's, so it is written, not a mode.+ // Shown only while it would move something; equal weights keep theirs+ const sortBtn = el("button", "text rt-wsort", t("Sort by weight"));+ sortBtn.type = "button";+ sortBtn.title = t("Heaviest first. When a model fails, the next one in this order takes over");+ const byWeight = () => d.members.slice(0, named()).map((id, i) => [id, i]).sort(([a, i], [b, j]) => Math.max(d.weights[b] || 0, 1) - Math.max(d.weights[a] || 0, 1) || i - j).map(([id]) => id);+ sortBtn.onclick = () => { d.members.splice(0, named(), ...byWeight()); draw(); };// moveMember puts the member at `from` at `to` among those named — a// pattern's follow them, in the catalog's order — and keeps the// keyboard on its handle when it was there@@ -5887,6 +5895,7 @@ function routingPage(part) {list.append(row);});addBtn.querySelector("span").textContent = t(d.members.length ? "Add another model" : "Add a model");+ sortBtn.hidden = d.routing !== "weight" || byWeight().every((id, i) => d.members[i] === id);};// the picker stays open for as many models as are wanted, each ticked// once in, and says which other groups a model is in already (PAMI on@@ -5921,7 +5930,9 @@ function routingPage(part) {draw(); drawRules();} }, addBtn, ev);};- box.append(list, addBtn);+ const adds = el("div", "rt-madds");+ adds.append(addBtn, sortBtn);+ box.append(list, adds);draw();const mw = el("div");mw.append(box, el("div", "hint", t("The first answers for what the model can do. In order, they are tried top first.")));diff --git a/internal/gui/assets/plugins/routing/i18n.js b/internal/gui/assets/plugins/routing/i18n.jsindex 62b620ae9..e2acbb4cd 100644--- a/internal/gui/assets/plugins/routing/i18n.js+++ b/internal/gui/assets/plugins/routing/i18n.js@@ -100,6 +100,8 @@ magpie.strings({"Read the accounts' allowances again": "重新读取各账号的额度","live, as the gateway decides": "实时 · 网关正在做的决定","Add another model": "再添加一个模型",+ "Sort by weight": "按权重排序",+ "Heaviest first. When a model fails, the next one in this order takes over": "权重大的排在前面:某个模型失败时按这个顺序接替","Add pattern": "添加模式","e.g. openrouter/*:free or re:…": "例如 openrouter/*:free 或 re:…","Every model this pattern matches is in the group, as providers list them": "此模式匹配的模型都在组内,随供应商模型列表变化",@@ -682,6 +684,8 @@ magpie.strings({"Read the accounts' allowances again": "重新讀取各帳號的額度","live, as the gateway decides": "即時 · 閘道正在做的決定","Add another model": "再新增一個模型",+ "Sort by weight": "依權重排序",+ "Heaviest first. When a model fails, the next one in this order takes over": "權重大的排在前面:某個模型失敗時依這個順序接替","Add pattern": "新增模式","e.g. openrouter/*:free or re:…": "例如 openrouter/*:free 或 re:…","Every model this pattern matches is in the group, as providers list them": "此模式匹配的模型都在組內,隨供應商模型列表變化",@@ -1242,6 +1246,8 @@ magpie.strings({"Read the accounts' allowances again": "アカウントの利用枠を読み直します","live, as the gateway decides": "ライブ · ゲートウェイの判断どおり","Add another model": "別のモデルを追加",+ "Sort by weight": "重みで並べ替え",+ "Heaviest first. When a model fails, the next one in this order takes over": "重みの大きい順に並べます:モデルが失敗したときはこの順で代わります","Add pattern": "パターンを追加","e.g. openrouter/*:free or re:…": "例:openrouter/*:free または re:…","Every model this pattern matches is in the group, as providers list them": "このパターンに一致するモデルは、プロバイダの一覧に合わせてすべてグループに入ります",@@ -1814,6 +1820,8 @@ magpie.strings({"Read the accounts' allowances again": "Kontingente der Konten neu lesen","live, as the gateway decides": "live, während der Zugangspunkt entscheidet","Add another model": "Weiteres Modell hinzufügen",+ "Sort by weight": "Nach Gewicht sortieren",+ "Heaviest first. When a model fails, the next one in this order takes over": "Schwerstes zuerst: In dieser Reihenfolge springt das nächste Modell ein, wenn eines ausfällt","Add pattern": "Muster hinzufügen","e.g. openrouter/*:free or re:…": "z. B. openrouter/*:free oder re:…","Every model this pattern matches is in the group, as providers list them": "Jedes Modell, auf das dieses Muster passt, ist in der Gruppe, so wie die Anbieter es auflisten",diff --git a/internal/gui/assets/plugins/routing/routing.css b/internal/gui/assets/plugins/routing/routing.cssindex 2d89a9aad..254aa5b67 100644--- a/internal/gui/assets/plugins/routing/routing.css+++ b/internal/gui/assets/plugins/routing/routing.css@@ -650,6 +650,9 @@ button.rt-session { cursor: pointer; }/* Add a rule, and beside it a rule by what the message asks for */.rt-gadds { display: flex; flex-wrap: wrap; gap: 6px; }.rt-gadds > [hidden] { display: none; }+/* Add a model, and beside it Sort by weight while it would move something */+.rt-madds { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }+.rt-madds > [hidden] { display: none; }/* a group's rules, each one line read as a sentence: the conditions ithas, → and the model it sends that turn to first; its acts under ⋯ */.rt-rules .fbl:not(:empty) + .rt-gadds { margin-top: 2px; }diff --git a/internal/gui/tests/group-member-weight.test.cjs b/internal/gui/tests/group-member-weight.test.cjsindex 578f2a308..72c4a2b6a 100644--- a/internal/gui/tests/group-member-weight.test.cjs+++ b/internal/gui/tests/group-member-weight.test.cjs@@ -7,6 +7,7 @@// Enter keeps it, Escape puts it back, and one out of 1 to 1000 is refused// with a warning. Nothing on the page moves. Saved, the group goes with// routing "weight" and the weights above 1 of the members it still has. At+// Sort by weight puts the heaviest first once, and is saved so. At// 420px the segments and the rows don't spill. English, Chinese and German,// Chromium and WebKit; no backend, the API is faked here.const assert = require("node:assert/strict");@@ -85,6 +86,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",const weight = (name) => row(name).locator("button.rt-weight");await row("glm-5").waitFor();assert.equal(await ed.locator("button.rt-weight").count(), 0, "In order shows no weights");+ const sort = ed.locator("button.rt-wsort");+ assert.equal(await sort.isVisible(), false, "In order offers no sort by weight");const byWeight = ed.locator(".segs .opt", { hasText: await tr("By weight") });// what is clicked is wheeled into view by the test, as the reader@@ -129,6 +132,22 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",assert.equal(await weight("o4-mini").textContent(), await tr("Weight {n} · {share}%", { n: 1, share: 10 }));assert(await page.locator("body", { hasText: await tr("A weight is 1 to 1000") }).count(), "the refusal is said");+ // Sort by weight (Norcleeh on Discord) puts the heaviest first once,+ // equal weights in their order, one switched off too; then it goes,+ // since nothing is left to move+ const order = async () => {+ const names = await ed.locator(".fbl").first().locator(":scope > .fbrow .n > span:first-child").allTextContents();+ return names.map((x) => ["gpt-6.1-sol", "glm-5", "o4-mini", "kimi-k2.6"].find((n) => x.includes(n)));+ };+ assert.deepEqual(await order(), ["gpt-6.1-sol", "glm-5", "o4-mini", "kimi-k2.6"]);+ assert.equal(await sort.textContent(), await tr("Sort by weight"));+ await reach(page, sort);+ assert(await page.evaluate(() => document.querySelector(".rt-wsort").getBoundingClientRect().right <= document.querySelector(".rt-gedit").getBoundingClientRect().right + 1), "Sort by weight fits at " + width);+ await sort.click();+ assert.deepEqual(await order(), ["glm-5", "gpt-6.1-sol", "kimi-k2.6", "o4-mini"], "heaviest first");+ assert.equal(await sort.isVisible(), false, "sorted, it has nothing to do");+ assert.equal(await weight("glm-5").textContent(), await tr("Weight {n} · {share}%", { n: 6, share: 60 }), "each keeps its weight");+// nothing spills, and no left-border accentconst spill = await page.evaluate(() => {const ed = document.querySelector(".rt-gedit").getBoundingClientRect();@@ -153,9 +172,10 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",const sent = posts.find((p) => p.path === "/api/groups/save");assert.equal(sent.body.routing, "weight");assert.deepEqual(sent.body.weights, { "oa/gpt-6.1-sol:high": 3, "rl/glm-5": 6, "rl/kimi-k2.6": 2 });+ assert.deepEqual(sent.body.members, ["rl/glm-5", "oa/gpt-6.1-sol:high", "rl/kimi-k2.6", "rl/o4-mini"], "the sorted order is saved");const missing = await page.evaluate(() => [- "By weight", "Weight {n}", "Weight {n} · {share}%", "Weight of {name}", "A weight is 1 to 1000",+ "By weight", "Sort by weight", "Heaviest first. When a model fails, the next one in this order takes over", "Weight {n}", "Weight {n} · {share}%", "Weight of {name}", "A weight is 1 to 1000","Its share of the requests: a model weighing 3 takes three for every one a model weighing 1 takes","By weight: each model takes its share of the requests by the weight set beside it — one weighing 3 three for every one a model weighing 1 takes, spread out rather than in bursts. One resting after a failure leaves the round and the others share its requests; the next model is the fallback when one fails.",].filter((k) => !I18N.zh[k] || !I18N["zh-TW"][k] || !I18N.ja[k] || !I18N.de[k]));