diff --git a/src/core/webview/ClineProvider.ts b/src/core/webview/ClineProvider.ts index a8d64d6600..b6a1ae3cd4 100644 --- a/src/core/webview/ClineProvider.ts +++ b/src/core/webview/ClineProvider.ts @@ -211,9 +211,13 @@ export class ClineProvider } // Initialize Roo Code Cloud profile sync. - this.initializeCloudProfileSync().catch((error) => { - this.log(`Failed to initialize cloud profile sync: ${error}`) - }) + if (CloudService.hasInstance()) { + this.initializeCloudProfileSync().catch((error) => { + this.log(`Failed to initialize cloud profile sync: ${error}`) + }) + } else { + this.log("CloudService not ready, deferring cloud profile sync") + } } /** @@ -303,6 +307,25 @@ export class ClineProvider } } + /** + * Initialize cloud profile synchronization when CloudService is ready + * This method is called externally after CloudService has been initialized + */ + public async initializeCloudProfileSyncWhenReady(): Promise { + try { + if (CloudService.hasInstance() && CloudService.instance.isAuthenticated()) { + await this.syncCloudProfiles() + } + + if (CloudService.hasInstance()) { + CloudService.instance.off("settings-updated", this.handleCloudSettingsUpdate) + CloudService.instance.on("settings-updated", this.handleCloudSettingsUpdate) + } + } catch (error) { + this.log(`Failed to initialize cloud profile sync when ready: ${error}`) + } + } + // Adds a new Task instance to clineStack, marking the start of a new task. // The instance is pushed to the top of the stack (LIFO order). // When the task is completed, the top instance is removed, reactivating the diff --git a/src/extension.ts b/src/extension.ts index 8cb739922e..dec9b8a80d 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -231,6 +231,15 @@ export async function activate(context: vscode.ExtensionContext) { // Add to subscriptions for proper cleanup on deactivate. context.subscriptions.push(cloudService) + // Trigger initial cloud profile sync now that CloudService is ready + try { + await provider.initializeCloudProfileSyncWhenReady() + } catch (error) { + outputChannel.appendLine( + `[CloudService] Failed to initialize cloud profile sync: ${error instanceof Error ? error.message : String(error)}`, + ) + } + // Finish initializing the provider. TelemetryService.instance.setProvider(provider)