@@ -213,9 +213,13 @@ export class ClineProvider
213213 }
214214
215215 // Initialize Roo Code Cloud profile sync.
216- this . initializeCloudProfileSync ( ) . catch ( ( error ) => {
217- this . log ( `Failed to initialize cloud profile sync: ${ error } ` )
218- } )
216+ if ( CloudService . hasInstance ( ) ) {
217+ this . initializeCloudProfileSync ( ) . catch ( ( error ) => {
218+ this . log ( `Failed to initialize cloud profile sync: ${ error } ` )
219+ } )
220+ } else {
221+ this . log ( "CloudService not ready, deferring cloud profile sync" )
222+ }
219223 }
220224
221225 /**
@@ -305,6 +309,25 @@ export class ClineProvider
305309 }
306310 }
307311
312+ /**
313+ * Initialize cloud profile synchronization when CloudService is ready
314+ * This method is called externally after CloudService has been initialized
315+ */
316+ public async initializeCloudProfileSyncWhenReady ( ) : Promise < void > {
317+ try {
318+ if ( CloudService . hasInstance ( ) && CloudService . instance . isAuthenticated ( ) ) {
319+ await this . syncCloudProfiles ( )
320+ }
321+
322+ if ( CloudService . hasInstance ( ) ) {
323+ CloudService . instance . off ( "settings-updated" , this . handleCloudSettingsUpdate )
324+ CloudService . instance . on ( "settings-updated" , this . handleCloudSettingsUpdate )
325+ }
326+ } catch ( error ) {
327+ this . log ( `Failed to initialize cloud profile sync when ready: ${ error } ` )
328+ }
329+ }
330+
308331 // Adds a new Task instance to clineStack, marking the start of a new task.
309332 // The instance is pushed to the top of the stack (LIFO order).
310333 // When the task is completed, the top instance is removed, reactivating the
0 commit comments