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 <samleejackson0@gmail.com>
This commit is contained in:
Nilay 2026-06-10 02:13:24 +05:30 committed by GitHub
commit 436525d6de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -212,6 +212,7 @@ export function ChatProvidersSettings({
onProvidersChange,
}: ChatProvidersSettingsProps) {
const providersRef = useRef(providers);
const seededProviderTypeRef = useRef<string | null>(null);
const [page, setPage] = useState<"list" | "form">("list");
const [providerType, setProviderType] = useState<string>("");
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;
}