Refactor planActSeparateModelSetting initial value implementation

This commit is contained in:
Saoud Rizwan committed 2025-03-09 18:47:42 -07:00
1 parent eda2a60a69
commit 07cf5cddad
1 file changed
+13 -14
+13 -14
View File
@@ -139,19 +139,6 @@ export class ClineProvider implements vscode.WebviewViewProvider {
cleanupLegacyCheckpoints(this.context.globalStorageUri.fsPath, this.outputChannel).catch((error) => {
console.error("Failed to cleanup legacy checkpoints:", error)
})
// Set defaults for new users
;(async () => {
const existingPlanActSeparateModelsSetting = await this.getGlobalState("planActSeparateModelsSetting")
// initial state may be undefined or empty string, so we check for existence of expected values
if (existingPlanActSeparateModelsSetting !== true && existingPlanActSeparateModelsSetting !== false) {
// If api provider is not set, it's a new user. In order to get past the welcome screen, the user needs to choose an api provider and api key (logging into cline sets provider to cline). This is a good opportunity to set values for NEW users that we don't want to modify defaults for existing users. For example, existing users may already be using model switching between plan/act, but new users shouldn't be opted in to this behavior by default.
const apiProvider = await this.getGlobalState("apiProvider")
if (!apiProvider) {
await this.updateGlobalState("planActSeparateModelsSetting", false)
}
}
})()
}
/*
@@ -2073,10 +2060,22 @@ Here is the project's README to help you get started:\n\n${mcpDetails.readmeCont
const mcpMarketplaceEnabled = vscode.workspace.getConfiguration("cline").get<boolean>("mcpMarketplace.enabled", true)
// Plan/Act separate models setting is a boolean indicating whether the user wants to use different models for plan and act. Existing users expect this to be enabled, while we want new users to opt in to this being disabled by default.
// On win11 state sometimes initializes as empty string instead of undefined
let planActSeparateModelsSetting: boolean | undefined = undefined
if (planActSeparateModelsSettingRaw === true || planActSeparateModelsSettingRaw === false) {
planActSeparateModelsSetting = planActSeparateModelsSettingRaw
} else {
// default to true for existing users
if (storedApiProvider) {
planActSeparateModelsSetting = true
} else {
// default to false for new users
planActSeparateModelsSetting = false
}
// this is a special case where it's a new state, but we want it to default to different values for existing and new users.
// persist so next time state is retrieved it's set to the correct value.
await this.updateGlobalState("planActSeparateModelsSetting", planActSeparateModelsSetting)
}
return {
@@ -2142,7 +2141,7 @@ Here is the project's README to help you get started:\n\n${mcpDetails.readmeCont
previousModeThinkingBudgetTokens,
mcpMarketplaceEnabled,
telemetrySetting: telemetrySetting || "unset",
planActSeparateModelsSetting: planActSeparateModelsSetting ?? true,
planActSeparateModelsSetting,
}
}