Skip to content

Commit 01b6630

Browse files
committed
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
1 parent 1e17b3b commit 01b6630

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

webview-ui/src/components/settings/providers/OpenAICompatible.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,17 @@ export const OpenAICompatible = ({
8787
// Add effect to update the parent component's state when local headers change
8888
useEffect(() => {
8989
const timer = setTimeout(() => {
90-
const headerObject = convertHeadersToObject(customHeaders)
91-
setApiConfigurationField("openAiHeaders", headerObject)
90+
const currentConfigHeaders = apiConfiguration?.openAiHeaders || {}
91+
const newHeadersObject = convertHeadersToObject(customHeaders)
92+
93+
// Only update if the processed object is different from the current config
94+
if (JSON.stringify(currentConfigHeaders) !== JSON.stringify(newHeadersObject)) {
95+
setApiConfigurationField("openAiHeaders", newHeadersObject)
96+
}
9297
}, 300)
9398

9499
return () => clearTimeout(timer)
95-
}, [customHeaders, setApiConfigurationField])
100+
}, [customHeaders, apiConfiguration?.openAiHeaders, setApiConfigurationField])
96101

97102
const handleInputChange = useCallback(
98103
<K extends keyof ProviderSettings, E>(

0 commit comments

Comments
 (0)