gui: a model's key tag is drawn from keyrates.js, back under the core budget

92e760f3d put keysTag in app.js and took the core's scripts to 1,269,382
bytes of code, 421 over coreScriptBudget (1,268,961), so
TestCoreScriptBudget was red on main from it. The full suite at that
head on mica found it; the targeted run before the push did not include
the budget test.

The server sends a model's keys only for a provider with two or more keys
on, which is when keyrates.js is loaded already. keysTag moves there,
unchanged, and renderModels imports the file for a chip that has keys,
appending the tag when it arrives. The core is 1,268,954 now, 7 under,
with no raise.

Run (mica, at this tree on 8ce32d700):
- go test -tags nogui -run 'TestCoreScriptBudget|TestAppScriptBudget|
  TestModelSaysItsKeys|TestModelKeysCapped' ./internal/gui: ok
- GUI model-key-tag, model-same-name-tell, i18n-keys, key-price-rate,
  provider-price-rate, old-webkit (both engines, every language, 420px):
  74 of 76; the two reds are old-webkit's headerpresets.js list (#6030)
  and app.css :has() (#5919), both on main before this.
- gofmt -l: clean.

Not tried: the real app with a relay that lists models per key.
This commit is contained in:
yetone
2026-11-14 10:07:21 +08:00
parent 8ce32d7008
commit f1f34d624f
2 changed files with 16 additions and 15 deletions
+2 -15
View File
@@ -5306,19 +5306,6 @@ function tellTag(tell) {
return tell ? el("span", "mtell", tell) : null;
}
// keysTag: which of a provider's keys list a model, when not all of them
// do (cliddO11 on X): the key's name, two named, or how many; none when
// every key lists it
function keysTag(p, m) {
const ids = m.keys || [];
if (!ids.length) return null;
const n = m.keyCount || ids.length;
const names = ids.map((id) => { const k = p.keyList?.find((x) => x.id === id); return k ? k.name || k.masked : id; });
const tag = el("span", "badge mkey", n <= 2 ? names.join(" · ") : t("{n} keys", { n }));
tag.title = t("Listed by {keys} only", { keys: names.join(", ") + (n > names.length ? " …" : "") });
return tag;
}
// contextTag: the small grey 1M by a model that holds a million tokens or
// more (Cursor's names said it, and no longer do); the usual 128K–400K
// aren't marked, as nearly every model has one of those; nor is a name
@@ -11490,8 +11477,8 @@ function renderModels(p) {
c.append(el("span", "", m.name && m.name !== m.id ? m.name : m.id));
const tell = tellTag(tells.get(m.id));
if (tell) c.append(tell);
const kt = keysTag(p, m);
if (kt) c.append(kt);
// which keys list it, when not all do (keysTag, in keyrates.js)
if (m.keys) import("./keyrates.js").then(() => c.append(keysTag(p, m)), () => {});
// one the plan serves at no cost to it (WorkBuddy's x0.00 credits)
// or one its vendor names free (#185), or lists at $0
const free = m.free || m.zero || namedFree(m.id, m.name);
+14
View File
@@ -49,3 +49,17 @@ window.keyPriceRates = function (ed) {
}
return map;
};
// keysTag: which of a provider's keys list a model, when not all of them
// do (cliddO11 on X): the key's name, two named, or how many; none when
// every key lists it. The server sends keys only for a provider with two
// or more on, the same providers this file is loaded for.
window.keysTag = function (p, m) {
const ids = m.keys || [];
if (!ids.length) return null;
const n = m.keyCount || ids.length;
const names = ids.map((id) => { const k = p.keyList?.find((x) => x.id === id); return k ? k.name || k.masked : id; });
const tag = el("span", "badge mkey", n <= 2 ? names.join(" · ") : t("{n} keys", { n }));
tag.title = t("Listed by {keys} only", { keys: names.join(", ") + (n > names.length ? " …" : "") });
return tag;
};