Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
fix(settings): preserve unavailable image default row
Jackca81bcb0fc38
diff --git a/apps/desktop/src/components/settings/ImageGenerationModelRow.tsx b/apps/desktop/src/components/settings/ImageGenerationModelRow.tsxindex ef1070881..3d39db620 100644--- a/apps/desktop/src/components/settings/ImageGenerationModelRow.tsx+++ b/apps/desktop/src/components/settings/ImageGenerationModelRow.tsx@@ -27,16 +27,21 @@ export function ImageGenerationModelRow({const { t } = useTranslation();const binding = settings.imageGeneration;const candidates = imageGenerationBindings(settings.imageGenerationModels, binding);- if (!binding || candidates.length === 0) return null;+ if (candidates.length === 0) return null;- const activeCandidate = candidates.find((candidate) =>- candidate.providerId === binding.providerId &&- modelIdsMatch(candidate.modelId, binding.modelId),- );- const provider = providers.find((entry) => entry.id === binding.providerId);+ const activeCandidate = binding+ ? candidates.find((candidate) =>+ candidate.providerId === binding.providerId &&+ modelIdsMatch(candidate.modelId, binding.modelId),+ )+ : undefined;+ const provider = binding+ ? providers.find((entry) => entry.id === binding.providerId)+ : undefined;// The same availability rule that decides whether this binding may stay the// app default, so the row can never claim a pairing the runtime rejects.- const valid = imageGenerationBindingAvailable(provider, binding.modelId);+ const valid = binding !== null && binding !== undefined &&+ imageGenerationBindingAvailable(provider, binding.modelId);const options = candidates.map((candidate) => {const candidateProvider = providers.find((entry) => entry.id === candidate.providerId);const available = imageGenerationBindingAvailable(diff --git a/apps/desktop/src/components/settings/ModelConfigPage.tsx b/apps/desktop/src/components/settings/ModelConfigPage.tsxindex b117253af..343079422 100644--- a/apps/desktop/src/components/settings/ModelConfigPage.tsx+++ b/apps/desktop/src/components/settings/ModelConfigPage.tsx@@ -205,6 +205,8 @@ export function ModelConfigPage() {saved.id,imageModelIds,[...providers.filter((provider) => provider.id !== saved.id), saved],+ current.imageGeneration?.providerId === saved.id &&+ !saved.models.some((model) => modelIdsMatch(model.id, current.imageGeneration?.modelId ?? "")),);const nextSettings = {...current,diff --git a/apps/desktop/src/components/settings/image-generation-default.ts b/apps/desktop/src/components/settings/image-generation-default.tsindex 63259aa62..31718a2e5 100644--- a/apps/desktop/src/components/settings/image-generation-default.ts+++ b/apps/desktop/src/components/settings/image-generation-default.ts@@ -106,6 +106,7 @@ export function planImageGenerationDefaults(savedProviderId: string,selectedModelIds: readonly string[],providers: readonly ProviderPublic[],+ removedDefaultModel = false,): ImageGenerationDefaultPlan {const existing = imageGenerationBindings(current.imageGenerationModels,@@ -132,6 +133,8 @@ export function planImageGenerationDefaults() ?? null;return {imageGenerationModels,- imageGeneration: resolvesImageGenerationDefault(active, providers) ? active : fallback,+ imageGeneration: removedDefaultModel+ ? null+ : resolvesImageGenerationDefault(active, providers) ? active : fallback,};}diff --git a/apps/desktop/test/image-generation-default.test.mjs b/apps/desktop/test/image-generation-default.test.mjsindex b33dc9418..8b3b89896 100644--- a/apps/desktop/test/image-generation-default.test.mjs+++ b/apps/desktop/test/image-generation-default.test.mjs@@ -321,6 +321,21 @@ test("unchecking the active model selects a remaining runnable candidate", () =>assert.deepEqual(plan.imageGenerationModels, [binding("y", "other"), binding("x", "next")]);});+test("removing the active provider model clears the image default", () => {+ const plan = planImageGenerationDefaults(+ {+ imageGenerationModels: [binding("x", "old"), binding("y", "other")],+ imageGeneration: binding("x", "old"),+ },+ "x",+ ["next"],+ [provider("x", ["next"]), provider("y", ["other"])],+ true,+ );+ assert.equal(plan.imageGeneration, null);+ assert.deepEqual(plan.imageGenerationModels, [binding("y", "other"), binding("x", "next")]);+});+test("saving the active provider preserves a still-selected default", () => {const plan = planImageGenerationDefaults({ imageGeneration: binding("x", "current") },diff --git a/apps/desktop/test/model-advanced-capabilities.test.mjs b/apps/desktop/test/model-advanced-capabilities.test.mjsindex c41c39378..935ff30c8 100644--- a/apps/desktop/test/model-advanced-capabilities.test.mjs+++ b/apps/desktop/test/model-advanced-capabilities.test.mjs@@ -79,7 +79,7 @@ test("the capability row carries no explanatory copy or extra controls", () => {});-test("image generation selection is an attachment capability and hides when unset", () => {+test("image generation selection is an attachment capability and keeps an unavailable row when unbound", () => {assert.match(pickerSource,/className="provider-chosen-capability-rows">[\s\S]*?settings\.setImageModel/,@@ -91,7 +91,8 @@ test("image generation selection is an attachment capability and hides when unseassert.match(pickerSource, /imageModelIds\?\.some\([\s\S]*?modelIdsMatch/);assert.match(pickerSource, /onImageModelChange\(binding\.id, event\.target\.checked\)/);assert.match(imageModelRowSource, /imageGenerationBindings\(settings\.imageGenerationModels, binding\)/);- assert.match(imageModelRowSource, /if \(!binding \|\| candidates\.length === 0\) return null;/);+ assert.match(imageModelRowSource, /if \(candidates\.length === 0\) return null;/);+ assert.match(imageModelRowSource, /imageModelUnavailable/);});test("the Composer model rows use the provider binding for vision badges", () => {diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex eb416c57d..6ece1622e 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -12,13 +12,15 @@- **Preconditions:** API-boundary fixture with an image-marked model and anotherconfigured model on its provider; repeat with legacy single binding and with- an additional runnable image candidate on another provider.+ another image candidate on another provider.- **Steps:** Remove the marked model in the provider editor without toggling itsimage checkbox. Cancel once, repeat and Save, then reopen settings and editor.- **Expected:** Cancel preserves both configurations. Save removes the model and- its image candidate; the image default clears or switches to the remaining- runnable candidate. An unaffected chat default stays unchanged; a removed chat- default still falls back to the first configured model. Reload preserves results.+ its image candidate and clears the image default, even when another image+ candidate remains on this or another provider. The settings summary therefore+ shows the unavailable state until the user explicitly chooses a new default.+ An unaffected chat default stays unchanged; a removed chat default still falls+ back to the first configured model. Reload preserves results.- **Specs:** 03-runtime/21-image-generation. **Acceptance:** B.- **Milestone:** Maintenance. **Status:** Automated in English and Chinese by`scripts/e2e-image-generation-ui.mjs`.@@ -563,7 +565,7 @@ identify the platform validation still needed.- **Preconditions**: App running; provider A saved and set as the app default model; a second provider B serving different models; one image-capable model configured on A and another on a different service.- **Steps**: 1) Open Settings → Model configuration and add provider B; save without touching the Default model row. 2) Confirm the Default model row still names provider A and its exact model, and that a new session starts on it. 3) Set an image model as the default image model, then add a provider that also serves image models; save. 4) Confirm the Default image model row still names the earlier binding while the picker lists the new provider's image models as candidates. 5) Delete the provider that owned a default, then add a service that serves a model and an image model; save. 6) Confirm both defaults now resolve to that newly added provider.-- **Expected**: Saving a new provider never repoints an app default that still resolves: the model default keeps the pairing the Default model row already renders, and the image default keeps its stored binding while its candidate list grows. Only a default that no longer resolves — its provider deleted, or its model removed from the provider — is filled by the newly added provider, so settings are written only when the app would otherwise have nothing to run. The explicit make-default actions, the edit path, and the fallback to the first remaining binding are unchanged.+- **Expected**: Saving a new provider never repoints an app default that still resolves: the model default keeps the pairing the Default model row already renders, and the image default keeps its stored binding while its candidate list grows. A removed image model is cleared and requires an explicit new selection; a removed chat default still uses the existing chat repair rule. The explicit make-default actions and the edit path remain unchanged.- **Specs linked**: `03-runtime/13-model-catalog-and-selection.md`- **Acceptance**: B (model selection)- **Milestone**: M6diff --git a/scripts/e2e/image-generation-ui.tsx b/scripts/e2e/image-generation-ui.tsxindex 98d4e8650..2bb125eec 100644--- a/scripts/e2e/image-generation-ui.tsx+++ b/scripts/e2e/image-generation-ui.tsx@@ -388,7 +388,7 @@ globalThis.imageGenerationProbe = async () => {ok: true,locales: ["en", "zh-CN"],scenarios: [- "remove-marked-model-cancel-save-reopen-and-fallback",+ "remove-marked-model-cancel-save-reopen-and-clear","advanced-save-cancel","unmark-only-image-model-save-reopen-chat-selection","advanced-provider-switch",