Skip to content

Commit b801673

Browse files
jrhannesrudolph
authored andcommitted
Cloud: fix provider syncing (#7603)
ClineProvider creation was moved before CloudService which broke the old way of doing things.
1 parent a840116 commit b801673

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

src/core/webview/ClineProvider.ts

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

src/extension.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,15 @@ export async function activate(context: vscode.ExtensionContext) {
231231
// Add to subscriptions for proper cleanup on deactivate.
232232
context.subscriptions.push(cloudService)
233233

234+
// Trigger initial cloud profile sync now that CloudService is ready
235+
try {
236+
await provider.initializeCloudProfileSyncWhenReady()
237+
} catch (error) {
238+
outputChannel.appendLine(
239+
`[CloudService] Failed to initialize cloud profile sync: ${error instanceof Error ? error.message : String(error)}`,
240+
)
241+
}
242+
234243
// Finish initializing the provider.
235244
TelemetryService.instance.setProvider(provider)
236245

0 commit comments

Comments
 (0)