gui: a key's concurrency pill shows the provider's limit as typed in the editor
An account or key that takes the provider's limit showed the saved Concurrency on its pill and in its menu's "Provider's" line while the editor's Concurrency box, a few rows up, said another number. Both now read the draft while the editor is open on that provider: a whole number as typed, empty as the plugin's (or no limit), and the saved one while the box holds something out of range. The pills are drawn again on each keystroke in the box. Save and Cancel are unchanged. Run (mote, at this tree): - lane-limit.test.cjs, Chromium and WebKit, en and zh: 20 pass. - go test ./internal/gui -run 'TestCoreScriptBudget|TestI18n|TestCSS': ok. Broken by hand: the new test against the old app.js, 4 of 20 red (the pill kept "2 at once" after 5 was typed), both engines and languages. Not tried: the real app window.
This commit is contained in:
@@ -7896,7 +7896,10 @@ function concurrencyField(p) {
|
||||
b.max = String(max);
|
||||
b.step = "1";
|
||||
b.inputMode = "numeric";
|
||||
b.oninput = () => { draft[k] = b.value; };
|
||||
b.oninput = () => {
|
||||
draft[k] = b.value;
|
||||
if (k === "concurrency") document.querySelectorAll(".alane").forEach(laneText);
|
||||
};
|
||||
}
|
||||
return [
|
||||
...field(t("Concurrency"), box, (plugin ? t("Over it, requests queue and go out in order; empty takes the plugin's {n}, 0 is no limit", { n: plugin }) : t("Over it, requests queue and go out in order; 0 or empty is no limit"))),
|
||||
@@ -14642,9 +14645,14 @@ function laneOwnOf(p, ref) {
|
||||
const k = String(ref).toLowerCase();
|
||||
return Object.prototype.hasOwnProperty.call(m, k) ? m[k] : null;
|
||||
}
|
||||
// laneBase: the provider's limit, as typed in its open editor before Save
|
||||
function laneBase(p) {
|
||||
const d = draft && editing === p?.id ? concurrencyOfDraft() : undefined;
|
||||
return d != null ? d : d === null ? p?.pluginConcurrency || 0 : p?.maxConcurrency != null ? p.maxConcurrency : p?.pluginConcurrency || 0;
|
||||
}
|
||||
function laneLimitOf(p, ref) {
|
||||
const own = laneOwnOf(p, ref);
|
||||
return own != null ? own : p?.maxConcurrency != null ? p.maxConcurrency : p?.pluginConcurrency || 0;
|
||||
return own != null ? own : laneBase(p);
|
||||
}
|
||||
function laneText(pill) {
|
||||
const p = providers?.providers?.find((x) => x.id === pill.dataset.provider);
|
||||
@@ -14681,7 +14689,7 @@ function laneLimitPill(p, ref, who, name) {
|
||||
pill.onclick = (e) => {
|
||||
e.stopPropagation();
|
||||
if (pill.classList.contains("open")) return closeProtoMenu();
|
||||
const base = p.maxConcurrency != null ? p.maxConcurrency : p.pluginConcurrency || 0;
|
||||
const base = laneBase(p);
|
||||
const opts = [{ v: "default", name: "Provider's", note: base ? t("{n} at once", { n: base }) : t("No limit") }, { v: 0, name: "No limit", note: "Any number at once" }];
|
||||
const nums = own == null || own === 0 || LANE_LIMITS.includes(own) ? LANE_LIMITS : [...LANE_LIMITS, own].sort((a, b) => a - b);
|
||||
for (const n of nums) opts.push({ v: n, name: String(n), note: "", literalName: true });
|
||||
|
||||
@@ -72,12 +72,12 @@ function serve(lang, posts, lanes) {
|
||||
|
||||
const words = {
|
||||
en: {
|
||||
busy: "1/1 running · 2 queued", running: "3 running", one: "1 at once", two: "2 at once", three: "3 at once", four: "4 at once", seven: "7 at once", none: "No limit at once",
|
||||
busy: "1/1 running · 2 queued", running: "3 running", one: "1 at once", two: "2 at once", three: "3 at once", four: "4 at once", five: "5 at once", seven: "7 at once", none: "No limit at once",
|
||||
menu: "Requests at once", def: "Provider's", other: "Other…", save: "Save", queue: "Queue size", wait: "Queue wait",
|
||||
badQueue: "Queue size: a whole number from 0 to 10000",
|
||||
},
|
||||
zh: {
|
||||
busy: "1/1 运行中 · 2 排队", running: "3 运行中", one: "并发 1", two: "并发 2", three: "并发 3", four: "并发 4", seven: "并发 7", none: "并发不限",
|
||||
busy: "1/1 运行中 · 2 排队", running: "3 运行中", one: "并发 1", two: "并发 2", three: "并发 3", four: "并发 4", five: "并发 5", seven: "并发 7", none: "并发不限",
|
||||
menu: "同时请求数", def: "沿用提供商", other: "其他…", save: "保存", queue: "排队上限", wait: "排队等待",
|
||||
badQueue: "排队上限:0 到 10000 的整数",
|
||||
},
|
||||
@@ -238,6 +238,27 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test(`${engine} ${lang}: a key on the provider's limit shows the Concurrency typed before Save`, async (t) => {
|
||||
// the pill read the saved limit while the editor said another
|
||||
const lanes = { now: {}, reads: 0 };
|
||||
const { page, errors, posts } = await open(t, "Relay", lanes);
|
||||
const box = page.locator(".editor input.concurrency");
|
||||
assert.equal(await pill(page, "k2").textContent(), w.two);
|
||||
await box.fill("5");
|
||||
assert.equal(await pill(page, "k2").textContent(), w.five, "the provider's limit as typed");
|
||||
assert.equal(await pill(page, "k1").textContent(), w.one, "its own limit stays");
|
||||
await pill(page, "k2").click();
|
||||
await menu(page).waitFor();
|
||||
assert.match(await item(page, w.def).textContent(), new RegExp(w.five), "the menu's provider's limit as typed");
|
||||
await page.keyboard.press("Escape");
|
||||
await box.fill("");
|
||||
assert.equal(await pill(page, "k2").textContent(), w.none, "empty is no limit");
|
||||
await box.fill("2000");
|
||||
assert.equal(await pill(page, "k2").textContent(), w.two, "typed wrong: the saved one");
|
||||
assert.equal(posts.length, 0, "nothing saved");
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test(`${engine} ${lang}: the queue's length and wait are saved with the editor, and refused out of range`, async (t) => {
|
||||
const lanes = { now: {}, reads: 0 };
|
||||
const { page, errors, posts } = await open(t, "Relay", lanes);
|
||||
|
||||
Reference in New Issue
Block a user