Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(settings): upgrade a hand-typed model row from the answer the host returns

vastsaa887d9128ef8
diff --git a/apps/desktop/src/components/settings/ModelSelectionPanes.tsx b/apps/desktop/src/components/settings/ModelSelectionPanes.tsx
index 46aba2908..ebc770525 100644
--- a/apps/desktop/src/components/settings/ModelSelectionPanes.tsx
+++ b/apps/desktop/src/components/settings/ModelSelectionPanes.tsx
@@ -360,8 +360,14 @@ export function ModelSelectionPanes({
} catch {
return;
}
- // A catalog hit for a different wire id is not metadata for this row.
- if (info && info.modelId.toLowerCase() !== seed.id.toLowerCase()) return;
+ /*
+ The host answered for the id this row was added with, so the record is this
+ row's — including when the same model is published under another spelling
+ of it (a route prefix, a date, a marker the deployment appends). That is the
+ resolution the runtime reads for the row too, so checking the spelling again
+ here would only drop an answer the rest of the app uses. The stored wire id
+ stays exactly what the user typed.
+ */
setModels((current) => applyCustomModelLookup(current, seed, info));
};
diff --git a/apps/desktop/test/model-custom-lookup.test.mjs b/apps/desktop/test/model-custom-lookup.test.mjs
index 251fdd22a..7e0d6de72 100644
--- a/apps/desktop/test/model-custom-lookup.test.mjs
+++ b/apps/desktop/test/model-custom-lookup.test.mjs
@@ -63,6 +63,26 @@ test("the upgraded row keeps the id the user typed", () => {
assert.equal(upgraded.id, "Claude-Opus-4.6");
});
+test("a record published under another spelling of the id upgrades the row", () => {
+ /*
+ A deployment appends a route or a marker of its own, so the host answers with
+ the id the model is published under — `mimo-v2.5` for a row added as
+ `test/mimo-v2.5`. The picker used to drop that answer and leave the row on the
+ generic 128k / 8.2k seed until the provider was saved and re-read.
+ */
+ const seeded = customModelSeedBinding("test/mimo-v2.5", null);
+ const hit = {
+ ...published,
+ modelId: "mimo-v2.5",
+ displayName: "MiMo-V2.5",
+ limit: { context: 1_048_576, output: 131_072 },
+ };
+ const [upgraded] = applyCustomModelLookup([seeded], seeded, hit);
+ assert.equal(upgraded.id, "test/mimo-v2.5", "the wire id stays what the user typed");
+ assert.equal(upgraded.contextWindow, 1_048_576);
+ assert.equal(upgraded.maxTokens, 131_072);
+});
+
test("a miss keeps the generic seed and never drops the row", () => {
const seed = customModelSeedBinding("not-published", null);
const next = applyCustomModelLookup([seed], seed, null);
diff --git a/apps/desktop/test/provider-model-config.test.mjs b/apps/desktop/test/provider-model-config.test.mjs
index 9a0b5513d..9ecfcbd2b 100644
--- a/apps/desktop/test/provider-model-config.test.mjs
+++ b/apps/desktop/test/provider-model-config.test.mjs
@@ -377,7 +377,11 @@ test("settings match complete case-normalized wire ids, not proxy suffixes", ()
assert.doesNotMatch(pageSource, /modelIdsMatch|isImageGenerationModel/);
assert.doesNotMatch(setupSource, /modelIdsMatch/);
assert.doesNotMatch(pickerSource, /modelIdsMatch/);
- assert.match(pickerSource, /info\.modelId\.toLowerCase\(\) !== seed\.id\.toLowerCase\(\)/);
+ // The host decides identity now: a record the service's id reduces to (a route
+ // prefix, a dated stamp, a marker the deployment appends) still upgrades the
+ // row, so the picker must not re-check the spelling it asked about.
+ assert.doesNotMatch(pickerSource, /info\.modelId\.toLowerCase\(\) !== seed\.id\.toLowerCase\(\)/);
+ assert.match(pickerSource, /applyCustomModelLookup\(current, seed, info\)/);
assert.match(pickerSource, /bindingForCustomModelInfo\(row\.id, row\.info\)/);
assert.match(setupSource, /model\.id\.toLowerCase\(\) === imageModelId\.toLowerCase\(\)/);
assert.match(setupSource, /entry\.toLowerCase\(\) !== id\.toLowerCase\(\)/);
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index f19f5ad1f..8e3ff16df 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -639,6 +639,9 @@ identify the platform validation still needed.
- **Preconditions**: App running; the models.dev snapshot ships with the build; a provider editor is open.
- **Steps**: 1) Type a model id the snapshot publishes into the add-model field and add it; confirm the new row's context window, max output tokens and thinking levels match the published record instead of 128,000 / 8,192 with none. 2) Type an id the snapshot does not publish and add it; confirm the row keeps the generic 128,000 / 8,192 seed and no thinking levels. 3) Add an id while the service list is unreachable; confirm the row still appears exactly once and stays editable. 4) Add an id and edit its limits immediately, before the lookup answers; confirm the typed values survive.
- **Expected**: `providers.lookupModel` answers a hand-typed id from the local snapshot only — no provider network request and no host call — and a hit seeds the binding the way a picked model is seeded (published context window, max output tokens, thinking levels, `contextWindowSource: "catalog"`) while the stored id stays exactly what the user typed. A miss, a failed call, or an id the current discovery already described leaves the previous behavior intact: one usable row, the generic seed, and no stalled or duplicated list.
+ A record published under another spelling of that id — a route prefix, a dated
+ stamp, a marker the deployment appends — is a hit too: the row is upgraded in
+ place as soon as the answer arrives, without waiting for a save.
- **Specs linked**: `03-runtime/12-provider-config-schema.md`, `03-runtime/13-model-catalog-and-selection.md`
- **Acceptance**: B (multi-model provider configuration)
- **Milestone**: M2
diff --git a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
index b3a1061ec..b69c224d6 100644
--- a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
@@ -291,6 +291,8 @@ task-candidate E2E 从请求工作树运行,但使用主工作区已经准备
- **前提条件**:应用运行;models.dev 快照随构建发布;已打开某个提供商编辑器。
- **步骤**:1) 在「添加模型」输入框里输入模型库已发布的模型 id 并添加,确认新行的上下文长度、最大输出与思考等级与已发布记录一致,而不是 128,000 / 8,192 且无思考等级。2) 输入模型库未发布的 id 并添加,确认该行沿用通用种子 128,000 / 8,192 且无思考等级。3) 在服务模型列表不可用的状态下添加一个 id,确认该行仍然只出现一次且可编辑。4) 添加一个 id 后立刻修改其限额(此时查询尚未返回),确认手输的值被保留。
- **预期**:`providers.lookupModel` 只从本地快照回答手输 id —— 不访问提供商网络、不调用主机 —— 命中时按「被勾选的模型」同样的口径播种绑定(已发布的上下文长度、最大输出、思考等级,`contextWindowSource: "catalog"`),而存储的 id 保持用户输入的原样。未命中、调用失败,或该 id 已被本次发现结果描述过时,行为与之前一致:一行可用,通用种子,列表既不卡住也不重复。
+ 该 id 以另一种拼写发布(路由前缀、日期戳、部署自己追加的标记)同样算命中:
+ 答复到达即就地升级该行,不必等到保存。
- **链接规格**:`03-runtime/12-provider-config-schema.md`、`03-runtime/13-model-catalog-and-selection.md`
- **接受**:B(多模型提供商配置)
- **里程碑**:M2