-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Cloud: fix provider syncing #7603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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<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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this intentional? The method removes and then immediately re-adds the "settings-updated" event listener (lines 321-322). This could lead to duplicate listeners if |
||
} | ||
} 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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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)}`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The error is caught and logged, but should the extension take any recovery action here? If cloud profile sync is critical for certain features, users might want to know if it fails during startup. Consider whether a user notification would be appropriate for this failure case. |
||
) | ||
} | ||
|
||
// Finish initializing the provider. | ||
TelemetryService.instance.setProvider(provider) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider enhancing this comment to explain why this deferred initialization pattern is necessary. For example: 'Initialize cloud profile synchronization when CloudService is ready. This method is called externally after CloudService has been initialized to handle the race condition where ClineProvider may be created before CloudService.'