agents: an agent's model list has its providers down the left, one picked showing its models alone (蓝猫 on Discord: picking models in the list meant scrolling down one at a time; they asked for providers on the left, then their models) — with three or more providers (routing groups count as one) and room for it, the list widens to 580px and gains a rail: All providers, then each provider with its icon and how many of its models are shown. One picked shows only its group, open even if long; All brings back the folded list as before; a search still looks in every provider; the counts follow each click. Narrow windows and lists of one or two providers stay as they were. agent-models.test.cjs checks the rail's entries and counts, picking OpenRouter (24 rows, open), a click updating its count, a search past the picked one, All, and that the rail sits left of the list; its click-away now clicks outside the wider box. GUI: agent-models, agent-models-loading, agent-model-groups, agent-models-all-hidden, desktop-model-menu and click-scroll pass on WebKit; go test ./internal/gui passes.

This commit is contained in:
yetone
2026-10-04 16:03:00 +08:00
parent 0e409a04b7
commit a7cd091ac6
3 changed files with 76 additions and 7 deletions
+12
View File
@@ -2663,6 +2663,18 @@ body.window .row.agent .who.with-models { flex-wrap: wrap; row-gap: 0; }
.am-seg button { height: 24px; padding: 0 9px; border: 0; border-radius: 6px; background: none; color: var(--ctl-fg); font: inherit; font-size: 12px; cursor: pointer; transition: background-color .15s, color .15s; }
.am-seg button.on { background: var(--seg-thumb); color: var(--fg); box-shadow: var(--seg-edge); }
.am-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 2px; }
/* the providers down the left (蓝猫 on Discord), the models of the one
picked beside them, each scrolling on its own */
.am-body { flex: 1 1 auto; min-height: 0; display: flex; gap: 6px; }
.am-body .am-list { min-width: 0; }
.am-rail { flex: none; width: 176px; overflow-y: auto; overscroll-behavior: contain; padding: 4px 6px 2px 2px; border-right: 1px solid var(--line-2); }
.am-ri { display: flex; align-items: center; gap: 8px; width: 100%; height: 30px; padding: 0 8px; border: 0; border-radius: 8px; background: none; color: var(--fg-2); font: inherit; font-size: 12.5px; text-align: left; cursor: pointer; transition: background-color .12s; }
.am-ri:hover { background: var(--pill); }
.am-ri.on { background: var(--accent-soft); color: var(--fg); }
.am-ri > .ic, .am-ri > svg { width: 14px; height: 14px; flex: none; color: var(--muted); }
.am-ri .rn { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.am-ri .c { flex: none; font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.am-ri:focus-visible { outline: 1.5px solid var(--accent); outline-offset: -1.5px; }
.am-gh { display: flex; align-items: center; margin: 6px 2px 0; }
.am-fold { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 10px; border: 0; border-radius: 8px; background: none; color: var(--muted); font: inherit; font-size: 12px; text-align: left; cursor: pointer; }
.am-fold > .ic, .am-fold > svg { width: 14px; height: 14px; flex: none; }
+39 -4
View File
@@ -2101,8 +2101,6 @@ async function openAgentModels(a, anchor, ev) {
const reset = el("button", "am-reset", t("Show all"));
hideAll.type = reset.type = "button";
foot.append(el("span", "", t("New models are shown")), el("span", "sp"), hideAll, el("span", "am-dot", "·"), reset);
box.append(head, tools, list, foot);
// groups as the catalog has them, routing groups first; a long one
// starts folded, unless the agent is set to a model in it
const groups = [];
@@ -2113,6 +2111,41 @@ async function openAgentModels(a, anchor, ev) {
}
groups.sort((x, y) => (y.name === ROUTING_GROUPS) - (x.name === ROUTING_GROUPS));
const shut = new Set(groups.filter((g) => groups.length > 1 && g.models.length > 8 && !g.models.some((m) => m.inUse)).map((g) => g.name));
// with a few providers, a rail of them down the left: one picked shows
// its models alone, so a long list is one click away rather than a
// scroll down past the others (蓝猫 on Discord); a search looks in all
const railed = groups.length > 2 && innerWidth >= 600;
let pick = "";
const rail = el("div", "am-rail");
if (railed) {
const body = el("div", "am-body");
body.append(rail, list);
box.classList.add("railed");
box.append(head, tools, body, foot);
} else box.append(head, tools, list, foot);
const drawRail = () => {
if (!railed) return;
const top = rail.scrollTop;
rail.replaceChildren();
const item = (name, label, lead, on, n) => {
const b = el("button", "am-ri" + (pick === name ? " on" : ""));
b.type = "button";
b.setAttribute("aria-pressed", String(pick === name));
b.append(lead, el("span", "rn", label), el("span", "c", `${on}/${n}`));
b.title = label;
b.onclick = () => { pick = name; q.value = ""; list.scrollTop = 0; draw(); };
rail.append(b);
};
const all = el("span", "ic");
all.append(svg("M3 4.5h10M3 8h10M3 11.5h10", 14, 1.5));
item("", t("All providers"), all, models.filter((m) => !m.hidden).length, models.length);
for (const g of groups) {
const route = g.name === ROUTING_GROUPS;
item(g.name, route ? t(g.name) : g.name, route ? svg(FAN, 14, 1.5) : icon(g.icon || "generic"),
g.models.filter((m) => !m.hidden).length, g.models.length);
}
rail.scrollTop = top;
};
// under "Shown", one just turned off stays until the view changes
let onlyShown = false, kept = new Set();
@@ -2147,12 +2180,14 @@ async function openAgentModels(a, anchor, ev) {
const top = list.scrollTop;
list.replaceChildren();
const words = q.value.trim().toLowerCase();
drawRail();
for (const g of groups) {
if (pick && !words && g.name !== pick) continue;
const rows = g.models.filter((m) => (!onlyShown || !m.hidden || kept.has(m.id)) &&
(!words || [m.name, m.id, g.name].some((s) => s.toLowerCase().includes(words))));
if (!rows.length) continue;
const on = g.models.filter((m) => !m.hidden).length;
const folded = !words && shut.has(g.name);
const folded = !words && !pick && shut.has(g.name);
const sec = el("section", "am-g" + (folded ? " shut" : "") + (g.name === ROUTING_GROUPS ? " routes" : ""));
const gh = el("div", "am-gh");
const fold = el("button", "am-fold");
@@ -2246,7 +2281,7 @@ async function openAgentModels(a, anchor, ev) {
document.body.append(box);
// under the line, or over it where there's no room; the list scrolls
const r = anchor.getBoundingClientRect(), pad = 8;
const w = Math.min(380, innerWidth - pad * 2);
const w = Math.min(railed ? 580 : 380, innerWidth - pad * 2);
box.style.width = w + "px";
const x = Math.max(pad, Math.min(r.left - 10, innerWidth - w - pad));
box.style.left = x + "px";
+25 -3
View File
@@ -64,8 +64,8 @@ function fixture(lang) {
}
const W = {
en: { entry: "23 hidden", after: "24 hidden", all: "", title: "Codex's model list", current: "Current", shown: "Shown", hideAll: "Hide all", one: "30 hidden", showAll: "Show all" },
zh: { entry: "已隐藏 23 个", after: "已隐藏 24 个", all: "", title: "Codex 的模型列表", current: "在用", shown: "已显示", hideAll: "全部隐藏", one: "已隐藏 30 个", showAll: "全部显示" },
en: { entry: "23 hidden", after: "24 hidden", all: "", title: "Codex's model list", current: "Current", shown: "Shown", hideAll: "Hide all", one: "30 hidden", showAll: "Show all", allTab: "All providers", routes: "Routing groups" },
zh: { entry: "已隐藏 23 个", after: "已隐藏 24 个", all: "", title: "Codex 的模型列表", current: "在用", shown: "已显示", hideAll: "全部隐藏", one: "已隐藏 30 个", showAll: "全部显示", allTab: "全部供应商", routes: "路由组" },
};
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
@@ -181,12 +181,34 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert(await showAll.isDisabled());
assert(!(await hideAll.isDisabled()));
// the providers down the left: one picked shows its models alone,
// a long one open; a search looks in all of them; All brings back the lot
const rail = pop.locator(".am-rail .am-ri");
assert.deepEqual((await rail.allInnerTexts()).map((s) => s.replace(/\s+/g, " ").trim()),
[`${w.allTab} 31/31`, `${w.routes} 1/1`, "OpenAI 6/6", "OpenRouter 24/24"]);
assert.equal(await rail.first().getAttribute("aria-pressed"), "true");
await rail.nth(3).click();
assert.deepEqual(await pop.locator(".am-fold .gn").allInnerTexts(), ["OpenRouter"]);
assert.equal(await pop.locator(".am-mr").count(), 24, "the picked one is open");
assert.equal(await rail.nth(3).getAttribute("aria-pressed"), "true");
await pop.locator(".am-mr", { hasText: "Router model 7" }).click();
await page.waitForTimeout(150);
assert.equal(await rail.nth(3).locator(".c").innerText(), "23/24", "the rail counts what's shown");
await q.fill("O4-MINI");
assert.deepEqual(await pop.locator(".am-fold .gn").allInnerTexts(), ["OpenAI"], "a search looks past the picked one");
await q.fill("");
await rail.first().click();
assert.equal(await pop.locator(".am-fold .gn").count(), 3);
const lb = await pop.locator(".am-list").boundingBox(), rb = await pop.locator(".am-rail").boundingBox();
assert(rb.x + rb.width <= lb.x + 1 && Math.abs(rb.y - lb.y) < 2, "the rail is left of the list");
// Esc closes it; so does a click elsewhere
await page.keyboard.press("Escape");
await pop.waitFor({ state: "detached" });
await entry.click();
await pop.waitFor();
await page.mouse.click(900, 650);
const ob = await pop.boundingBox();
await page.mouse.click(ob.x + ob.width + 8 < 1000 ? ob.x + ob.width + 8 : ob.x - 8, 690);
await pop.waitFor({ state: "detached" });
assert.deepEqual(errors, []);
});