Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
routing: a group's rules are dragged into order
yetoneb5a78fd8b535
diff --git a/docs/subsystems/gateway-routing.md b/docs/subsystems/gateway-routing.mdindex 82c2d38da..fa17f69e0 100644--- a/docs/subsystems/gateway-routing.md+++ b/docs/subsystems/gateway-routing.md@@ -110,6 +110,7 @@ recorded as a prediction failure (`noPrediction`).- A classifier that can't say which kind a turn is (an error, no answer within `classifyTimeout()`, an answer that isn't a number, or resting `classifyRest` after a failure) leaves a turn whose conversation had an intent, still one of this turn's, with that intent (`Classified.Fallback` is `previous`, its `Error` kept), so the turn goes where the turn before went rather than to the group's first member; with no intent before, no rule with an intent matches, as before. The Routing page says the turn kept it (`classWhy`). The turn's decision itself (`turnRules`) is kept in memory only: after a restart a turn under way waits for the next one and the stick holds it meanwhile. `TestIntentClassifierFailsKeepsThePreviousIntent`, `routing-intent-fallback.test.cjs`.- The classifier's requests are magpie's own (#1839). Asked in words, they go out with `RouterAgent`'s User-Agent (`magpie-router/1`), so their records' agent is magpie and `callKind` marks them `routing`; a decision model's (Jev, System One) record is written with `Kind: "routing"` too. They go to the same key or account as any other request and count in its totals, while `usage.Group.Own` (`Record.ByMagpie`: agent `magpie` or one of its `magpie-` User-Agents, with search's and image description's) says how many of an account's, key's or model's calls, tokens and cost were magpie's own. A classifier set to a subscription's model (`modelRef.Sub`, or a group whose first member is one) asks that subscription as every turn begins, twice when it picks both intent and effort in words; the Routing page says so beside it (`classifierSub` in `plugins/routing/client.js`). `TestIntentRoutesATurn`, `TestJevPicksTheIntent`, `TestSummaryCountsMagpiesOwnCallsApart`, `TestByMagpie`, `TestServedRefSaysASubscription`, `own-requests.test.cjs`.- A rule may name several members (`Rule.More` after `Rule.Use`, `more` in the group's JSON, `use=a,b` typed; monkeyin_92 on X: one rule, several models, not a rule each). They go first in that order, ahead of the later matching rules' members (`ThenUses` leaves out every one the rule names) and the group's others: when the first fails or rests the rule's next takes the request, and the hit says so (`RuleHit.More`; `Instead` is that next one with `Unready` false, where an `Instead` from a later rule comes with `Unready` true). `Uses`, `SetUses`, `MapUses`, `Without` and `Names` in [`grouprule.go`](../../internal/provider/grouprule.go) are how every reader goes through them: `cleanRules` (each must be the group's, each named once, a pause names one), the turn's hold, the tool rounds and compaction (`ruleFor`, the rule's first that takes the summary), `nestedRules` and `ruleLed` (the one of them a nested group's turn stays on), `ruleEffort` (the rule's `useEffort` asked of each), `ruledEntry` (what a group takes is what every one of them takes), a model's rename and removal (a rule goes with its last), `ShareGroup` and its import (one this magpie hasn't is left out of the rule), the CLI's `groups rules` and the TUI. The editor draws a chip per member with a + for the next and an × on each while there is more than one (`rUses`/`setUses` in [`plugins/routing/client.js`](../../internal/gui/assets/plugins/routing/client.js)). A rule of one member writes no `more`, so a group saved before it reads and saves as it was. A magpie from before it reads `use` alone: its requests go to the first, and the others are plain members in the group's order; if it saves the group, `more` is dropped. `TestRuleSeveralModelsInOrder`, `TestCleanRulesSeveralModels`, `routing-rule-models.test.cjs`.+ - The editor's rules are checked top first, so their order is theirs to set: a rule's number is its handle (`ruleHandle`, `.rt-rhandle`), dragged (`dragRows`, as the members are) or moved a place with Alt+↑/↓, the rules renumbered at once; the grip beside it shows on hover only, and Move up and down stay under its ⋯ (`moveRule`). Saved as the group's `rules` in their new order. `routing-rule-drag.test.cjs`.- A rule can set the reasoning its member is asked for (`Rule.UseEffort`, `useEffort` in the group's JSON, `use-effort=low` typed; #2633, dengtongcai: an intent picks the model and the effort as a pair). It is an output like `Use`, not a condition like `Effort`. `ruleFor` copies it onto the hit (`RuleHit.UseEffort`) from the rule that put a member first, outer or nested; `ruleOver` keeps that rule's members, and `ruleEffort` gives each candidate of them the level fitted to its model's own (`fitLevel`), which `withFixedEffort` writes into the request's field for its protocol (Chat's `reasoning_effort`, Responses' `reasoning.effort`, Anthropic's thinking budget or `output_config.effort`) even when the agent asked none. A member fixed at an effort keeps its own; otherwise the rule's beats the model's suffix, the turn's pick and the agent's pick, and isn't bounded by the group's levels. A model whose levels aren't known (`Efforts` empty) is asked as the agent asked, as with the auto verdict. The members the group fails over to are asked as the agent asked. A Gemini-protocol client's request is left as it came, as for every effort magpie sets. `cleanRules` refuses a value outside `provider.Efforts` and a pause with one. The try records it (`Try.RuleEffort`), and the Routing page says the rule set it. `rule_effort_test.go`, `grouprule_useeffort_test.go`, `routing-rule-effort.test.cjs`.- A rule by folder (`Rule.Folders`, `folders=~/work/acme,~/oss`; Cario0x on X: routing by the project being worked on) matches when the folder the agent works in is one of them or inside one (`provider.FolderUnder`, [`rulefolder.go`](../../internal/provider/rulefolder.go)): at a path's boundary, so `/a/b` is not under `/a/bc`; `~` is the home folder; a Windows drive is one with its WSL mount (`C:\work` is `/mnt/c/work`) and a `\\wsl$\<distro>` or `\\wsl.localhost\<distro>` share is the distro's own path; case doesn't count on macOS and Windows, nor ever for a drive. A rule outside folders (`Rule.ExceptFolders`, `except-folders=~/big-task`; #1606, Ti800) matches when the folder is in none of them, and an agent that says none isn't known to be in one, so it matches; a rule may have both (`Rule.ByFolder`, `inFolders`). The folder is read from the request only when a rule of the group has folders or except-folders (`workDir` in [`workdir.go`](../../internal/gateway/workdir.go)), in each agent's own words, taken from captured requests: Claude Code's ` - Primary working directory: <path>` (its `<`/`>` as entities; ` (was <old>)` after a change dropped), Codex's `<environment_context>` `<cwd>`, Pi's `<cwd>` in the system prompt, and OpenCode's `Working directory:` inside its `<env>` block. Only the system prompt and the user's and system messages' text count, never the model's words or a tool's result, and the last said wins. An agent that says none has no folder, and no `folders=` rule matches it (unknown, never empty). The same reading tells a plugin's fetch where its agent works ([provider-plugins](provider-plugins.md#where-the-agent-works-for-a-plugins-fetch)). A pause rule may hold by folder too (below). The trace's `RuleHit.Folder` is the folder read, and the Routing page tells it beside the rule's `folder …` condition. `TestFolderUnder`, `TestRuleMatchesByFolder`, `TestParseRuleFolders`, `TestWorkDirOfEachAgent`, `TestRuleByFolder`, `TestRuleMatchesExceptFolders`, `routing-folder.test.cjs`. Rules by folder are never in a shared group (`ShareGroup` drops every `ByFolder` rule).- A rule by agent (`Rule.Agents`, `agents=codex,sillytavern`) matches the agent the gateway names the request's (`agentOf` in [`gateway.go`](../../internal/gateway/gateway.go): its `magpie-<name>` key, else its User-Agent), in lower case (`cleanRules`, `MatchesBesidesIntent`, `Pauses`). A client magpie doesn't know is named by its User-Agent's product name, before the first `/` or space (`usage.AgentOf`), so a rule can hold SillyTavern or one's own app (raikyou on Discord). The editor's agent picker lists the agents magpie knows, then those `/api/usage?period=30d` heard from that it doesn't (not `other`, nor `magpie`), and takes a name typed in its filter as the gateway reads a User-Agent (`uaName` in [`plugins/routing/client.js`](../../internal/gui/assets/plugins/routing/client.js), through the picker's `field.typed`): "MyApp/2.0 (Linux)" is `myapp`. `routing-rule-agent-typed.test.cjs`.diff --git a/internal/gui/assets/plugins/routing/client.js b/internal/gui/assets/plugins/routing/client.jsindex 3edd7a303..0cb26b5de 100644--- a/internal/gui/assets/plugins/routing/client.js+++ b/internal/gui/assets/plugins/routing/client.js@@ -5542,6 +5542,37 @@ function routingPage(part) {b.style.width = `clamp(6ch, ${w}px, 44ch)`;if (!b.isConnected) requestAnimationFrame(() => { if (b.isConnected) fitBox(b); });};+ // moveRule puts the rule at `from` at `to` and keeps the keyboard on+ // the same control of the moved rule (its handle, or its ⋯)+ const moveRule = (from, to, keep) => {+ if (to < 0 || to >= d.rules.length || to === from) return;+ d.rules.splice(to, 0, d.rules.splice(from, 1)[0]);+ drawRules();+ if (keep) rlist.querySelectorAll(keep)[to]?.focus({ preventScroll: true });+ };+ // ruleHandle is a rule's number, which is also its handle (monkeyin_92+ // on X): drag it to move the rule, or Alt+↑/↓ from the keyboard, as a+ // model's number does; Move up and down stay under ⋯. The grip shows+ // only on hover.+ const ruleHandle = (i, row) => {+ const b = el("button", "i ag-handle rt-rhandle", String(i + 1));+ b.type = "button";+ b.dataset.at = i;+ b.setAttribute("aria-label", t("Move rule {n}", { n: i + 1 }));+ b.title = t("Drag to reorder · Alt+↑/↓ to move");+ b.onkeydown = (e) => {+ if (!e.altKey || (e.key !== "ArrowUp" && e.key !== "ArrowDown")) return;+ e.preventDefault();+ e.stopPropagation();+ moveRule(i, i + (e.key === "ArrowUp" ? -1 : 1), ".rt-rhandle");+ };+ b.onclick = (e) => { e.stopPropagation(); delete b.dataset.dragged; };+ b.onpointerdown = (e) => {+ const rows = [...rlist.children].filter((r) => r.classList.contains("rt-rule"));+ dragRows(e, b, row, rlist, rows, (to) => moveRule(i, to));+ };+ return b;+ };const drawRules = () => {drawCtx(); // the members' windows changed with themrlist.replaceChildren();@@ -5876,7 +5907,7 @@ function routingPage(part) {more.setAttribute("aria-label", t("Actions for rule {n}", { n: i + 1 }));more.title = t("Actions for rule {n}", { n: i + 1 });more.append(svg(DOTS, 14, 2.2));- const move = (to) => { d.rules.splice(to, 0, d.rules.splice(i, 1)[0]); drawRules(); rlist.querySelectorAll(".rt-rmore")[to]?.focus({ preventScroll: true }); };+ const move = (to) => moveRule(i, to, ".rt-rmore");more.onclick = () => {const again = agentMenu?.anchor === more;closeAgentMenu();@@ -5891,7 +5922,7 @@ function routingPage(part) {{ name: "Remove rule", icon: CROSS, sep: true, run: () => { d.rules.splice(i, 1); drawRules(); } },]);};- row.append(el("span", "i", String(i + 1)), line, then, more, need);+ row.append(ruleHandle(i, row), line, then, more, need);rlist.append(row);});drawClassifier();diff --git a/internal/gui/assets/plugins/routing/i18n.js b/internal/gui/assets/plugins/routing/i18n.jsindex 0ab3d0cc2..d33d40cd4 100644--- a/internal/gui/assets/plugins/routing/i18n.js+++ b/internal/gui/assets/plugins/routing/i18n.js@@ -188,6 +188,7 @@ magpie.strings({"Hours and days": "时段","Remove condition": "移除条件","Actions for rule {n}": "规则 {n} 的操作",+ "Move rule {n}": "移动规则 {n}","Pause the model instead": "改为暂停该模型","Send to the model instead": "改为先发给该模型","Remove rule": "删除规则",@@ -576,6 +577,7 @@ magpie.strings({"Hours and days": "時段","Remove condition": "移除條件","Actions for rule {n}": "規則 {n} 的操作",+ "Move rule {n}": "移動規則 {n}","Pause the model instead": "改為暫停該模型","Send to the model instead": "改為先發給該模型","Remove rule": "刪除規則",@@ -1302,6 +1304,7 @@ magpie.strings({"Hours and days": "時間帯","Remove condition": "条件を削除","Actions for rule {n}": "ルール {n} の操作",+ "Move rule {n}": "ルール {n} を移動","Pause the model instead": "代わりにモデルを一時停止","Send to the model instead": "代わりにモデルへ送信","Remove rule": "ルールを削除",@@ -1860,6 +1863,7 @@ magpie.strings({"Hours and days": "Uhrzeit und Tage","Remove condition": "Bedingung entfernen","Actions for rule {n}": "Aktionen für Regel {n}",+ "Move rule {n}": "Regel {n} verschieben","Pause the model instead": "Stattdessen Modell pausieren","Send to the model instead": "Stattdessen an das Modell senden","Remove rule": "Regel entfernen",diff --git a/internal/gui/assets/plugins/routing/routing.css b/internal/gui/assets/plugins/routing/routing.cssindex eee170e16..2323cf2d1 100644--- a/internal/gui/assets/plugins/routing/routing.css+++ b/internal/gui/assets/plugins/routing/routing.css@@ -632,6 +632,18 @@ button.rt-session { cursor: pointer; }@supports (grid-template-columns: subgrid) { .rt-rule { grid-template-columns: subgrid; } }.rt-rule:first-child { border-top: 0; padding-top: 2px; }.rt-rule > .i { line-height: 26px; color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; text-align: right; }+/* a rule's number is its handle, as a model's is: the grip beside it+ shows on hover, dragged or from the keyboard only */+.rt-rule > .rt-rhandle.ag-handle { position: relative; width: 16px; height: 26px; padding: 0; margin: 0; font: inherit; font-size: 11.5px; line-height: 26px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }+.rt-rule > .rt-rhandle::before { content: ""; position: absolute; left: -5px; top: 50%; width: 5px; height: 11px; margin-top: -5.5px; background: radial-gradient(circle, var(--muted) .9px, transparent 1.2px) 0 0 / 3.5px 3.75px; opacity: 0; transition: opacity .15s; }+.rt-rule:is(:hover, .dragging) > .rt-rhandle::before { opacity: 1; }+/* apart: Safari before 15.4 drops a whole selector list with :focus-visible in it */+.rt-rule > .rt-rhandle:focus-visible::before { opacity: 1; }+.rt-rules > .fbl.sorting { user-select: none; -webkit-user-select: none; }+.rt-rules > .fbl.sorting > .rt-rule { transition: transform .22s cubic-bezier(.22, 1, .36, 1); }+.rt-rules > .fbl.sorting .rt-rhandle { cursor: grabbing; }+.rt-rules > .fbl > .rt-rule.dragging { position: relative; z-index: 2; background: var(--card); box-shadow: 0 6px 18px rgba(20, 22, 30, .12), 0 0 0 1px var(--line); border-radius: 8px; transition: none; }+@media (prefers-reduced-motion: reduce) { .rt-rules > .fbl.sorting > .rt-rule { transition: none; } }.rt-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }/* on a narrow page what it does goes under the conditions */@media (max-width: 640px) {diff --git a/internal/gui/tests/routing-rule-drag.test.cjs b/internal/gui/tests/routing-rule-drag.test.cjsnew file mode 100644index 000000000..bd356a4cb--- /dev/null+++ b/internal/gui/tests/routing-rule-drag.test.cjs@@ -0,0 +1,148 @@+// Run with Node's test runner and Playwright on the module path; see README.md.+// A routing group's rules are put in order by dragging (monkeyin_92 on X:+// "I'd like to drag rules up and down"), as the group's models are. In the+// editor a rule's number is its handle, with a grip beside it drawn only+// while the rule is under the pointer; dragging it moves the rule, Alt+↑/↓+// moves it from the keyboard, which stays on its handle, and the rule's ⋯+// keeps Move up and Move down. Saved, the rules go in the new order. No+// click or drag moves the page. Chromium and WebKit, every language.+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(process.env.ASSETS || path.join(__dirname, "../assets"));+const models = [+ { id: "a/one", name: "one", providerName: "A", icon: "generic", context: 1000000, ready: true },+ { id: "a/two", name: "two", providerName: "A", icon: "generic", context: 1000000, ready: true },+ { id: "b/three", name: "three", providerName: "B", icon: "generic", context: 1000000, ready: true },+];+const members = models.map((m) => m.id);+const groups = () => ({+ models, deciders: [], pools: [],+ groups: [{ id: "g", name: "G", members, routing: "order", ready: true,+ rules: [{ use: "a/one", images: true }, { use: "a/two", tokens: 5000 }, { use: "b/three", agents: ["codex"] }],+ memberInfo: members.map((id) => ({ id, ready: true, context: 1000000, images: true })) }],+});+const words = {+ en: { edit: "Edit", save: "Save", move: "Move rule 3", down: "Move down", tip: "Drag to reorder · Alt+↑/↓ to move" },+ zh: { edit: "编辑", save: "保存", move: "移动规则 3", down: "下移" },+ "zh-TW": { edit: "編輯", save: "儲存", move: "移動規則 3", down: "下移" },+ ja: { edit: "編集", save: "保存", move: "ルール 3 を移動", down: "下へ移動" },+ de: { edit: "Bearbeiten", save: "Speichern", move: "Regel 3 verschieben", down: "Nach unten" },+};++function serve(lang, posts) {+ 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/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)];+ try { await r.fulfill({ body: await fs.readFile(file), contentType }); } catch { await r.fulfill({ status: 404 }); }+ };+}++for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {+ for (const lang of Object.keys(words)) {+ const w = words[lang];+ test(`${engine} ${lang}: a group's rules are dragged into order`, async (t) => {+ const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));+ t.after(() => browser.close());+ const page = await (await browser.newContext({ viewport: { width: 1100, height: 1400 }, reducedMotion: "reduce" })).newPage();+ page.setDefaultTimeout(5000);+ const errors = [], posts = [];+ page.on("pageerror", (e) => errors.push(e.message));+ await page.route("**/*", serve(lang, posts));+ await page.goto("http://magpie.test/?view=routing");+ const card = page.locator(".rt-group").first();+ await card.waitFor();+ await card.locator("button", { hasText: w.edit }).click();+ const ed = page.locator(".rt-gedit");+ await ed.locator(".rt-rule").first().waitFor();+ const order = () => ed.locator(".rt-rule .rt-then .rt-model").evaluateAll((bs) => bs.map((b) => b.textContent.split(" · ")[0].trim()));+ const rule = (name) => ed.locator(".rt-rule", { has: page.locator(".rt-then .rt-model", { hasText: name }) });+ const handle = (name) => rule(name).locator(".rt-rhandle");++ // every rule's number is its handle+ assert.deepEqual(await ed.locator(".rt-rule .rt-rhandle").allTextContents(), ["1", "2", "3"]);+ assert.equal(await handle("three").getAttribute("aria-label"), w.move);+ if (w.tip) assert.equal(await handle("three").getAttribute("title"), w.tip);+ // the grip shows on the rule under the pointer only+ await page.mouse.move(1, 1);+ await page.waitForFunction(() => [...document.querySelectorAll(".rt-rhandle")].map((h) => getComputedStyle(h, "::before").opacity).join() === "0,0,0");+ await rule("two").locator(".rt-then").hover();+ await page.waitForFunction(() => [...document.querySelectorAll(".rt-rhandle")].map((h) => getComputedStyle(h, "::before").opacity).join() === "0,1,0");++ // wheeled to the rules, as the reader would (a scroll no reader asked+ // for is put back)+ const v = await page.locator("#view-routing").boundingBox();+ await page.mouse.move(v.x + 10, 300);+ for (let n = 0; n < 40; n++) {+ const b = await ed.locator(".rt-rules").boundingBox();+ const d = Math.round(b.y + b.height / 2 - 700);+ if (Math.abs(d) < 120) break;+ await page.mouse.wheel(0, Math.sign(d) * Math.min(Math.abs(d), 300));+ await page.waitForTimeout(60);+ }+ await page.waitForTimeout(200);+ const at = () => page.evaluate(() => [...document.querySelectorAll("*")].filter((e) => e.scrollTop).map((e) => [e.id || e.className, e.scrollTop]).join(";") + "|" + Math.round(document.querySelector(".rt-gedit").getBoundingClientRect().top));+ const before = await at();+ // drag "three" above "one"+ const hb = await handle("three").boundingBox(), top = await rule("one").boundingBox();+ await page.mouse.move(hb.x + hb.width / 2, hb.y + hb.height / 2);+ await page.mouse.down();+ for (let i = 1; i <= 8; i++) await page.mouse.move(hb.x + hb.width / 2, hb.y + hb.height / 2 - ((hb.y - top.y + 6) * i) / 8);+ await page.mouse.up();+ assert.deepEqual(await order(), ["three", "one", "two"], "the drag moved it");+ assert.equal(await page.locator(".pop:not([hidden]), .row-menu").count(), 0, "the drag's click opened something");+ assert.deepEqual(await ed.locator(".rt-rule .rt-rhandle").allTextContents(), ["1", "2", "3"], "numbered again");++ // Alt+↓ from the keyboard, which stays on the moved rule's handle+ await handle("three").focus();+ await page.keyboard.press("Alt+ArrowDown");+ assert.deepEqual(await order(), ["one", "three", "two"]);+ assert(await handle("three").evaluate((h) => h === document.activeElement), "the keyboard left the moved rule");+ await page.keyboard.press("Alt+ArrowDown");+ await page.keyboard.press("Alt+ArrowDown"); // past the last: stays+ assert.deepEqual(await order(), ["one", "two", "three"]);+ await page.keyboard.press("Alt+ArrowUp");+ assert.deepEqual(await order(), ["one", "three", "two"]);+ // the ⋯'s Move down still moves it a step+ await rule("one").locator(".rt-rmore").click();+ await page.locator(".row-menu .rm-item", { hasText: w.down }).click();+ assert.deepEqual(await order(), ["three", "one", "two"]);+ assert.equal(await at(), before, "a click or drag moved the page");++ 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"));+ const sent = posts.find((p) => p.path === "/api/groups/save");+ assert.deepEqual(sent.body.rules.map((r) => r.use), ["b/three", "a/one", "a/two"]);+ assert.deepEqual(sent.body.rules[0].agents, ["codex"], "a rule moves with its conditions");+ assert.deepEqual(errors, []);+ });+ }+}