Skip to content

Commit 6659a23

Browse files
kr4chininclaude
andcommitted
fix(settings): fallback model switch never saves the text generation model
Turning the fallback on with no other provider ready saved the text generation model itself, which generation skips, so the switch showed a fallback that never ran. It now needs another ready provider and otherwise stays off with a toast. The fallback picker disables the text generation model, and the switch shows a mixed state when targets disagree. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent acc1f99 commit 6659a23

1 file changed

Lines changed: 27 additions & 23 deletions

File tree

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

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -874,22 +874,25 @@ export function GeneralSettingsPanel() {
874874
// saved model, so substituting one here would show a model that never runs.
875875
const textGenerationFallbackSelection =
876876
settings.textGenerationFallbackModelSelection ?? textGenerationModelSelection;
877-
// Turning the fallback on starts from another provider when one is ready,
878-
// since a model on the primary's provider goes down with it.
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-
];
877+
// Turning the fallback on starts from another provider, since a model on the
878+
// primary's provider goes down with it.
879+
const textGenerationFallbackSeeds = textGenerationProviders
880+
.filter((provider) =>
881+
textGenerationModelInstanceEntries.some(
882+
(entry) =>
883+
entry.instanceId === provider.instanceId &&
884+
entry.instanceId !== textGenInstanceId &&
885+
entry.enabled &&
886+
entry.isAvailable,
887+
),
888+
)
889+
.map((provider) => resolveAppModelSelectionState(settings, [provider]));
890+
// Generation never retries the model that just failed, so the primary model
891+
// would be a fallback that never runs.
892+
const textGenerationFallbackDisabledReason = (instanceId: ProviderInstanceId, model: string) =>
893+
instanceId === textGenInstanceId && model === textGenModel
894+
? "This is already the text generation model."
895+
: textGenerationModelDisabledReason(instanceId, model);
893896
const textGenerationFallbackInstanceEntry = textGenerationModelInstanceEntries.find(
894897
(entry) => entry.instanceId === textGenerationFallbackSelection.instanceId,
895898
);
@@ -1976,7 +1979,7 @@ export function GeneralSettingsPanel() {
19761979
triggerClassName={SETTINGS_PICKER_TRIGGER_CLASSNAME}
19771980
triggerAriaLabel="Text generation fallback model"
19781981
{...(mixedTextGenerationFallbackModel ? { triggerLabel: "Mixed" } : {})}
1979-
getModelDisabledReason={textGenerationModelDisabledReason}
1982+
getModelDisabledReason={textGenerationFallbackDisabledReason}
19801983
{...(environmentId
19811984
? {
19821985
onOpenProviderSetup: (instanceId: ProviderInstanceId) => {
@@ -1988,7 +1991,7 @@ export function GeneralSettingsPanel() {
19881991
}
19891992
: {})}
19901993
onInstanceModelChange={(instanceId, model) => {
1991-
const reason = textGenerationModelDisabledReason(instanceId, model);
1994+
const reason = textGenerationFallbackDisabledReason(instanceId, model);
19921995
if (reason) {
19931996
toastManager.add({
19941997
type: "error",
@@ -2032,7 +2035,8 @@ export function GeneralSettingsPanel() {
20322035
}
20332036
/>
20342037
) : null}
2035-
<Switch
2038+
<ScopedSwitch
2039+
settingKeys={["textGenerationFallbackModelSelection"]}
20362040
checked={usesTextGenerationFallback}
20372041
disabled={!usesTextGenerationFallback && !hasTextGenerationProvider}
20382042
onCheckedChange={(checked) => {
@@ -2047,13 +2051,13 @@ export function GeneralSettingsPanel() {
20472051
null,
20482052
);
20492053
if (!seed) {
2054+
const [firstSeed] = textGenerationFallbackSeeds;
20502055
toastManager.add({
20512056
type: "error",
20522057
title: "Text generation fallback model not saved",
2053-
description: textGenerationModelDisabledReason(
2054-
textGenInstanceId,
2055-
textGenModel,
2056-
),
2058+
description: firstSeed
2059+
? textGenerationModelDisabledReason(firstSeed.instanceId, firstSeed.model)
2060+
: "No other text generation provider is ready to use as a fallback.",
20572061
});
20582062
return;
20592063
}

0 commit comments

Comments
 (0)