Skip to content

Commit 836a519

Browse files
committed
refactor: remove invalid label, redundant
1 parent 7d9075e commit 836a519

File tree

19 files changed

+36
-76
lines changed

19 files changed

+36
-76
lines changed

webview-ui/src/components/settings/ApiOptions.tsx

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -207,17 +207,8 @@ const ApiOptions = ({
207207
}))
208208
: []
209209

210-
// Add the current selected model if it's not in the valid models list
211-
// This allows users to see their invalid selection
212-
if (selectedModelId && !modelOptions.some((option) => option.value === selectedModelId)) {
213-
modelOptions.unshift({
214-
value: selectedModelId,
215-
label: `${selectedModelId} ${t("settings:labels.invalidModel")}`,
216-
})
217-
}
218-
219210
return modelOptions
220-
}, [selectedProvider, organizationAllowList, selectedModelId])
211+
}, [selectedProvider, organizationAllowList])
221212

222213
const onProviderChange = useCallback(
223214
(value: ProviderName) => {
@@ -238,13 +229,9 @@ const ApiOptions = ({
238229
// in case we haven't set a default value for a provider
239230
if (!defaultValue) return
240231

241-
const providerModels = MODELS_BY_PROVIDER[value]
242-
const filteredModels = filterModels(providerModels || null, value, organizationAllowList)
243-
const isModelValid = modelId && filteredModels && Object.keys(filteredModels).includes(modelId)
244-
245-
// set default if no model is set OR if the current model is invalid for the new provider
246-
// this is to help 'reset' the invalid model when switching providers
247-
const shouldSetDefault = !modelId || !isModelValid
232+
// only set default if no model is set, but don't reset invalid models
233+
// let users see and decide what to do with invalid model selections
234+
const shouldSetDefault = !modelId
248235

249236
if (shouldSetDefault) {
250237
setApiConfigurationField(field, defaultValue)
@@ -290,7 +277,7 @@ const ApiOptions = ({
290277
)
291278
}
292279
},
293-
[setApiConfigurationField, apiConfiguration, organizationAllowList],
280+
[setApiConfigurationField, apiConfiguration],
294281
)
295282

296283
const modelValidationError = useMemo(() => {

webview-ui/src/components/ui/hooks/useSelectedModel.ts

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -94,35 +94,27 @@ function getSelectedModel({
9494
: openRouterModelProviders[specificProvider]
9595
}
9696

97-
return info
98-
? { id, info }
99-
: { id, info: undefined }
97+
return { id, info }
10098
}
10199
case "requesty": {
102100
const id = apiConfiguration.requestyModelId ?? requestyDefaultModelId
103101
const info = routerModels.requesty[id]
104-
return info
105-
? { id, info }
106-
: { id, info: undefined }
102+
return { id, info }
107103
}
108104
case "glama": {
109105
const id = apiConfiguration.glamaModelId ?? glamaDefaultModelId
110106
const info = routerModels.glama[id]
111-
return info ? { id, info } : { id, info: undefined }
107+
return { id, info }
112108
}
113109
case "unbound": {
114110
const id = apiConfiguration.unboundModelId ?? unboundDefaultModelId
115111
const info = routerModels.unbound[id]
116-
return info
117-
? { id, info }
118-
: { id, info: undefined }
112+
return { id, info }
119113
}
120114
case "litellm": {
121115
const id = apiConfiguration.litellmModelId ?? litellmDefaultModelId
122116
const info = routerModels.litellm[id]
123-
return info
124-
? { id, info }
125-
: { id, info: undefined }
117+
return { id, info }
126118
}
127119
case "xai": {
128120
const id = apiConfiguration.apiModelId ?? xaiDefaultModelId
@@ -132,12 +124,12 @@ function getSelectedModel({
132124
case "groq": {
133125
const id = apiConfiguration.apiModelId ?? groqDefaultModelId
134126
const info = groqModels[id as keyof typeof groqModels]
135-
return info ? { id, info } : { id, info: undefined }
127+
return { id, info }
136128
}
137129
case "chutes": {
138130
const id = apiConfiguration.apiModelId ?? chutesDefaultModelId
139131
const info = chutesModels[id as keyof typeof chutesModels]
140-
return info ? { id, info } : { id, info: undefined }
132+
return { id, info }
141133
}
142134
case "bedrock": {
143135
const id = apiConfiguration.apiModelId ?? bedrockDefaultModelId
@@ -151,34 +143,32 @@ function getSelectedModel({
151143
}
152144
}
153145

154-
return info ? { id, info } : { id, info: undefined }
146+
return { id, info }
155147
}
156148
case "vertex": {
157149
const id = apiConfiguration.apiModelId ?? vertexDefaultModelId
158150
const info = vertexModels[id as keyof typeof vertexModels]
159-
return info ? { id, info } : { id, info: undefined }
151+
return { id, info }
160152
}
161153
case "gemini": {
162154
const id = apiConfiguration.apiModelId ?? geminiDefaultModelId
163155
const info = geminiModels[id as keyof typeof geminiModels]
164-
return info ? { id, info } : { id, info: undefined }
156+
return { id, info }
165157
}
166158
case "deepseek": {
167159
const id = apiConfiguration.apiModelId ?? deepSeekDefaultModelId
168160
const info = deepSeekModels[id as keyof typeof deepSeekModels]
169-
return info ? { id, info } : { id, info: undefined }
161+
return { id, info }
170162
}
171163
case "openai-native": {
172164
const id = apiConfiguration.apiModelId ?? openAiNativeDefaultModelId
173165
const info = openAiNativeModels[id as keyof typeof openAiNativeModels]
174-
return info
175-
? { id, info }
176-
: { id, info: undefined }
166+
return { id, info }
177167
}
178168
case "mistral": {
179169
const id = apiConfiguration.apiModelId ?? mistralDefaultModelId
180170
const info = mistralModels[id as keyof typeof mistralModels]
181-
return info ? { id, info } : { id, info: undefined }
171+
return { id, info }
182172
}
183173
case "openai": {
184174
const id = apiConfiguration.openAiModelId ?? ""
@@ -209,7 +199,7 @@ function getSelectedModel({
209199
default: {
210200
const id = apiConfiguration.apiModelId ?? anthropicDefaultModelId
211201
const info = anthropicModels[id as keyof typeof anthropicModels]
212-
return info ? { id, info } : { id, info: undefined }
202+
return { id, info }
213203
}
214204
}
215205
}

webview-ui/src/i18n/locales/ca/settings.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,6 @@
600600
},
601601
"labels": {
602602
"customArn": "ARN personalitzat",
603-
"useCustomArn": "Utilitza ARN personalitzat...",
604-
"invalidModel": "(invàlid)"
603+
"useCustomArn": "Utilitza ARN personalitzat..."
605604
}
606605
}

webview-ui/src/i18n/locales/de/settings.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,6 @@
600600
},
601601
"labels": {
602602
"customArn": "Benutzerdefinierte ARN",
603-
"useCustomArn": "Benutzerdefinierte ARN verwenden...",
604-
"invalidModel": "(ungültig)"
603+
"useCustomArn": "Benutzerdefinierte ARN verwenden..."
605604
}
606605
}

webview-ui/src/i18n/locales/en/settings.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,6 @@
600600
},
601601
"labels": {
602602
"customArn": "Custom ARN",
603-
"useCustomArn": "Use custom ARN...",
604-
"invalidModel": "(invalid)"
603+
"useCustomArn": "Use custom ARN..."
605604
}
606605
}

webview-ui/src/i18n/locales/es/settings.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,6 @@
600600
},
601601
"labels": {
602602
"customArn": "ARN personalizado",
603-
"useCustomArn": "Usar ARN personalizado...",
604-
"invalidModel": "(inválido)"
603+
"useCustomArn": "Usar ARN personalizado..."
605604
}
606605
}

webview-ui/src/i18n/locales/fr/settings.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,6 @@
600600
},
601601
"labels": {
602602
"customArn": "ARN personnalisé",
603-
"useCustomArn": "Utiliser un ARN personnalisé...",
604-
"invalidModel": "(invalide)"
603+
"useCustomArn": "Utiliser un ARN personnalisé..."
605604
}
606605
}

webview-ui/src/i18n/locales/hi/settings.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,6 @@
600600
},
601601
"labels": {
602602
"customArn": "कस्टम ARN",
603-
"useCustomArn": "कस्टम ARN का उपयोग करें...",
604-
"invalidModel": "(अमान्य)"
603+
"useCustomArn": "कस्टम ARN का उपयोग करें..."
605604
}
606605
}

webview-ui/src/i18n/locales/it/settings.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,6 @@
600600
},
601601
"labels": {
602602
"customArn": "ARN personalizzato",
603-
"useCustomArn": "Usa ARN personalizzato...",
604-
"invalidModel": "(non valido)"
603+
"useCustomArn": "Usa ARN personalizzato..."
605604
}
606605
}

webview-ui/src/i18n/locales/ja/settings.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,6 @@
600600
},
601601
"labels": {
602602
"customArn": "カスタム ARN",
603-
"useCustomArn": "カスタム ARN を使用...",
604-
"invalidModel": "(無効)"
603+
"useCustomArn": "カスタム ARN を使用..."
605604
}
606605
}

0 commit comments

Comments
 (0)