Skip to content

A local-first multi-agent app development platform, built on PenguinHarness

fix(web): sync presets keeps what says how this install reaches a model (#844)

Yaowei Zheng750383f9ab21
diff --git a/changelog/unreleased/2026-09-21-sync-presets-keeps-deployment-fields.md b/changelog/unreleased/2026-09-21-sync-presets-keeps-deployment-fields.md
new file mode 100644
index 00000000..a52febac
--- /dev/null
+++ b/changelog/unreleased/2026-09-21-sync-presets-keeps-deployment-fields.md
@@ -0,0 +1,20 @@
+# Sync presets keeps your base URL, key and output cap
+
+- **Date:** 2026-09-21
+- **Type:** fix
+- **Scope:** `web`
+- **PR:** [#844](https://github.com/Prism-Shadow/penguin-harness/pull/844)
+
+[中文版](2026-09-21-sync-presets-keeps-deployment-fields.zh.md)
+
+**Sync presets** used to reset every catalog-owned field on a preset model that was already configured, and the base URL was one of them. A model pointed at a proxy, a self-hosted gateway or a company egress lost that endpoint on the next sync: the built-in catalog carries no base URL for a first-party vendor model, so the field was overwritten with nothing and the model stopped working. A sync now updates what the catalog knows about the model and leaves how this installation reaches it alone.
+
+## Details
+
+- Never overwritten on a model that is already configured: base URL, API key, max output tokens and fast mode. The output cap and fast mode were already safe; the base URL joins them, and the key was never part of the write.
+- Still refreshed from the catalog: context window, pricing, protocol, vision support and the promotion. Re-running the sync remains the way to repair a built-in model saved before the catalog pinned its protocol.
+- An **empty** base URL is filled in from the catalog where the catalog has one. A gateway model, or a preset in the `custom` group such as Atria, reaches nothing without an endpoint, so a blank field on those rows is damage rather than a choice — the same repair a blank display name already gets, with the same consequence that a deliberately cleared one comes back.
+- The Models badge follows the same rule: a base URL of your own is no longer counted as "out of date", so the dot cannot point at a button that would refuse to change it.
+- The button's hint and the confirmation dialog now name both lists.
+
+A base URL an earlier sync already cleared cannot be brought back — the old value is no longer in `.project_config.toml`. Enter it again on the model, and from now on it stays.
diff --git a/changelog/unreleased/2026-09-21-sync-presets-keeps-deployment-fields.zh.md b/changelog/unreleased/2026-09-21-sync-presets-keeps-deployment-fields.zh.md
new file mode 100644
index 00000000..293531f8
--- /dev/null
+++ b/changelog/unreleased/2026-09-21-sync-presets-keeps-deployment-fields.zh.md
@@ -0,0 +1,20 @@
+# 同步预置不再覆盖你的 base URL、API key 与输出上限
+
+- **Date:** 2026-09-21
+- **Type:** fix
+- **Scope:** `web`
+- **PR:** [#844](https://github.com/Prism-Shadow/penguin-harness/pull/844)
+
+[English](2026-09-21-sync-presets-keeps-deployment-fields.md)
+
+**同步预置**此前会把已配置的预置模型上所有「目录字段」一律复位,base URL 也在其中。于是指向代理、自建网关或公司出口的模型,在下一次同步时丢掉了那个端点:内置目录不为一方厂商模型记录 base URL,该字段因此被清空,模型随即不可用。现在同步只更新目录知道的那部分模型事实,本机怎么访问这个模型则原样保留。
+
+## 细节
+
+- 已配置的模型上一律不覆盖:base URL、API key、最大输出 Token 与快速模式。输出上限与快速模式原本就在覆盖范围之外,现在 base URL 与它们同列,而 API key 从来就不在这次写入里。
+- 仍按目录刷新:上下文窗口、定价、协议、视觉支持与促销折扣。内置模型在目录钉住协议之前存下的行,修复方式依旧是重跑一次同步。
+- base URL **为空**且目录带有一个时,会被补齐。网关模型,以及 `custom` 分组里的预置行(如 Atria),没有端点就什么也访问不到,这类行上的空值是损坏而不是选择——与显示名为空时的补齐同一处理,代价也相同:有意清空的值会在下次同步时回来。
+- 「模型库」角标遵循同一条规则:你自己的 base URL 不再算作「有差异」,红点不会再指向一个并不打算改它的按钮。
+- 按钮提示与确认弹窗的文案改为分别点名这两类字段。
+
+早先的同步已经清掉的 base URL 无法找回——旧值已不在 `.project_config.toml` 里。请在模型上重新填写,此后它会保留下来。
diff --git a/packages/web/src/features/models/catalog-sync.ts b/packages/web/src/features/models/catalog-sync.ts
index 0b5972e1..20c7812a 100644
--- a/packages/web/src/features/models/catalog-sync.ts
+++ b/packages/web/src/features/models/catalog-sync.ts
@@ -1,19 +1,32 @@
/**
* One-click sync of the Project model table with the built-in catalog ("sync presets" next
- * to the search box): union semantics — catalog entries not configured locally are added;
- * entries present on both sides are reset to the catalog's fields (context window, pricing,
- * protocol, base URL, vision, and the promotion — the catalog wins wherever the two differ).
- * Missing catalog pricing removes local pricing, and a missing catalog promotion removes the
- * stored one. Locally added models (including user-defined groups) are kept untouched. A retired
- * catalog entry (see `ModelCatalogEntry.retired`) is never added, but one configured locally is
- * reset like any other preset, which is what keeps its stored price on the catalog's.
+ * to the search box): union semantics — catalog entries not configured locally are added,
+ * and an entry present on both sides has its catalog facts brought back in line while the
+ * fields describing this installation's own deployment are left exactly as they are.
+ *
+ * That split is the whole rule, and it runs along one question: does the catalog know the
+ * answer better than the user does?
+ *
+ * - **Catalog facts** — context window, the three price buckets, the protocol pin, the vision
+ * flag, and the promotion — describe the model itself, so the catalog wins wherever the two
+ * differ. Missing catalog pricing removes local pricing, and a missing catalog promotion
+ * removes the stored one. The protocol pin is the reason this direction matters: re-syncing
+ * is how a built-in row saved before the catalog pinned its protocol gets repaired.
+ * - **Deployment fields** — base URL, API key, output cap, fast mode — say how this install
+ * reaches the model, and nothing in the catalog can know them. A sync never overwrites one.
+ * An empty base URL is the single exception, and it is a fill rather than a reset: see
+ * {@link baseUrlFill}.
+ *
+ * Locally added models (including user-defined groups) are kept untouched. A retired catalog
+ * entry (see `ModelCatalogEntry.retired`) is never added, but one configured locally has its
+ * facts updated like any other preset, which is what keeps its stored price on the catalog's.
* Credentials are never touched: merged rows carry no apiKey input (the PUT keeps the stored
* key) and existing rows keep their credential display state.
*
* The price a sync writes is the catalog's list price; the promotion running on it is stored by
* the server outside the config file, which is why it travels as a declaration rather than as a
* field — see {@link catalogPromotion}, which also covers the Penguin Go group it leaves alone.
- * The display name is the one catalog field that is filled but never overwritten — see
+ * The display name is filled but never overwritten, on the same terms as the base URL — see
* {@link displayNameFill}.
*/
import {
@@ -30,10 +43,19 @@ type PresetEntry = ReturnType<typeof catalogModelEntries>[number];
/** One saved model entry, as the models endpoint sends it. */
type ModelDto = ModelsResponse["models"][number];
-/** The catalog-owned fields, in the string-typed form both sides are compared in. */
+/** The catalog facts, in the string-typed form both sides are compared in. */
type CatalogFields = ReturnType<typeof presetFields>;
-/** The catalog-owned fields of a row, in RowState's string-typed form (mirrors toRow). */
+/**
+ * The catalog facts of a preset entry, in RowState's string-typed form (mirrors toRow): the
+ * fields a sync rewrites outright on a row that already exists, because they describe the
+ * model and the catalog tracks it.
+ *
+ * What is missing from here is deliberate. The base URL, the API key, the output cap and fast
+ * mode belong to the installation rather than to the model, so they are never compared and
+ * never written over: a merged row keeps its own through the `{...row, ...fields}` spread, and
+ * the base URL's fill-only repair lives in {@link baseUrlFill}.
+ */
function presetFields(p: PresetEntry) {
const pricing = p.pricing
? {
@@ -49,7 +71,6 @@ function presetFields(p: PresetEntry) {
cacheRead: pricing?.cacheRead ?? "",
cacheWrite: pricing?.cacheWrite ?? "",
output: pricing?.output ?? "",
- baseUrl: p.base_url ?? "",
};
}
@@ -74,6 +95,34 @@ function displayNameFill(p: PresetEntry, current: string | undefined): string |
return catalogEntryFor(p.provider, p.model_id)?.displayName;
}
+/**
+ * The base URL a sync writes onto an entry that currently holds `current`, or undefined to leave
+ * it alone (`undefined` for `current` is a saved entry with no credential block at all, which
+ * the row state spells as the empty string — both mean the same thing here).
+ *
+ * Fill-only, like the display name and for a stronger reason. An entry's base URL is how THIS
+ * install reaches the model — a proxy, a self-hosted gateway, an egress the company routes
+ * everything through — and the catalog, which ships one list for every install, cannot know
+ * better than the person who typed it. Overwriting a stored one takes the model offline and
+ * leaves no trace of what it used to be, so a sync never does.
+ *
+ * An empty field is a different situation: there is nothing to destroy, and on the rows the
+ * catalog carries a URL for the empty state is far more likely damage than intent. A gateway
+ * group and a `custom`-group preset (Atria) reach nothing without one, because neither the
+ * group nor the protocol implies an endpoint — such a row is simply broken until something puts
+ * the URL back, and a sync is the one thing that knows it. Filling it in is therefore the same
+ * repair the name fill performs, at the same cost: a base URL deliberately cleared comes back on
+ * the next sync, and clearing one has no meaning on these rows anyway. A first-party vendor row
+ * is untouched either way — the catalog carries no URL for one (the client brings the official
+ * endpoint), so there is never anything to fill.
+ */
+function baseUrlFill(p: PresetEntry, current: string | undefined): string | undefined {
+ if (current?.trim()) return undefined;
+ // A catalog entry with no URL of its own has nothing to fill with, and an empty one would be
+ // a rewrite that changes nothing while counting as an update the badge could never clear.
+ return p.base_url ? p.base_url : undefined;
+}
+
/** A promotion as the catalog declares it for one row: `undefined` is "none". */
type CatalogPromotion = { discount: number | undefined };
@@ -138,9 +187,12 @@ function presetToRow(p: PresetEntry): RowState {
// the same lookup is fill-only (see displayNameFill).
...(displayName !== undefined ? { displayName } : {}),
...(promotion !== null ? declared(promotion) : {}),
- // The output cap and fast mode are user-owned, not catalog-owned (deliberately outside
- // presetFields, so a sync never clobbers them on existing rows): fresh rows inherit the
- // Agent setting / default to off.
+ // The deployment fields, which presetFields deliberately leaves out so that no sync ever
+ // rewrites them on an existing row (see the module doc). A brand-new row has no deployment
+ // to preserve, so it starts on the catalog's base URL where there is one — that is what
+ // makes a freshly added gateway model reachable — and on the defaults for the rest: the
+ // output cap inherits the Agent setting, fast mode is off, and the key is the user's to add.
+ baseUrl: p.base_url ?? "",
maxTokens: "",
fastMode: false,
originalBaseUrl: "",
@@ -150,13 +202,18 @@ function presetToRow(p: PresetEntry): RowState {
}
/**
- * The saved entry's form of those same fields, straight from the DTO. It mirrors the subset of
- * `models-page.tsx`'s `toRow` the catalog owns — deliberately, so the badge below can read a
- * model table the page has not loaded into row state. `test/catalog-sync.test.ts` pins the two
- * together: whatever `toRow` does to a DTO, this must do to the same DTO, or the badge and the
- * sync button would disagree about whether anything is out of date. The promotion is the one
- * catalog-owned value compared outside these fields, and both sides read it verbatim: `toRow`
- * copies `discount` straight off the DTO.
+ * The saved entry's form of those same catalog facts, straight from the DTO. It mirrors the
+ * subset of `models-page.tsx`'s `toRow` the catalog owns — deliberately, so the badge below can
+ * read a model table the page has not loaded into row state. `test/catalog-sync.test.ts` pins
+ * the two together: whatever `toRow` does to a DTO, this must do to the same DTO, or the badge
+ * and the sync button would disagree about whether anything is out of date.
+ *
+ * Three values are compared outside these fields, and all three read the DTO the same way
+ * `toRow` does: the promotion (`toRow` copies `discount` verbatim), the display name, and the
+ * base URL — the last two because they are filled rather than reset, so their emptiness is the
+ * only thing about them either side looks at. No deployment field appears here at all — a row
+ * the sync would not rewrite must not count as out of date, or the dot would sit over a button
+ * that has nothing to do.
*/
function savedFields(m: ModelDto): CatalogFields {
return {
@@ -166,7 +223,6 @@ function savedFields(m: ModelDto): CatalogFields {
cacheRead: m.pricing ? String(m.pricing.cacheRead) : "",
cacheWrite: m.pricing ? String(m.pricing.cacheWrite) : "",
output: m.pricing ? String(m.pricing.output) : "",
- baseUrl: m.credential?.baseUrl ?? "",
};
}
@@ -185,9 +241,11 @@ export interface CatalogDelta {
*
* The same union `syncRowsWithCatalog` applies, so the two cannot disagree about whether there
* is anything to do: catalog entries the table does not carry are additions (retired ones
- * never are), entries it does carry whose catalog-owned fields differ — a promotion-only
- * difference included, outside the Penguin Go group — or whose display name is blank are
- * updates, and locally added models are invisible to both. `refs` is what a dismissal is stamped
+ * never are), entries it does carry whose catalog facts differ — a promotion-only difference
+ * included, outside the Penguin Go group — or whose display name or base URL the sync would
+ * fill are updates, and locally added models are invisible to both. A row whose base URL is
+ * merely different from the catalog's is NOT an update: the sync leaves that URL alone, so
+ * counting it would be a dot nobody could ever put down. `refs` is what a dismissal is stamped
* against, so a later catalog release touching a different model raises the badge again (see
* `lib/todo-badges.ts`).
*/
@@ -207,10 +265,13 @@ export function catalogDelta(
}
const fields = savedFields(entry);
const target = presetFields(p);
- // The name counts as an update on the same fill-only rule the merge applies, or a Project
- // carrying rows with no name would hold a badge the button answers "already up to date".
+ // The name and the base URL count as updates on the same fill-only rule the merge applies,
+ // and only on it: either one blank is a repair the button performs, either one set is a row
+ // the button leaves alone. Reading them any other way would leave a Project holding a badge
+ // the button answers "already up to date".
if (
displayNameFill(p, entry.displayName) !== undefined ||
+ baseUrlFill(p, entry.credential?.baseUrl) !== undefined ||
promotionDiffers(catalogPromotion(p), entry.discount) ||
(Object.keys(target) as (keyof CatalogFields)[]).some((k) => fields[k] !== target[k])
) {
@@ -222,11 +283,15 @@ export function catalogDelta(
}
/**
- * Merges the current rows with the built-in catalog. Existing rows keep their identity,
- * credential state, and list position (fields are updated in place); catalog-only entries
- * other than retired ones are appended in catalog order. Returns the merged rows plus
- * added/updated counts for the success toast (updated counts only rows the merge actually
- * rewrote).
+ * Merges the current rows with the built-in catalog. Existing rows keep their identity, their
+ * credential state, their deployment fields and their list position (the catalog facts are
+ * updated in place); catalog-only entries other than retired ones are appended in catalog
+ * order. Returns the merged rows plus added/updated counts for the success toast.
+ *
+ * `updated` counts the rows the merge actually rewrote, which is what the toast claims it is.
+ * A row that differs from the catalog only in a field the sync will not touch — a base URL of
+ * the user's own, an output cap, fast mode — is not rewritten and is not counted, so the number
+ * the toast reports is the number of rows that came back different.
*
* Every preset row outside the Penguin Go group leaves the merge declaring its catalog
* promotion, rewritten or not (see catalogPromotion), so such a row is a new object even when
@@ -252,10 +317,15 @@ export function syncRowsWithCatalog(
}
const row = next[i]!;
const fields = presetFields(p);
- const fill = displayNameFill(p, row.displayName);
+ const nameFill = displayNameFill(p, row.displayName);
+ // Only ever fills a blank one. Everything the row says about reaching the model — this URL
+ // when it is set, the stored key, the output cap, fast mode — survives the spread below
+ // untouched, because none of it is in `fields`.
+ const urlFill = baseUrlFill(p, row.baseUrl);
const promotion = catalogPromotion(p);
const changed =
- fill !== undefined ||
+ nameFill !== undefined ||
+ urlFill !== undefined ||
promotionDiffers(promotion, row.discount) ||
(Object.keys(fields) as (keyof typeof fields)[]).some((k) => row[k] !== fields[k]);
if (changed) updated += 1;
@@ -263,7 +333,8 @@ export function syncRowsWithCatalog(
next[i] = {
...row,
...fields,
- ...(fill !== undefined ? { displayName: fill } : {}),
+ ...(nameFill !== undefined ? { displayName: nameFill } : {}),
+ ...(urlFill !== undefined ? { baseUrl: urlFill } : {}),
// Only a rewritten row reaches here without a catalog promotion: a Penguin Go row,
// which keeps the platform's promotion it already has.
...(promotion !== null
diff --git a/packages/web/src/features/models/models-page.tsx b/packages/web/src/features/models/models-page.tsx
index 8c4c4160..e6e0ba25 100644
--- a/packages/web/src/features/models/models-page.tsx
+++ b/packages/web/src/features/models/models-page.tsx
@@ -892,9 +892,10 @@ export function ModelsPage() {
const searching = query.trim() !== "";
/**
- * "Sync presets": merge the built-in catalog into the current table (union; the catalog
- * wins on differing preset entries, local additions and API keys stay untouched — see
- * catalog-sync.ts). No-op with a toast when everything is already up to date.
+ * "Sync presets": merge the built-in catalog into the current table (union; the catalog wins
+ * on the facts it tracks about a model, while base URLs, keys and output caps stay as this
+ * install has them, and local additions are untouched — see catalog-sync.ts). No-op with a
+ * toast when everything is already up to date.
*/
const syncPresets = async () => {
if (!rows) return;
diff --git a/packages/web/src/lib/strings-en.ts b/packages/web/src/lib/strings-en.ts
index 33a4b499..e9278032 100644
--- a/packages/web/src/lib/strings-en.ts
+++ b/packages/web/src/lib/strings-en.ts
@@ -1264,7 +1264,7 @@ export const en: Strings = {
noSearchResults: "No matching models",
syncCatalog: "Sync presets",
syncCatalogHint:
- "Update preset models from the built-in catalog: add missing entries and reset differing ones to the catalog's fields; locally added models and API keys are left untouched",
+ "Update preset models from the built-in catalog: add missing entries, and refresh context window, pricing, protocol and vision on the ones already here. Your base URL, API key and output cap are never overwritten, and locally added models are left untouched",
syncDone: (added: number, updated: number) =>
`Presets synced: ${added} added, ${updated} updated`,
syncUpToDate: "Presets are already up to date",
diff --git a/packages/web/src/lib/strings.ts b/packages/web/src/lib/strings.ts
index 90bb469b..6f92fff4 100644
--- a/packages/web/src/lib/strings.ts
+++ b/packages/web/src/lib/strings.ts
@@ -1294,7 +1294,7 @@ export const zh = {
noSearchResults: "没有匹配的模型",
syncCatalog: "同步预置",
syncCatalogHint:
- "用内置目录更新预置模型:新增缺失条目、以目录字段为准刷新差异;本地新增模型与 API key 保持不变",
+ "用内置目录更新预置模型:新增缺失条目,并按目录刷新已有条目的上下文、定价、协议与视觉标志;base URL、API key 与输出上限一律不覆盖,本地新增模型保持不变",
syncDone: (added: number, updated: number) => `预置模型已同步:新增 ${added}、更新 ${updated}`,
syncUpToDate: "预置模型已是最新",
/**
diff --git a/packages/web/test/catalog-sync.test.ts b/packages/web/test/catalog-sync.test.ts
index 1e396984..b589d7f6 100644
--- a/packages/web/test/catalog-sync.test.ts
+++ b/packages/web/test/catalog-sync.test.ts
@@ -1,10 +1,12 @@
/**
* catalog-sync.ts unit tests: the "sync presets" merge — union of the local model table and
- * the built-in catalog, catalog winning on differing preset entries (their promotion included,
- * outside the Penguin Go group), local additions and credentials untouched, the display name
- * filled but never overwritten, a retired catalog row updated where the table carries it and
- * never added — plus `catalogDelta`, the same question asked of a saved table so the Models nav
- * badge can answer it before the page has loaded any rows.
+ * the built-in catalog, the catalog winning on the facts it tracks about a model (pricing, the
+ * context window, the protocol pin, vision, and the promotion outside the Penguin Go group),
+ * this install's own deployment fields never overwritten (base URL, key, output cap), the
+ * display name and an empty base URL filled, local additions untouched, a retired catalog row
+ * updated where the table carries it and never added — plus `catalogDelta`, the same question
+ * asked of a saved table so the Models nav badge can answer it before the page has loaded any
+ * rows.
*
* The last block is the one that matters most: the badge and the button must never disagree
* about whether there is anything to do, so every case above is replayed through both.
@@ -159,17 +161,16 @@ describe("syncRowsWithCatalog", () => {
expect(rows.find((r) => r.modelId === "qwen3.8-max-preview")!.displayName).toBeUndefined();
});
- it("resets differing preset rows to the catalog's fields, keeping identity and credentials", () => {
+ it("updates the catalog's facts on a differing preset row, keeping identity and credentials", () => {
const local = makeRow({
provider: "deepseek",
modelId: "deepseek-v4-pro",
vision: true, // user flipped it
contextWindow: "500000", // stale
+ clientType: "", // saved before the catalog pinned the protocol
cacheRead: "1",
cacheWrite: "2",
output: "3",
- baseUrl: "http://my-proxy", // user override -> catalog wins (cleared)
- originalBaseUrl: "http://my-proxy",
credential: { hasApiKey: true } as RowState["credential"],
});
const { rows, added, updated } = syncRowsWithCatalog([local], PRESET);
@@ -180,8 +181,6 @@ describe("syncRowsWithCatalog", () => {
expect(row.displayName).toBe(catalogName("deepseek", "deepseek-v4-pro"));
expect(row.vision).toBe(false);
expect(row.cacheRead).toBe("0.003571");
- expect(row.baseUrl).toBe(""); // catalog has no base_url; differs from originalBaseUrl -> cleared on PUT
- expect(row.originalBaseUrl).toBe("http://my-proxy");
// Identity and credential state untouched: no rename, no key input, credential kept.
expect(row.original).toEqual({ provider: "deepseek", modelId: "deepseek-v4-pro" });
expect(row.apiKeyInput).toBe("");
@@ -189,6 +188,95 @@ describe("syncRowsWithCatalog", () => {
expect(row.credential).toEqual({ hasApiKey: true });
});
+ it("re-pins the protocol a stale preset row is missing (the documented repair)", () => {
+ const local = makeRow({
+ provider: "qwen-token-plan",
+ modelId: "glm-5.3",
+ displayName: catalogName("qwen-token-plan", "glm-5.3"),
+ vision: false,
+ contextWindow: "1048576",
+ clientType: "", // stored before the catalog pinned openai-chat
+ cacheRead: "0.285714",
+ cacheWrite: "1.142857",
+ output: "4",
+ baseUrl: PRESET[1]!.base_url!,
+ originalBaseUrl: PRESET[1]!.base_url!,
+ });
+ const { rows, updated } = syncRowsWithCatalog([local], PRESET);
+ expect(updated).toBe(1);
+ expect(rows[0]!.clientType).toBe("openai-chat");
+ });
+
+ it("never overwrites a base URL the row already carries, whatever the catalog says", () => {
+ // A first-party vendor row the user points at their own proxy: the catalog carries no URL
+ // for it, and the reset that used to apply here wiped the endpoint the model was reached
+ // through. Nothing the sync does may touch it.
+ const proxied = inSyncRow({
+ baseUrl: "http://my-proxy",
+ originalBaseUrl: "http://my-proxy",
+ contextWindow: "500000", // stale, so the row IS rewritten — the URL still survives it
+ });
+ const vendor = syncRowsWithCatalog([proxied], PRESET);
+ expect(vendor.updated).toBe(1);
+ expect(vendor.rows[0]!.contextWindow).toBe("1000000");
+ expect(vendor.rows[0]!.baseUrl).toBe("http://my-proxy");
+ // Unchanged against what was loaded, so the PUT says nothing about the base URL at all and
+ // the stored one stands.
+ expect(rowToEntry(vendor.rows[0]!).baseUrl).toBeUndefined();
+
+ // Same for a gateway row, where the catalog does carry a URL of its own.
+ const gateway = makeRow({
+ provider: "qwen-token-plan",
+ modelId: "glm-5.3",
+ baseUrl: "http://my-gateway",
+ originalBaseUrl: "http://my-gateway",
+ });
+ const merged = syncRowsWithCatalog([gateway], PRESET);
+ expect(merged.rows[0]!.baseUrl).toBe("http://my-gateway");
+ expect(rowToEntry(merged.rows[0]!).baseUrl).toBeUndefined();
+ });
+
+ it("counts a base URL of the user's own as nothing to do, in the merge and the badge", () => {
+ // In line with the catalog on every fact, differing only in the endpoint the sync will not
+ // touch. Counting it would leave a dot over a button that can only answer "already up to
+ // date", which is exactly the nagging the reset used to hide.
+ const row = inSyncRow({ baseUrl: "http://my-proxy", originalBaseUrl: "http://my-proxy" });
+ const merged = syncRowsWithCatalog([row], [PRESET[0]!]);
+ expect(merged.updated).toBe(0);
+ const dto = inSyncDto(PRESET[0]!, {
+ credential: { baseUrl: "http://my-proxy" } as ModelDto["credential"],
+ });
+ expect(catalogDelta([dto], [PRESET[0]!])).toEqual({ added: 0, updated: 0, refs: [] });
+ });
+
+ it("fills an empty base URL from the catalog, which is a row that could not reach anything", () => {
+ // A gateway row saved without its endpoint: the group implies none and the protocol implies
+ // none, so the model is unreachable until something puts the URL back. Nothing is destroyed
+ // by writing it, so the sync repairs it the way it repairs a blank display name.
+ const blank = makeRow({
+ provider: "qwen-token-plan",
+ modelId: "glm-5.3",
+ displayName: catalogName("qwen-token-plan", "glm-5.3"),
+ vision: false,
+ contextWindow: "1048576",
+ clientType: "openai-chat",
+ cacheRead: "0.285714",
+ cacheWrite: "1.142857",
+ output: "4",
+ });
+ const merged = syncRowsWithCatalog([blank], PRESET);
+ expect(merged.updated).toBe(1);
+ expect(merged.rows[0]!.baseUrl).toBe(PRESET[1]!.base_url);
+ // Differing from what was loaded, so this one does travel to the server.
+ expect(rowToEntry(merged.rows[0]!).baseUrl).toBe(PRESET[1]!.base_url);
+
+ // A blank base URL on a row the catalog gives no URL for stays blank and counts as nothing:
+ // a first-party vendor model reaches its own official endpoint.
+ const vendor = syncRowsWithCatalog([inSyncRow()], [PRESET[0]!]);
+ expect(vendor.updated).toBe(0);
+ expect(vendor.rows[0]!.baseUrl).toBe("");
+ });
+
it("leaves up-to-date rows unchanged (updated not counted), declaring their catalog promotion", () => {
const upToDate = inSyncRow();
const { rows, updated } = syncRowsWithCatalog([upToDate], PRESET);
@@ -435,6 +523,24 @@ describe("catalogDelta", () => {
expect(catalogDelta([local], PRESET).refs).not.toContain("custom/my-own");
});
+ it("raises a blank base URL and stays silent about one the user set", () => {
+ // The dot has to mean the same thing the button does. A gateway row with no endpoint is a
+ // repair the button performs, so it counts; a row pointed somewhere of the user's own is a
+ // row the button leaves alone, so it must not.
+ const gateway = PRESET[1]!;
+ expect(catalogDelta([inSyncDto(gateway, { credential: undefined })], [gateway])).toEqual({
+ added: 0,
+ updated: 1,
+ refs: ["qwen-token-plan/glm-5.3"],
+ });
+ expect(
+ catalogDelta(
+ [inSyncDto(gateway, { credential: { baseUrl: "http://mine" } as ModelDto["credential"] })],
+ [gateway],
+ ).updated,
+ ).toBe(0);
+ });
+
it("counts a promotion-only difference as an update, outside the Penguin Go group", () => {
expect(catalogDelta([inSyncDto(PROMOTED)], [PROMOTED]).updated).toBe(1);
expect(
@@ -466,6 +572,19 @@ describe("catalogDelta", () => {
}),
],
[makeDto({ provider: "custom", modelId: "my-own", contextWindow: 8192 })],
+ // The base URL: the user's own on a vendor row and on a gateway row (neither is touched),
+ // and blank where the catalog carries one (filled).
+ [
+ inSyncDto(PRESET[0]!, {
+ credential: { baseUrl: "http://my-proxy" } as ModelDto["credential"],
+ }),
+ ],
+ [
+ inSyncDto(PRESET[1]!, {
+ credential: { baseUrl: "http://my-gateway" } as ModelDto["credential"],
+ }),
+ ],
+ [inSyncDto(PRESET[1]!, { credential: undefined })],
// The display name: in sync, blank (an earlier sync's damage), and the user's own.
[inSyncDto(PRESET[0]!)],
[inSyncDto(PRESET[0]!, { displayName: "" })],