routing: routing groups get a page of their own, beside Routing

The owner asked for the groups to leave the Routing page (11-06): under
the live stage and every request they were a long scroll down, and New
group with them. The design was reviewed before this was built.

- New page, Routing groups (#view-groups), drawn by the routing plugin's
  same script (routingPage), so the editor, its dirty/discard and every
  group action are unchanged. Toolbar: filter, "N groups · M on",
  Templates, Import, Select, and New group as the filled button. The list
  is right under it, and a Settings section under the list holds Found
  groups (with Exclude providers…) and Names in agents' lists.
- No Export button: each group already has its own Copy to share.
- Routing keeps the live stage and the requests. A request's group opens
  the groups page at its row.
- The sidebar has a Routing groups tab right after Routing (from 1024
  points). The header's row has no room for one: at 860px the extra tab
  pushed the logo out (brand.test). There the tab is hidden, Routing's
  tab is lit for both pages (markNav), and Routing's head has a
  "Routing groups ›" button, hidden beside the sidebar.
- Every way in now goes to the groups page: the guide's Open routing
  groups, the panel's and the provider editor's Make a routing group
  (window/main?view=groups&newgroup=…). mainView still takes
  view=routing&newgroup from an older panel.
- Words: "Routing groups", "Open routing groups", "Once saved, make a
  group of them in Routing groups.", and the editor's names note now says
  the setting is under the list, in zh, zh-TW, ja and de. "Open Routing"
  stays for the Agents page's button.
- Docs: providers-accounts, gateway-routing, plugin-runtime, gui-shell
  and reference say "Routing groups page" where they mean the groups.
- Core budget: the core's scripts are 1,533,774 of 1,533,802, paid for
  by three show()/setGatewayMode comments cut in app.js. No raise.

Tests: routing-groups-page.test.cjs (new) covers the page in Chromium and
WebKit, en/zh/zh-TW/ja/de, at 1280, 640 (window) and 420 (web): no
groups on Routing, the tab or the head's button by width, the lit tab,
toolbar order, New group primary and in sight, list then Settings, no
sideways scroll, no native select, no left-border accent; a request's
group to its row; quotas redrawn with an open editor left alone. The
trace tests (routing-compact, -pause-folder, -rule-models, -folder) open
Routing, then show the groups; routing-editor-foot and
name-suffix-where-named scroll by wheel, as the scroll guard lets a
reader; builtins expects the groups tab beside the sidebar only.
Removed: routing-groups-jump (the head's "Routing groups ↓" that scrolled
down to them, gone with them), routing-pointer-pin and routing-steady
(the groups kept in place under requests streaming in above them: no
request is above them now). Their guarantee that what redraws leaves an
open editor and its typing alone is routing-groups-page's quotas case;
Routing's own lists keep their keepInView.

The groups page's jump: a request's group, or a pool's "Several keys"
chip, opened the groups page and scrolled the row to the centre, and the
next frame show()'s backAfterLoad put the page back where the reader
last left it, then brought the focused segment in by "nearest": in
WebKit the pool sat half under the window's foot (routing-mode-goes, 9
of its 10 WebKit cases). goRouting now jumps at once on a page it opens and
marks it arrived(). The wheel in routing-many-keys turns over the keys:
at the page's foot, now shorter, the mouse rested over the requests list
(.rt-reqs, overscroll-behavior: contain), which took every wheel up, and
the test stopped with 2 keys in sight. That is #4082's cause.
routing-days-fit's fixture has 12 requests, a day that fills the window,
since the day bar held needs room under it.

Run on mote (macOS 27, load 25 to 65), Playwright 1.62.0:
- Go: go vet, gofmt -l and go test ./... at the rebased head (650bf8412
  base) ok except TestMainWindowCorners (#3949); internal/gui again
  after the last edits: the same, TestCoreScriptBudget ok (1,533,773 of
  1,533,802, no raise).
- GUI, the 262 files a change here can reach, at the head and at the
  base: the reds at the head are the base's, with their issues:
  menu-input-scroll #3402, provider-mask #5109, context-fold and
  order-unknown (webkit) #3479, header-centre #3479, i18n-keys
  #5332/#5426/#5482, account-eye #5052/#4244, call-headers webkit de
  #5045, codex-predictions #2624, codex-auto-reset webkit de #4790,
  routing-* under load #5088, and zero-priced-free, last-page,
  reasoning-speed, routing-row-swap/-tag-whole/-story-shrinks/-steps-cap
  and routing-intent-entry, red at the base the same way.
- After the last edits: the 11 files with a way to the groups page or
  its scroll (group-*, routing-groups-page, routing-mode-goes,
  routing-groups-off, routing-provider-off, routing-many-keys,
  click-scroll), 175 of 176; the one red is routing-many-keys webkit's
  wire at the foot, red at the base in 8 of 12 (#5543). brand,
  gateway-mode-sessions, header-zoom-fit, header-centre,
  inner-scroll-contain and mobile-web: the same 11 reds at the head and
  the base (mobile-web compares with origin/main through git, which a
  mote-run copy hasn't).
- Rebased on ecc26a339, again: gofmt -l, go vet ./internal/gui and
  TestCoreScriptBudget ok; 10 GUI files (i18n-keys, routing-groups-page,
  routing-mode-goes, sidebar, brand, menu-first-second, library-bar-more,
  click-scroll, name-suffix-saved, unlisted-models) 211 of 212, the one
  red i18n-keys' "a plugin's words are its own", red the same at
  ecc26a339 (#5332/#5426/#5482).
- Broken by hand: without the groups page's CSS rule, brand and
  routing-groups-page go red (32 fails); with the old goRouting,
  routing-mode-goes is red in 9 of its 10 WebKit cases.

Not tried: the whole GUI suite on Linux (WSL magpie-desktop) at this
head; a run at an earlier head is under way and has the Linux reds
#4120/#4121 name. Not tried in the real macOS app, only Playwright's
WebKit.
This commit is contained in:
yetone
2026-11-06 23:11:43 +08:00
parent ecc26a3394
commit 80ae904c23
113 changed files with 746 additions and 865 deletions
+1 -1
View File
@@ -2049,7 +2049,7 @@ provider or group still set to one of them is tried in its listed order.
Your own routing groups are the built-in plugin `groups` (Routing groups in
Plugins › Built-in), which stays on while you have one. The groups magpie
finds for a model two providers serve don't need it. Turned off, the gateway
doesn't list or serve a group of your own, and the Routing page has no New
doesn't list or serve a group of your own, and the Routing groups page has no New
group button; `magpie groups` still lists them.
**Make first** sets the accounts' order. How much that order counts
File diff suppressed because one or more lines are too long
+20 -8
View File
@@ -648,16 +648,28 @@ confirmations and menus interactive through redraws. `closeModal` releases
that background as soon as the close animation starts, so clicks reach the
page while the editor fades away. Opening an editor during that animation
protects the background again. `ux-safety.test.cjs` checks these transitions.
Routing's New group buttons share `newGroup`, which asks before replacing a
Routing groups have a page of their own, `#view-groups`, beside Routing
under Models (11-06; below every request on the Routing page they were a
long scroll down). The routing plugin adds both pages, and `routingPage`
draws the groups' section (`.rt-gsec`) into the second one's `#rtGroups`
(`window.routingGroupsHome`, again after its Try again), so one draft and
one `dirty` hook (`magpie.call("routing", "dirty")`) serve both; `rtView`
in app.js asks it on leaving either. Its toolbar is the filter, how many
groups there are and how many are on, then Templates, Import, Select and
New group (`text primary`); the list follows, then Settings (found groups,
the names agents' lists show), then the providers routing over several
keys. A request's group or pool link (`goRouting`) opens the page first,
then brings the row into sight when the reader's click asked for it.
The window opened with `view=groups&newgroup=<model>` (`mainView` keeps
`view=routing&newgroup=` too) opens a new group of that model
(`routing-groups-page.test.cjs`). Its tab sits in the sidebar only: the
header's row has no room for it (at 860px it pushed the logo out,
`brand.test.cjs`), so there app.css hides it, `markNav` lights Routing's
tab for both pages, and Routing's head shows `#rtToGroups` instead.
The page's New group goes through `newGroup`, which asks before replacing a
dirty group draft; Cancel retains the draft and Discard opens the new editor.
`newGroupWith` applies the same guard when creating a group from a model and
waits for `show` to accept navigation before creating its draft.
The Routing page's head also has Routing groups (`#rtGoGroups`), since the
groups sit below every request. Its click goes through `scrollOnPurpose`,
brings `.rt-gsec` to the top of the view and focuses it; the page's layout is
unchanged. `fitGo` gives it only the head's spare room: named, its arrow
alone, or left out, so nothing else in the head moves or wraps for it
(`routing-groups-jump.test.cjs`).
waits for `show("groups")` to accept navigation before creating its draft.
Live, the Routing page's card (its head, story and context window) tells of
one request, `cur`, chosen by `told()` in `plugins/routing/client.js`: it
stays on the request it tells of until that one is done, then goes to the
+2 -2
View File
@@ -28,7 +28,7 @@ the plugin host) are a different thing; see
| Ctx | What `Apply` gets: `OnDispose(f)`, `Contribute(slot, key)`, `Provide(name, v)` (withdrawn when it goes), `Service(name)`, and its composed `Config`. Disposers run in reverse, each one's panic logged and the rest still run. | [`pluginrt.go`](../../internal/pluginrt/pluginrt.go) |
| plugins.yml | `appdir.Config()/plugins.yml`: `preset` (`essentials` or `all`; `all` unless the user picks Essentials), `settled` (the defaults the file was last brought up to) and `plugins`, rows of `{id, enabled, config}` holding only what the user set. | [`config.go`](../../internal/pluginrt/config.go) |
| Settings schema | `SchemaOf(Settings)` makes a JSON Schema object of the struct, in its fields' order (`x-order`): each exported field with a json name is a setting, of `bool`, an int, `float64` or `string`, with tags `title` (English; the window translates it), `description`, `enum` (comma separated) and `min`/`max`. Its values are the defaults. A field a form can't draw, or a tag that doesn't parse, panics at `Register`. `Schema.Validate` takes a value only as the schema allows it (a JSON float64 or a YAML int for an integer); `SetConfig(id, config)` writes the user's row through it, and `Compose` leaves out a value edited into plugins.yml by hand that it doesn't allow, so the default stands. | [`schema.go`](../../internal/pluginrt/schema.go), [`config.go`](../../internal/pluginrt/config.go) |
| Built-in plugins | `groups`, `library`, `otel`, `sessions`, `warmups` (P0), `gateway` (P1), the Gateway page, which is Essential and in use while a gateway key is there (`access.List`), and `routing` (P2), the Routing page, Essential and in use while the user has a routing group, since the page is where groups are made and changed. `rotation` (P3), the routings besides Smart, is Essential and in use while a provider or group is routed by one of them. `middleware` (P3), the JS gateway middleware, is Essential and in use while plugins.json has a middleware on (`middleware.On`). `redact` (P3), privacy masking, is Essential and in use while Settings → Privacy asks for any masking (`masking.Wanted`). `search` (P3), magpie's web search, is Essential and in use while a search API is set up or a searcher is picked. `budget` (P3), key limits, is Essential and in use while a gateway key has a limit. `usage` (P2), the Usage page, is Essential too, with no `InUse`: what it shows the gateway counts anyway, and the tray panel's Usage tab still shows the allowances with it off. The Gateway page's one setting, `callsPage` (10, 20, 50 or 100; 20), is how many recent calls the page shows at a time. The other five aren't Essential. Each one's `InUse` counts what the user made with it: routing groups not Auto and not hidden, library items given to agents, a collector sent to, gateway conversations recorded, warm-ups and check-ins on. | [`plugins/`](../../plugins) |
| Built-in plugins | `groups`, `library`, `otel`, `sessions`, `warmups` (P0), `gateway` (P1), the Gateway page, which is Essential and in use while a gateway key is there (`access.List`), and `routing` (P2), the Routing and Routing groups pages, Essential and in use while the user has a routing group, since the second page is where groups are made and changed. `rotation` (P3), the routings besides Smart, is Essential and in use while a provider or group is routed by one of them. `middleware` (P3), the JS gateway middleware, is Essential and in use while plugins.json has a middleware on (`middleware.On`). `redact` (P3), privacy masking, is Essential and in use while Settings → Privacy asks for any masking (`masking.Wanted`). `search` (P3), magpie's web search, is Essential and in use while a search API is set up or a searcher is picked. `budget` (P3), key limits, is Essential and in use while a gateway key has a limit. `usage` (P2), the Usage page, is Essential too, with no `InUse`: what it shows the gateway counts anyway, and the tray panel's Usage tab still shows the allowances with it off. The Gateway page's one setting, `callsPage` (10, 20, 50 or 100; 20), is how many recent calls the page shows at a time. The other five aren't Essential. Each one's `InUse` counts what the user made with it: routing groups not Auto and not hidden, library items given to agents, a collector sent to, gateway conversations recorded, warm-ups and check-ins on. | [`plugins/`](../../plugins) |
The boundary is checked by `TestPluginsImportOnlyCore`: no package outside
`plugins/` imports one (but `main.go`, through `plugins/all`), a plugin never
@@ -201,7 +201,7 @@ the core. The seven other routings are the built-in plugin `rotation`'s.
| `Register`, `Find`, `Apply` | `Register(routing, s)` serves a routing until its remove; registering again stacks, and the last one serves. `Find("")` is `Smart` always. `Apply` fails open: a strategy that panics, or answers what isn't a permutation, leaves the pool in its listed order, logged. Every route is still tried. | [`routes.go`](../../internal/routes/routes.go) |
| Strategies | `Smart` (core), and `Ordered`, `Rotate`, `LeastUsed`, `Pace`, `Weighted`, `FreeFirst`, `Fastest`, `Cheapest` (a group's only: `provider.normalize` drops `cheap` from a provider), `Drain` and `FreeExpiring` (a group's only too: free quota first, the soonest lost first, then the paid as `Smart` orders them) in `routes.Builtin`. `Drain` remembers the seat each pool is on (`drains`). `Rotate` keeps a turn per pool and `Weighted` a smooth weighted round (`Round`, `MoveRound`), both moved out of the gateway, and `Fastest` a probe count per pool, so a seat not measured lately gets one request in `ProbeEvery`; `Forget` clears them, `Drain`'s too. | [`strategies.go`](../../internal/routes/strategies.go), [`round.go`](../../internal/routes/round.go) |
| Off | A routing no strategy serves is its listed order. `routingOf` in the gateway reads it as `order` wherever the core asks about a routing (a turn's mark, `sinks`, a rotate group's sessions, a group's heads), so nothing of the routing is left half on. | [`routing.go`](../../internal/gateway/routing.go) |
| `plugins/rotation` | Requires `providers` and `gateway`, `Essential`. Apply registers every `routes.Builtin` and removes them when turned off. `InUse` counts the providers and groups providers.json routes by one of them (`provider.Routings`, the file alone, not the catalog); an unreadable providers.json is an error, so it stays on. The gateway's `KeepFresh` watches providers.json too, so a routing set from the CLI or the TUI turns it on within 2s. Off, the window's routing pickers (the provider editor, the Routing page's pools and groups) offer Smart alone: their options are marked `data-feature="rotation"` (`routingSegs`). | [`rotation.go`](../../plugins/rotation/rotation.go), [`provider.go`](../../internal/provider/provider.go), [`app.js`](../../internal/gui/assets/app.js) |
| `plugins/rotation` | Requires `providers` and `gateway`, `Essential`. Apply registers every `routes.Builtin` and removes them when turned off. `InUse` counts the providers and groups providers.json routes by one of them (`provider.Routings`, the file alone, not the catalog); an unreadable providers.json is an error, so it stays on. The gateway's `KeepFresh` watches providers.json too, so a routing set from the CLI or the TUI turns it on within 2s. Off, the window's routing pickers (the provider editor, the Routing groups page's pools and groups) offer Smart alone: their options are marked `data-feature="rotation"` (`routingSegs`). | [`rotation.go`](../../plugins/rotation/rotation.go), [`provider.go`](../../internal/provider/provider.go), [`app.js`](../../internal/gui/assets/app.js) |
The user's own routing groups are the `groups` plugin's on this point. The
groups magpie finds (a model two providers serve, `auto/<model>`) stay the
File diff suppressed because one or more lines are too long
+2 -1
View File
@@ -330,6 +330,7 @@ body.window .top.inrow .actions { margin-left: 0; }
.top.cramped .seg button { padding: 0 8px; }
.top.crowded .seg button { padding: 0 6px; font-size: 12px; }
.top.crowded .brand { display: none; }
body:not(.side-nav) #nav button[data-view="groups"], body.side-nav .rt-togroups { display: none; }
.top.packed .seg button { padding: 0 3px; font-size: 11.5px; }
/* and when even that doesn't fit, the tabs scroll sideways rather than push the page wider */
.top.packed .seg { min-width: 0; flex: 0 1 auto; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
@@ -602,7 +603,7 @@ body.window .view { padding: 2px max(0px, calc(16px - var(--bar, 0px))) 8px 16px
stretch them alone edge to edge while the others sit in the middle (面条 on
Discord): their tables and charts lay out by the room they get. Masking
too, which stretched alone (refeccd on Discord) */
body.window :is(#view-agents, #view-sessions, #view-providers, #view-routing, #view-gateway, #view-usage, #view-masking, #view-library, #view-plugins, #view-settings) { padding-left: max(16px, calc(50% - 600px)); padding-right: max(0px, calc(max(16px, calc(50% - 600px)) - var(--bar, 0px))); }
body.window :is(#view-agents, #view-sessions, #view-providers, #view-routing, #view-groups, #view-gateway, #view-usage, #view-masking, #view-library, #view-plugins, #view-settings) { padding-left: max(16px, calc(50% - 600px)); padding-right: max(0px, calc(max(16px, calc(50% - 600px)) - var(--bar, 0px))); }
/* a view takes focus (tabIndex -1) only so the keys scroll it after a click;
a ring round the whole list there marks nothing a reader can act on (#1601) */
.view:focus { outline: none; }
+29 -23
View File
@@ -1838,13 +1838,13 @@ function guideCard(g) {
add.onclick = (e) => { e.stopPropagation(); guideTemplate(tp, name); };
acts.append(add);
}
const open = el("button", "text guide-open", t("Open Routing"));
const open = el("button", "text guide-open", t("Open routing groups"));
open.type = "button";
open.dataset.feature = "routing";
open.onclick = (e) => {
e.stopPropagation();
if (mode === "window") show("routing");
else api("window/main?view=routing", {}).catch(statusErr);
if (mode === "window") show("groups");
else api("window/main?view=groups", {}).catch(statusErr);
};
acts.append(open);
three.body.append(acts);
@@ -5652,7 +5652,7 @@ function keptNote(m) {
act.onclick = (ev) => {
ev.stopPropagation();
closePicker();
if (mode !== "window") api("window/main?view=routing&newgroup=" + encodeURIComponent(m.id), {}).catch(statusErr);
if (mode !== "window") api("window/main?view=groups&newgroup=" + encodeURIComponent(m.id), {}).catch(statusErr);
else window.newGroupWith?.(m.id, m.name, ev);
};
}
@@ -6001,6 +6001,7 @@ function loadProviders() {
return p;
}
const rtView = (v) => v === "routing" || v === "groups";
async function loadProvidersNow() {
// The page's first opening (#1519, fatkun): a list is drawn at once, as
// the Agents page draws the last state, and the fresh one replaces it
@@ -6053,7 +6054,7 @@ async function loadProvidersNow() {
magpie.call(view, "render", was);
backAfterLoad($("#view-" + view));
// under Routing: drawn when opened (#4652)
} else if (view === "routing") { providersBehind = true; markNewPartners(); }
} else if (rtView(view)) { providersBehind = true; markNewPartners(); }
else renderProviders();
renderArchive();
providersWhileFetching();
@@ -6070,7 +6071,7 @@ function providersWhileFetching() {
clearTimeout(providersWhileFetching.timer);
if (!providers?.fetching) return;
providersWhileFetching.timer = setTimeout(async () => {
if (!(["providers", "routing"].includes(view) || providersPage(view)) || editing !== null || adding || document.hidden) return;
if (!(view === "providers" || rtView(view) || providersPage(view)) || editing !== null || adding || document.hidden) return;
let next;
try { next = await api("providers"); } catch { providersWhileFetching(); return; }
const json = (p) => JSON.stringify({ ...p, fetching: false, gateway: { ...p.gateway, calls: 0 } });
@@ -11429,11 +11430,11 @@ function renderModels(p) {
lost.hidden = !none.length;
if (!none.length) return;
lost.append(t("In no routing group, so no agent can use them now: {models}.", { models: none.slice(0, 8).join(", ") + (none.length > 8 ? " …" : "") }));
if (!p.unlisted) { lost.append(" " + t("Once saved, make a group of them in Routing.")); return; }
if (!p.unlisted) { lost.append(" " + t("Once saved, make a group of them in Routing groups.")); return; }
for (const id of none.slice(0, 4)) {
const b = el("button", "text action", t("Make a routing group of {model}", { model: id }));
b.dataset.feature = "routing"; // made on the Routing page
b.onclick = (ev) => { if (mode !== "window") api("window/main?view=routing&newgroup=" + encodeURIComponent(p.id + "/" + id), {}); else window.newGroupWith?.(p.id + "/" + id, "", ev); };
b.onclick = (ev) => { if (mode !== "window") api("window/main?view=groups&newgroup=" + encodeURIComponent(p.id + "/" + id), {}); else window.newGroupWith?.(p.id + "/" + id, "", ev); };
lost.append(b);
}
};
@@ -22877,7 +22878,7 @@ const readerAt = new WeakMap();
// took it out of sight, and it isn't brought back (backToReader)
const scrolledFrom = new WeakMap();
// Where the reader is is the view's scrollTop, unless the view names a part
// to keep in place (keepInView, the Routing page's groups under parts that
// to keep in place (keepInView, the Routing page's lists under parts that
// redraw on their own): then it is where that part is on screen as the
// reader leaves it, and the view follows it (scroll anchoring WebKit lacked).
const pinOf = new Map(), pinAt = new WeakMap();
@@ -23156,7 +23157,7 @@ async function show(v) {
if (view === "library" && modalFormDirty() && !(await confirmDiscard())) return false;
if (view === "library") magpie.call("library", "close"); else closeModal();
}
if (view === "routing" && magpie.call("routing", "dirty")) {
if (rtView(view) && magpie.call("routing", "dirty")) {
if (!(await confirmDiscard())) return false;
magpie.call("routing", "discard");
}
@@ -23164,8 +23165,7 @@ async function show(v) {
if (!(await confirmDiscard())) return false;
magpie.call("library", "discard");
}
// the page left lets go of what was only for this visit (the Usage
// page's Requests, what a click filtered them by)
// the page left lets go of what was only for this visit
magpie.call(view, "leave");
}
view = v;
@@ -23176,11 +23176,7 @@ async function show(v) {
$("#pageTitle").dataset.en = title;
$("#pageTitle").textContent = t(title);
if (mode === "window") {
for (const b of $("#nav").querySelectorAll("button[data-view]")) {
const on = b.dataset.view === v;
b.classList.toggle("on", on);
if (on) b.setAttribute("aria-current", "page"); else b.removeAttribute("aria-current");
}
markNav(v);
if (!sideNav()) { slide($("#nav"), "nav"); navInSight(); }
else navTopGo($("#nav").querySelector("button[data-view].on"), true);
}
@@ -23197,10 +23193,9 @@ async function show(v) {
// a plugin's page loads what it shows; back once it has
magpie.call(v, "open")?.then?.(back);
if (v === "providers" && providersBehind) renderProviders();
if (v === "providers" || v === "routing" || providersPage(v)) loadProviders().then(back, statusErr);
// Routing's accounts show their windows as the Usage page read them
// (#1833): what is kept, read in an ordinary way, never an asked read
if (v === "routing" && (!quotas || Date.now() - quotasAt > 60e3)) loadQuotas();
if (v === "providers" || rtView(v) || providersPage(v)) loadProviders().then(back, statusErr);
// Routing's accounts' windows as Usage read them (#1833), never an asked read
if (rtView(v) && (!quotas || Date.now() - quotasAt > 60e3)) loadQuotas();
if (v === "settings") (settingsLoad = loadSettings()).then(back, statusErr);
if (v === "plugins") window.loadPlugins?.()?.then(back);
syncTitle();
@@ -23229,8 +23224,7 @@ if (mode === "window") for (const b of $("#nav").querySelectorAll("button[data-v
b.onpointerleave = (e) => { if (e.buttons & 1) navTopGo(navTopOn(), true); };
b.onclick = () => { show(b.dataset.view).then((went) => { if (!went) navTopGo(navTopOn(), true); }); b.blur(); };
}
// setGatewayMode shows or leaves out gateway mode's pages' tabs; the page
// open, one of them, gives way to Providers
// gateway mode's pages' tabs; the page open, one of them, gives way to Providers
function setGatewayMode(on) {
gatewayMode = on;
document.body.classList.toggle("gateway-mode", on);
@@ -23509,6 +23503,17 @@ document.fonts?.ready.then(fitTop);
// a font picked later (Settings' Font) can still be loading when it's applied
document.fonts?.addEventListener("loadingdone", fitTop);
// the shown page's tab; Routing's for its groups in the header's row,
// which has no room for theirs (app.css)
function markNav(v) {
const tab = v === "groups" && !sideNav() ? "routing" : v;
for (const b of $("#nav").querySelectorAll("button[data-view]")) {
const on = b.dataset.view === tab;
b.classList.toggle("on", on);
if (on) b.setAttribute("aria-current", "page"); else b.removeAttribute("aria-current");
}
}
// ---- the sidebar ----------------------------------------------------------
// A window wide enough has its pages down a sidebar, as a Mac app's: in
// groups, the open page's own tabs under it, Settings at its foot and the
@@ -23554,6 +23559,7 @@ function layoutNav() {
$("#crumb").after(nav);
$(".actions").insertBefore(prefs, $("#winclose"));
}
markNav(view);
navSubsAt = "";
// the sidebar coming or going isn't a list opening
navSubs.quiet = true;
+8 -8
View File
@@ -3703,7 +3703,6 @@ const I18N = {
"No {api} URL": "没有 {api} 地址",
"This key is set to {api} only, but {name} has no {api} URL, so no request reaches {api} with it. Fill in the {api} URL, or set the key to Any protocol.": "这个 key 只用于 {api},但 {name} 没有填 {api} 地址,所以用这个 key 的请求到不了 {api}。请填上 {api} 地址,或者把 key 改回「任意协议」。",
"any API": "任意 API",
"models agents pick as one": "Agent 当作一个模型来选",
"Client": "客户端",
"Unhide": "取消隐藏",
"found by magpie": "magpie 自动发现",
@@ -3993,6 +3992,7 @@ const I18N = {
"At least: {k} replies read from session files, which don't say when their answers began, so time before that is counted too": "下限:{k} 次读自会话文件的回复。会话文件不记录正文何时开始,之前的时间也算在里面",
"Protocol": "协议",
"Upstream stop reason": "上游结束原因",
"Open routing groups": "打开路由组",
"Open Routing": "打开路由",
"{n} min": "{n} 分钟",
"{n} h": "{n} 小时",
@@ -4064,7 +4064,7 @@ const I18N = {
"Agents don't see them: only the routing groups they are in use them.": "Agent 看不到这些模型,只有它们所在的路由分组会用到。",
"Agents see the models picked.": "Agent 看到的是已勾选的模型。",
"In no routing group, so no agent can use them now: {models}.": "不在任何路由分组中,暂无 Agent 能用:{models}。",
"Once saved, make a group of them in Routing.": "保存后可在「路由」里为它们建分组。",
"Once saved, make a group of them in Routing groups.": "保存后可在「路由组」里为它们建分组。",
"Make a routing group of {model}": "用 {model} 建路由分组",
"Make a routing group of it": "用它建路由分组",
"Pick {group}": "选 {group}",
@@ -8321,7 +8321,6 @@ const I18N = {
"No {api} URL": "沒有 {api} 位址",
"This key is set to {api} only, but {name} has no {api} URL, so no request reaches {api} with it. Fill in the {api} URL, or set the key to Any protocol.": "這個 key 只用於 {api},但 {name} 沒有填 {api} 位址,所以用這個 key 的請求到不了 {api}。請填上 {api} 位址,或把 key 改回「任意協議」。",
"any API": "任意 API",
"models agents pick as one": "Agent 當作一個模型來選",
"Client": "用戶端",
"Unhide": "取消隱藏",
"found by magpie": "magpie 自動發現",
@@ -8608,6 +8607,7 @@ const I18N = {
"At least: {k} replies read from session files, which don't say when their answers began, so time before that is counted too": "下限:{k} 次讀自會話檔案的回覆。會話檔案不記錄正文何時開始,之前的時間也算在裡面",
"Protocol": "協議",
"Upstream stop reason": "上游結束原因",
"Open routing groups": "開啟路由組",
"Open Routing": "開啟路由",
"{n} min": "{n} 分鐘",
"{n} h": "{n} 小時",
@@ -8677,7 +8677,7 @@ const I18N = {
"Agents don't see them: only the routing groups they are in use them.": "Agent 看不到這些模型,只有它們所在的路由分組會用到。",
"Agents see the models picked.": "Agent 看到的是已勾選的模型。",
"In no routing group, so no agent can use them now: {models}.": "不在任何路由分組中,暫無 Agent 能用:{models}。",
"Once saved, make a group of them in Routing.": "儲存後可在「路由」裡為它們建分組。",
"Once saved, make a group of them in Routing groups.": "儲存後可在「路由組」裡為它們建分組。",
"Make a routing group of {model}": "用 {model} 建路由分組",
"Make a routing group of it": "用它建路由分組",
"Pick {group}": "選 {group}",
@@ -12951,7 +12951,6 @@ const I18N = {
"No {api} URL": "{api} の URL がありません",
"This key is set to {api} only, but {name} has no {api} URL, so no request reaches {api} with it. Fill in the {api} URL, or set the key to Any protocol.": "このキーは {api} 専用ですが、{name} には {api} の URL がないため、このキーでのリクエストは {api} に届きません。{api} の URL を入力するか、キーを「任意のプロトコル」に戻してください。",
"any API": "任意の API",
"models agents pick as one": "エージェントが 1 つとして選ぶモデル群",
"Client": "クライアント",
"Unhide": "再表示",
"found by magpie": "magpie が自動作成",
@@ -13237,6 +13236,7 @@ const I18N = {
"At least: {k} replies read from session files, which don't say when their answers began, so time before that is counted too": "下限:セッションファイルから読んだ {k} 件の応答。回答が始まった時刻がないため、その前の時間も含まれます",
"Protocol": "プロトコル",
"Upstream stop reason": "上流の終了理由",
"Open routing groups": "ルーティンググループを開く",
"Open Routing": "ルーティングを開く",
"{n} min": "{n} 分",
"{n} h": "{n} 時間",
@@ -13306,7 +13306,7 @@ const I18N = {
"Agents don't see them: only the routing groups they are in use them.": "エージェントには見えません。所属するルーティンググループだけが使います。",
"Agents see the models picked.": "エージェントには選択したモデルが表示されます。",
"In no routing group, so no agent can use them now: {models}.": "どのルーティンググループにも入っていないため、現在どのエージェントも使えません:{models}。",
"Once saved, make a group of them in Routing.": "保存したら「ルーティング」でこれらのグループを作成してください。",
"Once saved, make a group of them in Routing groups.": "保存したら「ルーティンググループ」でこれらのグループを作成してください。",
"Make a routing group of {model}": "{model} でルーティンググループを作成",
"Make a routing group of it": "これでルーティンググループを作成",
"Pick {group}": "{group} を選択",
@@ -17592,7 +17592,6 @@ const I18N = {
"No {api} URL": "Keine {api}-URL",
"This key is set to {api} only, but {name} has no {api} URL, so no request reaches {api} with it. Fill in the {api} URL, or set the key to Any protocol.": "Dieser Schlüssel ist nur für {api} eingestellt, aber {name} hat keine {api}-URL, daher erreicht keine Anfrage mit ihm {api}. Trag die {api}-URL ein oder stell den Schlüssel auf Beliebiges Protokoll.",
"any API": "beliebige API",
"models agents pick as one": "Modelle, die Agenten als eines wählen",
"Client": "Client",
"Unhide": "Einblenden",
"found by magpie": "von magpie gefunden",
@@ -17881,6 +17880,7 @@ const I18N = {
"At least: {k} replies read from session files, which don't say when their answers began, so time before that is counted too": "Mindestens: {k} Antworten aus Sitzungsdateien. Sie sagen nicht, wann die Antworten begannen, also zählt die Zeit davor mit",
"Protocol": "Protokoll",
"Upstream stop reason": "Endgrund des Upstreams",
"Open routing groups": "Weiterleitungsgruppen öffnen",
"Open Routing": "Weiterleitung öffnen",
"{n} min": "{n} min",
"{n} h": "{n} h",
@@ -17950,7 +17950,7 @@ const I18N = {
"Agents don't see them: only the routing groups they are in use them.": "Agenten sehen sie nicht: Nur die Weiterleitungsgruppen, in denen sie sind, nutzen sie.",
"Agents see the models picked.": "Agenten sehen die gewählten Modelle.",
"In no routing group, so no agent can use them now: {models}.": "In keiner Weiterleitungsgruppe, daher kann sie derzeit kein Agent nutzen: {models}.",
"Once saved, make a group of them in Routing.": "Erstellen Sie nach dem Speichern unter Weiterleitung eine Gruppe daraus.",
"Once saved, make a group of them in Routing groups.": "Erstellen Sie nach dem Speichern unter Weiterleitungsgruppen eine Gruppe daraus.",
"Make a routing group of {model}": "Weiterleitungsgruppe aus {model} erstellen",
"Make a routing group of it": "Weiterleitungsgruppe daraus erstellen",
"Pick {group}": "{group} wählen",
+1
View File
@@ -72,6 +72,7 @@
<span class="nav-gl" data-t>Models</span>
<button data-view="providers"><svg class="nav-ic" viewBox="0 0 20 20" width="16" height="16" aria-hidden="true"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><circle cx="7" cy="10" r="3"/><path d="M10 10h7M14 10v3M16.5 10v2"/></g></svg><span data-t>Providers</span></button>
<button data-view="routing" data-feature="routing"><svg class="nav-ic" viewBox="0 0 20 20" width="16" height="16" aria-hidden="true"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M3 10h5l4-5h5M8 10l4 5h5M14.5 3l2.5 2-2.5 2M14.5 13l2.5 2-2.5 2"/></g></svg><span data-t>Routing</span></button>
<button data-view="groups" data-feature="routing"><svg class="nav-ic" viewBox="0 0 20 20" width="16" height="16" aria-hidden="true"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><rect x="3.5" y="3.5" width="5" height="5" rx="1.2"/><rect x="11.5" y="3.5" width="5" height="5" rx="1.2"/><rect x="3.5" y="11.5" width="5" height="5" rx="1.2"/><path d="M14 11.5v5M11.5 14h5"/></g></svg><span data-t>Routing groups</span></button>
<button data-view="gateway" data-feature="gateway"><svg class="nav-ic" viewBox="0 0 20 20" width="16" height="16" aria-hidden="true"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="14" height="5" rx="1.5"/><rect x="3" y="11" width="14" height="5" rx="1.5"/><path d="M6 6.5h.01M6 13.5h.01"/></g></svg><span data-t>Gateway</span></button>
<span class="nav-gl" data-t>Insights</span>
<button data-view="usage" data-feature="usage"><svg class="nav-ic" viewBox="0 0 20 20" width="16" height="16" aria-hidden="true"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M4 16V9M8 16V5M12 16v-5M16 16V7"/></g></svg><span data-t>Usage</span></button>
+97 -92
View File
@@ -21,8 +21,7 @@ magpie.plugin("routing", (ctx) => {
title: "Routing",
html: `
<div class="row-head"><span class="label" data-t>Routing</span><span class="rt-livedot" aria-hidden="true"></span><span class="note" data-t>live, as the gateway decides</span><span class="grow"></span>
<button class="text rt-gogroups" id="rtGoGroups" type="button" data-tt="Go to the routing groups, below the requests"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 3v9.5M4 8.5l4 4 4-4"/></svg><span data-t>Routing groups</span></button>
<button class="text rt-newgroup" id="rtNewGroup" type="button" data-feature="groups" data-tt="Make a routing group of any models you like — agents pick it as one model"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true"><path d="M8 3.5v9M3.5 8h9"/></svg><span data-t>New group</span></button>
<button class="text rt-togroups" type="button" id="rtToGroups"><span data-t>Routing groups</span> ›</button>
<button class="text rt-mask" id="rtMask" aria-pressed="false" data-tt="Mask the accounts on every page — email addresses and account names — for a screenshot to share"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9.9 4.2A10.4 10.4 0 0 1 12 4c6.5 0 10 8 10 8a17.6 17.6 0 0 1-2.2 3.2M6.6 6.6C3.9 8.4 2 12 2 12s3.5 8 10 8a9.7 9.7 0 0 0 5.4-1.6M9.9 9.9a3 3 0 0 0 4.2 4.2M2 2l20 20"/></svg><span data-t>Hide accounts</span></button></div>
<section class="rt" id="rt"></section>
<div class="rt-more" id="rtMore"></div>
@@ -36,6 +35,16 @@ magpie.plugin("routing", (ctx) => {
return ready.then(() => routingPage(this));
},
});
// Routing groups, a page of their own beside Routing (11-06): under the
// stage and every request they were a long scroll down, and New group
// with them. The same script draws them (routingPage), into this page.
ctx.slots.add("page", {
key: "groups",
title: "Routing groups",
html: `<div class="rt-gpage" id="rtGroups"></div>`,
// Try again filled the page with its markup anew: the groups go back in
mount(main) { window.routingGroupsHome?.(main); },
});
});
// The page, drawn once app.js is set up; part is its part, given the hooks
@@ -43,14 +52,20 @@ magpie.plugin("routing", (ctx) => {
function routingPage(part) {
const box = $("#rt");
if (!box) return;
// the groups' way in where the header's row has no tab for them (markNav)
const toGroups = $("#rtToGroups");
if (toGroups) toGroups.onclick = () => window.show("groups");
const NS = "http://www.w3.org/2000/svg";
const still = calm;
const shown = () => !$("#view-routing").hidden && !document.hidden;
// the Routing groups page, which this script draws too (gsec)
const gView = () => $("#view-groups");
const gShown = () => !gView().hidden && !document.hidden;
// steady redraws a part of the page where the reader is: WebKit has no
// scroll anchoring, and a part emptied and filled again, measured between,
// pulls the page up to what was left of it for that moment
function steady(fn) {
const v = $("#view-routing"), top = v.scrollTop;
function steady(fn, v = $("#view-routing")) {
const top = v.scrollTop;
try { return fn(); } finally { if (v.scrollTop !== top) v.scrollTop = top; }
}
@@ -2702,26 +2717,40 @@ function routingPage(part) {
if (e.title !== title) e.title = title;
} else for (const a of ["data-go", "tabindex", "role", "title"]) e.removeAttribute(a);
}
function goRouting(e, go) {
async function goRouting(e, go) {
const i = go.indexOf(":"), kind = go.slice(0, i), id = CSS.escape(go.slice(i + 1));
const row = kind === "group" ? gList.querySelector(`.rt-group[data-id="${id}"]`) : pList.querySelector(`.rt-pool[data-provider="${id}"]`);
if (!row) return;
if (window.scrollOnPurpose?.(e)) row.scrollIntoView({ block: "center", behavior: still() ? "auto" : "smooth" });
// they are on the Routing groups page: it opens, and the row comes
// into sight as the reader's click asked. A page just opened is at the
// row at once, and that is where the reader is in it (arrived): else
// the page put itself back where the reader last left it
const asked = window.scrollOnPurpose?.(e), opens = gView().hidden;
if (opens && !(await window.show("groups"))) return;
if (asked) {
readerScrolls(1000);
row.scrollIntoView({ block: "center", behavior: opens || still() ? "auto" : "smooth" });
if (opens) window.arrived?.(gView());
}
row.classList.remove("rt-found");
void row.offsetWidth;
row.classList.add("rt-found");
row.querySelector(".segs .opt.on")?.focus({ preventScroll: true });
}
$("#view-routing").addEventListener("click", (e) => {
const g = e.target.closest(".rt-go[data-go]");
if (g) goRouting(e, g.dataset.go);
});
$("#view-routing").addEventListener("keydown", (e) => {
const g = (e.key === "Enter" || e.key === " ") && e.target.closest?.(".rt-go[data-go]");
if (!g) return;
e.preventDefault();
goRouting(e, g.dataset.go);
});
// on both pages: a request's group, and a group or provider named in
// another group's card
for (const v of [$("#view-routing"), gView()]) {
v?.addEventListener("click", (e) => {
const g = e.target.closest(".rt-go[data-go]");
if (g) goRouting(e, g.dataset.go);
});
v?.addEventListener("keydown", (e) => {
const g = (e.key === "Enter" || e.key === " ") && e.target.closest?.(".rt-go[data-go]");
if (!g) return;
e.preventDefault();
goRouting(e, g.dataset.go);
});
}
// lightRow lights a row and its wire: on for the one answering or that
// answered the request shown, now and a flowing wire only while a
@@ -5531,11 +5560,21 @@ function routingPage(part) {
};
const gOffBox = el("div", "list rt-goffbox");
gOffBox.append(el("div", "rt-goffwhy", t("Routing groups are off in Plugins › Built-in: the groups magpie finds, one model several providers serve, still route, but your own can't be made or changed here.")), gOn);
gOff.append(el("div", "row-head", el("span", "label", t("Routing groups"))), gOffBox);
gsec.append(gHead, gFound, gNames, gList, gOff, pHead, pList);
// after the requests: a request picked in the list plays on the stage,
// so the list sits right under it
more.append(gsec);
gOff.append(gOffBox);
// the settings that hold for every group, under the list (11-06)
const sHead = el("div", "row-head rt-gset-head");
sHead.dataset.feature = "groups";
sHead.append(el("span", "label", t("Settings")));
const gSet = el("div", "list rt-gset");
gSet.dataset.feature = "groups";
gSet.append(gFound, gNames);
gsec.append(gHead, gList, gOff, sHead, gSet, pHead, pList);
// on the Routing groups page, a page of their own; Try again on it puts
// them back in its markup made anew
const gHome = () => $("#rtGroups");
window.routingGroupsHome = (main) => (main?.querySelector("#rtGroups") || gHome())?.append(gsec);
window.routingGroupsHome();
if (gHome()) byWidth(gHome(), { max520: (w) => w <= 520 });
const ROUTE_OPTS = [["", "Smart"], ["order", "In order"], ["drain", "Until used up"], ["rotate", "In turn"], ["usage", "Least used"], ["pace", "Use before expiry"], ["free", "Free first"], ["fast", "Speed first"]];
// a group may also be routed by hand: every request to the member the
// user picks on its card (provider.Manual, #317) — a provider's keys can't
@@ -5675,8 +5714,8 @@ function routingPage(part) {
// calling it on a row already in view would drop the hold the next editor
// opens under (backToReader, app.js, guards the same way).
const saved = body.id || body.from || "";
const row = saved && document.querySelector(`#view-routing .rt-group[data-id="${CSS.escape(saved)}"]`);
const view = row && gFolded !== saved && document.getElementById("view-routing");
const row = saved && gList.querySelector(`.rt-group[data-id="${CSS.escape(saved)}"]`);
const view = row && gFolded !== saved && gView();
if (view) {
const rr = row.getBoundingClientRect(), vb = view.getBoundingClientRect();
if (rr.bottom > vb.bottom || rr.top < vb.top) { readerScrolls(1000); row.scrollIntoView({ block: "nearest" }); }
@@ -5808,7 +5847,7 @@ function routingPage(part) {
if (!groups) return;
// not under a row being dragged: it is drawn when let go
if (groupArranging) { groupRenderPending = true; return; }
steady(drawGroups);
steady(drawGroups, gView());
}
// gSel: the groups picked to be removed together, while picking (lc on
// Discord: they could only be removed one at a time); null otherwise
@@ -5900,16 +5939,23 @@ function routingPage(part) {
const shown = words.length ? all.filter((g) => gEdit?.id === g.id || groupMatches(g, words)) : all;
if (gSel) gSel = new Set([...gSel].filter((id) => shown.some((g) => g.id === id)));
if (gSel && !all.length) gSel = null;
const newBtn = el("button", "text rt-gnew");
// the page's toolbar (11-06): the filter and how many there are on the
// left, what makes or picks groups on the right, New group the one
// filled button
const newBtn = el("button", "text primary rt-gnew");
newBtn.type = "button";
newBtn.dataset.feature = "groups"; // off with them, as the note says
newBtn.append(svg(PLUS, 11, 1.8), el("span", "", t("New group")));
newBtn.title = t("Make a routing group of any models you like — agents pick it as one model");
newBtn.onclick = () => newGroup();
const head = [el("span", "label", t("Routing groups")), el("span", "grow"), el("span", "note", t("models agents pick as one"))];
const head = [];
if (all.length > 1 || gQ.value) {
gQ.placeholder = t("Filter groups and models");
gQ.setAttribute("aria-label", gQ.placeholder);
head.push(gQ);
}
if (all.length) head.push(el("span", "note rt-gcount", t("{n} groups · {m} on", { n: all.length, m: all.filter((g) => !g.disabled).length })));
head.push(el("span", "grow"));
// templates: a group for a common need made of the user's own models
// in a click (provider.Templates). Cards while the user has no group of
// their own, a menu by New group after
@@ -5989,7 +6035,7 @@ function routingPage(part) {
let gMorph = null, gSaved = null, gFolded = null;
const slotKey = (n) => n.dataset?.gslot;
function slotsOf() {
const m = new Map(), vt = document.getElementById("view-routing").getBoundingClientRect().top;
const m = new Map(), vt = gView().getBoundingClientRect().top;
for (const n of gList.children) {
const k = slotKey(n);
if (k === undefined) continue;
@@ -6001,7 +6047,7 @@ function routingPage(part) {
function morphSlots(was) {
const alias = gMorph, saved = gSaved;
gMorph = gSaved = gFolded = null;
if (still() || !shown()) return;
if (still() || !gShown()) return;
for (const n of gList.children) {
const k = slotKey(n);
if (k === undefined) continue;
@@ -6043,7 +6089,7 @@ function routingPage(part) {
// was above the window's; the page's scroll is read once the redraw
// has put it back (steady).
function foldInSight(n, grow, from, to, top) {
const view = document.getElementById("view-routing");
const view = gView();
readerScrolls(1000);
let s0, target;
const step = () => {
@@ -6712,7 +6758,7 @@ function routingPage(part) {
const sfxSaid = el("span", "hint");
const sayLabel = () => {
sfxSaid.textContent = t("Agents’ lists show “{label}”", { label: (d.name.trim() || t("New group")) + (suffixMode() === "on" ? " · routing group" : "") }) +
" · " + t("“· routing group” is set for every group above");
" · " + t("“· routing group” is set for every group, under the list");
};
name.oninput = () => { d.name = name.value; showId(); sayLabel(); };
const nw = el("div");
@@ -8001,15 +8047,26 @@ function routingPage(part) {
}
// loaded when the view is shown, and again when the window comes back
// back on the page, the same groups aren't drawn again either (#4652)
new MutationObserver(() => { if (!$("#view-routing").hidden) loadGroups(true); }).observe($("#view-routing"), { attributes: true, attributeFilter: ["hidden"] });
window.addEventListener("focus", () => { if (shown()) loadGroups(true); });
// on either page: Routing names the groups too (its stage, the story)
for (const v of [$("#view-routing"), gView()]) new MutationObserver(() => { if (!v.hidden) loadGroups(true); }).observe(v, { attributes: true, attributeFilter: ["hidden"] });
window.addEventListener("focus", () => { if (shown() || gShown()) loadGroups(true); });
// the groups' rows say what is left of their accounts, drawn again when
// the Usage page's readings come while the page is open (Routing's own
// second does it there); the page may be open already, from ?view=groups
let gTick = 0;
const gTicks = () => {
clearInterval(gTick);
gTick = gView().hidden ? 0 : setInterval(() => { if (gShown()) groupsReadAgain(); }, 1000);
};
gTicks();
new MutationObserver(gTicks).observe(gView(), { attributes: true, attributeFilter: ["hidden"] });
// newGroupWith: a new group's editor, opened with the model in it — a
// model of a provider kept for routing groups that no group has, which
// agents can reach no other way. The picker and the provider's editor
// ask it (and the tray panel, by ?newgroup= on the window it opens).
window.newGroupWith = async (id, name, ev) => {
// app.js's show, the page's: this one's own show is the stage's caption
if (document.body.classList.contains("window") && $("#view-routing").hidden && !(await window.show("routing"))) return;
if (document.body.classList.contains("window") && gView().hidden && !(await window.show("groups"))) return;
if (!groups) await loadGroups();
if (!groups) return;
if (groupDirty() && !(await confirmDiscard())) return;
@@ -8019,9 +8076,7 @@ function routingPage(part) {
if (ed && window.scrollOnPurpose?.(ev)) ed.scrollIntoView({ block: "center", behavior: "smooth" });
ed?.querySelector("input")?.focus({ preventScroll: true });
};
// newGroup: an empty new group's editor. The groups sit below the
// requests, out of sight on a first look, so the page's head has a New
// group too (mintonight, #944), which brings the editor into view.
// newGroup: an empty new group's editor, at the list's top
async function newGroup(ev) {
if (groupDirty() && !(await confirmDiscard())) return;
gSel = null;
@@ -8032,71 +8087,21 @@ function routingPage(part) {
if (ed && window.scrollOnPurpose?.(ev)) ed.scrollIntoView({ block: "center", behavior: "smooth" });
ed?.querySelector("input")?.focus({ preventScroll: true });
}
const headNew = $("#rtNewGroup");
if (headNew) headNew.onclick = async (ev) => {
if (!groups) await loadGroups();
if (groups) newGroup(ev);
};
// the head's Routing groups: the groups sit below the stage, the story
// and every request, a long scroll down with many models (shihh on
// Discord). Its click brings them to the top of the view, and the focus
// with them, so Tab goes on from there; the page is laid out as before
gsec.tabIndex = -1;
const headGo = $("#rtGoGroups");
if (headGo) headGo.onclick = (ev) => {
if (!window.scrollOnPurpose?.(ev)) return;
gsec.scrollIntoView({ block: "start", behavior: still() ? "auto" : "smooth" });
gsec.focus({ preventScroll: true });
};
// fitGo: it takes only room the head has spare, so nothing else in the
// head moves or wraps for it: named where its name fits, its arrow alone
// where only that does, and left out of a head with no room (a phone's)
const goHead = headGo?.parentElement, goGrow = goHead?.querySelector(".grow");
function fitGo() {
if (!goGrow || !goHead.offsetParent) return;
headGo.dataset.fit = "none";
const room = goGrow.getBoundingClientRect().width, gap = parseFloat(getComputedStyle(goHead).columnGap) || 0;
for (const fit of ["full", "icon"]) {
headGo.dataset.fit = fit;
if (room >= headGo.getBoundingClientRect().width + 6 + gap) return;
}
headGo.dataset.fit = "none";
}
let goFitting = 0;
const fitGoSoon = () => { if (!goFitting) goFitting = requestAnimationFrame(() => { goFitting = 0; fitGo(); }); };
if (goHead) {
const ro = new ResizeObserver(fitGoSoon);
for (const n of [goHead, ...goHead.querySelectorAll(".label, .note")]) ro.observe(n);
new MutationObserver(fitGoSoon).observe(document.documentElement, { attributes: true, attributeFilter: ["lang"] });
}
const askedGroup = document.body.classList.contains("window") && params.get("newgroup");
if (askedGroup) loadGroups().then(() => window.newGroupWith(askedGroup, ""));
else loadGroups();
// ---------- where the reader is, as requests come ----------
// Every request redraws what is above the routing groups: the stage gains
// or loses a row, the story a line, the lists theirs. The view kept its
// scrollTop, so all of it pushed the groups down or pulled them up under
// the reader, a group being edited too (Jerell.OvO on Discord). The view
// keeps a part of itself where it is on the screen instead (keepInView in
// app.js): the groups, while they are in the upper half of the view or a
// field in them has the focus, else the lists, while they are; with
// neither (the stage in sight at the top), the view stays as it is.
// The groups too while the pointer is on them, low in the view as they
// are at the page's foot: a manual group's card, its pick a click away,
// slid down from under the pointer as the requests list above it grew
// (cwfox67 on X).
// Every request redraws what is above the lists: the stage gains or
// loses a row, the story a line. The view keeps the lists where they are
// on the screen while they are in its upper half (keepInView in app.js);
// with the stage in sight at the top, the view stays as it is. The
// routing groups sat below them until they had a page of their own.
const rv = $("#view-routing");
keepInView(rv, () => {
const mid = rv.getBoundingClientRect().top + rv.clientHeight / 2;
if ((gsec.contains(document.activeElement) || gsec.matches(":hover")) && gsec.offsetParent) return gsec;
return [gsec, hist].find((p) => p.offsetParent && p.getBoundingClientRect().top <= mid) || null;
return hist.offsetParent && hist.getBoundingClientRect().top <= mid ? hist : null;
});
// the pointer coming onto the groups or off them changes the part kept,
// so where the reader is is taken again, as their scroll would
const repin = () => { if (held?.v !== rv && !rv.hidden) readerLeaves(rv); };
gsec.addEventListener("pointerenter", repin);
gsec.addEventListener("pointerleave", repin);
// ---------- the tray panel's Routing tab ----------
// The gateway's latest requests, as they come, from the same trace the
+8 -8
View File
@@ -13,7 +13,7 @@ magpie.strings({
"magpie is masking this request before routing it (Settings › Privacy), so who takes it isn't picked yet.": "magpie 正在给这个请求脱敏(设置 › 隐私),脱敏完才路由,所以还没选出由谁处理。",
"magpie hasn't routed this request yet, so who takes it isn't picked yet.": "magpie 还没开始路由这个请求,所以还没选出由谁处理。",
"Nothing took this request: {error}": "没有谁处理这个请求:{error}",
"Go to the routing groups, below the requests": "跳到请求下方的路由组",
"{n} groups · {m} on": "{n} 个组 · {m} 个开启",
"Filter, or type an agent's name…": "筛选,或输入 Agent 名称…",
"the name its User-Agent begins with": "User-Agent 开头的名称",
"heard from in the last 30 days": "近 30 天有请求",
@@ -43,7 +43,7 @@ magpie.strings({
"In agents’ lists": "Agent 列表里的名称",
"Names in agents’ lists": "Agent 列表里的名称",
"Whether “· routing group” follows a group’s name in the agents’ lists: one setting for every group, and for the provider after each model’s name, as on Settings.": "Agent 的模型列表里,路由组名后面是否带「· routing group」。这是所有路由组共用的一个设置,也决定模型名后面是否带供应商,和「设置」里的是同一个。",
"“· routing group” is set for every group above": "是否带「· routing group」在上方统一设置,对所有路由组生效",
"“· routing group” is set for every group, under the list": "是否带「· routing group」在列表下方统一设置,对所有路由组生效",
"{agent} guessed your next message for its composer by itself, reading the whole conversation again. Not a turn of the conversation; Codex composer predictions, under Settings in Codex's row on the Agents page, picks its model, and Codex's Settings › General › Show predictions turns it off.": "{agent} 自行为输入框猜测你的下一条消息,每次都把整段对话重读一遍。不属于对话轮次;在 Agent 页 Codex 那一行的设置里,用 Codex 输入框预测 选它用的模型,在 Codex 的 设置 › 常规 › 显示预测内容 里可以关掉。",
"{name} is switched off: the group skips it until it is on again": "{name} 已关闭:开启前这个组会跳过它",
"{n} switched off": "{n} 个已关闭",
@@ -680,7 +680,7 @@ magpie.strings({
"magpie is masking this request before routing it (Settings › Privacy), so who takes it isn't picked yet.": "magpie 正在為這個請求脫敏(設定 › 隱私),脫敏完才路由,所以還沒選出由誰處理。",
"magpie hasn't routed this request yet, so who takes it isn't picked yet.": "magpie 還沒開始路由這個請求,所以還沒選出由誰處理。",
"Nothing took this request: {error}": "沒有誰處理這個請求:{error}",
"Go to the routing groups, below the requests": "跳到請求下方的路由組",
"{n} groups · {m} on": "{n} 個組 · {m} 個開啟",
"Filter, or type an agent's name…": "篩選,或輸入 Agent 名稱…",
"the name its User-Agent begins with": "User-Agent 開頭的名稱",
"heard from in the last 30 days": "近 30 天有請求",
@@ -721,7 +721,7 @@ magpie.strings({
"In agents’ lists": "Agent 列表裡的名稱",
"Names in agents’ lists": "Agent 列表裡的名稱",
"Whether “· routing group” follows a group’s name in the agents’ lists: one setting for every group, and for the provider after each model’s name, as on Settings.": "Agent 的模型列表裡,路由組名後面是否帶「· routing group」。這是所有路由組共用的一個設定,也決定模型名後面是否帶供應商,和「設定」裡的是同一個。",
"“· routing group” is set for every group above": "是否帶「· routing group」在上方統一設定,對所有路由組生效",
"“· routing group” is set for every group, under the list": "是否帶「· routing group」在列表下方統一設定,對所有路由組生效",
"{name} is switched off: the group skips it until it is on again": "{name} 已關閉:開啟前這個組會跳過它",
"{n} switched off": "{n} 個已關閉",
"Off: agents aren't offered {name} and a request to it is turned away. Click to switch it on": "已關閉:Agent 列表裡沒有 {name},發給它的請求會被拒絕。點選開啟",
@@ -1347,7 +1347,7 @@ magpie.strings({
"magpie is masking this request before routing it (Settings › Privacy), so who takes it isn't picked yet.": "magpie はルーティングの前にこのリクエストをマスクしています(設定 › プライバシー)。誰が処理するかはまだ決まっていません。",
"magpie hasn't routed this request yet, so who takes it isn't picked yet.": "magpie はまだこのリクエストをルーティングしていないため、誰が処理するかはまだ決まっていません。",
"Nothing took this request: {error}": "このリクエストを処理したものはありません: {error}",
"Go to the routing groups, below the requests": "リクエストの下にあるルーティンググループへ移動",
"{n} groups · {m} on": "{n} 個のグループ · {m} 個がオン",
"Filter, or type an agent's name…": "絞り込み、またはエージェント名を入力…",
"the name its User-Agent begins with": "User-Agent の先頭の名前",
"heard from in the last 30 days": "過去 30 日にリクエストあり",
@@ -1375,7 +1375,7 @@ magpie.strings({
"In agents’ lists": "エージェントの一覧での名前",
"Names in agents’ lists": "エージェントの一覧での名前",
"Whether “· routing group” follows a group’s name in the agents’ lists: one setting for every group, and for the provider after each model’s name, as on Settings.": "エージェントの一覧でグループ名の後に「· routing group」を付けるかどうか。すべてのグループに共通の設定で、モデル名の後のプロバイダ名にも効きます(「設定」と同じものです)。",
"“· routing group” is set for every group above": "「· routing group」を付けるかは上で全グループ共通に設定します",
"“· routing group” is set for every group, under the list": "「· routing group」を付けるかは一覧の下で全グループ共通に設定します",
"{agent} guessed your next message for its composer by itself, reading the whole conversation again. Not a turn of the conversation; Codex composer predictions, under Settings in Codex's row on the Agents page, picks its model, and Codex's Settings › General › Show predictions turns it off.": "{agent} が入力欄に表示する次のメッセージの予測を自分で行い、そのたびに会話全体を読み直しました。会話のターンではありません。エージェントページの Codex の行にある設定の Codex の入力予測 でモデルを選べ、Codex の 設定 › 一般 › 予測候補を表示 でオフにできます。",
"{name} is switched off: the group skips it until it is on again": "{name} はオフです。オンに戻すまでグループはスキップします",
"{n} switched off": "{n} 件オフ",
@@ -2014,7 +2014,7 @@ magpie.strings({
"magpie is masking this request before routing it (Settings › Privacy), so who takes it isn't picked yet.": "magpie maskiert diese Anfrage vor der Weiterleitung (Einstellungen › Datenschutz), daher steht noch nicht fest, wer sie übernimmt.",
"magpie hasn't routed this request yet, so who takes it isn't picked yet.": "magpie hat diese Anfrage noch nicht weitergeleitet, daher steht noch nicht fest, wer sie übernimmt.",
"Nothing took this request: {error}": "Niemand hat diese Anfrage übernommen: {error}",
"Go to the routing groups, below the requests": "Zu den Weiterleitungsgruppen unter den Anfragen springen",
"{n} groups · {m} on": "{n} Gruppen · {m} an",
"Filter, or type an agent's name…": "Filtern oder Namen eines Agenten eingeben…",
"the name its User-Agent begins with": "der Name, mit dem sein User-Agent beginnt",
"heard from in the last 30 days": "in den letzten 30 Tagen gesehen",
@@ -2042,7 +2042,7 @@ magpie.strings({
"In agents’ lists": "In den Listen der Agenten",
"Names in agents’ lists": "Namen in den Listen der Agenten",
"Whether “· routing group” follows a group’s name in the agents’ lists: one setting for every group, and for the provider after each model’s name, as on Settings.": "Ob in den Listen der Agenten „· routing group“ auf den Namen einer Gruppe folgt: eine Einstellung für alle Gruppen, und für den Anbieter nach jedem Modellnamen, wie in den Einstellungen.",
"“· routing group” is set for every group above": "„· routing group“ wird oben für alle Gruppen eingestellt",
"“· routing group” is set for every group, under the list": "„· routing group“ wird unter der Liste für alle Gruppen eingestellt",
"{agent} guessed your next message for its composer by itself, reading the whole conversation again. Not a turn of the conversation; Codex composer predictions, under Settings in Codex's row on the Agents page, picks its model, and Codex's Settings › General › Show predictions turns it off.": "{agent} hat deine nächste Nachricht für sein Eingabefeld selbst vorhergesagt und dafür das ganze Gespräch erneut gelesen. Kein Zug des Gesprächs; das Modell wählst du mit Codex-Eingabevorhersagen unter Einstellungen in der Zeile von Codex auf der Seite Agenten, und in Codex unter Einstellungen › Allgemein › Textvorschläge anzeigen schaltest du es ab.",
"{name} is switched off: the group skips it until it is on again": "{name} ist ausgeschaltet: Die Gruppe überspringt es, bis es wieder eingeschaltet ist",
"{n} switched off": "{n} ausgeschaltet",
+16 -18
View File
@@ -270,20 +270,18 @@
.rt-accts:where(.max460, .max560) li > em { text-align: left; }
:where(.rt.max560) .rt-stats { gap: 14px; }
/* the Routing view */
#view-routing .row-head { margin: 14px 0 6px; padding: 0 2px; gap: 0; }
#view-routing .row-head .note { font-size: 11px; color: var(--faint); margin-left: 8px; }
/* the Routing view, and the Routing groups view beside it */
:is(#view-routing, #view-groups) .row-head { margin: 14px 0 6px; padding: 0 2px; gap: 0; }
:is(#view-routing, #view-groups) .row-head .note { font-size: 11px; color: var(--faint); margin-left: 8px; }
#view-routing .row-head .rt-livedot + .note { margin-left: 8px; }
.rt-newgroup, .rt-gogroups { display: inline-flex; align-items: center; gap: 5px; }
.rt-newgroup svg, .rt-gogroups svg { width: 13px; height: 13px; flex: none; }
/* the routing groups, far below with many models: the head goes to them */
.rt-gogroups { margin-right: 6px; flex: none; }
.rt-gogroups[data-fit="icon"] > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.rt-gogroups[data-fit="none"] { display: none; }
.rt-gsec:focus { outline: none; }
/* the routing groups' New group, at the top too: the groups sit below the
requests, out of sight on a first look (#944) */
.rt-newgroup { margin-right: 6px; }
.rt-gnew { display: inline-flex; align-items: center; gap: 4px; }
/* the groups page's toolbar: the filter first, then how many */
.rt-gsec > .row-head:first-child .rt-gfilter { flex: 0 1 300px; width: auto; margin: 0; }
.rt-gsec > .row-head:first-child .rt-gcount { margin-left: 10px; white-space: nowrap; }
.rt-gsec > .row-head:first-child .rt-gfilter + .rt-gcount { margin-left: 10px; }
/* the settings for every group, a card under the list */
.rt-gset > :is(.rt-gfound, .rt-gnames) { padding: 12px 14px; }
.rt-gset > .rt-gnames { border-top: 1px solid var(--line-2); }
/* an email, hidden: stand-in letters of its shape, softly blurred —
coming in out of focus when asked for */
.pii { filter: blur(2.2px); opacity: .5; user-select: none; }
@@ -549,7 +547,7 @@ button.rt-session { cursor: pointer; }
/* it pulses while a request is under way only (#2827) */
@media (prefers-reduced-motion: reduce) { .rt-livedot.on::after { animation: none; } }
/* routing groups, and the providers routing over several of their own */
.rt-gsec { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; margin-top: 16px; }
.rt-gsec { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.rt-gsec .row-head .note { margin-right: 6px; }
/* the groups filtered by name and model, beside Select and New group */
.rt-gsec .rt-gfilter { width: 190px; min-width: 0; flex: 0 1 190px; height: 24px; margin: 0 6px 0 4px; }
@@ -741,11 +739,11 @@ body.window .rt-gedit > .bar { --vfoot: 8px; }
}
.rt-gsec .segs .opt { white-space: nowrap; }
/* the groups, in a page 520px wide or less */
:where(.rt-more.max520) .rt-gsec .row-head .note { display: none; }
:where(.rt-more.max520) .rt-gsec .rt-gfilter { flex: 1 1 auto; width: auto; }
:where(.rt-more.max520) .rt-gedit { grid-template-columns: minmax(0, 1fr); gap: 4px; }
:where(.rt-more.max520) .rt-gedit label { text-align: left; padding-top: 8px; }
:where(.rt-more.max520) .rt-gedit .segs .opt { padding-left: 9px; padding-right: 9px; }
:where(.rt-gpage.max520) .rt-gsec .row-head .note { display: none; }
:where(.rt-gpage.max520) .rt-gsec .rt-gfilter { flex: 1 1 auto; width: auto; }
:where(.rt-gpage.max520) .rt-gedit { grid-template-columns: minmax(0, 1fr); gap: 4px; }
:where(.rt-gpage.max520) .rt-gedit label { text-align: left; padding-top: 8px; }
:where(.rt-gpage.max520) .rt-gedit .segs .opt { padding-left: 9px; padding-right: 9px; }
/* the models and patterns take the column's width and no more: a grid's
auto track grows to its widest row's content, so a long model name with
its chips pushed the rows past the editor's edge, cut off there, and
+21 -19
View File
@@ -646,22 +646,31 @@ model's name (#968): a new group named "GPT 6.1 Sol" is said and sent as
`group/gpt-6.1-sol`, and `groupSlug` folds a run of dots and trims them at the
ends as `provider.GroupSlug` does, in English and Chinese, Chromium and WebKit.
`group-new-head.test.cjs` checks that a routing group of any models can be
made from the top of the Routing page, in Chromium and WebKit, English and
`group-new-head.test.cjs` checks that a routing group of any models is made
from the Routing groups page's toolbar, in Chromium and WebKit, English and
Chinese (mintonight, #944: the groups' New group sat below the requests, so
only found groups were used). The page's head has New group with a plus and a
tooltip saying what a group is, in sight while the groups are below the fold;
its click opens an empty group's editor, brings it into view and focuses its
name. The groups' own New group has the plus too. No left-border accent.
only found groups were used). New group is in sight on arrival, with a plus
and a tooltip saying what a group is; its click opens an empty group's
editor, brings it into view and focuses its name, and a draft is replaced
only after Discard. No left-border accent.
`routing-groups-page.test.cjs` checks that routing groups have a page of
their own, after Routing in the sidebar: its toolbar holds the filter, how
many groups there are and how many are on, Import, Select and New group as
the one filled button, in sight on arrival; the list follows, then Settings
(found groups, the names in agents' lists). The Routing page has no groups
and no jump to them. A request's group opens the groups page on its row, and
`?view=groups&newgroup=` opens a new group there. Every language, Chromium
and WebKit, at 1280px, 640px and 420px, with no sideways scroll.
`name-suffix-where-named.test.cjs` checks the setting that says whether a
provider's name or "· routing group" follows a name in the agents' lists (#868)
where names are given, in Chromium and WebKit, English and Chinese. The
provider editor's Names, prices & levels has its three choices and says what the lists
show. For the groups it is one setting for all of them, so it sits over the
groups on Routing (PAMI on Discord: in one group's editor it read as that
group's): a group's editor has no choices, only what its group will be called
and that it is set above; a pick there posts settings/plain-names once and the
show. For the groups it is one setting for all of them, so it sits under the
list on the Routing groups page (PAMI on Discord: in one group's editor it read
as that group's): a group's editor has no choices, only what its group will be
called and that it is set under the list; a pick there posts settings/plain-names once and the
open editor's line follows it with its unsaved name. No click scrolls, nothing
native, no left border, and every string has its Chinese, Japanese and German.
@@ -714,13 +723,6 @@ back, neither click scrolls the page, the row is drawn in gateway mode, and
nothing runs out of the row or the page sideways at 420px and 900px. Every
language, Chromium and WebKit.
`routing-steady.test.cjs` scrolls the Routing page down to its routing groups,
opens one in its editor and types into its name, then streams six requests in
from the trace (new agents and accounts on the stage, failures and retries in
the story, the lists growing): the groups and the editor stay where they are
on the screen on every layout and scroll, the view's scrollTop moving by just
what grew above them, and the field keeps its focus and what was typed.
`routing-flood.test.cjs` takes the Routing page out of sight three ways
(#302): the window hidden, the window covered and drawing no frames
without saying it is hidden, and another tab open. Meanwhile 30 requests
@@ -1977,9 +1979,9 @@ groups" (只通过路由分组使用; 悠悠哥 on Discord: hy4 vanished from th
The model picker's filter, finding such a model, says why it isn't offered:
hy3, in the group Mine, is reached by picking Mine ("Pick Mine" sets it);
hy4, in no group, can't be used, and "Make a routing group of it" opens the
Routing page on a new group of it, added with `members: ["hunyuan/hy4"]`.
Routing groups page on a new group of it, added with `members: ["hunyuan/hy4"]`.
The provider's editor names its models in no group under the tick (not once
unticked), each a click from a group; `?view=routing&newgroup=` opens the
unticked), each a click from a group; `?view=groups&newgroup=` opens the
window on one, and the tray panel asks `window/main` for it. The page doesn't
move, no left-border accent; English and Chinese, Chromium and WebKit.
+7 -4
View File
@@ -112,7 +112,10 @@ function server(lang, posts, broken) {
const tabs = (page) => page.evaluate(() => [...document.querySelectorAll("#nav button[data-view]")].filter((b) => !b.hidden && b.offsetParent && getComputedStyle(b).display !== "none").map((b) => b.dataset.view));
const viewShown = (page) => page.evaluate(() => [...document.querySelectorAll("main.view")].filter((v) => !v.hidden).map((v) => v.id));
// the tabs with Sessions and Library off, the preset's masking on
// (Routing groups has a tab of its own in the sidebar only, from 1024
// points; under it Routing's page opens them)
const KEPT = ["agents", "providers", "routing", "gateway", "usage", "masking", "plugins"];
const keptAt = (width) => (width >= 1024 ? KEPT.flatMap((k) => (k === "routing" ? [k, "groups"] : [k])) : KEPT);
const rowsOf = (page) => page.evaluate(() => [...document.querySelectorAll("#builtinList .feat-row")].map((r) => {
const b = r.querySelector('[role="switch"]');
return { id: r.dataset.id, name: r.querySelector(".name").textContent, on: b.getAttribute("aria-checked"), disabled: b.disabled, why: r.querySelector(".feat-why")?.textContent || "" };
@@ -145,7 +148,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await page.waitForSelector("#nav button.on");
const side = await page.evaluate(() => document.body.classList.contains("side-nav"));
assert.equal(side, width >= 1024, `${where}: the layout`);
if (width >= 800) assert.deepEqual(await tabs(page), KEPT, `${where}: Sessions' and Library's tabs gone`);
if (width >= 800) assert.deepEqual(await tabs(page), keptAt(width), `${where}: Sessions' and Library's tabs gone`);
// an address kept for a page switched off opens Agents
assert.deepEqual(await viewShown(page), ["view-agents"], `${where}: ?view=sessions`);
// Settings has no Features tab of its own, and Observability's is off
@@ -206,7 +209,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await page.locator('#builtinList [data-id="library"] [role="switch"]').click();
await page.waitForSelector('#builtinList [data-id="library"] [aria-checked="true"]');
assert.deepEqual(posts, [["library", true]], where);
if (width >= 800) assert.deepEqual(await tabs(page), ["agents", "library", ...KEPT.slice(1)], `${where}: Library back`);
if (width >= 800) assert.deepEqual(await tabs(page), ["agents", "library", ...keptAt(width).slice(1)], `${where}: Library back`);
assert.deepEqual(await viewShown(page), ["view-plugins"], `${where}: Plugins stays`);
// Observability's, Routing's and Usage's rows can be below the fold:
// the reader scrolls to them with the wheel, since the page puts back
@@ -253,7 +256,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await page.locator('#builtinList [data-id="routing"] [role="switch"]').click();
await page.waitForSelector('#builtinList [data-id="routing"] [aria-checked="false"]');
assert.deepEqual(posts.at(-1), ["routing", false], where);
if (width >= 800) assert.deepEqual(await tabs(page), ["agents", "library", ...KEPT.slice(1).filter((k) => k !== "routing")], `${where}: Routing gone`);
if (width >= 800) assert.deepEqual(await tabs(page), ["agents", "library", ...keptAt(width).slice(1).filter((k) => k !== "routing" && k !== "groups")], `${where}: Routing gone`);
assert.deepEqual(await viewShown(page), ["view-plugins"], `${where}: Plugins stays`);
// and Usage: its tab goes
const usageSwitch = page.locator('#builtinList [data-id="usage"] [role="switch"]');
@@ -262,7 +265,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await usageSwitch.click();
await page.waitForSelector('#builtinList [data-id="usage"] [aria-checked="false"]');
assert.deepEqual(posts.at(-1), ["usage", false], where);
if (width >= 800) assert.deepEqual(await tabs(page), ["agents", "library", ...KEPT.slice(1).filter((k) => k !== "routing" && k !== "usage")], `${where}: Usage gone`);
if (width >= 800) assert.deepEqual(await tabs(page), ["agents", "library", ...keptAt(width).slice(1).filter((k) => k !== "routing" && k !== "groups" && k !== "usage")], `${where}: Usage gone`);
assert.deepEqual(await viewShown(page), ["view-plugins"], `${where}: Plugins stays`);
// Discover brings the search back
await pluginTabs(page, side).nth(1).click();
+1 -1
View File
@@ -71,7 +71,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
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");
await page.goto("http://magpie.test/?view=groups");
const card = page.locator(".rt-group[data-id=g]");
await card.waitFor();
const shift = (on) => page.evaluate((on) => {
+2 -4
View File
@@ -126,7 +126,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const typeIn = (page, text) => engine === "chromium" ? ime(page, text) : page.keyboard.type(text);
test(`${engine} ${lang} ${width}px: the routing group filter takes one character a key`, async (t) => {
const { page, errors } = await open(t, "routing");
const { page, errors } = await open(t, "groups");
const q = page.locator("input.rt-gfilter");
await q.waitFor();
await watch(page, "input.rt-gfilter");
@@ -135,7 +135,6 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.deepEqual(await field(page), { out: 0, same: true, value: "12", caret: [2, 2], connected: true }, "the filter after 1, 2");
// the groups follow it: only v12 has a 12 in it
await page.waitForFunction(() => [...document.querySelectorAll(".rt-groups .rt-group")].map((r) => r.dataset.id).join() === "v12");
assert.equal(await page.locator(".rt-gsec .row-head").first().locator(".label").textContent(), w.label);
// a key in the middle goes where the caret is
await page.keyboard.press("ArrowLeft");
await typeIn(page, "5");
@@ -147,8 +146,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
// the row around it is still drawn again: in the other language
// its words change, and the filter stays where it was
await page.evaluate((l) => setLocale(l), w.other[0]);
await page.waitForFunction((s) => document.querySelector(".rt-gsec .row-head .label")?.textContent === s, w.other[1]);
assert.equal(await q.getAttribute("placeholder"), w.other[2]);
await page.waitForFunction((s) => document.querySelector("input.rt-gfilter")?.placeholder === s, w.other[2]);
const f = await field(page);
assert.equal(f.out, 0, "switching the language took the filter out");
assert.equal(f.value, "1");
+3 -3
View File
@@ -85,7 +85,7 @@ const L = {
// the Library stays, its MCP servers alone, for the router (treeman_26897)
const HIDDEN = ["agents"];
// in the order the pages are grouped in (work, models, insights, extend)
const KEPT = ["sessions", "library", "providers", "routing", "gateway", "usage", "masking", "plugins"];
const KEPT = ["sessions", "library", "providers", "routing", "groups", "gateway", "usage", "masking", "plugins"];
// the tabs shown, the page shown
const tabs = (page) => page.evaluate(() => [...document.querySelectorAll("#nav button[data-view]")].filter((b) => !b.hidden && b.offsetParent).map((b) => b.dataset.view));
@@ -156,7 +156,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await clickStill(page, "#gatewayModeSegs .opt:nth-child(4)", `${where}: Off`);
await page.waitForFunction(() => !document.querySelector('#nav button[data-view="agents"]').hidden);
assert.deepEqual(posts.filter((p) => p[0] === "gateway-mode"), [["gateway-mode", "off"]], where);
assert.deepEqual(await tabs(page), ["agents", "sessions", "library", "providers", "routing", "gateway", "usage", "masking", "plugins"], `${where}: off`);
assert.deepEqual(await tabs(page), ["agents", "sessions", "library", "providers", "routing", "groups", "gateway", "usage", "masking", "plugins"], `${where}: off`);
assert.deepEqual(await viewShown(page), ["view-settings"], `${where}: Settings stays`);
assert.deepEqual(await agentRows(page), [true, true, true, true, true], `${where}: rows back`);
assert.doesNotMatch(await page.locator("#gatewayModeSub").textContent(), new RegExp(L[lang].noAgents), where);
@@ -190,7 +190,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await page.route("**/*", server(lang, [], { web, gateway: false, agents: true }));
await page.goto("http://magpie.test/");
await page.waitForSelector("#nav button.on");
assert.deepEqual(await tabs(page), ["agents", "sessions", "library", "providers", "routing", "gateway", "usage", "masking", "plugins"], where);
assert.deepEqual(await tabs(page), ["agents", "sessions", "library", "providers", "routing", "groups", "gateway", "usage", "masking", "plugins"], where);
assert.deepEqual(await viewShown(page), ["view-agents"], where);
await page.locator("#prefs").click();
await page.waitForSelector("#langPick span");
+2 -2
View File
@@ -111,9 +111,9 @@ const kinds = [
{ name: "Agents", mode: "window", view: "agents", row: '#agents > .row.agent[data-id="beta"]', grip: ".ag-handle" },
{ name: "Providers", mode: "window", view: "providers", row: "#providers > .row.provider", grip: ".pv-handle" },
{ name: "Usage", mode: "window", view: "usage", row: ".subscription-card", grip: ".us-handle" },
{ name: "Routing groups", mode: "window", view: "routing", row: '.rt-groups > .rt-group[data-id="g"]', grip: ".rt-ghandle" },
{ name: "Routing groups", mode: "window", view: "groups", row: '.rt-groups > .rt-group[data-id="g"]', grip: ".rt-ghandle" },
{
name: "a group's members", mode: "window", view: "routing", row: ".rt-gedit .fbrow:has(.rt-mhandle)", grip: ".rt-mhandle",
name: "a group's members", mode: "window", view: "groups", row: ".rt-gedit .fbrow:has(.rt-mhandle)", grip: ".rt-mhandle",
open: async (page) => {
await page.locator('.rt-groups > .rt-group[data-id="g"]').waitFor();
await page.evaluate(() => document.querySelector('.rt-groups > .rt-group[data-id="g"]').click());
+1 -1
View File
@@ -81,7 +81,7 @@ async function open(engine, lang, width, members, held, t) {
const errors = [], posts = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang, posts, members, held));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
const card = page.locator(".rt-group", { hasText: "Work" });
await card.waitFor();
return { page, card, errors, posts };
+1 -1
View File
@@ -95,7 +95,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
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");
await page.goto("http://magpie.test/?view=groups");
await page.locator(".rt-groups > .rt-group").nth(2).waitFor();
assert.deepEqual(await listed(page), ["one", "two", "auto-m"]);
// a stack of logos is held whole in its handle, in its card, clear of
@@ -83,7 +83,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
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");
await page.goto("http://magpie.test/?view=groups");
const card = (name) => page.locator(".rt-groups .rt-group", { hasText: name });
await card("Model M").waitFor();
@@ -64,7 +64,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
const card = page.locator(".rt-group[data-id=local]");
await card.waitFor();
const line = card.locator(".mem.clsfail");
+1 -1
View File
@@ -80,7 +80,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
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");
await page.goto("http://magpie.test/?view=groups");
const card = page.locator(".rt-group", { hasText: "Sol" });
await card.waitFor();
@@ -70,7 +70,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang));
await page.goto("http://magpie.test/?view=routing");
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");
@@ -84,7 +84,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const errors = [], posts = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang, theme, posts));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
const on = page.locator(".rt-group", { hasText: "Lit" });
const off = page.locator(".rt-group.disabled", { hasText: "Quiet" });
await off.waitFor();
+1 -1
View File
@@ -90,7 +90,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
// round is delivered on the next frame and nothing is painted wrong.
page.on("pageerror", (e) => { if (!/^ResizeObserver loop completed with undelivered notifications/.test(e.message)) errors.push(e.message); });
await page.route("**/*", serve(lang, posts));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
await page.locator(".rt-groups > .rt-group").nth(1).waitFor();
// tall enough that the rows are in view unscrolled (1400: German
// with the found groups' "leave out" line needs more than 1200): a scroll closes
@@ -95,7 +95,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang, withOne));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
const w = await page.evaluate((lang) => Object.fromEntries(["New group", "Edit"].map((k) => [k, lang === "en" ? k : I18N[lang][k]])), lang);
if (withOne) await page.locator(".rt-group", { hasText: "Glim" }).locator("button", { hasText: w.Edit }).click();
else await page.locator("button", { hasText: w["New group"] }).first().click();
@@ -67,7 +67,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang, web));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
const card = page.locator(".rt-group", { hasText: "Free" });
await card.waitFor();
await card.locator("button.text").first().click();
@@ -59,7 +59,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang, theme, web));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
const card = page.locator(".rt-group", { hasText: "Coding" });
await card.waitFor();
await card.locator("button.text").first().click();
@@ -83,7 +83,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
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");
await page.goto("http://magpie.test/?view=groups");
const card = page.locator(".rt-group", { hasText: "Sol" });
await card.waitFor();
assert.equal(await card.locator(".tag", { hasText: w.tag }).count(), 0, "off by default");
+1 -1
View File
@@ -74,7 +74,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
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");
await page.goto("http://magpie.test/?view=groups");
const card = page.locator(".rt-group", { hasText: "Sol" });
const ed = page.locator(".rt-gedit"), head = ed.locator(".ehead");
const closed = () => page.waitForFunction(() => !document.querySelector(".rt-gedit") && document.querySelector(".rt-group"));
+6 -5
View File
@@ -80,7 +80,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
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");
await page.goto("http://magpie.test/?view=groups");
const card = (name) => page.locator(".rt-group", { hasText: name });
await card("Model M").waitFor();
const box = page.locator(".rt-gsec .rt-gfound");
@@ -89,13 +89,14 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.equal(await sw.getAttribute("aria-checked"), "true");
assert((await box.textContent()).includes(w.label));
assert((await box.textContent()).includes(w.onHint), "it says what found groups are");
// by the list: right under the routing groups' head, over the cards
// under the list, in the page's Settings, the names in agents' lists
// (for every group) after it
const order = await page.evaluate(() => {
const s = document.querySelector(".rt-gsec");
return [...s.children].map((c) => c.className);
return [...s.children].map((c) => c.className).filter((c) => c !== "rt-goff");
});
// (the names in agents' lists, for every group, between them)
assert.deepEqual(order.slice(0, 4), ["row-head", "rt-gfound", "rt-gnames", "list rt-groups"]);
assert.deepEqual(order.slice(0, 4), ["row-head", "list rt-groups", "row-head rt-gset-head", "list rt-gset"]);
assert.deepEqual(await page.evaluate(() => [...document.querySelector(".rt-gset").children].map((c) => c.className)), ["rt-gfound", "rt-gnames"]);
const border = await sw.evaluate((e) => { const c = getComputedStyle(e); return c.borderLeftWidth !== c.borderRightWidth || c.borderLeftColor !== c.borderRightColor; });
assert.equal(border, false, "no left-border accent");
+1 -1
View File
@@ -86,7 +86,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
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");
await page.goto("http://magpie.test/?view=groups");
const card = page.locator(".rt-group", { hasText: "Model M" });
await card.waitFor();
const pick = page.locator(".rt-gsec .rt-gfound .rt-skip-pick");
@@ -64,8 +64,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang, posts, refuse));
await page.goto(`http://magpie.test/?view=routing&newgroup=${encodeURIComponent(MODEL)}`);
const ed = page.locator("#view-routing:not([hidden]) .rt-gedit");
await page.goto(`http://magpie.test/?view=groups&newgroup=${encodeURIComponent(MODEL)}`);
const ed = page.locator("#view-groups:not([hidden]) .rt-gedit");
await ed.waitFor();
await ed.locator("input").first().fill("Hy4 preview");
// the reader wheels down until Add itself is under the pointer's
@@ -93,7 +93,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const clickAdd = async () => {
for (let i = 0; i < 80; i++) {
const done = await page.evaluate(() => {
const v = document.querySelector("#view-routing");
const v = document.querySelector("#view-groups");
return v.scrollTop + v.clientHeight >= v.scrollHeight - 1;
});
if (done) break;
+1 -1
View File
@@ -58,7 +58,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const errors = [], saved = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang, saved));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
await page.locator(".rt-group", { hasText: "GPT-6.1 Sol" }).waitFor({ state: "attached" });
assert.deepEqual(await page.evaluate(() => ["GPT 6.1 Sol", "gpt-6.1-sol", "a..b", ".x.", "-.a.-", "claude/opus 5", "..."].map(groupSlug)),
@@ -84,7 +84,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const errors = [], posts = [];
page.on("pageerror", (e) => { if (!/^ResizeObserver loop completed with undelivered notifications/.test(e.message)) errors.push(e.message); });
await page.route("**/*", serve(lang, posts));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
await page.locator(".rt-groups > .rt-group").nth(1).waitFor();
await page.waitForTimeout(500);
await page.locator(".rt-gimportbtn").click();
@@ -62,7 +62,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
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");
await page.goto("http://magpie.test/?view=groups");
const last = () => posts.filter((p) => p.path === "/api/groups/save").at(-1)?.body;
const save = async (id) => {
@@ -71,7 +71,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
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");
await page.goto("http://magpie.test/?view=groups");
const card = page.locator(".rt-group", { hasText: "G" }).first();
await card.waitFor();
await card.locator("button", { hasText: w.edit }).click();
@@ -84,7 +84,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
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");
await page.goto("http://magpie.test/?view=groups");
const card = page.locator(".rt-group", { hasText: "Sol" });
await card.waitFor();
assert((await card.locator(".mem").textContent()).includes(w.label), "the card says the member is sent fast");
@@ -70,7 +70,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
const card = page.locator('.rt-group[data-id="g"]');
await card.waitFor();
@@ -123,10 +123,10 @@ const rows = (page) => page.locator(".rt-gedit .fbrow").evaluateAll((rs) => rs.m
// would: a scroll the reader didn't make (Playwright's own, before its
// click) is put back (#1554), and the click lands on the window's foot
async function reach(page, target) {
const view = await page.locator("#view-routing").boundingBox();
const view = await page.locator("#view-groups").boundingBox();
await page.mouse.move(view.x + view.width / 2, view.y + view.height / 2);
const rest = () => page.evaluate(() => new Promise((done) => {
const v = document.querySelector("#view-routing");
const v = document.querySelector("#view-groups");
let last = -1;
const look = () => { if (v.scrollTop === last) done(); else { last = v.scrollTop; setTimeout(look, 100); } };
look();
@@ -158,7 +158,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
await page.locator(".rt-group[data-id=g]").waitFor();
await page.locator(".rt-group[data-id=g]").click();
await page.locator(".rt-gedit .fbrow").first().waitFor();
@@ -210,7 +210,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
await page.locator(".rt-group[data-id=g3]").waitFor();
await page.locator(".rt-group[data-id=g3]").click();
await page.locator(".rt-gedit .fbrow").first().waitFor();
@@ -78,7 +78,7 @@ async function open(engine, lang, width, members, t) {
const errors = [], posts = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang, posts, members));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
const card = page.locator(".rt-group", { hasText: "Sol" });
await card.waitFor();
return { page, card, errors, posts };
+1 -1
View File
@@ -69,7 +69,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
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");
await page.goto("http://magpie.test/?view=groups");
const card = page.locator(".rt-group", { hasText: "Sol" });
await card.waitFor();
assert((await card.locator(".mem").textContent()).includes(w.off), "the card says the member is off");
@@ -77,7 +77,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
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");
await page.goto("http://magpie.test/?view=groups");
const tr = (k, v = {}) => page.evaluate(([lang, k, v]) => (lang === "en" ? k : I18N[lang][k] || k).replace(/\{(\w+)\}/g, (_, n) => v[n]), [lang, k, v]);
const card = page.locator(".rt-group", { hasText: "Sol" });
await card.waitFor();
+5 -5
View File
@@ -48,7 +48,7 @@ function serve(lang, saved) {
// the height animation running on group b's slot, if any: its first and last
// heights, and the slot's height now
const slotMotion = (page) => page.evaluate(() => {
const n = document.querySelector('#view-routing [data-gslot="b"]');
const n = document.querySelector('#view-groups [data-gslot="b"]');
const a = n?.getAnimations().find((x) => x.effect.getKeyframes().some((k) => k.height));
const ks = a?.effect.getKeyframes();
return {
@@ -63,7 +63,7 @@ const slotMotion = (page) => page.evaluate(() => {
// magpie moves the page only for the reader, so what is out of the window
// is wheeled to as a reader would, then clicked
async function reach(page, loc) {
const vb = await page.locator("#view-routing").boundingBox();
const vb = await page.locator("#view-groups").boundingBox();
await page.mouse.move(vb.x + vb.width / 2, vb.y + vb.height / 2);
for (let i = 0; i < 150; i++) {
const b = await loc.boundingBox();
@@ -77,7 +77,7 @@ async function reach(page, loc) {
const inSight = (page) => page.evaluate(() => {
const r = document.querySelector('.rt-group[data-id="b"]').getBoundingClientRect();
const v = document.querySelector("#view-routing").getBoundingClientRect();
const v = document.querySelector("#view-groups").getBoundingClientRect();
return r.top >= v.top - 1 && r.bottom <= v.bottom + 1;
});
@@ -93,7 +93,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
page.on("pageerror", (e) => errors.push(e.message));
let release;
await page.route("**/*", serve(lang, new Promise((r) => { release = r; })));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
const row = page.locator(".rt-group[data-id=b]");
await row.waitFor();
const rowH = (await row.boundingBox()).height;
@@ -155,7 +155,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
page.setDefaultTimeout(5000);
page.setDefaultNavigationTimeout(60000);
await page.route("**/*", serve("en", Promise.resolve()));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
await page.locator(".rt-group[data-id=b]").click();
await page.locator(".rt-gedit").waitFor();
assert.equal((await slotMotion(page)).from, null, "no height animation opening");
+17 -21
View File
@@ -2,11 +2,12 @@
// A routing group of any models is made with New group, which sat only at
// the routing groups' head, below the requests: out of sight on a first
// look, so a user used the found groups for days without knowing their
// own could be made (mintonight, #944). The Routing page's head has a New
// group too, by Hide accounts, with a plus and a tooltip saying what a
// group is; its click opens an empty group's editor and brings it into
// view, its name field focused. The groups' own New group has the plus as
// well. No left-border accent. In English and Chinese, Chromium and WebKit.
// own could be made (mintonight, #944). The groups have a page of their
// own since 11-06, and New group is its toolbar's filled button, in sight
// on arrival, with a plus and a tooltip saying what a group is; its click
// opens an empty group's editor and brings it into view, its name field
// focused. No left-border accent. In English and Chinese, Chromium and
// WebKit.
const assert = require("node:assert/strict");
const fs = require("node:fs/promises");
const path = require("node:path");
@@ -59,7 +60,7 @@ function serve(lang) {
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}: New group in the Routing page's head`, async (t) => {
test(`${engine} ${lang}: New group on the groups page`, async (t) => {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
const page = await (await browser.newContext({ viewport: { width: 1000, height: 560 }, reducedMotion: "reduce" })).newPage();
t.after(async () => {
@@ -74,25 +75,20 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
await page.locator(".rt-group", { hasText: "Model M" }).waitFor({ state: "attached" });
// the groups' own New group: with a plus
const inList = page.locator(".rt-gsec > .row-head button", { hasText: w.btn });
assert.equal(await inList.count(), 1);
assert.equal(await inList.locator("svg").count(), 1, "the groups' New group has a plus");
// the page's head: a New group in sight on arrival, the groups not
const head = page.locator("#view-routing > .row-head #rtNewGroup");
// the groups page's New group: in sight on arrival, with a plus
await page.evaluate(() => window.show("groups"));
const head = page.locator("#view-groups .rt-gsec > .row-head .rt-gnew");
await head.waitFor();
assert.equal(await page.locator(".rt-gsec > .row-head button", { hasText: w.btn }).count(), 1);
assert.equal((await head.textContent()).trim(), w.btn);
assert.equal(await head.getAttribute("title"), w.tip);
assert.equal(await head.locator("svg").count(), 1);
assert.equal(await head.locator("svg").count(), 1, "New group has a plus");
const vh = await page.evaluate(() => innerHeight);
const hb = await head.boundingBox();
assert(hb && hb.y >= 0 && hb.y + hb.height <= vh, "the head's New group is in sight");
const gTop = await page.locator(".rt-gsec").evaluate((e) => e.getBoundingClientRect().top);
assert(gTop > vh, `the groups are below the fold here (${gTop} > ${vh})`);
assert(hb && hb.y >= 0 && hb.y + hb.height <= vh, "New group is in sight");
const border = await head.evaluate((e) => { const c = getComputedStyle(e); return c.borderLeftWidth !== c.borderRightWidth || c.borderLeftColor !== c.borderRightColor; });
assert.equal(border, false, "no left-border accent");
@@ -107,10 +103,10 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
});
assert.equal(await ed.locator("input").first().inputValue(), "");
assert.equal(await ed.evaluate((e) => e.contains(document.activeElement) && document.activeElement.tagName), "INPUT");
// Both New group entrances replace the same draft only after Discard.
// New group replaces the draft only after Discard.
const name = ed.locator("input").first();
const ask = page.locator("dialog.action-confirm[open]");
for (const entrance of [inList, head]) {
for (const entrance of [head]) {
await name.fill("Unsaved group");
await page.mouse.move(500, 300);
for (let i = 0; i < 20; i++) {
@@ -128,7 +124,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await page.waitForFunction(() => document.querySelector(".rt-gedit input")?.value === "");
assert.equal(await ask.count(), 0, "Discard opens a clean new group");
}
// The model picker's entry must protect the same draft as both buttons.
// The model picker's entry protects the same draft as the button.
await name.fill("Unsaved group");
const fromModel = () => page.evaluate(() => { window.newGroupWith("a/m", "Model A"); });
await fromModel();
@@ -83,7 +83,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
const row = (name) => page.locator(".rt-group", { has: page.locator(".nm b", { hasText: new RegExp("^" + name + "$") }) });
await row("Fast").waitFor();
assert.deepEqual(await page.locator(".rt-group .nm b").allTextContents(), ["Fast", "Plugin", "Odd", "Slow"], "every group is listed");
+1 -1
View File
@@ -79,7 +79,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
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");
await page.goto("http://magpie.test/?view=groups");
const card = page.locator(".rt-group", { hasText: "Sol" });
await card.waitFor();
+1 -1
View File
@@ -72,7 +72,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
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");
await page.goto("http://magpie.test/?view=groups");
const card = page.locator(".rt-group", { hasText: "Free" });
await card.waitFor();
const pats = (await card.locator(".mem.pat").allTextContents()).map((x) => x.trim());
@@ -65,7 +65,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
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");
await page.goto("http://magpie.test/?view=groups");
const card = page.locator('.rt-group[data-id="g"]');
await card.waitFor();
await card.locator("button", { hasText: w.edit }).click();
@@ -77,7 +77,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
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");
await page.goto("http://magpie.test/?view=groups");
const card = (id) => page.locator(`.rt-group[data-id="${id}"]`);
await card("g").waitFor();
await page.locator(".rt-gsec").evaluate((x) => x.scrollIntoView({ block: "center" })); // as the reader would
@@ -89,7 +89,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
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");
await page.goto("http://magpie.test/?view=groups");
const card = page.locator(".rt-group", { hasText: "Free" });
await card.waitFor();
const ed = page.locator(".rt-gedit");
+1 -1
View File
@@ -105,7 +105,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
// page error; see group-duplicate.test.cjs
page.on("pageerror", (e) => { if (!/^ResizeObserver loop completed with undelivered notifications/.test(e.message)) errors.push(e.message); });
await page.route("**/*", serve(lang, posts));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
await page.locator(".rt-groups > .rt-group").nth(1).waitFor();
// tall enough that the import box is in view unscrolled in every
// language: a scroll closes the menu, and the page settles its own
@@ -81,7 +81,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
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");
await page.goto("http://magpie.test/?view=groups");
const card = (id) => page.locator(`.rt-group[data-id="${id}"]`);
await card("g").waitFor();
await page.locator(".rt-gsec").evaluate((x) => x.scrollIntoView({ block: "center" })); // as the reader would
+3 -3
View File
@@ -95,7 +95,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
// WebKit's notice when a layout outruns its observers, not a fault
page.on("pageerror", (e) => { if (!/^ResizeObserver loop completed with undelivered notifications/.test(e.message)) errors.push(e.message); });
await page.route("**/*", serve(lang, posts));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
const cards = page.locator(".rt-gtpl-card");
await cards.nth(2).waitFor();
await page.waitForTimeout(500);
@@ -159,7 +159,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
// enough groups of the user's that the editor, last in the list,
// opens below the window
await page.route("**/*", serve(lang, posts, 12));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
const btn = page.locator(".rt-gtplbtn");
await btn.waitFor();
await page.waitForTimeout(500);
@@ -191,7 +191,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
// WebKit's notice when a layout outruns its observers, not a fault
page.on("pageerror", (e) => { if (!/^ResizeObserver loop completed with undelivered notifications/.test(e.message)) errors.push(e.message); });
await page.route("**/*", serve(lang, []));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
const smart = page.locator(".rt-gtpl-card[data-kind=smart]");
await smart.waitFor();
if (process.env.ARTIFACT_DIR) await page.locator(".rt-gtpl").screenshot({ path: path.join(process.env.ARTIFACT_DIR, `${engine}-${lang}-group-template-cards.png`) });
+1 -1
View File
@@ -70,7 +70,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
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");
await page.goto("http://magpie.test/?view=groups");
const card = page.locator(".rt-group", { hasText: "Glim" });
await card.waitFor();
const w = await page.evaluate(([keys, lang]) => Object.fromEntries(keys.map((k) => [k, lang === "en" ? k : I18N[lang][k]])), [KEYS, lang]);
@@ -70,7 +70,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
const group = page.locator(".rt-group").first();
await group.waitFor();
await press(page, group.locator("button", { hasText: words[lang].edit }));
@@ -135,10 +135,10 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
]);
await page.keyboard.press("Escape");
// the Routing page's card of a group of two alike says each one's source
// the groups page's card of a group of two alike says each one's source
await page.evaluate(() => document.querySelector("#tellAnchor")?.remove());
await page.goto("http://magpie.test/?view=routing");
const mem = page.locator("#view-routing .mem", { hasText: "DeepSeek-V4.1-Flash" }).first();
await page.goto("http://magpie.test/?view=groups");
const mem = page.locator("#view-groups .mem", { hasText: "DeepSeek-V4.1-Flash" }).first();
await mem.waitFor();
const said = await mem.textContent();
assert.ok(said.includes("DeepSeek-V4.1-Flash · buddy") && said.includes("DeepSeek-V4.1-Flash · cline"), said);
+1 -1
View File
@@ -94,7 +94,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
} });
});
await page.route("**/*", serve(lang, asked));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
const card = page.locator(".rt-group", { hasText: "DeepSeek V4" });
await card.waitFor();
await card.locator("button", { hasText: words[lang].edit }).click();
@@ -92,7 +92,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await sub.waitFor();
assert.equal(await sub.textContent(), said[lang]);
assert.equal(await overflows(page), false, "the page scrolls sideways");
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
const note = page.locator(".rt-gnames .no-names");
await note.waitFor();
assert.equal(await note.textContent(), said[lang]);
@@ -123,7 +123,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const note = page.locator(".mnames:not([hidden]) .msuffix .no-names");
await note.waitFor();
assert.equal(await note.textContent(), said.en);
for (const [view, sel] of [["routing", ".rt-gnames .no-names"], ["settings", ".row.pref .sub.no-names"]]) {
for (const [view, sel] of [["groups", ".rt-gnames .no-names"], ["settings", ".row.pref .sub.no-names"]]) {
await page.goto(`http://magpie.test/?view=${view}`);
await page.locator(sel).waitFor();
assert.equal(await page.locator(sel).textContent(), said.en);
@@ -135,7 +135,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await page.goto("http://magpie.test/?view=settings");
await page.locator("#plainNamesSegs .opt").first().waitFor();
assert.equal(await page.locator(".row.pref", { has: page.locator("#plainNamesSegs") }).locator(".sub").count(), 0);
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
await page.locator(".rt-gnames .segs").waitFor();
assert.equal(await page.locator(".rt-gnames .no-names:visible").count(), 0);
assert.deepEqual(errors, []);
@@ -96,7 +96,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
test(`${engine} ${lang} ${width}px: Routing opened first shows the saved Off, and Settings and back keep it`, async (t) => {
const posts = [];
const { page, errors, tr } = await launch(t, engine, lang, width, OFF, {}, posts);
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
await page.locator(".rt-group", { hasText: "Fast" }).waitFor();
const set = page.locator(".rt-gnames");
await set.locator(".segs").waitFor();
@@ -105,12 +105,15 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
// a group's editor says what its group is called there: no suffix
await page.locator(".rt-group", { hasText: "Fast" }).locator("button", { hasText: await tr("Edit") }).click();
const row = page.locator(".rt-gedit label", { hasText: new RegExp(`^${await tr("In agents’ lists")}$`) }).locator("xpath=following-sibling::div[1]");
await says(row.locator(".hint"), (await tr("Agents’ lists show “{label}”", { label: "Fast" })) + " · " + (await tr("“· routing group” is set for every group above")));
await says(row.locator(".hint"), (await tr("Agents’ lists show “{label}”", { label: "Fast" })) + " · " + (await tr("“· routing group” is set for every group, under the list")));
// Settings says the same, and coming back still does
await page.locator("#prefs").click();
await page.locator("#plainNamesSegs .opt.on").waitFor();
await picked(page.locator("#plainNamesSegs .opt.on"), await tr("Off"));
await page.locator('#nav button[data-view="routing"]').click();
// the groups tab is the sidebar's; the header's row reaches them from Routing
const tab = page.locator('#nav button[data-view="groups"]');
if (await tab.isVisible()) await tab.click();
else { await page.locator('#nav button[data-view="routing"]').click(); await page.locator("#rtToGroups").click(); }
await picked(page.locator(".rt-gnames .opt.on"), await tr("Off"));
assert.deepEqual(posts, [], "nothing is written");
assert.deepEqual(errors, []);
@@ -119,7 +122,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
test(`${engine} ${lang} ${width}px: Routing drawn before the state comes in follows the saved "Not on names I set"`, async (t) => {
const posts = [];
const { page, errors, tr } = await launch(t, engine, lang, width, OWN, { stateDelay: 600 }, posts);
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
const set = page.locator(".rt-gnames");
await set.locator(".segs").waitFor();
await picked(set.locator(".opt.on"), await tr("Not on names I set"));
@@ -21,9 +21,9 @@ const { chromium, webkit } = require("playwright");
const assets = path.resolve(__dirname, "../assets");
const words = {
en: { names: "Names, prices & levels", edit: "Edit", general: "General", global: "“Provider in model names” is one setting for every provider", change: "Change in Settings", own: "Not on names I set", on: "On", off: "Off", label: "In agents’ lists",
shows: (l) => `Agents’ lists show “${l}”`, above: " · “· routing group” is set for every group above", setting: "Names in agents’ lists" },
shows: (l) => `Agents’ lists show “${l}”`, above: " · “· routing group” is set for every group, under the list", setting: "Names in agents’ lists" },
zh: { names: "名称、价格与推理档位", edit: "编辑", general: "常规", global: "「模型名带供应商」是全局设置,对所有供应商生效", change: "在设置中修改", own: "自定义名称不带供应商", on: "开启", off: "关闭", label: "Agent 列表里的名称",
shows: (l) => `Agent 的模型列表里显示为「${l}」`, above: " · 是否带「· routing group」在上方统一设置,对所有路由组生效", setting: "Agent 列表里的名称" },
shows: (l) => `Agent 的模型列表里显示为「${l}」`, above: " · 是否带「· routing group」在列表下方统一设置,对所有路由组生效", setting: "Agent 列表里的名称" },
};
function serve(lang, posts) {
@@ -135,16 +135,16 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
test(`${engine} ${lang}: "· routing group" is set over the groups, for all of them, and a group's editor says what it shows`, async (t) => {
const posts = [];
const { page, errors } = await launch(t, engine, lang, posts);
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
const card = page.locator(".rt-group", { hasText: "Fast" });
await card.waitFor();
// the setting is over the groups, before the first card
// the setting is under the groups, in the page's Settings (11-06)
const set = page.locator(".rt-gnames");
await set.waitFor();
assert.equal((await set.locator("b").textContent()).trim(), w.setting);
assert.deepEqual((await set.locator(".segs .opt").allTextContents()).map((s) => s.trim()), [w.off, w.own, w.on]);
assert.equal((await set.locator(".opt.on").textContent()).trim(), w.on);
assert.ok(await set.evaluate((s) => !!(s.compareDocumentPosition(document.querySelector(".rt-group")) & Node.DOCUMENT_POSITION_FOLLOWING)), "the setting is over the groups");
assert.ok(await set.evaluate((s) => !!(s.compareDocumentPosition(document.querySelector(".rt-group")) & Node.DOCUMENT_POSITION_PRECEDING)), "the setting is under the groups");
await card.locator("button", { hasText: w.edit }).click();
const ed = page.locator(".rt-gedit");
const row = ed.locator("label", { hasText: new RegExp(`^${w.label}$`) }).locator("xpath=following-sibling::div[1]");
@@ -155,6 +155,16 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
// the name typed is the name shown
await ed.locator("input").first().fill("Fast lane");
assert.equal(await row.locator(".hint").textContent(), w.shows("Fast lane · routing group") + w.above);
// the setting, under the open editor, brought into sight by the wheel
// first, as a reader would: what is measured is the click alone
const vp = page.viewportSize();
await page.mouse.move(vp.width / 2, vp.height / 2);
for (let i = 0; i < 40; i++) {
const r = await set.boundingBox();
if (r.y >= 0 && r.y + r.height <= vp.height) break;
await page.mouse.wheel(0, r.y + r.height - vp.height + 40);
await page.waitForTimeout(60);
}
const before = await scrolls(page);
await set.locator(".opt", { hasText: w.own }).click();
await page.locator(".rt-gnames .opt.on", { hasText: w.own }).waitFor();
@@ -164,12 +174,12 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.deepEqual(posts, [{ mode: "own" }]);
assert.deepEqual(await scrolls(page), before, "the click scrolled the page");
// nothing native, no stripe down the side
assert.equal(await page.locator("#view-routing select").count(), 0);
assert.equal(await page.locator("#view-groups select").count(), 0);
assert.equal(await set.evaluate((e) => getComputedStyle(e).borderLeftWidth), "0px");
assert.equal(await row2.evaluate((e) => getComputedStyle(e).borderLeftWidth), "0px");
const missing = await page.evaluate(() => ["Agents’ lists show “{label}”", "In agents’ lists",
"“Provider in model names” is one setting for every provider", "Change in Settings", "Not on names I set", "Provider in model names",
"Names in agents’ lists", "“· routing group” is set for every group above",
"Names in agents’ lists", "“· routing group” is set for every group, under the list",
"Whether “· routing group” follows a group’s name in the agents’ lists: one setting for every group, and for the provider after each model’s name, as on Settings."]
.filter((k) => !I18N.zh[k] || !I18N.ja[k] || !I18N.de[k]));
assert.deepEqual(missing, [], "every string has its Chinese, Japanese and German");
+1 -1
View File
@@ -231,7 +231,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await page.route("**/*", serveRouting(lang));
try {
const open = async (i) => {
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
const g = page.locator(".rt-group").nth(i);
await g.waitFor();
const edit = g.locator("button", { hasText: await page.evaluate(() => t("Edit")) });
@@ -144,7 +144,9 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.match(await stage.textContent(), new RegExp(w.row));
await page.waitForFunction((s) => document.body.innerText.includes(s), zh ? "已排到最后" : "so it went to the back");
// the providers with several accounts: set at once
// the providers with several accounts, on the Routing groups page:
// set at once
await page.evaluate(() => window.show("groups"));
const pool = page.locator(".rt-pool", { hasText: "WorkBuddy AI" });
await pool.waitFor();
// the pool sits under the window's foot: wheeled to, as the reader
@@ -71,7 +71,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
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");
await page.goto("http://magpie.test/?view=groups");
const line = page.locator(".rt-ghidden");
await line.waitFor();
assert.equal((await line.textContent()).trim(), words[lang]);
@@ -84,7 +84,7 @@ async function open(t, engine, lang, width) {
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang, routeOf()));
await page.goto("http://magpie.test/?view=routing");
await page.locator(".rt-group").first().waitFor();
await page.locator("#view-routing .rt-stage").waitFor();
return { page, errors };
}
@@ -80,7 +80,7 @@ async function open(t, engine, lang, width, said) {
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang, routeOf(said)));
await page.goto("http://magpie.test/?view=routing");
await page.locator(".rt-group").first().waitFor();
await page.locator("#view-routing .rt-stage").waitFor();
return { page, errors };
}
+5 -3
View File
@@ -73,7 +73,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
test(`${engine} ${lang}: a rule for compacting`, 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 } })).newPage();
const page = await (await browser.newContext({ viewport: { width: 1100, height: 1400 }, reducedMotion: "reduce" })).newPage();
page.setDefaultTimeout(5000);
page.setDefaultNavigationTimeout(60000);
const errors = [], posts = [];
@@ -81,14 +81,16 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await page.route("**/*", serve(lang, posts));
await page.goto("http://magpie.test/?view=routing");
const group = page.locator(".rt-group").first();
await group.waitFor();
await group.waitFor({ state: "attached" });
// the compaction in the trace, told as one
await page.waitForFunction((s) => document.documentElement.innerText.includes(s), w.story);
const said = await page.evaluate(() => document.documentElement.innerText);
assert(said.includes(w.small), "the model passed over is named");
// the group's rule, in words
// the group's rule, in words, on the groups page
await page.evaluate(() => window.show("groups"));
await group.waitFor();
const title = await group.evaluate((g) => [...g.querySelectorAll("[title]")].map((e) => e.title).join("\n"));
assert(title.includes(`1. ${w.cond} →`), `the rule reads as compacting: ${title}`);
+3 -1
View File
@@ -17,7 +17,9 @@ const ymd = (d) => [d.getFullYear(), d.getMonth() + 1, d.getDate()].map((n) => S
const allDays = Array.from({ length: 30 }, (_, i) => ({ day: ymd(new Date(now.getTime() - i * 864e5)), requests: 100 + i }));
const at = (i) => new Date(now.getTime() - (i + 1) * 60e3).toISOString();
const who = { id: "fixture-key", provider: "fixture", name: "Fixture", who: "key-1", kind: "key", model: "model-a", routing: "", used: 0 };
const routes = Array.from({ length: 4 }, (_, i) => ({
// a day's requests fill the window, as a day of 100 or more does: the bar
// held when a day comes in needs the room under it to scroll into
const routes = Array.from({ length: 12 }, (_, i) => ({
id: 100 - i, seq: 100 - i, time: at(i), agent: "fixture", model: "model-a", provider: "fixture",
order: [who], tries: [{ id: who.id, model: "model-a", start: at(i), done: true, status: 200, ms: 1200 }],
done: true, status: 200, ms: 1200, tokens: 3000,
+19 -12
View File
@@ -3,7 +3,7 @@
// the editor runs on below it (Jiabubu on Discord): the Scroll to top and
// Scroll to bottom capsule (scrollends.js) sat over Add, and under the bar's
// ground the view's own foot padding showed as a gap above the window's
// edge. Here a New group editor on a long Routing page is scrolled so its
// edge. Here the editor of a group far down the Routing groups page is scrolled so its
// bar is held: the bar's ground reaches the window's edge, and the capsule,
// once in, is above the bar and over none of its buttons. Chromium and
// WebKit, the desktop window and the browser page, wide and narrow,
@@ -20,7 +20,7 @@ const ids = models.map((m) => m.id);
// enough groups above for the page to be scrolled a screen down
const groups = {
models, pools: [],
groups: Array.from({ length: 16 }, (_, i) => ({ id: `g${i}`, name: `group ${i}`, routing: "order", members: ids, ready: true, memberInfo: ids.map((id) => ({ id, ready: true })), offers: [], shared: [] })),
groups: Array.from({ length: 40 }, (_, i) => ({ id: `g${i}`, name: `group ${i}`, routing: "order", members: ids, ready: true, memberInfo: ids.map((id) => ({ id, ready: true })), offers: [], shared: [] })),
};
function serve(lang, web) {
@@ -61,25 +61,32 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang, web));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
await page.locator(".rt-group").nth(15).waitFor();
await page.locator(".rt-newgroup:visible").first().click();
// a group far down the list, its editor opened in its place
await page.evaluate(() => [...document.querySelectorAll(".rt-group")[20].querySelectorAll("button")].find((b) => b.textContent === t("Edit")).click());
await page.locator(".rt-gedit").waitFor();
// the editor's top just under the window's: the page a screen
// down, the editor running on below, its bar held at the foot
await page.evaluate(() => {
const v = document.querySelector("#view-routing"), e = document.querySelector(".rt-gedit");
v.scrollTop += e.getBoundingClientRect().top - v.getBoundingClientRect().top - 20;
if (v.scrollTop <= v.clientHeight) { // the editor near the top: groups go above it
v.scrollTop = v.clientHeight + 40;
}
// down, the editor running on below, its bar held at the foot;
// by the wheel, as a reader scrolls (a scroll by code is put back)
const want = await page.evaluate(() => {
const v = document.querySelector("#view-groups"), e = document.querySelector(".rt-gedit");
return Math.max(v.scrollTop + e.getBoundingClientRect().top - v.getBoundingClientRect().top - 20, v.clientHeight + 40);
});
const vb = await page.locator("#view-groups").boundingBox();
await page.mouse.move(vb.x + vb.width / 2, vb.y + vb.height / 2);
for (let i = 0; i < 40; i++) {
const now = await page.evaluate(() => document.querySelector("#view-groups").scrollTop);
if (Math.abs(now - want) < 2) break;
await page.mouse.wheel(0, want - now);
await page.waitForTimeout(60);
}
// the capsule comes on the window's scroll, a frame later
await page.waitForFunction(() => document.querySelector(".view-ends.on"));
await page.evaluate(() => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(() => setTimeout(r, 250)))));
const m = await page.evaluate(() => {
const box = (e) => { const b = e.getBoundingClientRect(); return { top: b.top, bottom: b.bottom, left: b.left, right: b.right }; };
const v = document.querySelector("#view-routing"), e = document.querySelector(".rt-gedit"), bar = e.querySelector(":scope > .bar");
const v = document.querySelector("#view-groups"), e = document.querySelector(".rt-gedit"), bar = e.querySelector(":scope > .bar");
return { view: box(v), ed: box(e), bar: box(bar), ends: box(document.querySelector(".view-ends")), buttons: [...bar.querySelectorAll("button")].map((b) => ({ text: b.textContent, ...box(b) })), scrolled: v.scrollTop > v.clientHeight };
});
assert(m.scrolled && m.ed.bottom > m.view.bottom + 40, `${at}: the page a screen down and the editor running on below the window: ${JSON.stringify([m.ed, m.view])}`);
+5 -2
View File
@@ -73,7 +73,7 @@ function serve(lang, posts) {
async function open(t, engine, lang, width) {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
t.after(() => browser.close());
const page = await (await browser.newContext({ viewport: { width, height: 1400 } })).newPage();
const page = await (await browser.newContext({ viewport: { width, height: 1400 }, reducedMotion: "reduce" })).newPage();
page.setDefaultTimeout(5000);
page.setDefaultNavigationTimeout(60000);
const errors = [], posts = [];
@@ -81,7 +81,7 @@ async function open(t, engine, lang, width) {
await page.route("**/*", serve(lang, posts));
await page.goto("http://magpie.test/?view=routing");
const group = page.locator(".rt-group").first();
await group.waitFor();
await group.waitFor({ state: "attached" });
return { page, group, errors, posts };
}
@@ -115,6 +115,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await page.waitForFunction((s) => document.documentElement.innerText.includes(s), w.dir);
const said = await page.evaluate(() => document.documentElement.innerText);
assert(said.includes(w.cond), `the rule's folders are told: ${said.slice(0, 2000)}`);
await page.evaluate(() => window.show("groups"));
await group.waitFor();
// the group's rule, in words
const title = await group.evaluate((g) => [...g.querySelectorAll("[title]")].map((e) => e.title).join("\n"));
@@ -154,6 +156,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
test(`${engine} ${lang}: a rule by folder at a phone's width`, async (t) => {
const { page, group, errors } = await open(t, engine, lang, 390);
await page.evaluate(() => window.show("groups"));
await press(page, group.locator("button", { hasText: w.edit })); // the group is below the fold here
const fd = page.locator(".rt-gedit .rt-rule").first().locator(".rt-cond.fd");
await fd.waitFor();
@@ -86,7 +86,7 @@ async function open(t, engine, { lang, theme = "light", web = true, width = 1100
const errors = [], posts = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang, theme, web, posts));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
await page.locator(".rt-group", { hasText: "Auto" }).waitFor();
return { page, errors, posts };
}
@@ -94,7 +94,7 @@ async function open(t, engine, { lang, theme = "light", web = true, width = 1100
// the reader wheels the row into the middle of the view (code that scrolls
// is put back: only the reader moves the view)
async function wheelTo(page, row, width) {
const dy = await row.evaluate((g) => { const v = document.querySelector("#view-routing");
const dy = await row.evaluate((g) => { const v = document.querySelector("#view-groups");
return Math.round(g.getBoundingClientRect().top - v.getBoundingClientRect().top - v.clientHeight / 2); });
await page.mouse.move(width / 2, 400);
await page.mouse.wheel(0, dy);
@@ -124,8 +124,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.equal(await page.locator(".rt-group select, select").count(), 0, "no native select");
// the reader scrolls the card to the middle, then opens its routing
const view = page.locator("#view-routing");
const dy = await card().evaluate((g) => { const v = document.querySelector("#view-routing");
const view = page.locator("#view-groups");
const dy = await card().evaluate((g) => { const v = document.querySelector("#view-groups");
return Math.round(g.getBoundingClientRect().top - v.getBoundingClientRect().top - v.clientHeight / 2); });
await page.mouse.move(550, 400);
await page.mouse.wheel(0, dy);
@@ -1,172 +0,0 @@
// Run with Node's test runner and Playwright on the module path; see README.md.
// The routing groups sit at the Routing page's foot, below the stage, the
// story and every request: with many models a long scroll down (shihh on
// Discord). The page's head has a Routing groups beside New group, with a
// down arrow and a tooltip saying where they are; its click brings the
// groups' heading to the top of the view (or the view to its foot) and the
// focus into them, and nothing else moves: the groups stay where they were
// in the page, and a click no reader made scrolls nothing. It takes only
// room the head has spare: named where that fits, its arrow alone (still
// named to a screen reader) where only that does, left out where nothing
// does, and every other part of the head is where it is without it. Every
// language, Chromium and WebKit, wide, a phone's width and a narrow window.
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.MAGPIE_ROUTING_ASSETS || path.join(__dirname, "../assets"));
const models = [
{ id: "a/m", name: "m", providerName: "A", icon: "generic" },
{ id: "b/m", name: "m", providerName: "B", icon: "generic" },
];
const info = (ids) => ids.map((id) => ({ id, ready: true }));
const found = { id: "auto-m", name: "Model M", members: ["a/m", "b/m"], auto: true, ready: true, memberInfo: info(["a/m", "b/m"]) };
const words = {
en: { btn: "Routing groups", tip: "Go to the routing groups, below the requests" },
zh: { btn: "路由组", tip: "跳到请求下方的路由组" },
"zh-TW": { btn: "路由組", tip: "跳到請求下方的路由組" },
ja: { btn: "ルーティンググループ", tip: "リクエストの下にあるルーティンググループへ移動" },
de: { btn: "Weiterleitungsgruppen", tip: "Zu den Weiterleitungsgruppen unter den Anfragen springen" },
};
// requests enough to put the groups well below the window's fold
const now = Date.now();
const routes = Array.from({ length: 60 }, (_, i) => ({
id: "r" + i, seq: i + 1, at: new Date(now - i * 60000).toISOString(), agent: "claude", asked: "group/auto-m",
model: "a/m", provider: "a", status: 200, ms: 900, ttft: 300, in: 100, out: 20, done: true,
}));
function serve(lang, web) {
const state = { agents: [{ id: "claude", name: "Claude Code", path: "/test/claude", 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:${web}};` });
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: routes.length, totals: { requests: routes.length, rerouted: 0, errors: 0 }, routes });
}
if (url.pathname === "/api/gateway/history") return json({ cut: false, days: [], routes: [] });
if (url.pathname === "/api/groups") return json({ models, pools: [], deciders: [], found: true, groups: [found] });
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 });
};
}
// Under the whole suite's load webkit en once waited past the 5s default
// for the head button's fit (#3478): the page sizes the button a frame
// after the head's layout, and a loaded machine serves those first frames
// late, the fit with them. The waits that span the page's boot (the rows
// it fills, the head and the fit it gets in the first frames) get 15s;
// the goto keeps the minute every page's load has (#4470), and the waits
// inside a loaded page (the click's jump and its settle) the quick 5s.
const boot = 15000;
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
for (const lang of Object.keys(words)) {
for (const { width, web } of [{ width: 1000, web: true }, { width: 480, web: true }, { width: 640, web: false }]) {
const w = words[lang];
test(`${engine} ${lang} ${width}px${web ? " web" : " window"}: Routing groups in the Routing page's head goes to them`, async (t) => {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
const page = await (await browser.newContext({ viewport: { width, height: 600 }, reducedMotion: "reduce" })).newPage();
t.after(async () => {
if (process.env.ARTIFACT_DIR) {
await fs.mkdir(process.env.ARTIFACT_DIR, { recursive: true });
await page.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `${engine}-${lang}-${width}${web ? "-web" : ""}-routing-groups-jump.png`) });
}
await browser.close();
});
page.setDefaultTimeout(5000);
page.setDefaultNavigationTimeout(60000);
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang, web));
await page.goto("http://magpie.test/?view=routing");
await page.locator(".rt-group", { hasText: "Model M" }).waitFor({ state: "attached", timeout: boot });
await page.locator(".rt-reqs > *").first().waitFor({ state: "attached", timeout: boot });
const view = page.locator("#view-routing");
const go = page.locator("#view-routing > .row-head #rtGoGroups");
await go.waitFor({ state: "attached", timeout: boot });
await page.waitForFunction(() => document.getElementById("rtGoGroups").dataset.fit, null, { timeout: boot });
await page.waitForTimeout(100); // the fit settles in the frame after a resize
const fit = await go.getAttribute("data-fit");
if (width === 1000) assert.equal(fit, "full", "a wide head names it");
assert.equal(await go.getAttribute("title"), w.tip);
assert.equal(await go.evaluate((e) => e.tagName), "BUTTON", "a button, no native select");
assert.equal(await go.locator("svg").count(), 1, "a down arrow");
// nothing else in the head moves for it, or wraps, at this width (the
// spacer gives it its room)
const apart = await page.evaluate(() => {
const b = document.getElementById("rtGoGroups"), h = b.parentElement;
const at = () => JSON.stringify([h.getBoundingClientRect().height, ...[...h.children].filter((c) => c !== b && !c.classList.contains("grow")).map((c) => { const r = c.getBoundingClientRect(); return [c.className, Math.round(r.left), Math.round(r.top), Math.round(r.width), Math.round(r.height)]; })]);
const withIt = at();
b.style.setProperty("display", "none", "important");
const without = at();
b.style.removeProperty("display");
return { withIt, without, over: h.scrollWidth - h.clientWidth };
});
assert.equal(apart.withIt, apart.without, "the head is laid out as without it");
assert(apart.over <= 0, `nothing overflows the head (${apart.over}px)`);
const vw = await page.evaluate(() => document.documentElement.scrollWidth - innerWidth);
assert(vw <= 0, `no sideways scroll (${vw}px)`);
if (fit === "none") {
assert.equal(await go.isVisible(), false, "left out where the head has no room");
assert.deepEqual(errors, []);
return;
}
await go.waitFor();
// named on screen, or to a screen reader where only the arrow shows
assert.equal(await page.getByRole("button", { name: w.btn, exact: true }).count(), 1);
const label = go.locator("span");
if (fit === "full") assert.equal((await label.textContent()).trim(), w.btn);
else assert((await label.boundingBox()).width <= 1, "the arrow alone");
const border = await go.evaluate((e) => { const c = getComputedStyle(e); return c.borderLeftWidth !== c.borderRightWidth || c.borderLeftColor !== c.borderRightColor; });
assert.equal(border, false, "no left-border accent");
const hb = await go.boundingBox();
assert(hb.x >= 0 && hb.x + hb.width <= width && hb.y >= 0, "in sight on arrival");
// the layout as before: the groups after every request, below the fold
assert.equal(await page.evaluate(() => {
const more = document.getElementById("rtMore"), g = more.querySelector(".rt-gsec"), reqs = more.querySelector(".rt-reqs");
return g.parentElement === more && more.lastElementChild === g && !!(reqs.compareDocumentPosition(g) & Node.DOCUMENT_POSITION_FOLLOWING);
}), true, "the groups stay at the page's foot, after the requests");
const vh = await view.evaluate((v) => v.getBoundingClientRect().bottom);
const gTop = () => page.locator(".rt-gsec").evaluate((e) => e.getBoundingClientRect().top);
assert(await gTop() > vh, "the groups are below the fold on arrival");
assert.equal(await view.evaluate((v) => v.scrollTop), 0, "the page opens at its top");
// a click no reader made (code's own) scrolls nothing
await go.evaluate((b) => b.click());
await page.waitForTimeout(300);
assert.equal(await view.evaluate((v) => v.scrollTop), 0, "an untrusted click doesn't move the page");
// the reader's click: the groups' heading at the top of the view, the focus in them
await go.click();
// at the top of the view, or the view at its foot where the page ends first
await page.waitForFunction(() => {
const v = document.getElementById("view-routing"), g = document.querySelector(".rt-gsec");
const top = g.getBoundingClientRect().top - v.getBoundingClientRect().top;
return (top >= -1 && top < 40) || (top > 0 && v.scrollTop > 0 && v.scrollTop + v.clientHeight >= v.scrollHeight - 1);
});
assert.equal(await page.evaluate(() => document.querySelector(".rt-gsec").contains(document.activeElement)), true, "the focus goes with them");
const gh = await page.locator(".rt-gsec > .row-head .label").first().boundingBox();
assert(gh && gh.y >= 0 && gh.y + gh.height <= vh, "the groups' heading is in sight");
// and stays there: a moment later the view hasn't been pulled away
const at = await view.evaluate((v) => v.scrollTop);
await page.waitForTimeout(400);
assert.equal(await view.evaluate((v) => v.scrollTop), at, "the view stays where the click took it");
assert.deepEqual(errors, []);
});
}
}
}
@@ -82,7 +82,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const errors = [], posts = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang, false, posts));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
const note = page.locator(".rt-gsec .rt-goff");
await note.waitFor();
@@ -90,7 +90,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert(text.includes(w.why), text);
const btn = note.locator("button", { hasText: w.on });
assert(await btn.isVisible());
assert.equal(await page.locator("#rtNewGroup").isVisible(), false, "New group is off with them");
assert.equal(await page.locator(".rt-gnew").isVisible(), false, "New group is off with them");
assert.equal(await page.locator(".rt-group", { hasText: "Mine" }).isVisible(), false);
assert(await note.evaluate((n) => n.getBoundingClientRect().right <= innerWidth + 1), "the note fits the window");
assert(await btn.evaluate((b) => b.getBoundingClientRect().right <= innerWidth + 1), "so does its button");
@@ -99,7 +99,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await note.waitFor({ state: "hidden" });
assert.deepEqual(posts, [{ id: "groups", on: true }]);
await page.locator(".rt-group", { hasText: "Mine" }).waitFor({ state: "visible" });
await page.locator("#rtNewGroup").waitFor({ state: "visible" });
await page.locator(".rt-gnew").waitFor({ state: "visible" });
await page.waitForFunction((m) => document.querySelector("#status").textContent.includes(m), w.done);
assert.deepEqual(errors, []);
});
@@ -110,10 +110,10 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang, true, []));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
await page.locator(".rt-group", { hasText: "Mine" }).waitFor({ state: "visible" });
assert.equal(await page.locator(".rt-goff").isVisible(), false);
assert(await page.locator("#rtNewGroup").isVisible());
assert(await page.locator(".rt-gnew").isVisible());
assert.deepEqual(errors, []);
});
}
@@ -121,7 +121,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
test(`${engine}: the note's strings are in every language`, async (t) => {
const page = await open(engine, 900, t, `${engine}-routing-groups-off-i18n.png`);
await page.route("**/*", serve("en", false, []));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
await page.locator(".rt-goff").waitFor();
const missing = await page.evaluate((ks) => ["zh", "zh-TW", "ja", "de"].flatMap((l) => ks.filter((k) => !I18N[l]?.[k]).map((k) => `${l}: ${k}`)), keys);
assert.deepEqual(missing, []);
@@ -0,0 +1,261 @@
// Run with Node's test runner and Playwright on the module path; see README.md.
// Routing groups have a page of their own beside Routing (11-06): below the
// stage and every request they were a long scroll down, New group with
// them. The sidebar names the page under Models, after Routing; its
// toolbar is the filter, how many groups there are and how many are on,
// then Templates, Import, Select and New group, the one filled button;
// the list follows, then Settings (found groups, the names in agents'
// lists). The Routing page keeps the stage and the requests, and a
// request's group opens the groups page on its row. Every language,
// Chromium and WebKit, wide, a narrow window and a phone's width.
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.MAGPIE_ROUTING_ASSETS || path.join(__dirname, "../assets"));
const models = [
{ id: "a/m", name: "m", providerName: "A", icon: "generic" },
{ id: "b/m", name: "m", providerName: "B", icon: "generic" },
{ id: "a/n", name: "n", providerName: "A", icon: "generic" },
];
const info = (ids) => ids.map((id) => ({ id, ready: true }));
const groups = [
{ id: "auto-m", name: "Model M", members: ["a/m", "b/m"], auto: true, ready: true, memberInfo: info(["a/m", "b/m"]) },
{ id: "mine", name: "Mine", members: ["a/n", "b/m"], ready: true, memberInfo: info(["a/n", "b/m"]) },
{ id: "off", name: "Off one", members: ["a/n"], disabled: true, ready: true, memberInfo: info(["a/n"]) },
];
const words = {
en: { nav: "Routing groups", count: "3 groups · 2 on", fresh: "New group", settings: "Settings" },
zh: { nav: "路由组", count: "3 个组 · 2 个开启", fresh: "新建组", settings: "设置" },
"zh-TW": { nav: "路由組", count: "3 個組 · 2 個開啟", fresh: "新增組", settings: "設定" },
ja: { nav: "ルーティンググループ", count: "3 個のグループ · 2 個がオン", fresh: "新しいグループ", settings: "設定" },
de: { nav: "Weiterleitungsgruppen", count: "3 Gruppen · 2 an", fresh: "Neue Gruppe", settings: "Einstellungen" },
};
// enough requests that the Routing page scrolls
const now = Date.now();
const routes = Array.from({ length: 30 }, (_, i) => ({
id: "r" + i, seq: i + 1, at: new Date(now - i * 60000).toISOString(), agent: "claude", asked: "group/mine",
model: "a/n", provider: "a", status: 200, ms: 900, ttft: 300, in: 100, out: 20, done: true,
group: { id: "mine", name: "Mine" },
}));
function serve(lang, web) {
const state = { agents: [{ id: "claude", name: "Claude Code", path: "/test/claude", 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:${web}};` });
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: routes.length, totals: { requests: routes.length, rerouted: 0, errors: 0 }, routes });
}
if (url.pathname === "/api/gateway/history") return json({ cut: false, days: [], routes: [] });
if (url.pathname === "/api/groups") return json({ models, pools: [], deciders: [], found: true, 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 });
};
}
// the page's boot under the whole suite's load (#3478)
const boot = 15000;
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
for (const lang of Object.keys(words)) {
for (const { width, web } of [{ width: 1280, web: false }, { width: 640, web: false }, { width: 420, web: true }]) {
const w = words[lang];
test(`${engine} ${lang} ${width}px${web ? " web" : " window"}: Routing groups is a page of its own`, async (t) => {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
const page = await (await browser.newContext({ viewport: { width, height: 700 }, reducedMotion: "reduce" })).newPage();
t.after(async () => {
if (process.env.ARTIFACT_DIR) {
await fs.mkdir(process.env.ARTIFACT_DIR, { recursive: true });
await page.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `${engine}-${lang}-${width}${web ? "-web" : ""}-routing-groups-page.png`) });
}
await browser.close();
});
page.setDefaultTimeout(5000);
page.setDefaultNavigationTimeout(60000);
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang, web));
await page.goto("http://magpie.test/?view=routing");
await page.locator(".rt-reqs > *").first().waitFor({ state: "attached", timeout: boot });
await page.locator(".rt-group", { hasText: "Mine" }).waitFor({ state: "attached", timeout: boot });
// the Routing page: the stage and the requests, no groups, no jump
assert.equal(await page.locator("#view-routing .rt-gsec, #view-routing .rt-group").count(), 0, "no groups on the Routing page");
assert.equal(await page.locator("#rtGoGroups, #rtNewGroup").count(), 0, "its head has no way down to them");
assert.equal(await page.locator("#view-groups .rt-gsec").count(), 1, "the groups are on their own page");
// the sidebar (or the header's tabs) names the page, after Routing
const nav = page.locator('button[data-view="groups"]');
assert.equal(await nav.count(), 1);
assert.equal((await nav.textContent()).trim(), w.nav);
assert.equal(await page.evaluate(() => {
const r = document.querySelector('button[data-view="routing"]');
return r.nextElementSibling === document.querySelector('button[data-view="groups"]');
}), true, "right after Routing");
// the sidebar has the tab; the header's row has no room for it (at
// 860px it pushed the logo out), so there Routing's head opens the
// page and Routing's tab stands for both
const side = await page.evaluate(() => document.body.classList.contains("side-nav"));
const into = page.locator("#rtToGroups");
assert.equal(side, width >= 1024, "the sidebar from 1024 points");
assert.equal(await nav.isVisible(), side, "the tab where there is room");
assert.equal(await into.isVisible(), !side, "Routing's head opens them where there is no tab");
if (side) await nav.click();
else {
assert.equal((await into.textContent()).replace("›", "").trim(), w.nav);
await into.click();
}
const view = page.locator("#view-groups");
await view.waitFor();
const on = await page.evaluate(() => [...document.querySelectorAll("#nav button[data-view].on")].map((b) => b.dataset.view));
assert.deepEqual(on, [side ? "groups" : "routing"], "the tab shown as the page's");
assert.equal(await page.locator("#view-routing").isHidden(), true);
const rows = view.locator(".rt-group");
await rows.first().waitFor({ timeout: boot });
assert.equal(await rows.count(), 3);
// the toolbar: the filter, how many, then New group, the filled one
const head = view.locator(".rt-gsec > .row-head").first();
assert.equal(await head.locator(".rt-gfilter").count(), 1, "the filter");
assert.equal((await head.locator(".rt-gcount").textContent()).trim(), w.count);
const fresh = head.locator(".rt-gnew");
assert.equal((await fresh.textContent()).trim(), w.fresh);
assert.equal(await fresh.evaluate((e) => e.classList.contains("primary")), true, "New group is the filled button");
assert.equal(await head.locator(".rt-gimportbtn").count(), 1, "Import");
assert.equal(await head.locator(".rt-gselect").count(), 1, "Select");
assert.equal(await head.locator("select").count(), 0, "no native select");
const fb = await fresh.boundingBox();
assert(fb && fb.x >= 0 && fb.x + fb.width <= width && fb.y >= 0 && fb.y + fb.height <= 700, "New group in sight on arrival");
// the list right under the toolbar, Settings under the list
const order = await page.evaluate(() => {
const s = document.querySelector("#view-groups .rt-gsec"), kids = [...s.children];
const at = (q) => kids.findIndex((k) => k.matches(q));
return [at(".row-head"), at(".rt-groups"), at(".rt-gset-head"), at(".rt-gset")];
});
assert.deepEqual(order, [0, 1, 3, 4], "toolbar, list, (off), Settings, its card");
assert.equal((await view.locator(".rt-gset-head .label").textContent()).trim(), w.settings);
assert.equal(await view.locator(".rt-gset .rt-gfound").count(), 1, "found groups in Settings");
assert.equal(await view.locator(".rt-gset .rt-gnames").count(), 1, "the names in Settings");
const gb = await view.locator(".rt-groups").boundingBox(), hb = await head.boundingBox();
assert(gb.y >= hb.y + hb.height - 1 && gb.y - (hb.y + hb.height) < 24, "the list right below the toolbar");
const over = await page.evaluate(() => document.documentElement.scrollWidth - innerWidth);
assert(over <= 0, `no sideways scroll (${over}px)`);
const headOver = await head.evaluate((h) => h.scrollWidth - h.clientWidth);
assert(headOver <= 0, `nothing overflows the toolbar (${headOver}px)`);
const border = await fresh.evaluate((e) => { const c = getComputedStyle(e); return c.borderLeftWidth !== c.borderRightWidth || c.borderLeftColor !== c.borderRightColor; });
assert.equal(border, false, "no left-border accent");
// New group opens its editor at the list's top, on this page
await fresh.click();
await view.locator(".rt-gedit").first().waitFor();
assert.equal(await page.locator("#view-routing .rt-gedit").count(), 0);
assert.deepEqual(errors, []);
});
}
}
}
// a request's group on the Routing page opens the groups page on its row
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
test(`${engine}: a request's group goes to its row on the groups page`, 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: 1280, height: 700 }, reducedMotion: "reduce" })).newPage();
page.setDefaultTimeout(5000);
page.setDefaultNavigationTimeout(60000);
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve("en", false));
await page.goto("http://magpie.test/?view=routing");
await page.locator(".rt-group", { hasText: "Mine" }).waitFor({ state: "attached", timeout: boot });
const go = page.locator('#view-routing .rt-go[data-go="group:mine"]').first();
await go.waitFor({ timeout: boot });
await go.click();
await page.locator("#view-groups").waitFor();
assert.equal(await page.locator("#view-routing").isHidden(), true, "Routing is left");
const row = page.locator('#view-groups .rt-group[data-id="mine"]');
await row.waitFor();
const rb = await row.boundingBox();
assert(rb.y >= 0 && rb.y + rb.height <= 700, "its row in sight");
// the window opened on a new group of a model: the groups page
await page.goto("http://magpie.test/?view=groups&newgroup=a%2Fn");
await page.locator("#view-groups .rt-gedit").first().waitFor({ timeout: boot });
assert.equal(await page.locator("#view-groups").isVisible(), true);
assert.deepEqual(errors, []);
});
}
// The groups page draws itself again each second when the accounts' quotas
// change, as the Routing page did under streaming requests (routing-steady
// and routing-pointer-pin, gone with the groups' move): the quota line
// comes in under a group by itself, and with a group open in its editor
// and a name being typed, the field keeps its focus and what was typed,
// and the list stays where it is.
const withProvider = { models, pools: [], deciders: [], found: true, groups: groups.map((g) => ({ ...g, memberInfo: g.memberInfo.map((i) => ({ ...i, provider: i.id.split("/")[0], name: i.id.split("/")[0].toUpperCase() })) })) };
// two accounts: the line is what they have left together
const card = (amount) => ["a1@example.com", "a2@example.com"].map((user) => ({ provider: "a", name: "A", kind: "subscription", icon: "generic", plan: "Pro", user, readAt: new Date().toISOString(),
windows: [{ name: "Credits", amount, limit: 500, unit: "credits", used: (100 * amount) / 500, resetsAt: new Date(Date.now() + 9 * 864e5).toISOString() }] }));
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
for (const width of [1280, 420]) {
test(`${engine} ${width}px: the groups page draws new quotas by itself, an open editor left alone`, 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, height: 500 }, reducedMotion: "reduce" })).newPage();
page.setDefaultTimeout(5000);
page.setDefaultNavigationTimeout(60000);
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
const base = serve("en", width < 600);
await page.route("**/*", (r) => {
const at = new URL(r.request().url()).pathname;
if (at === "/api/groups") return r.fulfill({ json: withProvider });
if (at === "/api/usage/quotas") return r.fulfill({ json: [] });
return base(r);
});
await page.goto("http://magpie.test/?view=groups");
const row = page.locator('#view-groups .rt-group[data-id="mine"]');
await row.waitFor({ timeout: boot });
await page.waitForFunction(() => Array.isArray(quotas), null, { timeout: boot });
// quotas come in: the line shows with no click and no reload
await page.evaluate((q) => { quotas = q; }, card(400));
await row.locator(".rt-gquota").waitFor({ timeout: 5000 });
await row.getByRole("button", { name: "Edit", exact: true }).click();
const name = page.locator("#view-groups .rt-gedit input").first();
await name.waitFor();
// focus, not a click: at a phone's height the editor's Save bar can
// sit over it, and what is asked here is the redraw, not the reach
await name.focus();
await page.keyboard.type("Opus and more");
const typed = await name.inputValue();
const top = async () => (await name.boundingBox()).y;
const before = await top(), scrolled = await page.locator("#view-groups").evaluate((v) => v.scrollTop);
// new quotas twice, each a tick's redraw were the editor not open
for (const amount of [300, 200]) {
await page.evaluate((q) => { quotas = q; }, card(amount));
await page.waitForTimeout(1300);
}
assert.equal(await name.evaluate((e) => e === document.activeElement), true, "the field kept its focus");
assert.equal(await name.inputValue(), typed);
assert.equal(await page.locator("#view-groups").evaluate((v) => v.scrollTop), scrolled, "the view didn't scroll");
assert(Math.abs((await top()) - before) < 1, "the field stayed where it was");
await page.keyboard.type("!");
assert.equal(await name.inputValue(), typed + "!");
assert.deepEqual(errors, []);
});
}
}
@@ -62,7 +62,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang, web));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
await page.locator(".rt-group").nth(2).waitFor();
const settle = () => page.evaluate(() => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(() => setTimeout(r, 100)))));
for (const width of web ? [1440, 1100, 700, 440, 360] : [1440, 1100, 900, 700, 560]) {
@@ -70,7 +70,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await page.setViewportSize({ width, height: 900 });
await settle();
const m = await page.evaluate(() => {
const v = document.querySelector("#view-routing"), de = document.documentElement;
const v = document.querySelector("#view-groups"), de = document.documentElement;
const rows = [...document.querySelectorAll(".rt-groups > .rt-group")].map((g) => {
const b = g.getBoundingClientRect(), list = g.parentElement.getBoundingClientRect();
const kids = [...g.querySelectorAll(".mem, .tags, .switch, button")].map((e) => e.getBoundingClientRect()).filter((k) => k.width > 0);
@@ -90,7 +90,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
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");
await page.goto("http://magpie.test/?view=groups");
const group = page.locator(".rt-group").first();
await group.waitFor();
@@ -86,7 +86,7 @@ async function open(t, engine, lang, width, kept) {
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang, routeOf(kept)));
await page.goto("http://magpie.test/?view=routing");
await page.locator(".rt-group").first().waitFor();
await page.locator(".rt-group").first().waitFor({ state: "attached" });
return { page, errors };
}
+2 -2
View File
@@ -64,13 +64,13 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
test(`${engine} ${lang}: a group names the reasoning levels agents are offered`, 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 } })).newPage();
const page = await (await browser.newContext({ viewport: { width: 1100, height: 1400 }, reducedMotion: "reduce" })).newPage();
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=routing");
await page.goto("http://magpie.test/?view=groups");
await page.locator(".rt-group").first().waitFor();
const ed = page.locator(".rt-gedit");
// the editor's Levels row: the field after its label
+4 -4
View File
@@ -82,7 +82,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
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");
await page.goto("http://magpie.test/?view=groups");
const card = page.locator(".rt-group", { hasText: "Hand" });
await card.waitFor();
@@ -99,8 +99,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
// the reader scrolls the card to the middle, then picks luna: saved
// with the group's other fields as they were, nothing moves, the
// editor stays shut
const view = page.locator("#view-routing");
const dy = await card.evaluate((g) => { const v = document.querySelector("#view-routing");
const view = page.locator("#view-groups");
const dy = await card.evaluate((g) => { const v = document.querySelector("#view-groups");
return Math.round(g.getBoundingClientRect().top - v.getBoundingClientRect().top - v.clientHeight / 2); });
await page.mouse.move(550, 400);
await page.mouse.wheel(0, dy);
@@ -133,7 +133,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const wheelTo = async (x) => {
// the distance is read once the editor has stopped moving
await settled(page);
const d = await x.evaluate((e) => { const v = document.querySelector("#view-routing");
const d = await x.evaluate((e) => { const v = document.querySelector("#view-groups");
return Math.round(e.getBoundingClientRect().top - v.getBoundingClientRect().top - v.clientHeight / 2); });
await page.mouse.move(550, 400);
await page.mouse.wheel(0, d);
@@ -168,10 +168,13 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert(rows.wires >= 800, `${rows.wires} wires: each key has one, in the list or not`);
assert.deepEqual(rows.unwired, [], "a wire ends at each key in sight");
// scrolled to the foot, the last key is there, drawn, with its wire
await page.mouse.move(700, 500);
// by the wheel, as a reader would: on until the last key is in the
// list, then to it
// list, then to it. The wheel turns over the keys: at the page's foot
// the requests list sits below them, and a wheel over it scrolls it
// and stops there (overscroll-behavior: contain), as it should
const overKeys = () => page.evaluate(() => { const r = document.querySelector("#view-routing .rt-accts").getBoundingClientRect(); return [r.left + Math.min(40, r.width / 2), (Math.max(60, r.top) + Math.min(innerHeight - 20, r.bottom)) / 2]; }).then(([x, y]) => page.mouse.move(x, y));
for (let k = 0; k < 80; k++) {
await overKeys();
const at = await page.evaluate(() => [...document.querySelectorAll("#view-routing .rt-accts > li")].find((li) => li.title === "solpool2#k299")?.getBoundingClientRect().top);
if (at !== undefined && Math.abs(at - 400) < 150) break;
await page.mouse.wheel(0, at === undefined ? 3000 : Math.max(-3000, Math.min(3000, at - 400)));
@@ -189,6 +192,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
for (let k = 0; k < 80; k++) {
const f = await fold2();
if (f && Math.abs(f.top - 300) < 150) break;
await overKeys();
await page.mouse.wheel(0, !f ? -3000 : Math.max(-3000, Math.min(3000, f.top - 300)));
await page.waitForTimeout(!f ? 50 : 300);
}
+16 -11
View File
@@ -96,7 +96,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const { page, errors } = await open(engine, lang, "lone", width, t);
await page.waitForFunction((s) => document.querySelector(".rt-mode")?.textContent.trim() === s, lone[lang]);
// the groups are in, and the chip still names no routing
await page.locator(".rt-group").first().waitFor();
await page.locator("#view-groups .rt-group").first().waitFor({ state: "attached" });
await page.waitForTimeout(150);
assert.equal(await page.locator(".rt-hub i").isHidden(), true, "the chip names no routing");
assert.equal((await page.locator(".rt-mode").textContent()).trim(), lone[lang]);
@@ -120,18 +120,24 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.equal((await head.textContent()).trim(), smart[lang]);
assert.equal(await head.getAttribute("data-go"), "pool:relay");
const view = page.locator("#view-routing");
// the pools are on the Routing groups page: the chip opens it, with
// the pool in sight
const groups = page.locator("#view-groups");
const pool = page.locator('.rt-pool[data-provider="relay"]');
await pool.waitFor({ state: "attached" });
const inView = () => pool.evaluate((p) => { const v = document.querySelector("#view-routing").getBoundingClientRect(), r = p.getBoundingClientRect();
return r.top >= v.top && r.bottom <= v.bottom; });
const inView = () => pool.evaluate((p) => { const v = document.querySelector("#view-groups"), b = v.getBoundingClientRect(), r = p.getBoundingClientRect();
return !v.hidden && r.height > 0 && r.top >= b.top && r.bottom <= b.bottom; });
assert.equal(await inView(), false, "the pool starts out of view");
const top = await view.evaluate((v) => v.scrollTop);
const back = async () => {
await page.evaluate(() => window.show("routing"));
await page.waitForFunction(() => !document.querySelector("#view-routing").hidden);
await pool.evaluate((p) => p.classList.remove("rt-found"));
};
// a click takes the reader there: in view, marked, its routing focused
await chip.click();
await page.waitForFunction(() => document.querySelector('.rt-pool[data-provider="relay"]')?.classList.contains("rt-found"));
assert.ok(await view.evaluate((v) => v.scrollTop) > top, "the view went down to it");
assert.equal(await groups.isVisible(), true, "the groups page opened");
assert.equal(await inView(), true);
assert.equal(await page.evaluate(() => document.activeElement?.closest(".rt-pool")?.dataset.provider), "relay");
assert.equal(await page.evaluate(() => document.activeElement?.classList.contains("on")), true);
@@ -140,8 +146,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
// a press held over the head's redraw is still a click (#2151): the
// chip is not written over under the pointer, which WebKit takes
// for a press that never ends where it began
await view.evaluate((v) => { v.scrollTop = 0; });
await pool.evaluate((p) => p.classList.remove("rt-found"));
await back();
const box = await chip.boundingBox();
await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2);
await page.mouse.down();
@@ -151,11 +156,11 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await page.waitForFunction(() => document.querySelector('.rt-pool[data-provider="relay"]')?.classList.contains("rt-found"));
assert.equal(await inView(), true);
// the keyboard does the same from the top
await view.evaluate((v) => { v.scrollTop = 0; });
// the keyboard does the same
await back();
await chip.focus();
await page.keyboard.press("Enter");
await page.waitForFunction(() => document.querySelector("#view-routing").scrollTop > 0);
await page.waitForFunction(() => document.querySelector('.rt-pool[data-provider="relay"]')?.classList.contains("rt-found"));
assert.equal(await inView(), true);
// nothing is drawn wider than the window
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth), true);
@@ -88,7 +88,7 @@ function serve(lang, posts, route) {
async function open(t, engine, lang, width, folder) {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
t.after(() => browser.close());
const page = await (await browser.newContext({ viewport: { width, height: 1400 } })).newPage();
const page = await (await browser.newContext({ viewport: { width, height: 1400 }, reducedMotion: "reduce" })).newPage();
page.setDefaultTimeout(5000);
page.setDefaultNavigationTimeout(60000);
const errors = [], posts = [];
@@ -96,7 +96,7 @@ async function open(t, engine, lang, width, folder) {
await page.route("**/*", serve(lang, posts, routeFrom(folder)));
await page.goto("http://magpie.test/?view=routing");
const group = page.locator(".rt-group").first();
await group.waitFor();
await group.waitFor({ state: "attached" });
return { page, group, errors, posts };
}
@@ -125,6 +125,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const said = await page.evaluate(() => document.documentElement.innerText);
assert(said.includes(w.cond), `the pause's folders are told: ${said.slice(0, 2000)}`);
if (w.aside) assert(said.includes(w.aside), `the paused reason: ${said.slice(0, 2000)}`);
await page.evaluate(() => window.show("groups"));
await group.waitFor();
// the group's rule, in words
const title = await group.evaluate((g) => [...g.querySelectorAll("[title]")].map((e) => e.title).join("\n"));
@@ -189,6 +191,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
test(`${engine} ${lang}: a pause outside a folder at a phone's width, the agent saying none`, async (t) => {
const { page, group, errors } = await open(t, engine, lang, 390, "");
await page.waitForFunction((s) => document.documentElement.innerText.includes(s), w.none);
await page.evaluate(() => window.show("groups"));
await group.waitFor();
await press(page, group.locator("button", { hasText: w.edit })); // the group is below the fold here
const row = page.locator(".rt-gedit .rt-rule").first();
const xf = row.locator(".rt-cond.xf");
+7 -3
View File
@@ -86,7 +86,7 @@ async function open(engine, lang, width, t) {
await page.route("**/*", serve(lang, posts));
await page.goto("http://magpie.test/?view=routing");
const group = page.locator(".rt-group").first();
await group.waitFor();
await group.waitFor({ state: "attached" });
return { page, group, errors, posts };
}
// a click as the reader's: wheeled into the middle of the view first (a
@@ -96,11 +96,11 @@ async function press(page, x) {
// a group opening into its editor moves its height and parts for ~700ms
// (91b0be836): where x will be is read once that has stopped
await page.waitForFunction(() => !document.getAnimations().some((a) => a.playState === "running" && Number.isFinite(a.effect?.getComputedTiming().endTime)));
const d = await x.evaluate((e) => { const v = document.querySelector("#view-routing");
const d = await x.evaluate((e) => { const v = document.querySelector("#view-groups");
return Math.round(e.getBoundingClientRect().top - v.getBoundingClientRect().top - v.clientHeight / 2); });
if (Math.abs(d) > 100) {
// over the view, not the sidebar beside it
const v = await page.locator("#view-routing").boundingBox();
const v = await page.locator("#view-groups").boundingBox();
await page.mouse.move(v.x + 10, 300);
await page.mouse.wheel(0, d);
await page.waitForTimeout(400);
@@ -123,6 +123,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
// the trace: the model paused, by which rule and when
await page.waitForFunction((s) => document.documentElement.innerText.includes(s), w.aside);
await page.evaluate(() => window.show("groups"));
await group.waitFor();
// the group's rule, in words
const title = await group.evaluate((g) => [...g.querySelectorAll("[title]")].map((e) => e.title).join("\n"));
@@ -192,6 +194,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
for (const lang of Object.keys(words)) {
test(`${engine} ${lang}: a pause rule at a narrow width`, async (t) => {
const { page, group, errors } = await open(engine, lang, 420, t);
await page.evaluate(() => window.show("groups"));
await group.waitFor();
await press(page, group.locator("button", { hasText: EDIT[lang] }));
const row = page.locator(".rt-gedit .rt-rule").first();
await row.waitFor();
@@ -1,107 +0,0 @@
// Run with Node's test runner and Playwright on the module path; see README.md.
// Routing: the groups stay under the pointer as requests come in (cwfox67 on
// X: picking a manual group's model meant fighting the page, which shook as
// it updated). With the groups low in the view, as they are at the page's
// foot, the requests list above them kept its place and grew, so a group's
// card slid down from under the pointer with each request. With the pointer
// on a manual group's card and requests streaming in, the card stays where
// it is on the screen. In Chromium and WebKit, at a phone's width and a
// desk's.
const assert = require("node:assert/strict");
const { test } = require("node:test");
const fs = require("node:fs/promises");
const path = require("node:path");
const { chromium, webkit } = require("playwright");
const assets = path.resolve(__dirname, "../assets");
const now = Date.now(), iso = (ms) => new Date(ms).toISOString();
const seat = { id: "codex@me", provider: "codex", name: "ChatGPT", who: "me@example.com", kind: "account", model: "gpt-6.1-sol", known: true, plan: "Pro" };
const prompt = (n) => ({ window: 272000, tokens: 90000 + n * 8000, counted: true, turns: n, parts: [
{ kind: "system", tokens: 9000, items: [{ name: "prompt", tokens: 9000 }] },
{ kind: "files", tokens: 30000 + n * 4000, items: Array.from({length: 1 + (n % 5)}, (_, i) => ({ name: "/work/f" + i + ".js", tag: "read", tokens: 3000 })) },
{ kind: "chat", tokens: 19000 + n * 2000, items: [{ name: "turn", tag: "turns", n, tokens: 19000 + n * 2000 }] } ] });
function req(id, step) {
const t0 = now - (400 - id) * 1000, done = step === "done";
return { id, seq: id * 10 + ({ start: 0, read: 1, done: 2 })[step], time: iso(t0), agent: "codex", session: "019a-session", model: "gpt-6.1-sol", provider: "codex",
order: [seat], tries: [{ id: seat.id, model: seat.model, start: iso(t0), done, ...(done ? { status: 200, ms: 4000 } : {}) }],
done, ...(done ? { status: 200, ms: 4000, tokens: 2000, cost: 0.05, priced: true, usage: [{ in: 3000, cache_read: 87000, out: 400 }] } : {}),
...(step === "start" ? {} : { prompt: prompt(id - 100) }) };
}
const first = [101, 102, 103].map((i) => req(i, "done"));
const models = [{ id: "a/sol", name: "sol", providerName: "A", icon: "generic" }, { id: "b/flash", name: "flash", providerName: "B", icon: "generic" }];
const base = { members: ["a/sol", "b/flash"], ready: true, memberInfo: [{ id: "a/sol", ready: true }, { id: "b/flash", ready: true }], offers: [], shared: [] };
const groups = { models, pools: [], groups: [{ ...base, id: "hand", name: "Hand", routing: "manual", pick: "a/sol", picked: "a/sol" }, { ...base, id: "auto", name: "Auto", routing: "order" }] };
function serve(feed) {
const state = { agents: [{ id: "codex", name: "Codex", path: "/test/codex", fields: [] }], profiles: [], settings: { lang: "en", theme: "light" } };
return async (route) => {
const url = new URL(route.request().url()); const json = (d) => route.fulfill({ json: d });
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: 'window.bootPrefs = {lang:"en",theme:"light",web:true};' });
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
if (url.pathname === "/api/state") return json(state);
if (url.pathname === "/api/gateway/trace") {
const trace = (routes) => json({ mine: true, now: new Date().toISOString(), seq: routes.length ? routes[routes.length - 1].seq : Number(url.searchParams.get("after")), totals: { requests: 0, rerouted: 0, errors: 0 }, routes });
if (!url.searchParams.get("wait")) return trace(first);
return trace([await new Promise((res) => { feed.next = res; })]);
}
if (url.pathname === "/api/gateway/history") return json({ cut: false, days: [], routes: [] });
if (url.pathname === "/api/groups") 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 ct = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
await route.fulfill({ body: await fs.readFile(file).catch(() => ""), contentType: ct });
};
}
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
test(`${engine}: a group under the pointer stays put as requests come in`, async (t) => {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
t.after(() => browser.close());
for (const [w, h] of [[420, 760], [1100, 760]]) {
await t.test(`${w}x${h}`, async () => {
const context = await browser.newContext({ viewport: { width: w, height: h } });
const page = await context.newPage();
page.setDefaultTimeout(5000);
page.setDefaultNavigationTimeout(60000);
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
const feed = {};
await page.route("**/*", serve(feed));
await page.goto("http://magpie.test/?view=routing");
await page.locator(".rt-group").first().waitFor();
await page.waitForTimeout(1500);
// the reader wheels down to the groups, then puts the pointer on the
// manual group's card
// over the view, not the sidebar beside it
const v = await page.locator("#view-routing").boundingBox();
await page.mouse.move(v.x + 8, h / 2);
for (let i = 0; i < 80; i++) {
const top = await page.evaluate(() => document.querySelector(".rt-group").getBoundingClientRect().top);
if (top < 300) break;
await page.mouse.wheel(0, Math.min(200, top - 250));
await page.waitForTimeout(60);
}
await page.waitForTimeout(300);
const b = await page.locator(".rt-group").first().boundingBox();
await page.mouse.move(b.x + 40, b.y + 10);
await page.waitForTimeout(100);
const at = () => page.evaluate(() => [document.querySelector(".rt-group").getBoundingClientRect().top, document.querySelector(".rt-reqs").offsetHeight, document.querySelector("#rt").offsetHeight]);
const was = await at(), seen = [];
for (let id = 104; id < 112; id++) for (const s of ["start", "read", "done"]) {
for (let i = 0; i < 60 && !feed.next; i++) await page.waitForTimeout(50);
const next = feed.next;
assert(next, "the page asks for the next trace");
feed.next = null;
next(req(id, s));
await page.waitForTimeout(250);
seen.push(await at());
}
const last = seen[seen.length - 1];
assert(last[1] + last[2] - was[1] - was[2] > 50 || w < 760, `what is above the groups really changed: ${JSON.stringify([was, last])}`);
for (const s of seen) assert(Math.abs(s[0] - was[0]) <= 1.5, `the card stayed under the pointer: ${was[0]} → ${seen.map((x) => Math.round(x[0])).join(" ")}`);
assert.deepEqual(errors, []);
feed.next?.(req(999, "done"));
await context.close();
});
}
});
}
@@ -49,7 +49,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
const row = page.locator(".rt-pool");
await row.waitFor();
assert.equal(await row.getAttribute("title"), null, "the row itself carries no tooltip");
@@ -69,7 +69,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
const say = (key, vars = {}) => page.evaluate(([lang, key, vars]) => {
const s = (lang !== "en" && I18N[lang]?.[key]) || key;
return s.replace(/\{(\w+)\}/g, (_, k) => vars[k] ?? `{${k}}`);
@@ -70,7 +70,7 @@ const watch = () => {
new MutationObserver((ms) => { for (const m of ms) if (set(m.oldValue) !== set(m.target.getAttribute("class"))) w.flips.push(m.target.className); })
.observe(document.querySelector("#view-routing"), { subtree: true, attributes: true, attributeFilter: ["class"], attributeOldValue: true });
new MutationObserver((ms) => { w.providers += ms.length; }).observe(document.querySelector("#view-providers"), { subtree: true, childList: true });
new MutationObserver((ms) => { w.groups += ms.length; }).observe(document.querySelector("#view-routing .rt-groups"), { subtree: true, childList: true });
new MutationObserver((ms) => { w.groups += ms.length; }).observe(document.querySelector("#view-groups .rt-groups"), { subtree: true, childList: true });
// the picked request's story: its head, its steps and its context card
for (const s of [".rt-log-head", ".rt-steps", ".ctx-card"]) new MutationObserver((ms) => { w.story += ms.length; }).observe(document.querySelector("#view-routing " + s), { subtree: true, childList: true, characterData: true });
// the stage's nodes as they are now
+2 -2
View File
@@ -64,7 +64,7 @@ function serve(lang, web) {
// what sticks out: the page past the window, and a row's controls past the row
const measure = (page) => page.evaluate(() => {
const v = document.querySelector("#view-routing"), de = document.documentElement;
const v = document.querySelector("#view-groups"), de = document.documentElement;
const out = [];
for (const row of document.querySelectorAll(".rt-groups > *, .rt-pools > *")) {
const rb = row.getBoundingClientRect();
@@ -91,7 +91,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang, web));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
await page.locator(".rt-group").nth(2).waitFor();
const memLine = await page.locator(".rt-group[data-id=g1] .mem").first().textContent();
assert(memLine.includes("WorkBuddy AI · Hy3"), `the reporter's member line: ${memLine}`);
@@ -81,13 +81,13 @@ function serve(lang, posts, asked) {
async function open(t, engine, lang, width) {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
t.after(() => browser.close());
const page = await (await browser.newContext({ viewport: { width, height: 1400 } })).newPage();
const page = await (await browser.newContext({ viewport: { width, height: 1400 }, reducedMotion: "reduce" })).newPage();
page.setDefaultTimeout(5000);
page.setDefaultNavigationTimeout(60000);
const errors = [], posts = [], asked = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang, posts, asked));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
const group = page.locator(".rt-group").first();
await group.waitFor();
return { page, group, errors, posts, asked };
@@ -134,7 +134,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
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");
await page.goto("http://magpie.test/?view=groups");
const ed = await openEditor(page, lang);
for (const width of [1100, 900, 700]) {
await page.setViewportSize({ width, height: 1400 });
@@ -71,7 +71,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
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");
await page.goto("http://magpie.test/?view=groups");
const card = page.locator(".rt-group").first();
await card.waitFor();
await card.locator("button", { hasText: w.edit }).click();
@@ -93,7 +93,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
// 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();
const v = await page.locator("#view-groups").boundingBox();
await page.mouse.move(v.x + 10, 300);
for (let n = 0; n < 40; n++) {
const b = await ed.locator(".rt-rules").boundingBox();
@@ -70,7 +70,7 @@ async function open(engine, lang, width, t) {
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");
await page.goto("http://magpie.test/?view=groups");
const group = page.locator(".rt-group").first();
await group.waitFor();
return { page, group, errors, posts };
@@ -81,10 +81,10 @@ async function press(page, x) {
// a group opening into its editor moves its height and parts for ~700ms
// (91b0be836): where x will be is read once that has stopped
await page.waitForFunction(() => !document.getAnimations().some((a) => a.playState === "running" && Number.isFinite(a.effect?.getComputedTiming().endTime)));
const d = await x.evaluate((e) => { const v = document.querySelector("#view-routing");
const d = await x.evaluate((e) => { const v = document.querySelector("#view-groups");
return Math.round(e.getBoundingClientRect().top - v.getBoundingClientRect().top - v.clientHeight / 2); });
if (Math.abs(d) > 100) {
const v = await page.locator("#view-routing").boundingBox();
const v = await page.locator("#view-groups").boundingBox();
await page.mouse.move(v.x + 10, 300);
await page.mouse.wheel(0, d);
await page.waitForTimeout(400);
@@ -110,14 +110,14 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
test(`${engine} ${lang} ${width}: a group with no rule offers an example rule`, 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, height: 1400 } })).newPage();
const page = await (await browser.newContext({ viewport: { width, height: 1400 }, reducedMotion: "reduce" })).newPage();
page.setDefaultTimeout(5000);
page.setDefaultNavigationTimeout(60000);
const errors = [], posts = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang, posts));
shape = {};
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
let ed = await openEditor(page, w);
const tryIt = ed.locator("button.rt-try");
@@ -109,7 +109,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
test(`${engine} ${lang} ${width}: a rule names several models`, 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, height: 1400 } })).newPage();
const page = await (await browser.newContext({ viewport: { width, height: 1400 }, reducedMotion: "reduce" })).newPage();
page.setDefaultTimeout(5000);
page.setDefaultNavigationTimeout(60000);
const errors = [], posts = [];
@@ -117,10 +117,12 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await page.route("**/*", serve(lang, posts));
await page.goto("http://magpie.test/?view=routing");
const group = page.locator(".rt-group").first();
await group.waitFor();
await group.waitFor({ state: "attached" });
// the trace: the rule's next went first
await page.waitForFunction((s) => document.documentElement.innerText.includes(s), w.why);
await page.evaluate(() => window.show("groups"));
await group.waitFor();
await press(page, group.locator("button", { hasText: w.edit }));
const ed = page.locator(".rt-gedit");
@@ -122,13 +122,13 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
test(`${engine} ${lang} ${width}: a rule's ⋯ is there to remove it, and a rule with no condition says how`, 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, height: 1400 } })).newPage();
const page = await (await browser.newContext({ viewport: { width, height: 1400 }, reducedMotion: "reduce" })).newPage();
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=routing");
await page.goto("http://magpie.test/?view=groups");
// the ⋯ is drawn with the pointer off the rule, and Remove rule
// under it takes the rule out
@@ -118,13 +118,13 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
test(`${engine} ${lang} ${width}: a rule reads as one line, its conditions added from a menu`, 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, height: 1400 } })).newPage();
const page = await (await browser.newContext({ viewport: { width, height: 1400 }, reducedMotion: "reduce" })).newPage();
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=routing");
await page.goto("http://magpie.test/?view=groups");
// saved untouched: the rules as loaded, field for field
let ed = await openEditor(page, w);
@@ -59,7 +59,7 @@ function serve(lang) {
// What the reader sees: whether any group row is in the view's own box, and how
// much of the view's foot is the room kept for a click.
const seen = (page) => page.evaluate(() => {
const v = document.querySelector("#view-routing");
const v = document.querySelector("#view-groups");
const vr = v.getBoundingClientRect();
const rows = [...v.querySelectorAll(".rt-group")];
const inSight = rows.filter((r) => { const b = r.getBoundingClientRect(); return b.bottom > vr.top && b.top < vr.bottom; }).length;
@@ -92,14 +92,14 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
await page.locator(".rt-group[data-id=big]").waitFor();
// the editor, from the row
await page.locator(".rt-group[data-id=big]").click();
const save = page.locator(".rt-gedit button", { hasText: new RegExp(`^${w.save}$`) });
await save.waitFor();
const view = page.locator("#view-routing");
const view = page.locator("#view-groups");
const box = await view.boundingBox();
// the reader scrolls down to the editor's foot: the editor is taller
// than the window (its Save stays in sight on the way, held at the
@@ -56,7 +56,7 @@ function serve(lang) {
// What the reader sees: whether the row saved is in the view's own box, how many
// rows are at all, and how much of the view's foot is the room kept for a click.
const seen = (page) => page.evaluate(() => {
const v = document.querySelector("#view-routing");
const v = document.querySelector("#view-groups");
const vr = v.getBoundingClientRect();
const rows = [...v.querySelectorAll(".rt-group")];
const inBox = (r) => { const b = r.getBoundingClientRect(); return b.bottom > vr.top && b.top < vr.bottom; };
@@ -89,13 +89,13 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang));
await page.goto("http://magpie.test/?view=routing");
await page.goto("http://magpie.test/?view=groups");
await page.locator(".rt-group[data-id=big]").waitFor();
// narrow, the row is below the window's foot; magpie moves the page
// only for the reader, so it is wheeled to as a reader would
const row = page.locator(".rt-group[data-id=big]");
const vb = await page.locator("#view-routing").boundingBox();
const vb = await page.locator("#view-groups").boundingBox();
await page.mouse.move(vb.x + vb.width / 2, vb.y + vb.height / 2);
for (let i = 0; i < 100; i++) {
const b = await row.boundingBox();
@@ -108,7 +108,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const saveText = await page.evaluate(() => t("Save"));
const save = page.locator(".rt-gedit button", { hasText: new RegExp(`^${saveText}$`) });
await save.waitFor();
const view = page.locator("#view-routing");
const view = page.locator("#view-groups");
const box = await view.boundingBox();
// the reader scrolls down to the editor's foot: the editor is taller
// than the window (its Save stays in sight on the way, held at the
@@ -81,7 +81,7 @@ async function open(t, engine, lang, width, how) {
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang, routeOf(how)));
await page.goto("http://magpie.test/?view=routing");
await page.locator(".rt-group").first().waitFor();
await page.locator("#view-routing .rt-stage").waitFor();
return { page, errors };
}

Some files were not shown because too many files have changed in this diff Show More