From 4c820db2319dfacba8b26897618697c4e613b51f Mon Sep 17 00:00:00 2001 From: celestial-vault <58194240+celestial-vault@users.noreply.github.com> Date: Thu, 2 Oct 2025 14:26:47 -0700 Subject: [PATCH] do not initialize duplicate statemanager in migration; use vscode api directly (#6614) --- src/core/storage/state-migrations.ts | 97 +++++++++++++++++----------- 1 file changed, 60 insertions(+), 37 deletions(-) diff --git a/src/core/storage/state-migrations.ts b/src/core/storage/state-migrations.ts index 61ad69b7..53e080e5 100644 --- a/src/core/storage/state-migrations.ts +++ b/src/core/storage/state-migrations.ts @@ -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)