From 01b66303288d12df147bc5d6ce090a200ca7674b Mon Sep 17 00:00:00 2001 From: Roo Code Date: Thu, 24 Jul 2025 06:03:47 +0000 Subject: [PATCH] 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 --- .../settings/providers/OpenAICompatible.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/webview-ui/src/components/settings/providers/OpenAICompatible.tsx b/webview-ui/src/components/settings/providers/OpenAICompatible.tsx index 736b0253c4..76e2183531 100644 --- a/webview-ui/src/components/settings/providers/OpenAICompatible.tsx +++ b/webview-ui/src/components/settings/providers/OpenAICompatible.tsx @@ -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( (