do not initialize duplicate statemanager in migration; use vscode api directly (#6614)

This commit is contained in:
celestial-vault authored and GitHub committed 2025-10-02 14:26:47 -07:00
1 parent afa3eed7eb
commit 4c820db231
1 file changed
+60 -37
+60 -37
View File
@@ -3,7 +3,6 @@ import path from "path"
import * as vscode from "vscode"
import { HistoryItem } from "@/shared/HistoryItem"
import { ensureRulesDirectoryExists, readTaskHistoryFromState, writeTaskHistoryToState } from "./disk"
import { StateManager } from "./StateManager"
export async function migrateWorkspaceToGlobalStorage(context: vscode.ExtensionContext) {
// Keys to migrate from workspace storage back to global storage
@@ -566,44 +565,68 @@ export async function migrateWelcomeViewCompleted(context: vscode.ExtensionConte
if (welcomeViewCompleted === undefined) {
console.log("Migrating welcomeViewCompleted setting...")
// Get all extension state to check for existing API keys
const stateManager = new StateManager(context)
await stateManager.initialize()
const config = stateManager.getApiConfiguration()
// Fetch API keys directly from secrets
const apiKey = await context.secrets.get("apiKey")
const openRouterApiKey = await context.secrets.get("openRouterApiKey")
const clineAccountId = await context.secrets.get("clineAccountId")
const openAiApiKey = await context.secrets.get("openAiApiKey")
const ollamaApiKey = await context.secrets.get("ollamaApiKey")
const liteLlmApiKey = await context.secrets.get("liteLlmApiKey")
const geminiApiKey = await context.secrets.get("geminiApiKey")
const openAiNativeApiKey = await context.secrets.get("openAiNativeApiKey")
const deepSeekApiKey = await context.secrets.get("deepSeekApiKey")
const requestyApiKey = await context.secrets.get("requestyApiKey")
const togetherApiKey = await context.secrets.get("togetherApiKey")
const qwenApiKey = await context.secrets.get("qwenApiKey")
const doubaoApiKey = await context.secrets.get("doubaoApiKey")
const mistralApiKey = await context.secrets.get("mistralApiKey")
const asksageApiKey = await context.secrets.get("asksageApiKey")
const xaiApiKey = await context.secrets.get("xaiApiKey")
const sambanovaApiKey = await context.secrets.get("sambanovaApiKey")
const sapAiCoreClientId = await context.secrets.get("sapAiCoreClientId")
const difyApiKey = await context.secrets.get("difyApiKey")
// This is the original logic used for checking is the welcome view should be shown
// Fetch configuration values from global state
const awsRegion = context.globalState.get("awsRegion")
const vertexProjectId = context.globalState.get("vertexProjectId")
const planModeOllamaModelId = context.globalState.get("planModeOllamaModelId")
const planModeLmStudioModelId = context.globalState.get("planModeLmStudioModelId")
const actModeOllamaModelId = context.globalState.get("actModeOllamaModelId")
const actModeLmStudioModelId = context.globalState.get("actModeLmStudioModelId")
const planModeVsCodeLmModelSelector = context.globalState.get("planModeVsCodeLmModelSelector")
const actModeVsCodeLmModelSelector = context.globalState.get("actModeVsCodeLmModelSelector")
// This is the original logic used for checking if the welcome view should be shown
// It was located in the ExtensionStateContextProvider
const hasKey = config
? [
config.apiKey,
config.openRouterApiKey,
config.awsRegion,
config.vertexProjectId,
config.openAiApiKey,
config.ollamaApiKey,
config.planModeOllamaModelId,
config.planModeLmStudioModelId,
config.actModeOllamaModelId,
config.actModeLmStudioModelId,
config.liteLlmApiKey,
config.geminiApiKey,
config.openAiNativeApiKey,
config.deepSeekApiKey,
config.requestyApiKey,
config.togetherApiKey,
config.qwenApiKey,
config.doubaoApiKey,
config.mistralApiKey,
config.planModeVsCodeLmModelSelector,
config.actModeVsCodeLmModelSelector,
config.clineAccountId,
config.asksageApiKey,
config.xaiApiKey,
config.sambanovaApiKey,
config.sapAiCoreClientId,
config.difyApiKey,
].some((key) => key !== undefined)
: false
const hasKey = [
apiKey,
openRouterApiKey,
awsRegion,
vertexProjectId,
openAiApiKey,
ollamaApiKey,
planModeOllamaModelId,
planModeLmStudioModelId,
actModeOllamaModelId,
actModeLmStudioModelId,
liteLlmApiKey,
geminiApiKey,
openAiNativeApiKey,
deepSeekApiKey,
requestyApiKey,
togetherApiKey,
qwenApiKey,
doubaoApiKey,
mistralApiKey,
planModeVsCodeLmModelSelector,
actModeVsCodeLmModelSelector,
clineAccountId,
asksageApiKey,
xaiApiKey,
sambanovaApiKey,
sapAiCoreClientId,
difyApiKey,
].some((key) => key !== undefined)
// Set welcomeViewCompleted based on whether user has keys
await context.globalState.update("welcomeViewCompleted", hasKey)