routing: a group's tags, a provider's segments and the live stage stay inside the window
young02036 on Discord: a long line in a group's row ("WorkBuddy AI · Hy3 ·
免费") made the Routing page wider than the window, with a scrollbar under
it. v0.1.2769 held the member lines; the rest of each row could still go
past it:
- a group's tags never shrank or wrapped (flex: none, nowrap). With many
tags (German's long words, or any language at 700px) they pushed Edit
and the switch out past the row's edge, where the list cut them off.
The tags now take up to half the row and go onto more lines, each one
ellipsized; on a phone page they keep their own line as before.
- a provider's Routing and Stays segments (several accounts or keys) sat in
an auto-wide grid column and ran out past the row in the desktop window,
63px in Chinese and 265px in German at 560px. The column is now as wide
as the row has room for, and the segments wrap there, as they already
did on the browser page.
- in WebKit the live stage's "No request yet" row, out of sight
(content-visibility), kept the width it was last drawn at in a wider
window. In a grid column as wide as its rows, that held the stage, and
the page, 1193px wide in an 880px view after a group's editor opened.
The stage's list now has one column as wide as itself.
routing-rows-fit.test.cjs: three groups (smart, manual, and an order group
with every tag a row can carry) of the reporter's WorkBuddy AI members and
long model names, and a pooled provider. The list, then each group's
editor in turn on one page, at each width down to 560px (desktop) or 360px
(browser page) and back to 1440: the view and the document no wider than
the window, and every row's tags, buttons, switch and segments inside the
row. Chromium and WebKit, en/zh/zh-TW/ja/de.
Run on mote (mote-run) at the pushed head:
- routing-rows-fit and routing-accounts-narrow, Chromium and WebKit,
en/zh/zh-TW/ja/de: 20 of 20 ok. At origin/main's routing.css (rows-fit
copied in): red in both engines, en and de ("desktop list 700px: each
row's tags, Edit, switch and segments inside it").
- With the next two commits and the one before, at 77eed2ea4 rebased on
84da86ebd: 31 GUI files, both engines, every language they run
(drag-rows-shift, account-arrange, agent-grip, gateway-key-arrange,
group-member-drag, group-arrange, panel-arrange, provider-order,
usage-arrange, routing-rule-drag, routing-account-order, routing-rows-fit,
routing-accounts-narrow, routing-columns, routing-own-columns,
routing-keys-fold, routing-key-windows, routing-many-keys,
routing-groups-wide, routing-group-fold, routing-days-fit,
routing-hidden-stage, routing-pool-tooltip, routing-weight-chip,
routing-account-windows, group-editor-fits, group-first-token,
phone-rows, view-no-sideways, click-scroll, i18n-keys): 395 of 399 ok.
The 4 reds are routing-rule-drag in Chromium (en/zh/zh-TW/ja), at its
hover check (line 92) before any drag; it fails the same way alone at
origin/main 625938a2f (#3789). go test -run Budget ./internal/gui ok.
- Rebased again on 03d7927a8 (routing's client.js and i18n.js changed
under it), at this tree: drag-rows-shift, routing-rows-fit,
routing-accounts-narrow, i18n-keys, routing-sign-in-again and
group-member-drag 60 of 60 ok; the budget tests ok.
- Rebased on 1d8658abc (the group model picker in client.js): at this
tree drag-rows-shift, routing-rows-fit, routing-accounts-narrow,
group-pick-drawers and group-member-drag 38 of 38 ok.
- group-first-token went red once in WebKit en 420 under a run of 189
files at concurrency 4 (Cancel's bar over the 1 min option); alone it is
10 of 10 at 317e8a5aa (this change before the last rebase) and at
625938a2f.
Broken by hand, one at a time, each red in the new test:
- the tags' old rule: Chromium and WebKit en/de red at 700 and 1100px
(desktop list, the tags and Edit past the row), as at origin/main.
- the pool's old auto column: Chromium zh and de red ("segs ... 63px
past", "265px past").
- the stage list without its column: WebKit en and zh red ("desktop g2's
editor 1100px: ... 1193,880 LI.idle 798px").
Not tried: the reporter's own window and fonts; the Windows app.
This commit is contained in:
@@ -59,7 +59,11 @@
|
||||
.rt-hub i { font-style: normal; font-size: 10.5px; font-weight: 560; margin-top: 5px; padding: 1px 8px; border-radius: 999px; background: var(--fg); color: var(--card); }
|
||||
.rt-hub.tick, .rt-src.tick { animation: rttick .4s ease-out; }
|
||||
@keyframes rttick { 40% { transform: scale(1.04); } }
|
||||
.rt-accts { position: relative; z-index: 1; list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; min-width: 0; }
|
||||
/* one column as wide as the list: a row out of sight is as wide as WebKit
|
||||
last drew it (content-visibility), and in a column as wide as its rows
|
||||
"No request yet" held the page as wide as a wider window had it, a
|
||||
scrollbar under it (young02036 on Discord) */
|
||||
.rt-accts { position: relative; z-index: 1; list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 7px; min-width: 0; }
|
||||
.rt-accts li { position: relative; display: grid; grid-template-columns: 10px minmax(0, 1fr) fit-content(60%); align-items: center; column-gap: 10px; row-gap: 6px; padding: 9px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; font-size: 13px; transition: opacity .3s, border-color .3s, transform .5s cubic-bezier(.2, .8, .2, 1); }
|
||||
.rt-accts li { margin-left: calc(var(--depth, 0) * 18px); }
|
||||
/* a key off screen is not laid out or painted (#3164): with hundreds of
|
||||
@@ -520,8 +524,10 @@ button.rt-session { cursor: pointer; }
|
||||
.rt-patadd { display: flex; gap: 6px; align-items: center; }
|
||||
.rt-pats .fbl:not(:empty) + .rt-patadd { margin-top: 4px; }
|
||||
.rt-patadd input { flex: 1; min-width: 0; }
|
||||
.rt-group .tags { display: flex; gap: 4px; flex: none; }
|
||||
.rt-group .tag { font-size: 11px; line-height: 18px; padding: 0 8px; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--line); color: var(--muted); white-space: nowrap; }
|
||||
/* the tags take up to half the row, onto more lines rather than pushing
|
||||
Edit and the switch out of it (young02036 on Discord) */
|
||||
.rt-group .tags { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; flex: 0 1 auto; min-width: 0; max-width: 50%; }
|
||||
.rt-group .tag { max-width: 100%; overflow: hidden; text-overflow: ellipsis; font-size: 11px; line-height: 18px; padding: 0 8px; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--line); color: var(--muted); white-space: nowrap; }
|
||||
.rt-group .tag.bad { color: var(--red); }
|
||||
.rt-group .tag.idle { opacity: .55; }
|
||||
/* the routing tag is a pop-up button for the group's routings (#3450) */
|
||||
@@ -601,7 +607,8 @@ button.rt-session { cursor: pointer; }
|
||||
.rt-pool .nm span:last-child { font-size: 12px; color: var(--muted); }
|
||||
/* a label column and a control column, so Routing's and Stays' segments
|
||||
start at one edge whatever their labels' widths */
|
||||
.rt-pool .ctl { display: grid; grid-template-columns: auto auto; align-items: center; justify-items: start; gap: 6px 8px; }
|
||||
.rt-pool .ctl { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; justify-items: start; gap: 6px 8px; min-width: 0; max-width: 100%; }
|
||||
.rt-pool .segs { max-width: 100%; flex-wrap: wrap; }
|
||||
.rt-pool .lab { display: contents; }
|
||||
.rt-pool .lab small { font-size: 11px; color: var(--muted); }
|
||||
/* narrow, a row keeps only its routing, which switches from here */
|
||||
@@ -611,7 +618,7 @@ button.rt-session { cursor: pointer; }
|
||||
display: grid; grid-template-columns: auto minmax(0, 1fr) auto; /* the logos as wide as they are */
|
||||
gap: 6px 8px; padding: 12px 12px 12px 14px; /* the grip's room, as wide */
|
||||
}
|
||||
body.web .rt-group .tags { display: flex; flex-wrap: wrap; grid-column: 2 / -1; grid-row: 2; }
|
||||
body.web .rt-group .tags { justify-content: flex-start; max-width: none; grid-column: 2 / -1; grid-row: 2; }
|
||||
body.web .rt-group > .text { grid-column: 3; grid-row: 1; }
|
||||
body.web .rt-group .nm { flex-wrap: wrap; }
|
||||
body.web .rt-group .mem { white-space: normal; overflow-wrap: anywhere; }
|
||||
@@ -628,7 +635,6 @@ button.rt-session { cursor: pointer; }
|
||||
body.web .rt-gadd { min-height: 44px; }
|
||||
body.web .rt-pool .ctl { grid-template-columns: minmax(0, 1fr); }
|
||||
body.web .rt-pool .lab small { padding-top: 6px; }
|
||||
body.web .rt-pool .segs { flex-wrap: wrap; }
|
||||
body.web .rt-stats { flex-wrap: wrap; gap: 10px 16px; }
|
||||
/* the upstream a request went to takes a line of its own on a phone,
|
||||
so the reasoning beside the provider isn't cut to two letters */
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// Every row on the Routing page fits the window (young02036 on Discord: a
|
||||
// group's long line pushed the page wider than the window, with a scrollbar
|
||||
// under it). routing-groups-wide holds the member lines; this holds the rest
|
||||
// of each row as the window is made narrower and wider again, a group's
|
||||
// editor open and shut between:
|
||||
// - a group of many tags (German's long ones, or any at 700px) had pushed its
|
||||
// Edit and switch out past the row's edge, where the list cut them off;
|
||||
// - a provider's Routing and Stays segments (Several accounts or keys) ran
|
||||
// out past their row in the desktop window;
|
||||
// - in WebKit the live stage's "No request yet" kept the width it had in a
|
||||
// wider window once it was out of sight (content-visibility remembered
|
||||
// it), and held the whole page that wide, a scrollbar under it.
|
||||
// Members are "WorkBuddy AI · Hy3 · 免费", as the reporter's were. Chromium and
|
||||
// WebKit, the desktop window down to 560px and the browser page to 360px,
|
||||
// en/zh/zh-TW/ja/de.
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
const { test } = require("node:test");
|
||||
const { chromium, webkit } = require("playwright");
|
||||
|
||||
const assets = path.resolve(__dirname, "../assets");
|
||||
const long = "a-really-long-model-name-that-keeps-on-going-flash-preview-2026";
|
||||
const models = Array.from({ length: 6 }, (_, i) => ({ id: `p${i}/${long}-${i}`, name: `${long}-${i}`, providerName: "Provider With A Long Name " + i, icon: "generic" }));
|
||||
const ids = models.map((m) => m.id);
|
||||
// members no model of the list names: their line is the group's own words
|
||||
const hy = ["workbuddy-ai/hy3", "workbuddy-ai/hy3-turbo"];
|
||||
const info = [...ids.map((id) => ({ id, ready: true })), ...hy.map((id) => ({ id, ready: true, name: "WorkBuddy AI", model: "Hy3", provider: "workbuddy-ai", free: true }))];
|
||||
const base = { members: [...hy, ...ids], ready: true, memberInfo: info, offers: [], shared: [] };
|
||||
const groups = {
|
||||
models,
|
||||
pools: [{ provider: "workbuddy-ai", name: "WorkBuddy AI", icon: "generic", kind: "account", who: ["a", "b", "c"], routing: "order" }],
|
||||
groups: [
|
||||
{ ...base, id: "g1", name: "smart", routing: "smart" },
|
||||
{ ...base, id: "g2", name: "manual", routing: "manual", pick: hy[0] },
|
||||
// every tag a row can carry
|
||||
{ ...base, id: "g3", name: "order", routing: "order", affinity: "session", sink: true, unlists: true, firstToken: 30, rules: [{ use: ids[0], tokens: 100000 }, { use: ids[1], tokens: 5 }], off: [ids[2]] },
|
||||
],
|
||||
};
|
||||
|
||||
function serve(lang, web) {
|
||||
const state = { agents: [{ id: "codex", name: "Codex", path: "/t", 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: 1, totals: { requests: 0, rerouted: 0, errors: 0 }, routes: [] });
|
||||
}
|
||||
if (url.pathname === "/api/gateway/history") return json({ cut: false, days: [], routes: [] });
|
||||
if (url.pathname === "/api/groups") return json(groups);
|
||||
if (url.pathname === "/api/providers") return json({ providers: [], presets: [], excluded: [], gateway: { running: true, window: true } });
|
||||
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).catch(() => ""), contentType });
|
||||
};
|
||||
}
|
||||
|
||||
// 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 out = [];
|
||||
for (const row of document.querySelectorAll(".rt-groups > *, .rt-pools > *")) {
|
||||
const rb = row.getBoundingClientRect();
|
||||
for (const k of row.querySelectorAll(".tags, .tag, button, .segs, .ctl")) {
|
||||
const b = k.getBoundingClientRect();
|
||||
if (b.width && b.right > rb.right + 1) out.push(`${row.className} > ${k.className || k.tagName} "${k.textContent.slice(0, 24)}" ${Math.round(b.right - rb.right)}px past`);
|
||||
}
|
||||
}
|
||||
// what holds the page wide, for the message
|
||||
const wide = [...v.querySelectorAll("*")].filter((e) => e.getBoundingClientRect().right > innerWidth + 1 && ![...e.children].some((c) => c.getBoundingClientRect().right > innerWidth + 1)).slice(0, 4).map((e) => `${e.tagName}.${e.className} ${Math.round(e.getBoundingClientRect().width)}px`);
|
||||
return { view: [v.scrollWidth, v.clientWidth], doc: [de.scrollWidth, de.clientWidth], out, wide };
|
||||
});
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
|
||||
test(`${engine} ${lang}: every Routing row fits the window, an editor open or not`, async (t) => {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
t.after(() => browser.close());
|
||||
for (const web of [false, true]) {
|
||||
const widths = web ? [1100, 700, 440, 360] : [1100, 900, 700, 560];
|
||||
const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
|
||||
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").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}`);
|
||||
const settle = () => page.evaluate(() => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(() => setTimeout(r, 150)))));
|
||||
// the list, then each group's editor in turn, on one page: the
|
||||
// window narrowed and widened again under each
|
||||
for (const open of [null, "g1", "g2", "g3"]) {
|
||||
if (open) {
|
||||
await page.keyboard.press("Escape");
|
||||
await page.locator(`.rt-group[data-id=${open}] .main`).click({ position: { x: 4, y: 4 } });
|
||||
await page.locator(".rt-gedit").waitFor();
|
||||
}
|
||||
for (const width of [...widths, 1440]) {
|
||||
const at = `${web ? "web" : "desktop"} ${open ? open + "'s editor" : "list"} ${width}px`;
|
||||
await page.setViewportSize({ width, height: 900 });
|
||||
await settle();
|
||||
const m = await measure(page);
|
||||
assert(m.view[0] <= m.view[1] + 1, `${at}: the Routing view no wider than the window: ${m.view} ${m.wide.join(", ")}`);
|
||||
assert(m.doc[0] <= m.doc[1] + 1, `${at}: the document no wider than the window: ${m.doc} ${m.wide.join(", ")}`);
|
||||
assert.deepEqual(m.out, [], `${at}: each row's tags, Edit, switch and segments inside it`);
|
||||
}
|
||||
}
|
||||
assert.deepEqual(errors, [], `${web ? "web" : "desktop"}: no page error`);
|
||||
await page.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user