Skip to content

Commit cff8a23

Browse files
ENG-464 Fix Settings state issue with API provider reseting other settings. (RooCodeInc#3004)
* added a a difference between react state saves and core state saves so that the provider settings dont reset other set settings * added changeset * Update .changeset/thirty-bugs-admire.md Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * changed button text to say Save --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
1 parent e70264a commit cff8a23

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

.changeset/thirty-bugs-admire.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"claude-dev": patch
3+
---
4+
5+
Fixed bug causing saved settings to get reset by changing providers

webview-ui/src/components/chat/ChatTextArea.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,6 +1378,7 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
13781378
apiErrorMessage={undefined}
13791379
modelIdErrorMessage={undefined}
13801380
isPopup={true}
1381+
saveImmediately={true} // Ensure popup saves immediately
13811382
/>
13821383
</ModelSelectorTooltip>
13831384
)}

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

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ interface ApiOptionsProps {
6666
apiErrorMessage?: string
6767
modelIdErrorMessage?: string
6868
isPopup?: boolean
69+
saveImmediately?: boolean // Add prop to control immediate saving
6970
}
7071

7172
// This is necessary to ensure dropdown opens downward, important for when this is used in popup
@@ -92,8 +93,16 @@ declare module "vscode" {
9293
}
9394
}
9495

95-
const ApiOptions = ({ showModelOptions, apiErrorMessage, modelIdErrorMessage, isPopup }: ApiOptionsProps) => {
96-
const { apiConfiguration, setApiConfiguration, uriScheme } = useExtensionState()
96+
const ApiOptions = ({
97+
showModelOptions,
98+
apiErrorMessage,
99+
modelIdErrorMessage,
100+
isPopup,
101+
saveImmediately = false, // Default to false
102+
}: ApiOptionsProps) => {
103+
// Use full context state for immediate save payload
104+
const extensionState = useExtensionState()
105+
const { apiConfiguration, setApiConfiguration, uriScheme } = extensionState
97106
const [ollamaModels, setOllamaModels] = useState<string[]>([])
98107
const [lmStudioModels, setLmStudioModels] = useState<string[]>([])
99108
const [vsCodeLmModels, setVsCodeLmModels] = useState<vscodemodels.LanguageModelChatSelector[]>([])
@@ -115,14 +124,15 @@ const ApiOptions = ({ showModelOptions, apiErrorMessage, modelIdErrorMessage, is
115124
[field]: newValue,
116125
})
117126

118-
// If the field is the provider, save it immediately
119-
// Necessary for favorite model selection to work without undoing provider changes
120-
if (field === "apiProvider") {
127+
// If the field is the provider AND saveImmediately is true, save it immediately using the full context state
128+
if (saveImmediately && field === "apiProvider") {
129+
// Use apiConfiguration from the full extensionState context to send the most complete data
130+
const currentFullApiConfig = extensionState.apiConfiguration
121131
vscode.postMessage({
122132
type: "apiConfiguration",
123133
apiConfiguration: {
124-
...apiConfiguration,
125-
apiProvider: newValue,
134+
...currentFullApiConfig, // Send the most complete config available
135+
apiProvider: newValue, // Override with the new provider
126136
},
127137
})
128138
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ const SettingsView = ({ onDone }: SettingsViewProps) => {
148148
<div className="fixed top-0 left-0 right-0 bottom-0 pt-[10px] pr-0 pb-0 pl-5 flex flex-col overflow-hidden">
149149
<div className="flex justify-between items-center mb-[13px] pr-[17px]">
150150
<h3 className="text-[var(--vscode-foreground)] m-0">Settings</h3>
151-
<VSCodeButton onClick={() => handleSubmit(false)}>Done</VSCodeButton>
151+
<VSCodeButton onClick={() => handleSubmit(false)}>Save</VSCodeButton>
152152
</div>
153153
<div className="grow overflow-y-scroll pr-2 flex flex-col">
154154
{/* Tabs container */}

0 commit comments

Comments
 (0)