fix(provider,web): align provider availability predicates and add flow gating
This commit is contained in:
parent
d5f870feba
commit
e76527d932
5 changed files with 31 additions and 5 deletions
|
|
@ -984,8 +984,8 @@ func TestModelProviderOptions(t *testing.T) {
|
||||||
}
|
}
|
||||||
if option, ok := seen["bedrock"]; !ok {
|
if option, ok := seen["bedrock"]; !ok {
|
||||||
t.Fatal("bedrock option missing")
|
t.Fatal("bedrock option missing")
|
||||||
} else if option.CreateAllowed {
|
} else if !option.CreateAllowed {
|
||||||
t.Fatal("bedrock should not be creatable from the web form")
|
t.Fatal("bedrock should be creatable and defer credential/build errors to runtime")
|
||||||
}
|
}
|
||||||
if option, ok := seen["antigravity"]; !ok {
|
if option, ok := seen["antigravity"]; !ok {
|
||||||
t.Fatal("antigravity option missing")
|
t.Fatal("antigravity option missing")
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ var attachedModelProviderMetaByName = map[string]attachedModelProviderMeta{
|
||||||
protocolMeta: protocolMeta{defaultAPIBase: "https://api.anthropic.com/v1"},
|
protocolMeta: protocolMeta{defaultAPIBase: "https://api.anthropic.com/v1"},
|
||||||
createAllowed: true,
|
createAllowed: true,
|
||||||
},
|
},
|
||||||
"bedrock": {},
|
"bedrock": {createAllowed: true},
|
||||||
"antigravity": {createAllowed: true, defaultAuthMethod: "oauth", authMethodLocked: true},
|
"antigravity": {createAllowed: true, defaultAuthMethod: "oauth", authMethodLocked: true},
|
||||||
"claude-cli": {createAllowed: true},
|
"claude-cli": {createAllowed: true},
|
||||||
"codex-cli": {createAllowed: true},
|
"codex-cli": {createAllowed: true},
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,6 @@ func hasModelConfiguration(m *config.ModelConfig) bool {
|
||||||
if configured, checked := hasStoredOAuthCredential(m); checked {
|
if configured, checked := hasStoredOAuthCredential(m); checked {
|
||||||
return configured
|
return configured
|
||||||
}
|
}
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if authMethod == "" && providerUsesImplicitOAuth(protocol) {
|
if authMethod == "" && providerUsesImplicitOAuth(protocol) {
|
||||||
|
|
|
||||||
|
|
@ -253,6 +253,27 @@ func TestHandleListModels_AvailabilityForOAuthModelWithCredential(t *testing.T)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestHasModelConfiguration_OAuthWithoutMappedCredentialFallsBackToAPIKey(t *testing.T) {
|
||||||
|
noKey := &config.ModelConfig{
|
||||||
|
Provider: "gemini",
|
||||||
|
Model: "gemini-2.5-flash",
|
||||||
|
AuthMethod: "oauth",
|
||||||
|
}
|
||||||
|
if hasModelConfiguration(noKey) {
|
||||||
|
t.Fatal("oauth model without credential mapping and api key should be unconfigured")
|
||||||
|
}
|
||||||
|
|
||||||
|
withKey := &config.ModelConfig{
|
||||||
|
Provider: "gemini",
|
||||||
|
Model: "gemini-2.5-flash",
|
||||||
|
AuthMethod: "oauth",
|
||||||
|
APIKeys: config.SimpleSecureStrings("gemini-key"),
|
||||||
|
}
|
||||||
|
if !hasModelConfiguration(withKey) {
|
||||||
|
t.Fatal("oauth model without credential mapping should fall back to api key configuration")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestHandleListModels_AntigravityImplicitOAuthAvailability(t *testing.T) {
|
func TestHandleListModels_AntigravityImplicitOAuthAvailability(t *testing.T) {
|
||||||
configPath, cleanup := setupOAuthTestEnv(t)
|
configPath, cleanup := setupOAuthTestEnv(t)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ export function ModelsPage() {
|
||||||
const [settingDefaultIndex, setSettingDefaultIndex] = useState<number | null>(
|
const [settingDefaultIndex, setSettingDefaultIndex] = useState<number | null>(
|
||||||
null,
|
null,
|
||||||
)
|
)
|
||||||
|
const addDisabled = loading || providerOptions.length === 0
|
||||||
|
|
||||||
const fetchModels = useCallback(async () => {
|
const fetchModels = useCallback(async () => {
|
||||||
try {
|
try {
|
||||||
|
|
@ -141,7 +142,12 @@ export function ModelsPage() {
|
||||||
<div className="flex h-full flex-col">
|
<div className="flex h-full flex-col">
|
||||||
<PageHeader title={t("navigation.models")}>
|
<PageHeader title={t("navigation.models")}>
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
<Button size="sm" variant="outline" onClick={() => setAddOpen(true)}>
|
<Button
|
||||||
|
size="sm"
|
||||||
|
variant="outline"
|
||||||
|
disabled={addDisabled}
|
||||||
|
onClick={() => setAddOpen(true)}
|
||||||
|
>
|
||||||
<IconPlus className="size-4" />
|
<IconPlus className="size-4" />
|
||||||
{t("models.add.button")}
|
{t("models.add.button")}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue