Skip to content

Commit acc1f99

Browse files
kr4chininclaude
andcommitted
fix(settings): fallback model setting saves only models every target can run
Turning the fallback on in a scope that spans several environments or projects saved a model picked from one of them to all of them. It now saves the first candidate that every target can run, or shows the same "not saved" toast as the picker. The picker also shows the saved fallback instead of swapping in an available provider, since the server tries the saved one. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent e4fc7af commit acc1f99

1 file changed

Lines changed: 42 additions & 28 deletions

File tree

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

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -870,29 +870,26 @@ export function GeneralSettingsPanel() {
870870
"textGenerationFallbackModelSelection",
871871
]);
872872
const usesTextGenerationFallback = settings.textGenerationFallbackModelSelection !== null;
873-
const textGenerationFallbackSelection = resolveAppModelSelectionState(
874-
{
875-
...settings,
876-
textGenerationModelSelection:
877-
settings.textGenerationFallbackModelSelection ?? textGenerationModelSelection,
878-
},
879-
textGenerationProviders,
880-
);
873+
// Shown as saved, not resolved to an available provider: the server tries the
874+
// saved model, so substituting one here would show a model that never runs.
875+
const textGenerationFallbackSelection =
876+
settings.textGenerationFallbackModelSelection ?? textGenerationModelSelection;
881877
// Turning the fallback on starts from another provider when one is ready,
882878
// since a model on the primary's provider goes down with it.
883-
const textGenerationFallbackSeedProviders = textGenerationProviders.filter((provider) =>
884-
textGenerationModelInstanceEntries.some(
885-
(entry) =>
886-
entry.instanceId === provider.instanceId &&
887-
entry.instanceId !== textGenInstanceId &&
888-
entry.enabled &&
889-
entry.isAvailable,
890-
),
891-
);
892-
const textGenerationFallbackSeed =
893-
textGenerationFallbackSeedProviders.length > 0
894-
? resolveAppModelSelectionState(settings, textGenerationFallbackSeedProviders)
895-
: textGenerationModelSelection;
879+
const textGenerationFallbackSeeds = [
880+
...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+
),
889+
)
890+
.map((provider) => resolveAppModelSelectionState(settings, [provider])),
891+
textGenerationModelSelection,
892+
];
896893
const textGenerationFallbackInstanceEntry = textGenerationModelInstanceEntries.find(
897894
(entry) => entry.instanceId === textGenerationFallbackSelection.instanceId,
898895
);
@@ -2038,13 +2035,30 @@ export function GeneralSettingsPanel() {
20382035
<Switch
20392036
checked={usesTextGenerationFallback}
20402037
disabled={!usesTextGenerationFallback && !hasTextGenerationProvider}
2041-
onCheckedChange={(checked) =>
2042-
updateSettings({
2043-
textGenerationFallbackModelSelection: checked
2044-
? textGenerationFallbackSeed
2045-
: null,
2046-
})
2047-
}
2038+
onCheckedChange={(checked) => {
2039+
if (!checked) {
2040+
updateSettings({ textGenerationFallbackModelSelection: null });
2041+
return;
2042+
}
2043+
// The seed is saved to every target in scope, so it must work on all of them.
2044+
const seed = textGenerationFallbackSeeds.find(
2045+
(selection) =>
2046+
textGenerationModelDisabledReason(selection.instanceId, selection.model) ===
2047+
null,
2048+
);
2049+
if (!seed) {
2050+
toastManager.add({
2051+
type: "error",
2052+
title: "Text generation fallback model not saved",
2053+
description: textGenerationModelDisabledReason(
2054+
textGenInstanceId,
2055+
textGenModel,
2056+
),
2057+
});
2058+
return;
2059+
}
2060+
updateSettings({ textGenerationFallbackModelSelection: seed });
2061+
}}
20482062
aria-label="Use a text generation fallback model"
20492063
/>
20502064
</div>

0 commit comments

Comments
 (0)