Skip to content

Commit 0f994fc

Browse files
authored
Fix settings dirty check (RooCodeInc#5779)
1 parent 8c8888a commit 0f994fc

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

webview-ui/src/components/settings/ApiOptions.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,10 @@ const ApiOptions = ({
167167

168168
// Update `apiModelId` whenever `selectedModelId` changes.
169169
useEffect(() => {
170-
if (selectedModelId) {
170+
if (selectedModelId && apiConfiguration.apiModelId !== selectedModelId) {
171171
setApiConfigurationField("apiModelId", selectedModelId)
172172
}
173-
}, [selectedModelId, setApiConfigurationField])
173+
}, [selectedModelId, setApiConfigurationField, apiConfiguration.apiModelId])
174174

175175
// Debounced refresh model updates, only executed 250ms after the user
176176
// stops typing.

webview-ui/src/components/settings/SettingsView.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,15 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
218218
return prevState
219219
}
220220

221-
setChangeDetected(true)
221+
const previousValue = prevState.apiConfiguration?.[field]
222+
223+
// Don't treat initial sync from undefined to a defined value as a user change
224+
// This prevents the dirty state when the component initializes and auto-syncs the model ID
225+
const isInitialSync = previousValue === undefined && value !== undefined
226+
227+
if (!isInitialSync) {
228+
setChangeDetected(true)
229+
}
222230
return { ...prevState, apiConfiguration: { ...prevState.apiConfiguration, [field]: value } }
223231
})
224232
},

0 commit comments

Comments
 (0)