mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-05 08:10:14 +00:00
Remove debug logging
This commit is contained in:
parent
303598f014
commit
616472f807
2 changed files with 8 additions and 198 deletions
|
|
@ -2,8 +2,6 @@ import { ExtensionContext } from "vscode"
|
|||
import { z, ZodError } from "zod"
|
||||
import deepEqual from "fast-deep-equal"
|
||||
|
||||
import { debugLog } from "../../utils/debug-log"
|
||||
|
||||
import {
|
||||
type ProviderSettingsWithId,
|
||||
providerSettingsWithIdSchema,
|
||||
|
|
@ -379,21 +377,12 @@ export class ProviderSettingsManager {
|
|||
return await this.lock(async () => {
|
||||
const providerProfiles = await this.load()
|
||||
|
||||
const configs = Object.entries(providerProfiles.apiConfigs).map(([name, apiConfig]) => ({
|
||||
return Object.entries(providerProfiles.apiConfigs).map(([name, apiConfig]) => ({
|
||||
name,
|
||||
id: apiConfig.id || "",
|
||||
apiProvider: apiConfig.apiProvider,
|
||||
modelId: this.cleanModelId(getModelId(apiConfig)),
|
||||
}))
|
||||
|
||||
// DEBUG: Log listed configs
|
||||
debugLog("[ProviderSettingsManager.listConfig]", {
|
||||
configCount: configs.length,
|
||||
configs: configs.map((c) => ({ name: c.name, id: c.id, provider: c.apiProvider })),
|
||||
modeApiConfigs: providerProfiles.modeApiConfigs,
|
||||
})
|
||||
|
||||
return configs
|
||||
})
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to list configs: ${error}`)
|
||||
|
|
@ -469,40 +458,16 @@ export class ProviderSettingsManager {
|
|||
public async activateProfile(
|
||||
params: { name: string } | { id: string },
|
||||
): Promise<ProviderSettingsWithId & { name: string }> {
|
||||
// DEBUG: Log entry point
|
||||
debugLog("[ProviderSettingsManager.activateProfile] START", { params })
|
||||
|
||||
const { name, ...providerSettings } = await this.getProfile(params)
|
||||
|
||||
// DEBUG: Log what was retrieved from getProfile
|
||||
debugLog("[ProviderSettingsManager.activateProfile] getProfile result", {
|
||||
name,
|
||||
id: providerSettings.id,
|
||||
apiProvider: providerSettings.apiProvider,
|
||||
hasSettings: Object.keys(providerSettings).length > 0,
|
||||
settingsKeys: Object.keys(providerSettings).filter(
|
||||
(k) => providerSettings[k as keyof typeof providerSettings] !== undefined,
|
||||
),
|
||||
})
|
||||
|
||||
try {
|
||||
return await this.lock(async () => {
|
||||
const providerProfiles = await this.load()
|
||||
providerProfiles.currentApiConfigName = name
|
||||
await this.store(providerProfiles)
|
||||
|
||||
debugLog("[ProviderSettingsManager.activateProfile] END - profile activated", {
|
||||
name,
|
||||
id: providerSettings.id,
|
||||
})
|
||||
|
||||
return { name, ...providerSettings }
|
||||
})
|
||||
} catch (error) {
|
||||
debugLog("[ProviderSettingsManager.activateProfile] ERROR", {
|
||||
params,
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
})
|
||||
throw new Error(`Failed to activate profile: ${error instanceof Error ? error.message : error}`)
|
||||
}
|
||||
}
|
||||
|
|
@ -571,27 +536,10 @@ export class ProviderSettingsManager {
|
|||
public async getModeConfigId(mode: Mode) {
|
||||
try {
|
||||
return await this.lock(async () => {
|
||||
const providerProfiles = await this.load()
|
||||
const configId = providerProfiles.modeApiConfigs?.[mode]
|
||||
|
||||
// DEBUG: Log mode config lookup
|
||||
debugLog("[ProviderSettingsManager.getModeConfigId]", {
|
||||
mode,
|
||||
configId,
|
||||
allModeApiConfigs: providerProfiles.modeApiConfigs,
|
||||
availableConfigIds: Object.entries(providerProfiles.apiConfigs).map(([name, c]) => ({
|
||||
name,
|
||||
id: c.id,
|
||||
})),
|
||||
})
|
||||
|
||||
return configId
|
||||
const { modeApiConfigs } = await this.load()
|
||||
return modeApiConfigs?.[mode]
|
||||
})
|
||||
} catch (error) {
|
||||
debugLog("[ProviderSettingsManager.getModeConfigId] ERROR", {
|
||||
mode,
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
})
|
||||
throw new Error(`Failed to get mode config: ${error}`)
|
||||
}
|
||||
}
|
||||
|
|
@ -662,15 +610,7 @@ export class ProviderSettingsManager {
|
|||
try {
|
||||
const content = await this.context.secrets.get(this.secretsKey)
|
||||
|
||||
// DEBUG: Log raw secrets content
|
||||
debugLog("[ProviderSettingsManager.load] secrets.get result", {
|
||||
secretsKey: this.secretsKey,
|
||||
hasContent: !!content,
|
||||
contentLength: content?.length ?? 0,
|
||||
})
|
||||
|
||||
if (!content) {
|
||||
debugLog("[ProviderSettingsManager.load] returning default profiles (no content found)")
|
||||
return this.defaultProviderProfiles
|
||||
}
|
||||
|
||||
|
|
@ -691,31 +631,12 @@ export class ProviderSettingsManager {
|
|||
{} as Record<string, ProviderSettingsWithId>,
|
||||
)
|
||||
|
||||
const result = {
|
||||
return {
|
||||
...providerProfiles,
|
||||
apiConfigs: Object.fromEntries(
|
||||
Object.entries(apiConfigs).filter(([_, apiConfig]) => apiConfig !== null),
|
||||
),
|
||||
}
|
||||
|
||||
// DEBUG: Log loaded profiles summary
|
||||
debugLog("[ProviderSettingsManager.load] loaded profiles", {
|
||||
currentApiConfigName: result.currentApiConfigName,
|
||||
apiConfigNames: Object.keys(result.apiConfigs),
|
||||
modeApiConfigs: result.modeApiConfigs,
|
||||
configDetails: Object.entries(result.apiConfigs).map(([name, config]) => ({
|
||||
name,
|
||||
id: config.id,
|
||||
apiProvider: config.apiProvider,
|
||||
hasApiKey: !!(
|
||||
(config as any)?.apiKey ||
|
||||
(config as any)?.openRouterApiKey ||
|
||||
(config as any)?.requestyApiKey
|
||||
),
|
||||
})),
|
||||
})
|
||||
|
||||
return result
|
||||
} catch (error) {
|
||||
if (error instanceof ZodError) {
|
||||
TelemetryService.instance.captureSchemaValidationError({
|
||||
|
|
@ -724,10 +645,6 @@ export class ProviderSettingsManager {
|
|||
})
|
||||
}
|
||||
|
||||
debugLog("[ProviderSettingsManager.load] ERROR", {
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
})
|
||||
|
||||
throw new Error(`Failed to read provider profiles from secrets: ${error}`)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@ import * as path from "path"
|
|||
import fs from "fs/promises"
|
||||
import EventEmitter from "events"
|
||||
|
||||
import { debugLog, DebugLogger } from "../../utils/debug-log"
|
||||
|
||||
import { Anthropic } from "@anthropic-ai/sdk"
|
||||
import delay from "delay"
|
||||
import axios from "axios"
|
||||
|
|
@ -916,21 +914,9 @@ export class ClineProvider
|
|||
if (hasActualSettings) {
|
||||
await this.activateProviderProfile({ name: profile.name })
|
||||
} else {
|
||||
debugLog(
|
||||
"[createTaskWithHistoryItem] SKIPPING profile activation - profile has no apiProvider",
|
||||
{
|
||||
savedConfigId,
|
||||
profileName: profile.name,
|
||||
},
|
||||
)
|
||||
// The task will continue with the current/default configuration.
|
||||
}
|
||||
} catch (error) {
|
||||
// Log the error but continue with task restoration.
|
||||
this.log(
|
||||
`Failed to restore API configuration for mode '${historyItem.mode}': ${
|
||||
error instanceof Error ? error.message : String(error)
|
||||
}. Continuing with default configuration.`,
|
||||
)
|
||||
// The task will continue with the current/default configuration.
|
||||
}
|
||||
}
|
||||
|
|
@ -1260,15 +1246,6 @@ export class ClineProvider
|
|||
* @param newMode The mode to switch to
|
||||
*/
|
||||
public async handleModeSwitch(newMode: Mode) {
|
||||
// DEBUG: Log entry point with current state
|
||||
const currentApiConfigName = this.getGlobalState("currentApiConfigName")
|
||||
const currentMode = this.getGlobalState("mode")
|
||||
debugLog("[handleModeSwitch] START", {
|
||||
newMode,
|
||||
currentMode,
|
||||
currentApiConfigName,
|
||||
})
|
||||
|
||||
const task = this.getCurrentTask()
|
||||
|
||||
if (task) {
|
||||
|
|
@ -1307,14 +1284,6 @@ export class ClineProvider
|
|||
const savedConfigId = await this.providerSettingsManager.getModeConfigId(newMode)
|
||||
const listApiConfig = await this.providerSettingsManager.listConfig()
|
||||
|
||||
// DEBUG: Log mode config lookup results
|
||||
debugLog("[handleModeSwitch] getModeConfigId result", {
|
||||
newMode,
|
||||
savedConfigId,
|
||||
listApiConfigCount: listApiConfig.length,
|
||||
listApiConfigNames: listApiConfig.map((c) => ({ name: c.name, id: c.id, provider: c.apiProvider })),
|
||||
})
|
||||
|
||||
// Update listApiConfigMeta first to ensure UI has latest data.
|
||||
await this.updateGlobalState("listApiConfigMeta", listApiConfig)
|
||||
|
||||
|
|
@ -1322,12 +1291,6 @@ export class ClineProvider
|
|||
if (savedConfigId) {
|
||||
const profile = listApiConfig.find(({ id }) => id === savedConfigId)
|
||||
|
||||
// DEBUG: Log profile activation attempt
|
||||
debugLog("[handleModeSwitch] activating saved config", {
|
||||
savedConfigId,
|
||||
foundProfile: profile ? { name: profile.name, id: profile.id, provider: profile.apiProvider } : null,
|
||||
})
|
||||
|
||||
if (profile?.name) {
|
||||
// Check if the profile has actual API configuration (not just an id).
|
||||
// In CLI mode, the ProviderSettingsManager may return empty default profiles
|
||||
|
|
@ -1341,61 +1304,24 @@ export class ClineProvider
|
|||
if (hasActualSettings) {
|
||||
await this.activateProviderProfile({ name: profile.name })
|
||||
} else {
|
||||
debugLog(
|
||||
"[handleModeSwitch] SKIPPING profile activation - profile has no apiProvider (CLI mode workaround)",
|
||||
{
|
||||
savedConfigId,
|
||||
profileName: profile.name,
|
||||
profileKeys: Object.keys(fullProfile).filter(
|
||||
(k) => fullProfile[k as keyof typeof fullProfile] !== undefined,
|
||||
),
|
||||
},
|
||||
)
|
||||
// The task will continue with the current/default configuration.
|
||||
}
|
||||
} else {
|
||||
debugLog("[handleModeSwitch] WARNING: savedConfigId exists but profile not found in listApiConfig", {
|
||||
savedConfigId,
|
||||
availableIds: listApiConfig.map((c) => c.id),
|
||||
})
|
||||
// The task will continue with the current/default configuration.
|
||||
}
|
||||
} else {
|
||||
// If no saved config for this mode, save current config as default.
|
||||
const currentApiConfigNameAfter = this.getGlobalState("currentApiConfigName")
|
||||
|
||||
// DEBUG: Log no saved config case
|
||||
debugLog("[handleModeSwitch] no saved config for mode, using current", {
|
||||
newMode,
|
||||
currentApiConfigNameAfter,
|
||||
})
|
||||
|
||||
if (currentApiConfigNameAfter) {
|
||||
const config = listApiConfig.find((c) => c.name === currentApiConfigNameAfter)
|
||||
|
||||
if (config?.id) {
|
||||
debugLog("[handleModeSwitch] saving current config as mode default", {
|
||||
newMode,
|
||||
configId: config.id,
|
||||
configName: config.name,
|
||||
})
|
||||
await this.providerSettingsManager.setModeConfig(newMode, config.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DEBUG: Log final state after mode switch
|
||||
const finalState = await this.getState()
|
||||
debugLog("[handleModeSwitch] END - final state", {
|
||||
newMode,
|
||||
finalApiProvider: finalState.apiConfiguration?.apiProvider,
|
||||
finalApiConfigName: finalState.currentApiConfigName,
|
||||
// Check various provider API keys to see if any are set
|
||||
hasAnyApiKey: !!(
|
||||
(finalState.apiConfiguration as any)?.apiKey ||
|
||||
(finalState.apiConfiguration as any)?.openRouterApiKey ||
|
||||
(finalState.apiConfiguration as any)?.requestyApiKey
|
||||
),
|
||||
})
|
||||
|
||||
await this.postStateToWebview()
|
||||
}
|
||||
|
||||
|
|
@ -1535,27 +1461,8 @@ export class ClineProvider
|
|||
}
|
||||
|
||||
async activateProviderProfile(args: { name: string } | { id: string }) {
|
||||
// DEBUG: Log entry point
|
||||
debugLog("[activateProviderProfile] START", { args })
|
||||
|
||||
const { name, id, ...providerSettings } = await this.providerSettingsManager.activateProfile(args)
|
||||
|
||||
// DEBUG: Log what was returned from activateProfile
|
||||
debugLog("[activateProviderProfile] activateProfile result", {
|
||||
name,
|
||||
id,
|
||||
apiProvider: providerSettings.apiProvider,
|
||||
hasApiKey: !!(
|
||||
(providerSettings as any)?.apiKey ||
|
||||
(providerSettings as any)?.openRouterApiKey ||
|
||||
(providerSettings as any)?.requestyApiKey
|
||||
),
|
||||
// Log all keys that have values (but not the values themselves for security)
|
||||
settingsKeys: Object.keys(providerSettings).filter(
|
||||
(k) => providerSettings[k as keyof typeof providerSettings] !== undefined,
|
||||
),
|
||||
})
|
||||
|
||||
// See `upsertProviderProfile` for a description of what this is doing.
|
||||
await Promise.all([
|
||||
this.contextProxy.setValue("listApiConfigMeta", await this.providerSettingsManager.listConfig()),
|
||||
|
|
@ -1565,29 +1472,15 @@ export class ClineProvider
|
|||
|
||||
const { mode } = await this.getState()
|
||||
|
||||
// DEBUG: Log mode config update
|
||||
debugLog("[activateProviderProfile] setting mode config", { mode, id })
|
||||
|
||||
if (id) {
|
||||
await this.providerSettingsManager.setModeConfig(mode, id)
|
||||
}
|
||||
|
||||
// Change the provider for the current task.
|
||||
this.updateTaskApiHandlerIfNeeded(providerSettings, { forceRebuild: true })
|
||||
|
||||
await this.postStateToWebview()
|
||||
|
||||
// DEBUG: Log final state
|
||||
const finalState = this.contextProxy.getProviderSettings()
|
||||
debugLog("[activateProviderProfile] END - final provider settings", {
|
||||
name,
|
||||
apiProvider: finalState.apiProvider,
|
||||
hasApiKey: !!(
|
||||
(finalState as any)?.apiKey ||
|
||||
(finalState as any)?.openRouterApiKey ||
|
||||
(finalState as any)?.requestyApiKey
|
||||
),
|
||||
})
|
||||
|
||||
if (providerSettings.apiProvider) {
|
||||
this.emit(RooCodeEventName.ProviderProfileChanged, { name, provider: providerSettings.apiProvider })
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue