fix: prevent unnecessary change detection in OpenAI Compatible settings

- Added comparison check before updating openAiHeaders to prevent triggering
  change detection when headers haven't actually changed
- This fixes the issue where the Save button was always highlighted when
  using OpenAI Compatible provider with a base URL

Fixes #6151
This commit is contained in:
Roo Code 2025-07-24 06:03:47 +00:00
parent 1e17b3b3bb
commit 01b6630328

View file

@ -87,12 +87,17 @@ export const OpenAICompatible = ({
// Add effect to update the parent component's state when local headers change
useEffect(() => {
const timer = setTimeout(() => {
const headerObject = convertHeadersToObject(customHeaders)
setApiConfigurationField("openAiHeaders", headerObject)
const currentConfigHeaders = apiConfiguration?.openAiHeaders || {}
const newHeadersObject = convertHeadersToObject(customHeaders)
// Only update if the processed object is different from the current config
if (JSON.stringify(currentConfigHeaders) !== JSON.stringify(newHeadersObject)) {
setApiConfigurationField("openAiHeaders", newHeadersObject)
}
}, 300)
return () => clearTimeout(timer)
}, [customHeaders, setApiConfigurationField])
}, [customHeaders, apiConfiguration?.openAiHeaders, setApiConfigurationField])
const handleInputChange = useCallback(
<K extends keyof ProviderSettings, E>(