diff --git a/src/renderer/components/company-onboarding/useConnectorModelSelection.ts b/src/renderer/components/company-onboarding/useConnectorModelSelection.ts index 6b354e13..680ba44e 100644 --- a/src/renderer/components/company-onboarding/useConnectorModelSelection.ts +++ b/src/renderer/components/company-onboarding/useConnectorModelSelection.ts @@ -9,6 +9,33 @@ import type { ConnectorId, ProfileSnapshot } from "@shared/types"; import { unwrap } from "../../lib/desktop"; import type { TranslationFn } from "../../i18n"; +/** + * Structural equality over the per-connector model catalog. Returns true + * when the two maps hold the same connector ids, each list in the same + * order, and each entry has the same id/label/enabled flag. Used to keep + * React state references stable across snapshot refreshes so an open + * native dropdown. Only call + // setConnectorModelsById when the catalog actually changed. + setConnectorModelsById((previous) => + connectorCatalogsEqual(previous, next) ? previous : next, + ); } catch { if (cancelled) return; - setConnectorModelsById({}); + setConnectorModelsById((previous) => (Object.keys(previous).length === 0 ? previous : {})); setSelectedModel(""); } finally { if (!cancelled) {