diff --git a/.changeset/thirty-bugs-admire.md b/.changeset/thirty-bugs-admire.md new file mode 100644 index 00000000..bd23eb26 --- /dev/null +++ b/.changeset/thirty-bugs-admire.md @@ -0,0 +1,5 @@ +--- +"claude-dev": patch +--- + +Fixed bug causing saved settings to get reset by changing providers diff --git a/webview-ui/src/components/chat/ChatTextArea.tsx b/webview-ui/src/components/chat/ChatTextArea.tsx index b84ed08c..19a068de 100644 --- a/webview-ui/src/components/chat/ChatTextArea.tsx +++ b/webview-ui/src/components/chat/ChatTextArea.tsx @@ -1378,6 +1378,7 @@ const ChatTextArea = forwardRef( apiErrorMessage={undefined} modelIdErrorMessage={undefined} isPopup={true} + saveImmediately={true} // Ensure popup saves immediately /> )} diff --git a/webview-ui/src/components/settings/ApiOptions.tsx b/webview-ui/src/components/settings/ApiOptions.tsx index b05f6625..771bc651 100644 --- a/webview-ui/src/components/settings/ApiOptions.tsx +++ b/webview-ui/src/components/settings/ApiOptions.tsx @@ -66,6 +66,7 @@ interface ApiOptionsProps { apiErrorMessage?: string modelIdErrorMessage?: string isPopup?: boolean + saveImmediately?: boolean // Add prop to control immediate saving } // This is necessary to ensure dropdown opens downward, important for when this is used in popup @@ -92,8 +93,16 @@ declare module "vscode" { } } -const ApiOptions = ({ showModelOptions, apiErrorMessage, modelIdErrorMessage, isPopup }: ApiOptionsProps) => { - const { apiConfiguration, setApiConfiguration, uriScheme } = useExtensionState() +const ApiOptions = ({ + showModelOptions, + apiErrorMessage, + modelIdErrorMessage, + isPopup, + saveImmediately = false, // Default to false +}: ApiOptionsProps) => { + // Use full context state for immediate save payload + const extensionState = useExtensionState() + const { apiConfiguration, setApiConfiguration, uriScheme } = extensionState const [ollamaModels, setOllamaModels] = useState([]) const [lmStudioModels, setLmStudioModels] = useState([]) const [vsCodeLmModels, setVsCodeLmModels] = useState([]) @@ -115,14 +124,15 @@ const ApiOptions = ({ showModelOptions, apiErrorMessage, modelIdErrorMessage, is [field]: newValue, }) - // If the field is the provider, save it immediately - // Necessary for favorite model selection to work without undoing provider changes - if (field === "apiProvider") { + // If the field is the provider AND saveImmediately is true, save it immediately using the full context state + if (saveImmediately && field === "apiProvider") { + // Use apiConfiguration from the full extensionState context to send the most complete data + const currentFullApiConfig = extensionState.apiConfiguration vscode.postMessage({ type: "apiConfiguration", apiConfiguration: { - ...apiConfiguration, - apiProvider: newValue, + ...currentFullApiConfig, // Send the most complete config available + apiProvider: newValue, // Override with the new provider }, }) } diff --git a/webview-ui/src/components/settings/SettingsView.tsx b/webview-ui/src/components/settings/SettingsView.tsx index 5e141f5e..81c02198 100644 --- a/webview-ui/src/components/settings/SettingsView.tsx +++ b/webview-ui/src/components/settings/SettingsView.tsx @@ -148,7 +148,7 @@ const SettingsView = ({ onDone }: SettingsViewProps) => {

Settings

- handleSubmit(false)}>Done + handleSubmit(false)}>Save
{/* Tabs container */}