Skip to content

Commit 4c820db

Browse files
do not initialize duplicate statemanager in migration; use vscode api directly (cline#6614)
1 parent afa3eed commit 4c820db

1 file changed

Lines changed: 61 additions & 38 deletions

File tree

‎src/core/storage/state-migrations.ts‎

Lines changed: 61 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import path from "path"
33
import * as vscode from "vscode"
44
import { HistoryItem } from "@/shared/HistoryItem"
55
import { ensureRulesDirectoryExists, readTaskHistoryFromState, writeTaskHistoryToState } from "./disk"
6-
import { StateManager } from "./StateManager"
76

87
export async function migrateWorkspaceToGlobalStorage(context: vscode.ExtensionContext) {
98
// Keys to migrate from workspace storage back to global storage
@@ -566,44 +565,68 @@ export async function migrateWelcomeViewCompleted(context: vscode.ExtensionConte
566565
if (welcomeViewCompleted === undefined) {
567566
console.log("Migrating welcomeViewCompleted setting...")
568567

569-
// Get all extension state to check for existing API keys
570-
const stateManager = new StateManager(context)
571-
await stateManager.initialize()
572-
const config = stateManager.getApiConfiguration()
573-
574-
// This is the original logic used for checking is the welcome view should be shown
568+
// Fetch API keys directly from secrets
569+
const apiKey = await context.secrets.get("apiKey")
570+
const openRouterApiKey = await context.secrets.get("openRouterApiKey")
571+
const clineAccountId = await context.secrets.get("clineAccountId")
572+
const openAiApiKey = await context.secrets.get("openAiApiKey")
573+
const ollamaApiKey = await context.secrets.get("ollamaApiKey")
574+
const liteLlmApiKey = await context.secrets.get("liteLlmApiKey")
575+
const geminiApiKey = await context.secrets.get("geminiApiKey")
576+
const openAiNativeApiKey = await context.secrets.get("openAiNativeApiKey")
577+
const deepSeekApiKey = await context.secrets.get("deepSeekApiKey")
578+
const requestyApiKey = await context.secrets.get("requestyApiKey")
579+
const togetherApiKey = await context.secrets.get("togetherApiKey")
580+
const qwenApiKey = await context.secrets.get("qwenApiKey")
581+
const doubaoApiKey = await context.secrets.get("doubaoApiKey")
582+
const mistralApiKey = await context.secrets.get("mistralApiKey")
583+
const asksageApiKey = await context.secrets.get("asksageApiKey")
584+
const xaiApiKey = await context.secrets.get("xaiApiKey")
585+
const sambanovaApiKey = await context.secrets.get("sambanovaApiKey")
586+
const sapAiCoreClientId = await context.secrets.get("sapAiCoreClientId")
587+
const difyApiKey = await context.secrets.get("difyApiKey")
588+
589+
// Fetch configuration values from global state
590+
const awsRegion = context.globalState.get("awsRegion")
591+
const vertexProjectId = context.globalState.get("vertexProjectId")
592+
const planModeOllamaModelId = context.globalState.get("planModeOllamaModelId")
593+
const planModeLmStudioModelId = context.globalState.get("planModeLmStudioModelId")
594+
const actModeOllamaModelId = context.globalState.get("actModeOllamaModelId")
595+
const actModeLmStudioModelId = context.globalState.get("actModeLmStudioModelId")
596+
const planModeVsCodeLmModelSelector = context.globalState.get("planModeVsCodeLmModelSelector")
597+
const actModeVsCodeLmModelSelector = context.globalState.get("actModeVsCodeLmModelSelector")
598+
599+
// This is the original logic used for checking if the welcome view should be shown
575600
// It was located in the ExtensionStateContextProvider
576-
const hasKey = config
577-
? [
578-
config.apiKey,
579-
config.openRouterApiKey,
580-
config.awsRegion,
581-
config.vertexProjectId,
582-
config.openAiApiKey,
583-
config.ollamaApiKey,
584-
config.planModeOllamaModelId,
585-
config.planModeLmStudioModelId,
586-
config.actModeOllamaModelId,
587-
config.actModeLmStudioModelId,
588-
config.liteLlmApiKey,
589-
config.geminiApiKey,
590-
config.openAiNativeApiKey,
591-
config.deepSeekApiKey,
592-
config.requestyApiKey,
593-
config.togetherApiKey,
594-
config.qwenApiKey,
595-
config.doubaoApiKey,
596-
config.mistralApiKey,
597-
config.planModeVsCodeLmModelSelector,
598-
config.actModeVsCodeLmModelSelector,
599-
config.clineAccountId,
600-
config.asksageApiKey,
601-
config.xaiApiKey,
602-
config.sambanovaApiKey,
603-
config.sapAiCoreClientId,
604-
config.difyApiKey,
605-
].some((key) => key !== undefined)
606-
: false
601+
const hasKey = [
602+
apiKey,
603+
openRouterApiKey,
604+
awsRegion,
605+
vertexProjectId,
606+
openAiApiKey,
607+
ollamaApiKey,
608+
planModeOllamaModelId,
609+
planModeLmStudioModelId,
610+
actModeOllamaModelId,
611+
actModeLmStudioModelId,
612+
liteLlmApiKey,
613+
geminiApiKey,
614+
openAiNativeApiKey,
615+
deepSeekApiKey,
616+
requestyApiKey,
617+
togetherApiKey,
618+
qwenApiKey,
619+
doubaoApiKey,
620+
mistralApiKey,
621+
planModeVsCodeLmModelSelector,
622+
actModeVsCodeLmModelSelector,
623+
clineAccountId,
624+
asksageApiKey,
625+
xaiApiKey,
626+
sambanovaApiKey,
627+
sapAiCoreClientId,
628+
difyApiKey,
629+
].some((key) => key !== undefined)
607630

608631
// Set welcomeViewCompleted based on whether user has keys
609632
await context.globalState.update("welcomeViewCompleted", hasKey)

0 commit comments

Comments
 (0)