| 39 | }) |
| 40 | |
| 41 | export class ContextProxy { |
| 42 | private readonly originalContext: vscode.ExtensionContext |
| 43 | |
| 44 | private stateCache: GlobalState |
| 45 | private secretCache: SecretState |
| 46 | private _isInitialized = false |
| 47 | |
| 48 | constructor(context: vscode.ExtensionContext) { |
| 49 | this.originalContext = context |
| 50 | this.stateCache = {} |
| 51 | this.secretCache = {} |
| 52 | this._isInitialized = false |
| 53 | } |
| 54 | |
| 55 | public get isInitialized() { |
| 56 | return this._isInitialized |
| 57 | } |
| 58 | |
| 59 | public async initialize() { |
| 60 | for (const key of GLOBAL_STATE_KEYS) { |
| 61 | try { |
| 62 | // Revert to original assignment |
| 63 | this.stateCache[key] = this.originalContext.globalState.get(key) |
| 64 | } catch (error) { |
| 65 | logger.error(`Error loading global ${key}: ${error instanceof Error ? error.message : String(error)}`) |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | const promises = [ |
| 70 | ...SECRET_STATE_KEYS.map(async (key) => { |
| 71 | try { |
| 72 | this.secretCache[key] = await this.originalContext.secrets.get(key) |
| 73 | } catch (error) { |
| 74 | logger.error( |
| 75 | `Error loading secret ${key}: ${error instanceof Error ? error.message : String(error)}`, |
| 76 | ) |
| 77 | } |
| 78 | }), |
| 79 | ...GLOBAL_SECRET_KEYS.map(async (key) => { |
| 80 | try { |
| 81 | this.secretCache[key] = await this.originalContext.secrets.get(key) |
| 82 | } catch (error) { |
| 83 | logger.error( |
| 84 | `Error loading global secret ${key}: ${error instanceof Error ? error.message : String(error)}`, |
| 85 | ) |
| 86 | } |
| 87 | }), |
| 88 | ] |
| 89 | |
| 90 | await Promise.all(promises) |
| 91 | |
| 92 | // Migration: Check for old nested image generation settings and migrate them |
| 93 | await this.migrateImageGenerationSettings() |
| 94 | |
| 95 | // Migration: Downgrade legacy Roo Code Router state before generic sanitization. |
| 96 | await this.migrateLegacyRooApiProvider() |
| 97 | |
| 98 | // Migration: Sanitize invalid/removed API providers |
nothing calls this directly
no outgoing calls
no test coverage detected