From 436525d6de1dbbee2ef54ac3e010ee311616372b Mon Sep 17 00:00:00 2001 From: Nilay <118994073+NilayYadav@users.noreply.github.com> Date: Wed, 10 Jun 2026 02:13:24 +0530 Subject: [PATCH] Studio: stop the providers dialog from resetting custom provider form state (#6051) * fix custom provider state * Address provider seeding review feedback --------- Co-authored-by: Lee Jackson <130007945+Imagineer99@users.noreply.github.com> Co-authored-by: imagineer99 --- studio/frontend/src/features/chat/chat-providers-dialog.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/studio/frontend/src/features/chat/chat-providers-dialog.tsx b/studio/frontend/src/features/chat/chat-providers-dialog.tsx index 42f8e56ac5..e35a8e35e0 100644 --- a/studio/frontend/src/features/chat/chat-providers-dialog.tsx +++ b/studio/frontend/src/features/chat/chat-providers-dialog.tsx @@ -212,6 +212,7 @@ export function ChatProvidersSettings({ onProvidersChange, }: ChatProvidersSettingsProps) { const providersRef = useRef(providers); + const seededProviderTypeRef = useRef(null); const [page, setPage] = useState<"list" | "form">("list"); const [providerType, setProviderType] = useState(""); const [apiKey, setApiKey] = useState(""); @@ -317,6 +318,8 @@ export function ChatProvidersSettings({ useEffect(() => { if (!providerType || editingProviderId) return; + if (seededProviderTypeRef.current === providerType) return; + seededProviderTypeRef.current = providerType; const entry = registryByType.get(providerType); if (!entry) { if (isCustomProviderType(providerType)) { @@ -363,7 +366,8 @@ export function ChatProvidersSettings({ setProviderType((current) => { if ( current && - registryRows.some((entry) => entry.provider_type === current) + (isCustomProviderType(current) || + registryRows.some((entry) => entry.provider_type === current)) ) { return current; }