diff --git a/interface/src/routes/Settings.tsx b/interface/src/routes/Settings.tsx index 4e06a29e3..0fdc2897f 100644 --- a/interface/src/routes/Settings.tsx +++ b/interface/src/routes/Settings.tsx @@ -134,7 +134,7 @@ const PROVIDERS = [ description: "Fast inference for popular OSS models", placeholder: "...", envVar: "FIREWORKS_API_KEY", - defaultModel: "fireworks/accounts/fireworks/models/llama-v3p3-70b-instruct", + defaultModel: "fireworks/accounts/fireworks/models/minimax-m2p5", }, { id: "deepseek", @@ -262,6 +262,38 @@ export function Settings() { enabled: activeSection === "providers", }); + // Fetch agents list and default agent config so we can pre-populate the + // model field with the currently active routing model when editing an + // already-configured provider (instead of always showing the hardcoded + // defaultModel). + const { data: agentsData } = useQuery({ + queryKey: ["agents"], + queryFn: api.agents, + staleTime: 10_000, + enabled: activeSection === "providers", + }); + const defaultAgentId = + agentsData?.agents?.find((agent) => agent.id === "main")?.id ?? agentsData?.agents?.[0]?.id; + const { data: defaultAgentConfig } = useQuery({ + queryKey: ["agent-config", defaultAgentId], + queryFn: () => api.agentConfig(defaultAgentId!), + staleTime: 10_000, + enabled: activeSection === "providers" && !!defaultAgentId, + }); + + // If the routing config loads *after* the edit dialog is already open (race + // condition: user clicks edit before the agent-config query resolves), update + // the model field to show the active routing model instead of defaultModel. + useEffect(() => { + if (!editingProvider) return; + const currentChannel = defaultAgentConfig?.routing?.channel; + if (!currentChannel?.startsWith(`${editingProvider}/`)) return; + setModelInput(currentChannel); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [defaultAgentConfig]); + // Note: intentionally omitting editingProvider and modelInput from deps — we + // only want this to fire when the config data arrives, not on every keystroke. + // Fetch global settings (only when on api-keys, server, or worker-logs tabs) const { data: globalSettings, isLoading: globalSettingsLoading } = useQuery({ queryKey: ["global-settings"], @@ -591,7 +623,16 @@ export function Settings() { onEdit={() => { setEditingProvider(provider.id); setKeyInput(""); - setModelInput(provider.defaultModel ?? ""); + // When the provider is already configured, pre-populate + // the model field with the current routing model so the + // user sees (and can adjust) what's actually active, + // rather than the hardcoded defaultModel placeholder. + const currentChannel = defaultAgentConfig?.routing?.channel; + const currentModel = + isConfigured(provider.id) && currentChannel?.startsWith(`${provider.id}/`) + ? currentChannel + : null; + setModelInput(currentModel ?? provider.defaultModel ?? ""); setTestedSignature(null); setTestResult(null); setMessage(null); diff --git a/src/api/providers.rs b/src/api/providers.rs index 954409992..2aae17ed2 100644 --- a/src/api/providers.rs +++ b/src/api/providers.rs @@ -426,6 +426,7 @@ pub(super) async fn get_providers( ) -> Result, StatusCode> { let config_path = state.config_path.read().await.clone(); let instance_dir = (**state.instance_dir.load()).clone(); + let anthropic_oauth_configured = crate::auth::credentials_path(&instance_dir).exists(); let openai_oauth_configured = crate::openai_auth::credentials_path(&instance_dir).exists(); let ( @@ -470,7 +471,7 @@ pub(super) async fn get_providers( }; ( - has_value("anthropic_key", "ANTHROPIC_API_KEY"), + has_value("anthropic_key", "ANTHROPIC_API_KEY") || anthropic_oauth_configured, has_value("openai_key", "OPENAI_API_KEY"), openai_oauth_configured, has_value("openrouter_key", "OPENROUTER_API_KEY"), @@ -493,7 +494,7 @@ pub(super) async fn get_providers( ) } else { ( - std::env::var("ANTHROPIC_API_KEY").is_ok(), + std::env::var("ANTHROPIC_API_KEY").is_ok() || anthropic_oauth_configured, std::env::var("OPENAI_API_KEY").is_ok(), openai_oauth_configured, std::env::var("OPENROUTER_API_KEY").is_ok(),