fix(opencode): reject save when no models configured (#932)

Add validation to require at least one model before saving an OpenCode
provider. Shows a localized toast error when models are empty.
This commit is contained in:
Dex Miller
2026-02-06 16:03:39 +08:00
committed by GitHub
parent 95bc0e38df
commit 14fa749ca9
4 changed files with 9 additions and 1 deletions
@@ -746,7 +746,7 @@ export function ProviderForm({
return;
}
// OpenCode: validate provider key
// OpenCode: validate provider key and models
if (appId === "opencode") {
const keyPattern = /^[a-z0-9]+(-[a-z0-9]+)*$/;
if (!opencodeProviderKey.trim()) {
@@ -761,6 +761,11 @@ export function ProviderForm({
toast.error(t("opencode.providerKeyDuplicate"));
return;
}
// Validate that at least one model is configured
if (Object.keys(opencodeModels).length === 0) {
toast.error(t("opencode.modelsRequired"));
return;
}
}
// 非官方供应商必填校验:端点和 API Key