Compare commits

...

1 Commits

Author SHA1 Message Date
YoVinchen
38e4ed8e9a fix(opencode): reject save when no models configured
Add validation to require at least one model before saving an OpenCode
provider. Shows a localized toast error when models are empty.
2026-02-05 18:29:05 +08:00
4 changed files with 9 additions and 1 deletions

View File

@@ -746,7 +746,7 @@ export function ProviderForm({
return; return;
} }
// OpenCode: validate provider key // OpenCode: validate provider key and models
if (appId === "opencode") { if (appId === "opencode") {
const keyPattern = /^[a-z0-9]+(-[a-z0-9]+)*$/; const keyPattern = /^[a-z0-9]+(-[a-z0-9]+)*$/;
if (!opencodeProviderKey.trim()) { if (!opencodeProviderKey.trim()) {
@@ -761,6 +761,11 @@ export function ProviderForm({
toast.error(t("opencode.providerKeyDuplicate")); toast.error(t("opencode.providerKeyDuplicate"));
return; return;
} }
// Validate that at least one model is configured
if (Object.keys(opencodeModels).length === 0) {
toast.error(t("opencode.modelsRequired"));
return;
}
} }
// 非官方供应商必填校验:端点和 API Key // 非官方供应商必填校验:端点和 API Key

View File

@@ -633,6 +633,7 @@
"modelId": "Model ID", "modelId": "Model ID",
"modelName": "Display Name", "modelName": "Display Name",
"noModels": "No models configured", "noModels": "No models configured",
"modelsRequired": "Please add at least one model",
"providerKey": "Provider Key", "providerKey": "Provider Key",
"providerKeyPlaceholder": "my-provider", "providerKeyPlaceholder": "my-provider",
"providerKeyHint": "Unique identifier in config file. Cannot be changed after creation. Use lowercase letters, numbers, and hyphens only.", "providerKeyHint": "Unique identifier in config file. Cannot be changed after creation. Use lowercase letters, numbers, and hyphens only.",

View File

@@ -633,6 +633,7 @@
"modelId": "モデル ID", "modelId": "モデル ID",
"modelName": "表示名", "modelName": "表示名",
"noModels": "モデルが設定されていません", "noModels": "モデルが設定されていません",
"modelsRequired": "モデルを少なくとも1つ追加してください",
"providerKey": "プロバイダーキー", "providerKey": "プロバイダーキー",
"providerKeyPlaceholder": "my-provider", "providerKeyPlaceholder": "my-provider",
"providerKeyHint": "設定ファイルの一意の識別子。作成後は変更できません。小文字、数字、ハイフンのみ使用できます。", "providerKeyHint": "設定ファイルの一意の識別子。作成後は変更できません。小文字、数字、ハイフンのみ使用できます。",

View File

@@ -633,6 +633,7 @@
"modelId": "模型 ID", "modelId": "模型 ID",
"modelName": "显示名称", "modelName": "显示名称",
"noModels": "暂无模型配置", "noModels": "暂无模型配置",
"modelsRequired": "请至少添加一个模型配置",
"providerKey": "供应商标识", "providerKey": "供应商标识",
"providerKeyPlaceholder": "my-provider", "providerKeyPlaceholder": "my-provider",
"providerKeyHint": "配置文件中的唯一标识符,创建后无法修改,只能使用小写字母、数字和连字符", "providerKeyHint": "配置文件中的唯一标识符,创建后无法修改,只能使用小写字母、数字和连字符",