Fix settings dirty check (#5779)

This commit is contained in:
Matt Rubens 2025-07-16 10:57:34 -04:00 committed by GitHub
parent 8c8888a977
commit 0f994fcf22
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 3 deletions

View file

@ -167,10 +167,10 @@ const ApiOptions = ({
// Update `apiModelId` whenever `selectedModelId` changes.
useEffect(() => {
if (selectedModelId) {
if (selectedModelId && apiConfiguration.apiModelId !== selectedModelId) {
setApiConfigurationField("apiModelId", selectedModelId)
}
}, [selectedModelId, setApiConfigurationField])
}, [selectedModelId, setApiConfigurationField, apiConfiguration.apiModelId])
// Debounced refresh model updates, only executed 250ms after the user
// stops typing.

View file

@ -218,7 +218,15 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
return prevState
}
setChangeDetected(true)
const previousValue = prevState.apiConfiguration?.[field]
// Don't treat initial sync from undefined to a defined value as a user change
// This prevents the dirty state when the component initializes and auto-syncs the model ID
const isInitialSync = previousValue === undefined && value !== undefined
if (!isInitialSync) {
setChangeDetected(true)
}
return { ...prevState, apiConfiguration: { ...prevState.apiConfiguration, [field]: value } }
})
},