Skip to content

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

fix(settings): report an image model pick the page cannot accept

jacket0603e2b1fafc1e26
diff --git a/apps/desktop/src/components/settings/ModelConfigPage.tsx b/apps/desktop/src/components/settings/ModelConfigPage.tsx
index 351aefe1d..f061d73c3 100644
--- a/apps/desktop/src/components/settings/ModelConfigPage.tsx
+++ b/apps/desktop/src/components/settings/ModelConfigPage.tsx
@@ -267,6 +267,13 @@ export function ModelConfigPage() {
providers,
);
if (!isImageGenerationPickerCandidate(candidates, binding.providerId, binding.modelId)) {
+ // The row offered this binding when it rendered, but the settings read
+ // above no longer lists it: another window, another agent or a
+ // concurrent provider edit changed the candidates in between. Report
+ // the refusal instead of returning silently — a pick that keeps the
+ // previous default with no message reads as a broken menu, and the
+ // runtime would reject the binding on the next request anyway.
+ showToast(t("settings.imageModelSaveFailed"), { variant: "error" });
return;
}
const nextSettings = { ...current, imageGeneration: binding };
diff --git a/docs/spec/03-runtime/21-image-generation.md b/docs/spec/03-runtime/21-image-generation.md
index bddedcd0d..c6f5d6ade 100644
--- a/docs/spec/03-runtime/21-image-generation.md
+++ b/docs/spec/03-runtime/21-image-generation.md
@@ -7,7 +7,10 @@ The desktop exposes `AppSettings.imageGeneration` as the current default image-g
Saving a provider confirms the provider was saved or updated, including when
image capabilities were marked or unmarked. It must not claim that an image
model was selected after deselection. Choosing an image default from the
-summary menu retains the image-selection confirmation.
+summary menu retains the image-selection confirmation. A pick the menu can no
+longer offer — the stored candidate list changed between the menu rendering and
+the click — reports that the image model could not be saved instead of silently
+keeping the previous default.
Model Advanced exposes **Set as image model** alongside the image and document attachment capabilities in the model capability group, not as a separate control row. The checkbox is multi-select: saving a provider persists every checked model in `imageGenerationModels`; Cancel leaves settings unchanged. Saving candidates does not replace the default conversation model. Unchecking every image model on the provider that holds the current default clears that default, even when another provider still has a runnable candidate. The Models page drops the check and does not select the other candidate automatically. Unchecking the current model while another model on the same provider stays marked moves the default to the first runnable marked candidate. The unmarked model is available for chat again after saving and reopening settings. Saving another provider preserves a still-runnable image default. Below the default model row in the same defaults panel, **Image generation model** shows the current default and offers a menu to choose one from all marked candidates. When no candidate is configured, or none of them can be selected, the summary row is hidden. A candidate whose provider still exists but is disabled, credential-less or otherwise unusable displays only **Currently unavailable** while another marked candidate can still be selected; a candidate whose provider row is gone is dropped from the stored list on the next settings read or write instead of staying listed. A signed-in ChatGPT (Codex) account is eligible for its own image model, which its provider row offers next to the models it configures; every other OAuth account is not, and there is no fallback.
All marked provider/model pairs are excluded from the default conversation picker, provider quick-default action, and Composer model menu. Other providers with the same model ID remain independent. Existing conversation bindings and history are preserved; a conversation still pinned to any image candidate must select a chat model before sending. Runtime launch rejects every marked image model before inference.
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 3b93f18d3..6093b0f3c 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -378,10 +378,13 @@
- **Preconditions:** Image configuration UI fixture; English and Chinese.
- **Steps:** Mark image models and save the provider; choose a different image
- default from its summary; then unmark the sole image model and save.
+ default from its summary; pick a candidate the stored list no longer offers;
+ then unmark the sole image model and save.
- **Expected:** Provider edits confirm the provider update, including after
clearing the image selection. Explicit default selection keeps its specific
- image-selection confirmation. Persisted bindings retain their existing behavior.
+ image-selection confirmation. A pick the page can no longer accept reports
+ that the image model could not be saved instead of keeping the previous
+ default silently. Persisted bindings retain their existing behavior.
- **Specs:** 03-runtime/21-image-generation. **Acceptance:** B.
- **Milestone:** Maintenance. **Status:** Automated by
### E2E-IMAGES-remove-configured-model
diff --git a/docs/zh-CN/spec/03-runtime/21-image-generation.md b/docs/zh-CN/spec/03-runtime/21-image-generation.md
index c9d0df148..f5a9f3e7d 100644
--- a/docs/zh-CN/spec/03-runtime/21-image-generation.md
+++ b/docs/zh-CN/spec/03-runtime/21-image-generation.md
@@ -8,7 +8,9 @@
保存服务商时,无论是否勾选或取消生图标记,成功提示都确认“服务已保存”
或“服务已更新”,避免取消标记后仍声称“已设为生图模型”。
-从生图摘要菜单选择默认模型时,仍显示生图选择成功提示。
+从生图摘要菜单选择默认模型时,仍显示生图选择成功提示。当摘要菜单在渲染后已不再
+提供该选择(存储的候选列表在点选前发生变化)时,提示生图模型无法保存,而不是
+静默保留原默认值。
模型高级设置将“设为生图模型”与图片、文档附件能力放在同一能力组中,不再单独占一行;复选框支持多选,保存服务商表单后把所有勾选模型写入 `imageGenerationModels`,取消不会改变设置。保存候选不会替换默认对话模型。若当前默认生图模型所属服务商的生图勾选被全部取消,则清空该默认,即使其他服务商仍有可运行候选;模型页取消勾选,且不会自动改选其他候选。同一服务商仍保留其他生图勾选时,默认改到第一个可运行的已标记候选。取消标记的模型恢复为可选对话模型,重新打开设置后仍保持这一状态。保存其他服务商时保留仍可用的默认生图模型。默认模型下方同一面板中的“生图模型”显示当前默认,并提供菜单从所有已标记候选中选择一个。没有候选,或没有任何可选项时,隐藏摘要行。仍有其他可选候选时,服务商仍存在但已停用、缺少凭据或该模型已移除的候选仅显示“暂不可用”;服务商行已被删除的候选则在下次设置读取或写入时从存储列表中丢弃,不再继续列出。OAuth 账户不适用,也不会自动回退。
所有已标记的服务商/模型组合都会从默认对话模型选择器、服务商快速设为默认操作和 Composer 模型菜单中排除。其他服务商的同名模型独立保留。已有会话绑定和历史不改写;仍绑定任一生图候选的会话必须选择对话模型才能发送,运行时也会在推理前拒绝所有已标记生图模型。
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 e5693f124..6eff2b4e0 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
@@ -52,9 +52,10 @@
- **前提:** 生图配置 UI fixture,中英文界面。
- **步骤:** 勾选生图模型并保存服务商;从摘要菜单切换默认生图模型;
- 再取消唯一生图模型的标记并保存。
+ 选择一项存储候选列表已不再提供的候选;再取消唯一生图模型的标记并保存。
- **预期:** 服务商编辑确认“服务已更新”,清除生图选择后也不会提示已选择
- 生图模型;摘要菜单切换仍显示生图选择成功提示。绑定保存行为不变。
+ 生图模型;摘要菜单切换仍显示生图选择成功提示;页面已无法接受的选择会
+ 提示生图模型无法保存,而不是静默保留原默认值。绑定保存行为不变。
- **规格:** 03-runtime/21-image-generation。**验收:** B。
- **里程碑:** 维护。**状态:** `scripts/e2e-image-generation-ui.mjs` 自动覆盖。
diff --git a/scripts/e2e/image-generation-ui.tsx b/scripts/e2e/image-generation-ui.tsx
index c2eddda10..aa85ca863 100644
--- a/scripts/e2e/image-generation-ui.tsx
+++ b/scripts/e2e/image-generation-ui.tsx
@@ -232,6 +232,29 @@ globalThis.imageGenerationProbe = async () => {
assert(settings.defaultProviderId === "chat" && settings.defaultModelId === "chat-model", "image switch changed chat default");
assert(useAppStore.getState().toasts.at(-1)?.message === i18n.t("settings.imageModelSelected"),
"explicit image default selection lost its specific confirmation");
+ // A pick the page can no longer accept reports the failure instead of
+ // doing nothing: the stored candidate list is read when the pick is
+ // accepted, so narrowing it first is exactly the stale-picker race this
+ // covers.
+ const rejectionCandidates = structuredClone(settings.imageGenerationModels);
+ click(row.querySelector<HTMLButtonElement>('button[aria-haspopup="listbox"]'));
+ await until(
+ () => !!document.querySelector('[role="option"]'),
+ "image candidate picker did not reopen for the refusal case",
+ );
+ const refusedOption = [...document.querySelectorAll<HTMLElement>('[role="option"]')].find(
+ (element) => element.textContent?.includes("image-two"),
+ );
+ assert(refusedOption, "stale candidate missing from the picker");
+ settings = { ...settings, imageGenerationModels: [{ providerId: "q", modelId: "image-one" }] };
+ click(refusedOption);
+ await until(
+ () => useAppStore.getState().toasts.at(-1)?.message === i18n.t("settings.imageModelSaveFailed"),
+ "refused image default selection must report the failure",
+ );
+ assert(settings.imageGeneration?.providerId === "q" && settings.imageGeneration?.modelId === "image-one",
+ "refused image default selection changed the default");
+ settings = { ...settings, imageGenerationModels: rejectionCandidates };
assert(row.textContent?.includes("Images B"), "new provider name missing");
for (const invalid of [
{ ...alternate, enabled: false },
@@ -409,6 +432,7 @@ globalThis.imageGenerationProbe = async () => {
"image-preview-partial-failure",
"setup-navigation",
"absolute-image-markdown",
+ "refused-image-selection-report",
],
apiBoundary: "fixture",
};