diff --git a/.changeset/sharp-colts-add.md b/.changeset/sharp-colts-add.md new file mode 100644 index 0000000000..f424417967 --- /dev/null +++ b/.changeset/sharp-colts-add.md @@ -0,0 +1,5 @@ +--- +"kilo-code": patch +--- + +Fix wrong model after login (#213) diff --git a/webview-ui/src/components/settings/SettingsView.tsx b/webview-ui/src/components/settings/SettingsView.tsx index 088f90a8dd..5f2cbe5107 100644 --- a/webview-ui/src/components/settings/SettingsView.tsx +++ b/webview-ui/src/components/settings/SettingsView.tsx @@ -172,16 +172,22 @@ const SettingsView = forwardRef(({ onDone, o // kilocode_change start // Temporary way of making sure that the Settings view updates its local state properly when receiving // api keys from providers that support url callbacks. This whole Settings View needs proper with this local state thing later + const { kilocodeToken, openRouterApiKey, glamaApiKey, requestyApiKey } = extensionState.apiConfiguration ?? {} useEffect(() => { - setCachedState((prevCachedState) => ({ ...prevCachedState, ...extensionState })) - setChangeDetected(false) + setCachedState((prevCachedState) => ({ + ...prevCachedState, + apiConfiguration: { + ...prevCachedState.apiConfiguration, + // Only set specific tokens/keys instead of spreading the entire + // `prevCachedState.apiConfiguration` since it may contain unsaved changes + kilocodeToken, + openRouterApiKey, + glamaApiKey, + requestyApiKey, + }, + })) // eslint-disable-next-line react-hooks/exhaustive-deps - }, [ - extensionState.apiConfiguration?.kilocodeToken, - extensionState.apiConfiguration?.openRouterApiKey, - extensionState.apiConfiguration?.glamaApiKey, - extensionState.apiConfiguration?.requestyApiKey, - ]) + }, [kilocodeToken, openRouterApiKey, glamaApiKey, requestyApiKey]) useEffect(() => { // Only update if we're not already detecting changes @@ -315,7 +321,7 @@ const SettingsView = forwardRef(({ onDone, o if (confirm) { setCachedState(extensionState) setChangeDetected(false) - setTimeout(() => confirmDialogHandler.current?.(), 0) + confirmDialogHandler.current?.() } }, [setCachedState, setChangeDetected, extensionState],