Cloud: fix provider syncing (#7603)

ClineProvider creation was moved before CloudService which broke
the old way of doing things.
This commit is contained in:
John Richmond 2025-09-02 15:18:21 -07:00 committed by Shawn
parent 0eb97d0e21
commit a0e13fe388
2 changed files with 35 additions and 3 deletions

View file

@ -213,9 +213,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")
}
}
/**
@ -305,6 +309,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<void> {
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

View file

@ -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)