Skip to content

Commit 2f254e5

Browse files
kr4chininclaude
andcommitted
fix(settings): fallback model checks every target's saved text generation model
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 8cfe053 commit 2f254e5

1 file changed

Lines changed: 30 additions & 17 deletions

File tree

‎apps/web/src/components/settings/SettingsPanels.tsx‎

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -875,34 +875,47 @@ export function GeneralSettingsPanel() {
875875
// saved model, so substituting one here would show a model that never runs.
876876
const textGenerationFallbackSelection =
877877
settings.textGenerationFallbackModelSelection ?? textGenerationModelSelection;
878-
// Turning the fallback on starts from another provider, since a model on the
878+
// Every target's saved primary, not the one shown above: the server tries the
879+
// saved model even when the picker substitutes a ready provider for it.
880+
const textGenerationPrimaries = targets.map(
881+
(candidate) => candidate.settings.textGenerationModelSelection,
882+
);
883+
const isTextGenerationPrimary = (instanceId: ProviderInstanceId, model: string) =>
884+
textGenerationPrimaries.some(
885+
(primary) => primary.instanceId === instanceId && primary.model === model,
886+
);
887+
// Turning the fallback on starts from another provider, since a model on a
879888
// primary's provider goes down with it.
880889
const textGenerationFallbackSeeds = textGenerationProviders
881-
.filter((provider) =>
882-
textGenerationModelInstanceEntries.some(
883-
(entry) =>
884-
entry.instanceId === provider.instanceId &&
885-
entry.instanceId !== textGenInstanceId &&
886-
entry.enabled &&
887-
entry.isAvailable,
888-
),
890+
.filter(
891+
(provider) =>
892+
!textGenerationPrimaries.some((primary) => primary.instanceId === provider.instanceId) &&
893+
textGenerationModelInstanceEntries.some(
894+
(entry) => entry.instanceId === provider.instanceId && entry.enabled && entry.isAvailable,
895+
),
889896
)
890897
.map((provider) => resolveAppModelSelectionState(settings, [provider]));
891-
// Generation never retries the model that just failed, so the primary model
898+
// Generation never retries the model that just failed, so a primary model
892899
// would be a fallback that never runs.
893900
const textGenerationFallbackDisabledReason = (instanceId: ProviderInstanceId, model: string) =>
894-
instanceId === textGenInstanceId && model === textGenModel
901+
isTextGenerationPrimary(instanceId, model)
895902
? "This is already the text generation model."
896903
: textGenerationModelDisabledReason(instanceId, model);
897-
// For the same reason, a primary model that lands on the fallback turns the
898-
// fallback off rather than leaving a switch on that never retries.
904+
// For the same reason, a primary that lands on the fallback turns the fallback
905+
// off. The clear is written to every target, so it is skipped when another
906+
// target keeps a different fallback that still works.
899907
const textGenerationModelPatch = (selection: ModelSelection) => {
900-
const fallback = settings.textGenerationFallbackModelSelection;
908+
const isSelection = (fallback: ModelSelection | null) =>
909+
fallback !== null &&
910+
fallback.instanceId === selection.instanceId &&
911+
fallback.model === selection.model;
912+
const fallbacks = targets.map(
913+
(candidate) => candidate.settings.textGenerationFallbackModelSelection,
914+
);
901915
return {
902916
textGenerationModelSelection: selection,
903-
...(fallback &&
904-
fallback.instanceId === selection.instanceId &&
905-
fallback.model === selection.model
917+
...(fallbacks.some(isSelection) &&
918+
fallbacks.every((fallback) => fallback === null || isSelection(fallback))
906919
? { textGenerationFallbackModelSelection: null }
907920
: {}),
908921
};

0 commit comments

Comments
 (0)