Skip to content

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

fix(desktop): keep pure image-generation endpoints out of chat and admit dual-capability models

koeriaf9578f4d35fc
diff --git a/apps/desktop/electron/main/runtime/session-launch.ts b/apps/desktop/electron/main/runtime/session-launch.ts
index 48c8f2676..c6711abb4 100644
--- a/apps/desktop/electron/main/runtime/session-launch.ts
+++ b/apps/desktop/electron/main/runtime/session-launch.ts
@@ -14,8 +14,10 @@ import {
import {
type CommandShellCatalog,
GEN_UI_DIRECTORY_NAME,
+ imageGenerationBindings,
isActiveInProject,
isCommandShellCatalog,
+ isImageOnlyChatModel,
JEV_API_KEY_SECRET_REF,
type McpServerRecord,
type Mode,
@@ -398,8 +400,6 @@ export function createSessionLaunchRuntime({
errorCode: ErrorCodes.MODEL_NOT_CONFIGURED,
});
}
- // An image-generation designation does not block chat sessions: the image
- // binding is host-owned and independent of the conversation route.
// The authenticated collection owns a vendor account's available model IDs
// and wire endpoint. models.dev owns metadata; one account can span multiple
// wire APIs and gateway catalogs.
@@ -435,6 +435,21 @@ export function createSessionLaunchRuntime({
const modelConfig = storedModel
? modelConfigWithBinding(catalogModelConfig, storedModel)
: catalogModelConfig;
+ // Only a pure image-generation endpoint is rejected: a model the user
+ // marked for image generation that also supports conversation keeps its
+ // chat eligibility (#2253). The catalog row (or a catalog miss on a custom
+ // provider) owns the modalities answer; an unknown custom model stays
+ // chat-eligible.
+ if (isImageOnlyChatModel(
+ imageGenerationBindings(settings.imageGenerationModels, settings.imageGeneration),
+ provider.id,
+ modelId,
+ modelConfig,
+ )) {
+ throw Object.assign(new Error("The image model cannot be used for conversation; select a chat model"), {
+ errorCode: ErrorCodes.MODEL_NOT_CONFIGURED,
+ });
+ }
const thinkingCapabilities = capabilitiesFromModelConfig(modelConfig);
const thinkingLevel = clampThinkingLevel(
thinkingCapabilities,
diff --git a/apps/desktop/src/components/Composer.tsx b/apps/desktop/src/components/Composer.tsx
index 81b3b870c..8430a0e5e 100644
--- a/apps/desktop/src/components/Composer.tsx
+++ b/apps/desktop/src/components/Composer.tsx
@@ -13,8 +13,10 @@ import type {
PermissionMode,
} from "@pi-desktop/shared";
import {
+ imageGenerationBindings,
initialThinkingLevelForBinding,
initialThinkingLevelForUnmatchedModel,
+ isImageOnlyChatModel,
normalizeLargePasteThreshold,
} from "@pi-desktop/shared";
import { useAppStore } from "../stores/app-store";
@@ -88,6 +90,10 @@ export function Composer({
);
const settings = useAppStore((s) => s.settings);
const plugins = useAppStore((s) => s.plugins);
+ const imageGenerationCandidates = useMemo(
+ () => imageGenerationBindings(settings?.imageGenerationModels, settings?.imageGeneration),
+ [settings?.imageGenerationModels, settings?.imageGeneration],
+ );
const sessions = useAppStore((s) => s.sessions);
const activeSessionId = useAppStore((s) => s.activeSessionId);
const activeSessionSummary = sessions.find(
@@ -405,6 +411,7 @@ export function Composer({
: !!provider &&
provider.enabled &&
!!modelId &&
+ !isImageOnlyChatModel(imageGenerationCandidates, provider.id, modelId) &&
(provider.hasSecret || provider.authKind === "none");
const enterToSend = settings?.enterToSend ?? true;
const hasDraftContent = Boolean(value.trim() || activeFileReferences.length);
diff --git a/apps/desktop/src/components/settings/ModelConfigPage.tsx b/apps/desktop/src/components/settings/ModelConfigPage.tsx
index 25b090431..0f6c5109f 100644
--- a/apps/desktop/src/components/settings/ModelConfigPage.tsx
+++ b/apps/desktop/src/components/settings/ModelConfigPage.tsx
@@ -10,6 +10,7 @@
import { useEffect, useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
import {
+ isImageOnlyChatModel,
vendorAccountImageCandidates,
type ImageGenerationBinding,
type ModelBinding,
@@ -74,13 +75,17 @@ function imageCandidates(
return result;
}
-function chatModelOptions(providers: readonly ProviderPublic[]) {
+function chatModelOptions(
+ providers: readonly ProviderPublic[],
+ imageModels: readonly ImageGenerationBinding[],
+) {
return providers.flatMap((provider) => {
const ids = provider.models?.length
? provider.models.map((model) => model.id)
: [provider.defaultModelId ?? ""];
- // An image-generation designation does not exclude a model from chat.
- return ids.filter((id) => !!id.trim())
+ // Only a pure image-generation endpoint is excluded from chat; a
+ // dual-capability model stays selectable (#2253).
+ return ids.filter((id) => !!id.trim() && !isImageOnlyChatModel(imageModels, provider.id, id))
.map((modelId) => ({ provider, modelId }));
});
}
@@ -150,7 +155,7 @@ export function ModelConfigPage() {
[settings?.imageGenerationModels, settings?.imageGeneration, providers],
);
const providerReady = (provider: ProviderPublic) =>
- providerServesChatModels(provider);
+ providerServesChatModels(provider, imageGenerationCandidates);
if (!settings) return null;
@@ -169,9 +174,12 @@ export function ModelConfigPage() {
models: ModelBinding[],
imageModelIds?: string[],
) => {
- // An image-generation designation does not exclude a model from chat, so
- // the head binding is a legitimate chat default even when image-marked.
- const firstModelId = models[0]?.id;
+ // An image-generation designation does not exclude a dual-capability
+ // model from chat, so an image-marked head binding is a legitimate chat
+ // default; only a pure image-generation endpoint cannot hold one (#2253).
+ const firstModelId = models.find((model) =>
+ !isImageOnlyChatModel(imageGenerationCandidates, saved.id, model.id),
+ )?.id;
try {
if (pluginCatalogSetup?.providerId === saved.id) {
const defaultsProviders = [...providers.filter((provider) => provider.id !== saved.id), saved];
@@ -179,8 +187,8 @@ export function ModelConfigPage() {
(provider) => provider.id === settings.defaultProviderId,
);
const keepsCurrentDefault = !!currentDefault &&
- providerServesChatModels(currentDefault) &&
- chatModelOptions([currentDefault]).some(
+ providerServesChatModels(currentDefault, imageGenerationCandidates) &&
+ chatModelOptions([currentDefault], imageGenerationCandidates).some(
({ modelId }) => sameWireId(modelId, settings.defaultModelId ?? ""),
);
if (!keepsCurrentDefault && firstModelId) {
@@ -221,7 +229,7 @@ export function ModelConfigPage() {
// provider is still runnable — until they change it themselves.
const currentProvider = providers.find((provider) => provider.id === settings.defaultProviderId);
const keepsCurrentDefault = !!currentProvider && providerReady(currentProvider) &&
- chatModelOptions([currentProvider]).some(
+ chatModelOptions([currentProvider], imageGenerationCandidates).some(
({ modelId }) => sameWireId(modelId, settings.defaultModelId ?? ""),
);
if (!keepsCurrentDefault && firstModelId) {
diff --git a/apps/desktop/src/components/settings/SubagentEditorSheet.tsx b/apps/desktop/src/components/settings/SubagentEditorSheet.tsx
index df7b6cf84..11c6125df 100644
--- a/apps/desktop/src/components/settings/SubagentEditorSheet.tsx
+++ b/apps/desktop/src/components/settings/SubagentEditorSheet.tsx
@@ -9,6 +9,7 @@ import {
SUBAGENT_PRESETS,
SUBAGENT_THINKING_LEVELS,
findSubagentPreset,
+ imageGenerationBindings,
isSubagentAssignableTool,
isSubagentMutatingTool,
resolveScope,
@@ -590,7 +591,13 @@ export function SubagentEditorSheet({
const pristine = !editing && !draft.name.trim() && !draft.description.trim();
const bytes = new TextEncoder().encode(draft.body).length;
const slug = draft.id || subagentSlug(draft.name);
- const modelChoices = useMemo(() => subagentModelChoices(providers), [providers]);
+ const modelChoices = useMemo(
+ () => subagentModelChoices(providers, imageGenerationBindings(
+ useAppStore.getState().settings?.imageGenerationModels,
+ useAppStore.getState().settings?.imageGeneration,
+ )),
+ [providers],
+ );
const modelGroups = useMemo(
() => groupSubagentModelChoices(modelChoices),
[modelChoices],
diff --git a/apps/desktop/src/components/settings/SubagentFallbackModels.tsx b/apps/desktop/src/components/settings/SubagentFallbackModels.tsx
index 4a29e75da..54f5a23ff 100644
--- a/apps/desktop/src/components/settings/SubagentFallbackModels.tsx
+++ b/apps/desktop/src/components/settings/SubagentFallbackModels.tsx
@@ -1,5 +1,6 @@
import { useTranslation } from "react-i18next";
-import type { ProviderPublic } from "@pi-desktop/shared";
+import { imageGenerationBindings, type ProviderPublic } from "@pi-desktop/shared";
+import { useAppStore } from "../../stores/app-store";
import { Button, Field } from "../ui";
import { SubagentModelPicker } from "./SubagentModelPicker";
import {
@@ -21,7 +22,10 @@ export function SubagentFallbackModels({ primary, values, choices, providers, on
const selected = new Set([primary, ...values].map((pin) => subagentModelSelectValue(pin, choices)));
const available = choices.filter((choice) => !selected.has(choice.value));
const rows = values.map((pin) => {
- const choice = subagentModelDisplay(pin, providers);
+ const choice = subagentModelDisplay(pin, providers, imageGenerationBindings(
+ useAppStore.getState().settings?.imageGenerationModels,
+ useAppStore.getState().settings?.imageGeneration,
+ ));
return { choice, text: choice ? `${choice.providerName}/${choice.modelId}` : pin };
});
const move = (index: number, delta: number) => {
diff --git a/apps/desktop/src/components/settings/default-model.ts b/apps/desktop/src/components/settings/default-model.ts
index aea8366ea..7fbe9e337 100644
--- a/apps/desktop/src/components/settings/default-model.ts
+++ b/apps/desktop/src/components/settings/default-model.ts
@@ -7,7 +7,7 @@
* is not configured, so these helpers keep the two notions apart: what a
* provider itself offers, and what is safe to display for it.
*/
-import { modelWireIdsEqual as sameComposerModelId, type ProviderPublic } from "@pi-desktop/shared";
+import { isImageOnlyChatModel, type ImageGenerationBindings, modelWireIdsEqual as sameComposerModelId, type ProviderPublic } from "@pi-desktop/shared";
export type DefaultModelOption = {
provider: ProviderPublic;
@@ -17,16 +17,18 @@ export type DefaultModelOption = {
/** Expand runnable providers into the model choices they actually configure. */
export function defaultModelOptions(
providers: readonly ProviderPublic[],
+ imageGeneration?: ImageGenerationBindings | null,
): DefaultModelOption[] {
return providers.flatMap((provider) => {
const modelIds = (provider.models ?? [])
.map((binding) => binding.id.trim())
.filter(Boolean);
const ids = modelIds.length > 0 ? modelIds : [defaultModelIdOf(provider)?.trim() ?? ""];
- // An image-generation designation does not exclude a model from chat: the
- // image binding is host-owned and independent of the conversation route.
- return [...new Set(ids)].filter((modelId) => !!modelId)
- .map((modelId) => ({ provider, modelId }));
+ return [...new Set(ids)].filter((modelId) => !!modelId &&
+ // Only a pure image-generation endpoint is excluded; a dual-capability
+ // model the user marked for image generation stays selectable (#2253).
+ !isImageOnlyChatModel(imageGeneration, provider.id, modelId),
+ ).map((modelId) => ({ provider, modelId }));
});
}
@@ -96,10 +98,13 @@ export function hasResolvedDefaultModel(
* `defaultModelOptions` is the same expansion the default picker lists, so a
* provider the picker would not offer cannot hold a default either.
*/
-export function providerServesChatModels(provider: ProviderPublic): boolean {
+export function providerServesChatModels(
+ provider: ProviderPublic,
+ imageGeneration?: ImageGenerationBindings | null,
+): boolean {
return provider.enabled &&
(provider.hasSecret || !!provider.hasOauth || provider.authKind === "none") &&
- defaultModelOptions([provider]).length > 0;
+ defaultModelOptions([provider], imageGeneration).length > 0;
}
/**
@@ -116,9 +121,10 @@ export function keepsAppDefaultModel(
providers: readonly ProviderPublic[],
defaultProviderId?: string,
defaultModelId?: string,
+ imageGeneration?: ImageGenerationBindings | null,
): boolean {
const provider = providers.find((candidate) => candidate.id === defaultProviderId);
- if (!provider || !providerServesChatModels(provider)) return false;
+ if (!provider || !providerServesChatModels(provider, imageGeneration)) return false;
return hasResolvedDefaultModel(providers, defaultProviderId, defaultModelId);
}
@@ -134,14 +140,16 @@ export function loginDefaultModel(
providers: readonly ProviderPublic[],
providerId: string,
defaults: { defaultProviderId?: string; defaultModelId?: string },
+ imageGeneration?: ImageGenerationBindings | null,
): { providerId: string; modelId: string } | null {
if (keepsAppDefaultModel(
providers,
defaults.defaultProviderId,
defaults.defaultModelId,
+ imageGeneration,
)) return null;
const account = providers.find((candidate) => candidate.id === providerId);
- if (!account || !providerServesChatModels(account)) return null;
- const modelId = defaultModelOptions([account])[0]?.modelId;
+ if (!account || !providerServesChatModels(account, imageGeneration)) return null;
+ const modelId = defaultModelOptions([account], imageGeneration)[0]?.modelId;
return modelId ? { providerId: account.id, modelId } : null;
}
diff --git a/apps/desktop/src/components/settings/subagent-models.ts b/apps/desktop/src/components/settings/subagent-models.ts
index c27515aa6..fc09716de 100644
--- a/apps/desktop/src/components/settings/subagent-models.ts
+++ b/apps/desktop/src/components/settings/subagent-models.ts
@@ -100,6 +100,7 @@ export function pinMatchesChoice(pin: string, choice: SubagentModelChoice): bool
export function subagentModelDisplay(
pin: string,
providers: readonly ProviderPublic[],
+ imageGeneration?: import("@pi-desktop/shared").ImageGenerationBindings | null,
): { providerId: string; providerName: string; modelId: string; status: "available" | "disabled" | "unavailable" } | null {
const parts = subagentModelPinParts(pin);
if (!parts) return null;
@@ -113,7 +114,7 @@ export function subagentModelDisplay(
// identify another account just because only that account has the binding.
if (matches.length !== 1) return null;
const provider = matches[0];
- const model = defaultModelOptions([provider]).find((option) =>
+ const model = defaultModelOptions([provider], imageGeneration).find((option) =>
sameComposerModelId(parts.modelId, option.modelId));
if (!model) return null;
return {
@@ -155,6 +156,7 @@ function uniqueProviderPart(
/** Configured models the sheet can pin, in provider order, with unambiguous pins. */
export function subagentModelChoices(
providers: readonly ProviderPublic[],
+ imageGeneration?: import("@pi-desktop/shared").ImageGenerationBindings | null,
): SubagentModelChoice[] {
const runnableProviders = providers.filter(isSubagentModelProvider);
const seen = new Set<string>();
diff --git a/apps/desktop/src/components/settings/useVendorAccounts.ts b/apps/desktop/src/components/settings/useVendorAccounts.ts
index e67464c50..35daf793d 100644
--- a/apps/desktop/src/components/settings/useVendorAccounts.ts
+++ b/apps/desktop/src/components/settings/useVendorAccounts.ts
@@ -58,6 +58,7 @@ async function claimLoginDefault(providerId: string): Promise<void> {
providers,
providerId,
current,
+ imageGenerationBindings(current.imageGenerationModels, current.imageGeneration),
);
if (!claim) return;
await api.setSettings({
diff --git a/apps/desktop/src/features/chat/composer/hooks/useComposerModelMenu.ts b/apps/desktop/src/features/chat/composer/hooks/useComposerModelMenu.ts
index aa9fc5295..0917057e6 100644
--- a/apps/desktop/src/features/chat/composer/hooks/useComposerModelMenu.ts
+++ b/apps/desktop/src/features/chat/composer/hooks/useComposerModelMenu.ts
@@ -4,8 +4,10 @@ import type {
SessionThinkingLevel,
} from "@pi-desktop/shared";
import {
+ imageGenerationBindings,
initialThinkingLevelForBinding,
initialThinkingLevelForUnmatchedModel,
+ isImageOnlyChatModel,
} from "@pi-desktop/shared";
import { type KeyboardEvent, useEffect, useMemo, useRef, useState } from "react";
import {
@@ -66,6 +68,12 @@ export function useComposerModelMenu({
}: UseComposerModelMenuOptions) {
const providers = useAppStore((s) => s.providers);
const recentModels = useAppStore((s) => s.recentModels);
+ const imageGeneration = useAppStore((s) => s.settings?.imageGeneration);
+ const imageGenerationModels = useAppStore((s) => s.settings?.imageGenerationModels);
+ const imageGenerationCandidates = useMemo(
+ () => imageGenerationBindings(imageGenerationModels, imageGeneration),
+ [imageGenerationModels, imageGeneration],
+ );
const providerModels = useAppStore((s) => s.providerModels);
const loadProviderModels = useAppStore((s) => s.loadProviderModels);
const showToast = useAppStore((s) => s.showToast);
@@ -136,6 +144,7 @@ export function useComposerModelMenu({
const models = composerModelsForProvider(
candidate,
providerModels[candidate.id],
+ imageGenerationCandidates,
);
return {
provider: candidate,
@@ -145,7 +154,7 @@ export function useComposerModelMenu({
};
})
.filter((group) => group.models.length > 0),
- [providers, providerModels],
+ [providers, providerModels, imageGenerationCandidates],
);
const recentEntries = useMemo(() => {
const entries = modelGroups.flatMap(group => group.models.map(model => ({ provider: group.provider, model })));
@@ -280,8 +289,10 @@ export function useComposerModelMenu({
const selectModel = async (candidate: ProviderPublic, nextModelId: string) => {
thinkingQueueRef.current?.invalidate();
await thinkingQueueRef.current?.idle();
- // An image-generation designation must not block chat selection: the
- // image binding is independent of the conversation route.
+ // A pure image-generation endpoint cannot be selected for chat; a
+ // dual-capability model marked for image generation stays selectable
+ // (#2253).
+ if (isImageOnlyChatModel(imageGenerationCandidates, candidate.id, nextModelId)) return;
try {
const nextModelProvider = thinkingProviderForModel(
candidate,
diff --git a/apps/desktop/src/features/scheduled/ScheduledModelPicker.tsx b/apps/desktop/src/features/scheduled/ScheduledModelPicker.tsx
index b9d5f81d4..4e210031e 100644
--- a/apps/desktop/src/features/scheduled/ScheduledModelPicker.tsx
+++ b/apps/desktop/src/features/scheduled/ScheduledModelPicker.tsx
@@ -23,7 +23,9 @@ export function ScheduledModelPicker({ value, disabled, onChange }: {
const providerModels = useAppStore(s => s.providerModels);
const settings = useAppStore(s => s.settings);
const provider = providers.find(p => p.id === value.providerId);
- const selected = provider && composerModelsForProvider(provider, providerModels[provider.id])
+ const images = useMemo(() => imageGenerationBindings(settings?.imageGenerationModels,
+ settings?.imageGeneration), [settings?.imageGenerationModels, settings?.imageGeneration]);
+ const selected = provider && composerModelsForProvider(provider, providerModels[provider.id], images)
.find(model => sameComposerModelId(model.modelId, value.modelId ?? ""));
const thinkingProvider = thinkingProviderForModel(provider, value.modelId,
provider ? providerModels[provider.id] : undefined);
diff --git a/apps/desktop/src/lib/composer-models.ts b/apps/desktop/src/lib/composer-models.ts
index dc0b063ad..e22b6318f 100644
--- a/apps/desktop/src/lib/composer-models.ts
+++ b/apps/desktop/src/lib/composer-models.ts
@@ -1,6 +1,8 @@
import {
bindingSupportsImages,
effectiveContextWindow,
+ isImageOnlyChatModel,
+ type ImageGenerationBindings,
modelMatchesFilter,
modelWireIdsEqual,
type ModelBinding,
@@ -34,13 +36,19 @@ function configuredModelIds(provider: ConfiguredProvider): string[] {
export function composerModelsForProvider(
provider: ConfiguredProvider,
discovered: readonly ModelInfo[] | undefined,
+ imageGeneration?: ImageGenerationBindings | null,
): ModelInfo[] {
- return configuredModelIds(provider).filter((modelId) =>
- // An image-generation designation does not exclude a model from chat:
- // the image binding is host-owned and independent of the chat route.
- !(discovered ?? []).some((model) =>
- sameComposerModelId(model.modelId, modelId) && model.discoveryState === "unlisted"),
- ).map((modelId) => {
+ return configuredModelIds(provider).filter((modelId) => {
+ const metadata = (discovered ?? []).find((model) =>
+ sameComposerModelId(model.modelId, modelId),
+ );
+ // Only a pure image-generation endpoint is excluded: a model the user
+ // marked for image generation that also supports conversation stays in
+ // the Composer list (#2253).
+ return !isImageOnlyChatModel(imageGeneration, provider.id, modelId, metadata)
+ && !(discovered ?? []).some((model) =>
+ sameComposerModelId(model.modelId, modelId) && model.discoveryState === "unlisted");
+ }).map((modelId) => {
const metadata = (discovered ?? []).find((model) =>
sameComposerModelId(model.modelId, modelId),
);
diff --git a/apps/desktop/test/default-model-display.test.mjs b/apps/desktop/test/default-model-display.test.mjs
index c2f8ea113..d396f0834 100644
--- a/apps/desktop/test/default-model-display.test.mjs
+++ b/apps/desktop/test/default-model-display.test.mjs
@@ -197,13 +197,21 @@ test("a disabled default provider lets the new provider take over", () => {
});
test("a default provider with nothing left to run lets the new provider take over", () => {
- // Only a provider that names no model at all cannot run anything: an
- // image-generation designation does not exclude a model from chat.
+ // Either no chat model at all, or only a pure image-generation endpoint the
+ // chat menus exclude: both leave the default provider unable to run a chat.
const bare = provider({ models: [], defaultModelId: undefined });
const imageOnly = provider({ models: [binding("gpt-image-1")] });
const added = provider({ id: "p2", name: "Provider Two", models: [binding("llama-4")] });
assert.equal(providerServesChatModels(bare), false);
assert.equal(keepsAppDefaultModel([bare], "p1", ""), false);
+ assert.equal(
+ keepsAppDefaultModel([imageOnly], "p1", "gpt-image-1", {
+ providerId: "p1",
+ modelId: "gpt-image-1",
+ }),
+ false,
+ );
+ // A dual-capability model keeps its chat default even when image-marked.
assert.equal(
keepsAppDefaultModel([imageOnly], "p1", "gpt-image-1"),
true,
@@ -302,10 +310,19 @@ test("an account that cannot run a chat model claims nothing", () => {
assert.equal(loginDefaultModel([account()], "missing", {}), null);
});
-test("a login may claim an image-designated model as the chat default", () => {
+test("a login skips a pure image endpoint but may claim a dual-capability image-marked model", () => {
const images = account({ models: [binding("gpt-image-1"), binding("gpt-5")] });
+ const marked = { providerId: "acct", modelId: "gpt-image-1" };
+ // gpt-image-1 names a pure image-generation endpoint, so the chat default
+ // may not use it and the login falls through to the next model.
+ assert.deepEqual(
+ loginDefaultModel([images], "acct", {}, marked),
+ { providerId: "acct", modelId: "gpt-5" },
+ );
+ // A dual-capability image-marked model keeps its chat eligibility (#2253).
+ const dual = account({ models: [binding("gpt6.1-terra"), binding("gpt-5")] });
assert.deepEqual(
- loginDefaultModel([images], "acct", {}),
- { providerId: "acct", modelId: "gpt-image-1" },
+ loginDefaultModel([dual], "acct", {}, { providerId: "acct", modelId: "gpt6.1-terra" }),
+ { providerId: "acct", modelId: "gpt6.1-terra" },
);
});
diff --git a/apps/desktop/test/image-conversation-selection.test.mjs b/apps/desktop/test/image-conversation-selection.test.mjs
index 2dd1cc27a..166208b97 100644
--- a/apps/desktop/test/image-conversation-selection.test.mjs
+++ b/apps/desktop/test/image-conversation-selection.test.mjs
@@ -6,7 +6,16 @@ import { capabilitiesFromModelConfig } from "@pi-desktop/agent-runtime";
import { composerModelsForProvider } from "../src/lib/composer-models.ts";
import { defaultModelOptions } from "../src/components/settings/default-model.ts";
-const image = { providerId: "images", modelId: "gpt-image-2.5" };
+/**
+ * Two classes of image-marked model, which #2253 separates:
+ * - a pure image-generation endpoint (`gpt-image-2.5`) has no conversation
+ * route and must stay out of every chat surface, and
+ * - a dual-capability model (`gpt6.1-terra`) marked for image generation also
+ * supports conversation and keeps its chat eligibility everywhere.
+ */
+const pureImage = { providerId: "images", modelId: "gpt-image-2.5" };
+const dualCapability = { providerId: "images", modelId: "gpt6.1-terra" };
+const bindings = [pureImage, dualCapability];
/**
* Complete launch fixture for `resolveAgentRuntimeLaunch`: the Host/provider
@@ -76,62 +85,121 @@ async function makeLaunchRuntime({ bindingForModel = () => undefined } = {}) {
return { runtime, calls };
}
const providers = [
- { id: "images", models: [{ id: "gpt-image-2.5" }, { id: "chat" }] },
+ { id: "images", models: [{ id: "gpt-image-2.5" }, { id: "gpt6.1-terra" }, { id: "chat" }] },
{ id: "other", models: [{ id: "gpt-image-2.5" }] },
];
-test("an image-generation designation keeps the model usable for chat", () => {
- assert.deepEqual(defaultModelOptions(providers).map(x => [x.provider.id, x.modelId]), [
- ["images", "gpt-image-2.5"], ["images", "chat"], ["other", "gpt-image-2.5"],
+test("a pure image-generation model stays out of chat menus", () => {
+ assert.deepEqual(defaultModelOptions(providers, bindings).map(x => [x.provider.id, x.modelId]), [
+ ["images", "gpt6.1-terra"], ["images", "chat"], ["other", "gpt-image-2.5"],
]);
assert.deepEqual(
- composerModelsForProvider(providers[0], undefined).map(x => x.modelId),
- ["gpt-image-2.5", "chat"],
+ composerModelsForProvider(providers[0], undefined, bindings).map(x => x.modelId),
+ ["gpt6.1-terra", "chat"],
);
- assert.equal(isImageGenerationModel(image, "other", image.modelId), false);
- assert.equal(isImageGenerationModel(image, "images", image.modelId), true);
+ assert.equal(isImageGenerationModel(bindings, "other", pureImage.modelId), false);
+ assert.equal(isImageGenerationModel(bindings, "images", pureImage.modelId), true);
});
-test("clearing candidates never removes provider models", () => {
- assert.equal(defaultModelOptions(providers).length, 3);
- assert.equal(composerModelsForProvider(providers[0], undefined).length, 2);
- assert.equal(providers[0].models.length, 2);
- const legacy = { id: "images", models: [], defaultModelId: image.modelId };
- assert.deepEqual(defaultModelOptions([legacy]).map(x => x.modelId), [image.modelId]);
+test("a dual-capability image-marked model stays selectable for chat", () => {
+ // Both menus keep the image-marked model: the image binding is host-owned
+ // and independent of the conversation route (#2253).
+ assert.deepEqual(defaultModelOptions(providers, [dualCapability]).map(x => [x.provider.id, x.modelId]), [
+ ["images", "gpt-image-2.5"], ["images", "gpt6.1-terra"], ["images", "chat"],
+ ["other", "gpt-image-2.5"],
+ ]);
assert.deepEqual(
- composerModelsForProvider(legacy, undefined).map(x => x.modelId),
- [image.modelId],
+ composerModelsForProvider(providers[0], undefined, [dualCapability]).map(x => x.modelId),
+ ["gpt-image-2.5", "gpt6.1-terra", "chat"],
);
});
-test("launch succeeds with an image-designated model and keeps the image binding", async () => {
+test("discovered image-only output modalities exclude a marked model; unknown custom metadata does not", () => {
+ const discovered = [
+ {
+ modelId: "vision-image", displayName: "vision-image", providerId: "images",
+ modalities: { input: ["text"], output: ["image"] }, capabilities: [], source: "discovered",
+ },
+ ];
+ const visionProvider = { id: "images", models: [{ id: "vision-image" }] };
+ const marked = [{ providerId: "images", modelId: "vision-image" }];
+ // Published output modalities that name no text output put the marked model
+ // out of the Composer list.
+ assert.deepEqual(
+ composerModelsForProvider(visionProvider, discovered, marked).map(x => x.modelId),
+ [],
+ );
+ // Metadata is unknown, not an inference failure: the same id without
+ // discovery metadata is never excluded on a guess.
+ assert.deepEqual(
+ composerModelsForProvider(visionProvider, undefined, marked).map(x => x.modelId),
+ ["vision-image"],
+ );
+ // An unmarked model is never excluded by its own modalities either.
+ assert.deepEqual(
+ composerModelsForProvider(visionProvider, discovered, []).map(x => x.modelId),
+ ["vision-image"],
+ );
+});
+
+test("clearing candidates never removes provider models a chat route can serve", () => {
+ assert.equal(defaultModelOptions(providers, bindings).length, 3);
+ assert.equal(composerModelsForProvider(providers[0], undefined, bindings).length, 2);
+ assert.equal(providers[0].models.length, 3);
+ const legacy = { id: "images", models: [], defaultModelId: dualCapability.modelId };
+ assert.deepEqual(defaultModelOptions([legacy], bindings).map(x => x.modelId), [dualCapability.modelId]);
+ assert.deepEqual(
+ composerModelsForProvider(legacy, undefined, bindings).map(x => x.modelId),
+ [dualCapability.modelId],
+ );
+ // A legacy default naming a pure image-generation endpoint is still not a
+ // chat option.
+ const legacyPure = { id: "images", models: [], defaultModelId: pureImage.modelId };
+ assert.deepEqual(defaultModelOptions([legacyPure], bindings).map(x => x.modelId), []);
+});
+
+test("a pure image-generation endpoint cannot launch a conversation", async () => {
+ register(new URL("./helpers/ts-import-hooks.mjs", import.meta.url));
+ const { runtime } = await makeLaunchRuntime();
+ await assert.rejects(
+ runtime.resolveAgentRuntimeLaunch(
+ "session-pure-image",
+ { providerId: "images", modelId: pureImage.modelId },
+ { defaultProviderId: "images", defaultModelId: "chat", imageGenerationModels: [pureImage] },
+ ),
+ (error) => error.errorCode === "MODEL_NOT_CONFIGURED",
+ );
+});
+
+test("launch succeeds with a dual-capability image-marked model and keeps the image binding", async () => {
register(new URL("./helpers/ts-import-hooks.mjs", import.meta.url));
const bindingCalls = [];
const { runtime, calls } = await makeLaunchRuntime({
bindingForModel: (provider, modelId) => {
bindingCalls.push([provider.id, modelId]);
- if (modelId === image.modelId) {
+ if (modelId === dualCapability.modelId) {
return { thinkingLevels: [], supportsImages: true, supportsDocuments: null };
}
return undefined;
},
});
- // The launch path no longer fails the pairing up front: an image-generation
- // designation is host-owned and independent of the conversation route, so
- // the launch itself must succeed — not merely avoid the old error message.
+ // The launch path must not fail the pairing up front: an image-generation
+ // designation on a conversation-capable model is host-owned and independent
+ // of the conversation route, so the launch itself must succeed — not merely
+ // avoid the old error message.
const launch = await runtime.resolveAgentRuntimeLaunch(
"session-image",
- { providerId: "images", modelId: image.modelId },
- {},
+ { providerId: "images", modelId: dualCapability.modelId },
+ { defaultProviderId: "images", defaultModelId: "chat", imageGenerationModels: [pureImage, dualCapability] },
);
assert.equal(launch.providerId, "images");
- assert.equal(launch.modelId, image.modelId);
+ assert.equal(launch.modelId, dualCapability.modelId);
assert.equal(launch.sidecarParams.provider.id, "images");
- assert.equal(launch.sidecarParams.provider.modelId, image.modelId);
+ assert.equal(launch.sidecarParams.provider.modelId, dualCapability.modelId);
// The stored image binding reaches the send path: the explicit
// supportsImages pin survives the launch instead of being dropped.
assert.equal(launch.sidecarParams.provider.supportsVision, true);
- assert.deepEqual(bindingCalls, [["images", image.modelId]]);
+ assert.deepEqual(bindingCalls, [["images", dualCapability.modelId]]);
assert.deepEqual([...calls].sort(), [
"agents.active", "agents.disabledBuiltins", "commandShells.list",
"mcp.active", "providers.getSecret", "providers.list",
@@ -147,7 +215,7 @@ test("the chat default model is unchanged once an image binding is saved", async
bindingCalls.push([provider.id, modelId]);
// The image binding is stored only for the image model; the chat default
// keeps no binding of its own.
- return modelId === image.modelId
+ return modelId === dualCapability.modelId
? { thinkingLevels: [], supportsImages: true, supportsDocuments: null }
: undefined;
},
@@ -157,7 +225,7 @@ test("the chat default model is unchanged once an image binding is saved", async
const launch = await runtime.resolveAgentRuntimeLaunch(
"session-default",
{},
- { defaultProviderId: "images", defaultModelId: "chat" },
+ { defaultProviderId: "images", defaultModelId: "chat", imageGenerationModels: [pureImage, dualCapability] },
);
assert.equal(launch.providerId, "images");
assert.equal(launch.modelId, "chat");
diff --git a/apps/desktop/test/native-pi-sessions.test.mjs b/apps/desktop/test/native-pi-sessions.test.mjs
index 2b2d6546c..42cc484c3 100644
--- a/apps/desktop/test/native-pi-sessions.test.mjs
+++ b/apps/desktop/test/native-pi-sessions.test.mjs
@@ -47,7 +47,7 @@ test("native compact and session-addressed queue endpoints reject before host or
// Real slices/IPC with synthetic state; no Electron process or native home.
const { register } = await import("node:module");
register(new URL("./helpers/ts-import-hooks.mjs", import.meta.url));
-const { IPC, isImageGenerationModel, imageGenerationBindings } = await import("@pi-desktop/shared");
+const { IPC, isImageOnlyChatModel, imageGenerationBindings } = await import("@pi-desktop/shared");
const { registerAgentIpc } = await import("../electron/main/ipc/agent-ipc.ts");
const { localNativeProjectPaths, searchSessionsAcrossSources } = await import("../electron/main/services/session-search.ts");
const { createEventsSlice } = await import("../src/stores/slices/events-slice.ts");
@@ -161,9 +161,9 @@ test("native prompt only dispatches sidecar and cannot create a host queue entry
test("native model readiness never depends on a Desktop provider but read-only fails closed", () => {
const expression = composer.match(/const modelReady = ([\s\S]*?);/)[1];
- const evaluateReady = new Function("isImageGenerationModel", "imageGenerationCandidates", "settings", "nativeSession", "activeSessionSummary", "provider", "modelId", "remoteSession", "promptAllowed", `return ${expression}`);
+ const evaluateReady = new Function("isImageOnlyChatModel", "imageGenerationCandidates", "settings", "nativeSession", "activeSessionSummary", "provider", "modelId", "remoteSession", "promptAllowed", `return ${expression}`);
const ready = (nativeSession, activeSessionSummary, provider, modelId, settings, remoteSession = false, promptAllowed = false) =>
- evaluateReady(isImageGenerationModel, imageGenerationBindings(settings?.imageGenerationModels, settings?.imageGeneration), settings, nativeSession, activeSessionSummary, provider, modelId, remoteSession, promptAllowed);
+ evaluateReady(isImageOnlyChatModel, imageGenerationBindings(settings?.imageGenerationModels, settings?.imageGeneration), settings, nativeSession, activeSessionSummary, provider, modelId, remoteSession, promptAllowed);
assert.equal(ready(true, { capabilities: { canPrompt: true } }, undefined, undefined), true);
assert.equal(ready(true, { capabilities: { canPrompt: false } }, { enabled: true, hasSecret: true }, "model"), false);
assert.equal(ready(true, {}, undefined, undefined), false);
@@ -172,9 +172,12 @@ test("native model readiness never depends on a Desktop provider but read-only f
assert.equal(ready(false, {}, { enabled: true, hasSecret: true }, "model"), true);
const settings = { imageGeneration: { providerId: "images", modelId: "model" } };
const imageProvider = { id: "images", enabled: true, hasSecret: true };
- // An image-generation designation no longer blocks chat readiness: the
- // image binding is independent of the conversation route.
+ // "model" is a conversation-capable id, so an image designation on it does
+ // not block chat readiness; only a pure image-generation endpoint would.
assert.equal(ready(false, {}, imageProvider, "model", settings), true);
+ // A pure image-generation endpoint id stays unready for chat.
+ assert.equal(ready(false, {}, { ...imageProvider, id: "img" }, "gpt-image-2.5",
+ { imageGeneration: { providerId: "img", modelId: "gpt-image-2.5" } }), false);
assert.equal(ready(false, {}, { ...imageProvider, id: "chat" }, "model", settings), true);
assert.equal(ready(false, {}, imageProvider, "other-model", settings), true);
assert.equal(ready(true, { capabilities: { canPrompt: true } }, imageProvider, "model", settings), true);
diff --git a/apps/desktop/test/provider-model-config.test.mjs b/apps/desktop/test/provider-model-config.test.mjs
index 0c18b23cc..d43def0b4 100644
--- a/apps/desktop/test/provider-model-config.test.mjs
+++ b/apps/desktop/test/provider-model-config.test.mjs
@@ -255,7 +255,7 @@ test("model ids are matched case-insensitively across picking and hand entry", (
test("provider edits retain legacy defaults for non-chat consumers", () => {
assert.match(pageSource, /defaultModelId: firstModelId \?\? ""/);
- assert.match(pageSource, /const firstModelId = models\[0\]\?\.id/);
+ assert.match(pageSource, /const firstModelId = models\.find\(\(model\) =>/);
assert.doesNotMatch(pageSource, /setDefaultModel|displayedChatModelId/);
});
@@ -367,8 +367,8 @@ test("adding a service only claims the app default while none resolves", () => {
// default provider to be runnable (enabled, credentialed, a chat model
// configured), so a keyless default row cannot block the new provider.
// Provider readiness and default selection use the same exact chat choices.
- assert.match(pageSource, /chatModelOptions\(\[currentProvider\]\)/);
- assert.match(pageSource, /providerServesChatModels\(provider\)/);
+ assert.match(pageSource, /chatModelOptions\(\[currentProvider\], imageGenerationCandidates\)/);
+ assert.match(pageSource, /providerServesChatModels\(provider, imageGenerationCandidates\)/);
});
test("a saved image selection never takes the app's image default", () => {
@@ -413,10 +413,10 @@ test("settings match complete case-normalized wire ids, not proxy suffixes", ()
assert.match(setupSource, /entry\.toLowerCase\(\) !== id\.toLowerCase\(\)/);
});
-test("new chat default keeps an image-designated first model", () => {
- // An image-generation designation no longer excludes a model from chat, so
- // the head binding is a legitimate chat default even when image-marked.
- assert.match(pageSource, /const firstModelId = models\[0\]\?\.id/);
+test("new chat default skips only a pure image-generation endpoint", () => {
+ // A dual-capability image-marked model is a legitimate chat default (#2253);
+ // only a model no chat route can serve is skipped.
+ assert.match(pageSource, /const firstModelId = models\.find\(\(model\) =>\s*!isImageOnlyChatModel\(imageGenerationCandidates, saved\.id, model\.id\)/);
assert.match(pageSource, /if \(!keepsCurrentDefault && firstModelId\)/);
});
diff --git a/docs/spec/03-runtime/21-image-generation.md b/docs/spec/03-runtime/21-image-generation.md
index 48d649492..ddddda73f 100644
--- a/docs/spec/03-runtime/21-image-generation.md
+++ b/docs/spec/03-runtime/21-image-generation.md
@@ -13,7 +13,7 @@ the click — reports that the image model could not be saved instead of silentl
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.
+Only a pure image-generation endpoint is excluded from the default conversation picker, provider quick-default action, and Composer model menu; a marked model that also supports conversation keeps its chat eligibility everywhere, because the image binding is host-owned and independent of the conversation route (#2253). A pure image-generation endpoint is recognized by a model id its family reserves for image generation (for example `gpt-image-*`, DALL·E or Imagen ids) or by published output modalities that name no text output; unknown custom metadata stays chat-eligible. Other providers with the same model ID remain independent. Existing conversation bindings and history are preserved; a conversation still pinned to a pure image candidate must select a chat model before sending. Runtime launch rejects a marked pure image-generation model before inference.
The marking checkbox has localized help explaining chat/default-menu exclusion
after saving and distinguishing image generation from image input. A marked model
diff --git a/packages/i18n/src/locales/de/index.ts b/packages/i18n/src/locales/de/index.ts
index def5f888b..0312c76c7 100644
--- a/packages/i18n/src/locales/de/index.ts
+++ b/packages/i18n/src/locales/de/index.ts
@@ -1024,7 +1024,7 @@ export const de = {
"imageModelSaveFailed": "Bildmodell konnte nicht gespeichert werden.",
"clearImageModel": "Löschen",
"setImageModel": "Als Bildmodell festlegen",
- imageModelChatExclusionHint: "Ein als Bilderzeugungsmodell markiertes Modell bleibt für Chat und Subagents nutzbar; die Bildbindung ist unabhängig von der Unterhaltungsroute. Dies ist Bilderzeugung, keine Bildeingabe. Markieren Sie nur Modelle, mit denen Ihr Endpunkt Bilder erzeugen kann.",
+ imageModelChatExclusionHint: "Ein markiertes Modell, das auch Unterhaltungen unterstützt, bleibt für Chat und Subagents nutzbar; ein reiner Bilderzeugungs-Endpunkt verschwindet nach dem Speichern aus Chat- und Standardmodell-Menüs. Dies ist Bilderzeugung, keine Bildeingabe. Markieren Sie nur Modelle, mit denen Ihr Endpunkt Bilder erzeugen kann.",
"imageModelSelected": "Ausgewähltes Bildmodell",
"generatedImage": "Generiertes Bild {{index}}",
"downloadGeneratedImage": "Herunterladen",
diff --git a/packages/i18n/src/locales/en/index.ts b/packages/i18n/src/locales/en/index.ts
index 1fcfab969..a0ef6e292 100644
--- a/packages/i18n/src/locales/en/index.ts
+++ b/packages/i18n/src/locales/en/index.ts
@@ -1034,7 +1034,7 @@ export const en = {
imageModelSaveFailed: "Could not save the image model.",
clearImageModel: "Clear",
setImageModel: "Set as image model",
- imageModelChatExclusionHint: "Marking a model as the image-generation model keeps it usable for chat and subagents; the image binding is independent of the conversation route. This is image generation, not image input; only mark models your endpoint can generate images with.",
+ imageModelChatExclusionHint: "Marked models that also support conversation stay usable for chat and subagents; a pure image-generation endpoint leaves chat and default-model menus after saving. This is image generation, not image input. Only mark models your endpoint can generate images with.",
imageModelSelected: "Selected image model",
generatedImage: "Generated image {{index}}",
downloadGeneratedImage: "Download",
diff --git a/packages/i18n/src/locales/es/index.ts b/packages/i18n/src/locales/es/index.ts
index 90fa2fa55..ebe75a235 100644
--- a/packages/i18n/src/locales/es/index.ts
+++ b/packages/i18n/src/locales/es/index.ts
@@ -1024,7 +1024,7 @@ export const es = {
"imageModelSaveFailed": "No se pudo guardar el modelo.",
"clearImageModel": "Borrar",
"setImageModel": "Usar para generar imágenes",
- imageModelChatExclusionHint: "Un modelo marcado como modelo de generación de imágenes sigue usable para chat y subagents; el enlace de imágenes es independiente de la ruta de conversación. Esto es generación de imágenes, no entrada de imágenes. Marca solo modelos con los que tu endpoint pueda generar imágenes.",
+ imageModelChatExclusionHint: "Un modelo marcado que también admite conversación sigue usable para chat y subagents; un endpoint puramente de generación de imágenes desaparece de los menús de chat y modelo predeterminado al guardar. Esto es generación de imágenes, no entrada de imágenes. Marca solo modelos con los que tu endpoint pueda generar imágenes.",
"imageModelSelected": "Modelo de imágenes seleccionado",
"generatedImage": "Imagen generada {{index}}",
"downloadGeneratedImage": "Descargar",
diff --git a/packages/i18n/src/locales/fr/index.ts b/packages/i18n/src/locales/fr/index.ts
index a2556f58f..21c413687 100644
--- a/packages/i18n/src/locales/fr/index.ts
+++ b/packages/i18n/src/locales/fr/index.ts
@@ -1024,7 +1024,7 @@ export const fr = {
"imageModelSaveFailed": "Impossible d’enregistrer le modèle.",
"clearImageModel": "Effacer",
"setImageModel": "Définir comme modèle d’images",
- imageModelChatExclusionHint: "Un modèle marqué comme modèle de génération d’images reste utilisable pour le chat et les subagents ; la liaison d’images est indépendante de la route de conversation. Il s’agit de génération, pas d’entrée d’images. Marquez uniquement les modèles capables de générer des images sur votre endpoint.",
+ imageModelChatExclusionHint: "Un modèle marqué qui prend aussi en charge la conversation reste utilisable pour le chat et les subagents ; un endpoint purement dédié à la génération d’images quitte les menus de chat et de modèle par défaut après enregistrement. Il s’agit de génération, pas d’entrée d’images. Marquez uniquement les modèles capables de générer des images sur votre endpoint.",
"imageModelSelected": "Modèle d’images sélectionné",
"generatedImage": "Image générée {{index}}",
"downloadGeneratedImage": "Télécharger",
diff --git a/packages/i18n/src/locales/ko/index.ts b/packages/i18n/src/locales/ko/index.ts
index 26c312602..a5b75b253 100644
--- a/packages/i18n/src/locales/ko/index.ts
+++ b/packages/i18n/src/locales/ko/index.ts
@@ -1031,7 +1031,7 @@ export const ko = {
"imageModelSaveFailed": "이미지 모델을 저장할 수 없습니다.",
"clearImageModel": "지우기",
"setImageModel": "이미지 모델로 설정",
- imageModelChatExclusionHint: "생성 모델로 표시된 모델은 채팅과 subagent에서 계속 사용할 수 있습니다. 이미지 바인딩은 대화 경로와 별개입니다. 이미지 입력이 아닌 이미지 생성 설정이며, 엔드포인트에서 이미지를 생성할 수 있는 모델만 표시하세요.",
+ imageModelChatExclusionHint: "대화도 지원하는 표시된 모델은 채팅과 subagent에서 계속 사용할 수 있으며, 순수 이미지 생성 엔드포인트는 저장 후 채팅 및 기본 모델 메뉴에서 제외됩니다. 이미지 입력이 아닌 이미지 생성 설정이며, 엔드포인트에서 이미지를 생성할 수 있는 모델만 표시하세요.",
"imageModelSelected": "선택된 이미지 모델",
"generatedImage": "생성된 이미지 {{index}}",
"downloadGeneratedImage": "다운로드",
diff --git a/packages/i18n/src/locales/pt-BR/index.ts b/packages/i18n/src/locales/pt-BR/index.ts
index 58e0215f5..91ee0afce 100644
--- a/packages/i18n/src/locales/pt-BR/index.ts
+++ b/packages/i18n/src/locales/pt-BR/index.ts
@@ -1021,7 +1021,7 @@ export const ptBR = {
imageModelSaveFailed: "Não foi possível salvar o modelo de imagem.",
clearImageModel: "Limpar",
setImageModel: "Definir como modelo de geração de imagens",
- imageModelChatExclusionHint: "Um modelo marcado como modelo de geração de imagens continua utilizável para chat e subagents; o vínculo de imagens é independente da rota de conversa. Isto é geração de imagens, não entrada de imagens. Marque apenas modelos com os quais seu endpoint possa gerar imagens.",
+ imageModelChatExclusionHint: "Um modelo marcado que também suporta conversa continua utilizável para chat e subagents; um endpoint puramente de geração de imagens sai dos menus de chat e modelo padrão ao salvar. Isto é geração de imagens, não entrada de imagens. Marque apenas modelos com os quais seu endpoint possa gerar imagens.",
imageModelSelected: "Modelo de imagens selecionado",
generatedImage: "Imagem gerada {{index}}",
downloadGeneratedImage: "Baixar",
diff --git a/packages/i18n/src/locales/tr/index.ts b/packages/i18n/src/locales/tr/index.ts
index 013edeeed..66ec0b83a 100644
--- a/packages/i18n/src/locales/tr/index.ts
+++ b/packages/i18n/src/locales/tr/index.ts
@@ -1031,7 +1031,7 @@ export const tr = {
"imageModelSaveFailed": "Görsel modeli kaydedilemedi.",
"clearImageModel": "Temizle",
"setImageModel": "Görsel modeli olarak ayarla",
- imageModelChatExclusionHint: "Görsel üretim modeli olarak işaretlenen bir model sohbet ve subagent için kullanılabilir kalır; görsel bağlaması konuşma rotasından bağımsızdır. Bu, görsel girdisi değil görsel üretimidir. Yalnızca uç noktanızda görsel üretebilen modelleri işaretleyin.",
+ imageModelChatExclusionHint: "Konuşmayı da destekleyen işaretli bir model sohbet ve subagent için kullanılabilir kalır; yalnızca görsel üreten bir uç nokta kaydedildikten sonra sohbet ve varsayılan model menülerinden çıkar. Bu, görsel girdisi değil görsel üretimidir. Yalnızca uç noktanızda görsel üretebilen modelleri işaretleyin.",
"imageModelSelected": "Seçili görsel modeli",
"generatedImage": "Oluşturulan görsel {{index}}",
"downloadGeneratedImage": "İndir",
diff --git a/packages/i18n/src/locales/zh-CN/index.ts b/packages/i18n/src/locales/zh-CN/index.ts
index af68e81d7..cbfbbbe46 100644
--- a/packages/i18n/src/locales/zh-CN/index.ts
+++ b/packages/i18n/src/locales/zh-CN/index.ts
@@ -1027,7 +1027,7 @@ export const zhCN = {
imageModelSaveFailed: "无法保存生图模型。",
clearImageModel: "清除",
setImageModel: "设为生图模型",
- imageModelChatExclusionHint: "标记为生图模型后,该模型仍可正常用于对话和 subagent;生图绑定与对话通道相互独立。这是图片生成,不是图片输入;请只标记端点确实支持生图的模型。",
+ imageModelChatExclusionHint: "标记为生图模型且支持对话的模型仍可正常用于对话和 subagent;纯生图端点保存后会从聊天和默认模型菜单中移除。这是图片生成,不是图片输入;请只标记端点确实支持生图的模型。",
imageModelSelected: "已设为生图模型",
generatedImage: "生成图片 {{index}}",
downloadGeneratedImage: "下载",
diff --git a/packages/i18n/src/locales/zh-TW/index.ts b/packages/i18n/src/locales/zh-TW/index.ts
index 3526d14aa..e34436286 100644
--- a/packages/i18n/src/locales/zh-TW/index.ts
+++ b/packages/i18n/src/locales/zh-TW/index.ts
@@ -1027,7 +1027,7 @@ export const zhTW = {
imageModelSaveFailed: "無法儲存生圖模型。",
clearImageModel: "清除",
setImageModel: "設為生圖模型",
- imageModelChatExclusionHint: "標記為生圖模型後,該模型仍可正常用於對話和 subagent;生圖綁定與對話通道相互獨立。這是圖片生成,不是圖片輸入;請只標記端點確實支援生圖的模型。",
+ imageModelChatExclusionHint: "標記為生圖模型且支援對話的模型仍可正常用於對話和 subagent;純生圖端點儲存後會從聊天和預設模型選單中移除。這是圖片生成,不是圖片輸入;請只標記端點確實支援生圖的模型。",
imageModelSelected: "已設為生圖模型",
generatedImage: "生成圖片 {{index}}",
downloadGeneratedImage: "下載",
diff --git a/packages/shared/src/image-generation.ts b/packages/shared/src/image-generation.ts
index 2f2965ea3..f5d8ad66d 100644
--- a/packages/shared/src/image-generation.ts
+++ b/packages/shared/src/image-generation.ts
@@ -45,6 +45,48 @@ export function isImageGenerationModel(
entry.providerId === providerId && sameImageModelId(entry.modelId, modelId),
);
}
+
+/**
+ * Model id series a pure image-generation endpoint serves. These endpoints
+ * have no conversation route at all, so chat menus and session launch must
+ * keep them out even before any discovery metadata is available (ADR
+ * `image-generation-capability`).
+ */
+const IMAGE_ONLY_MODEL_ID =
+ /(^|\/)(gpt-image(?:-\d[\w.-]*)?|dall-e(?:-\d[\w.-]*)?|imagen(?:-\d[\w.-]*)?)$/i;
+
+/**
+ * Whether the model can serve a conversation. A discovered or catalog row that
+ * publishes its output modalities and names no text output cannot chat. An id
+ * a pure image endpoint serves has no conversation route either. Metadata that
+ * is absent is unknown, not an inference failure: an unknown custom model
+ * marked for image generation stays chat-eligible (#2253) — the image binding
+ * is host-owned and independent of the conversation route.
+ */
+export function modelSupportsConversation(
+ modelId: string | undefined,
+ model?: { modalities?: { output?: readonly string[] } | null } | null,
+): boolean {
+ const output = model?.modalities?.output;
+ if (output && output.length > 0 && !output.includes("text")) return false;
+ return !IMAGE_ONLY_MODEL_ID.test((modelId ?? "").trim());
+}
+
+/**
+ * Whether a model marked for image generation must stay out of chat. Only a
+ * pure image-generation endpoint is excluded; a dual-capability model — one
+ * the user marked for image generation that also supports conversation —
+ * keeps its chat eligibility everywhere (#2253).
+ */
+export function isImageOnlyChatModel(
+ binding: ImageGenerationBindings | null | undefined,
+ providerId: string | undefined,
+ modelId: string | undefined,
+ model?: { modalities?: { output?: readonly string[] } | null } | null,
+): boolean {
+ return isImageGenerationModel(binding, providerId, modelId) &&
+ !modelSupportsConversation(modelId, model);
+}
export const MAX_GENERATED_IMAGES = 10;
export const IMAGE_GENERATION_TIMEOUT_MS = 180_000;
export const IMAGE_BATCH_TIMEOUT_MS = 950_000;
diff --git a/scripts/e2e-image-chat.mjs b/scripts/e2e-image-chat.mjs
index f68f7f47d..f85fc19da 100644
--- a/scripts/e2e-image-chat.mjs
+++ b/scripts/e2e-image-chat.mjs
@@ -240,8 +240,8 @@ try {
await waitFor(() => evaluate(`!!document.querySelector('.composer-menu-entry')`),5000,"composer model root");
await evaluate(`document.querySelector('.composer-menu-entry').click()`);
await waitFor(() => evaluate(`document.querySelectorAll('.composer-model-option').length>0`),5000,"composer model options");
- assert.equal(await evaluate(`document.querySelectorAll('.composer-model-option').length`),1,"image-only provider must not be a chat candidate");
- assert.ok(await evaluate(`![...document.querySelectorAll('.composer-model-group-label')].some(e=>e.textContent.includes('Image-only fixture'))`));
+ assert.equal(await evaluate(`document.querySelectorAll('.composer-model-option').length`),2,"the image-marked fixture also supports conversation, so both providers stay chat candidates (#2253)");
+ assert.ok(await evaluate(`[...document.querySelectorAll('.composer-model-group-label')].some(e=>e.textContent.includes('Image-only fixture'))`));
await key("Escape",27);
await key("Escape",27);
const prompt = async (content) => {