@@ -94,27 +94,60 @@ export async function activate(context: vscode.ExtensionContext) {
9494
9595 const contextProxy = await ContextProxy . getInstance ( context )
9696
97- // Initialize code index managers for all workspace folders
97+ // Initialize code index managers for all workspace folders.
9898 const codeIndexManagers : CodeIndexManager [ ] = [ ]
99+
99100 if ( vscode . workspace . workspaceFolders ) {
100101 for ( const folder of vscode . workspace . workspaceFolders ) {
101102 const manager = CodeIndexManager . getInstance ( context , folder . uri . fsPath )
103+
102104 if ( manager ) {
103105 codeIndexManagers . push ( manager )
106+
104107 try {
105108 await manager . initialize ( contextProxy )
106109 } catch ( error ) {
107110 outputChannel . appendLine (
108111 `[CodeIndexManager] Error during background CodeIndexManager configuration/indexing for ${ folder . uri . fsPath } : ${ error . message || error } ` ,
109112 )
110113 }
114+
111115 context . subscriptions . push ( manager )
112116 }
113117 }
114118 }
115119
120+ const postStateListener = ( ) => ClineProvider . getVisibleInstance ( ) ?. postStateToWebview ( )
121+
116122 // Initialize Roo Code Cloud service.
117- const cloudService = await CloudService . createInstance ( context , cloudLogger )
123+ const cloudService = await CloudService . createInstance ( context , cloudLogger , {
124+ "auth-state-changed" : postStateListener ,
125+ "settings-updated" : postStateListener ,
126+ "user-info" : async ( { userInfo } ) => {
127+ postStateListener ( )
128+
129+ if ( ! CloudService . instance . cloudAPI ) {
130+ cloudLogger ( "[CloudService] CloudAPI is not initialized" )
131+ return
132+ }
133+
134+ try {
135+ const config = await CloudService . instance . cloudAPI . bridgeConfig ( )
136+ cloudLogger ( `[CloudService] bridgeConfig -> ${ JSON . stringify ( config ) } ` )
137+
138+ ExtensionBridgeService . handleRemoteControlState (
139+ userInfo ,
140+ contextProxy . getValue ( "remoteControlEnabled" ) ,
141+ { ...config , provider, sessionId : vscode . env . sessionId } ,
142+ ( message : string ) => outputChannel . appendLine ( message ) ,
143+ )
144+ } catch ( error ) {
145+ cloudLogger (
146+ `[CloudService] Failed to fetch bridgeConfig: ${ error instanceof Error ? error . message : String ( error ) } ` ,
147+ )
148+ }
149+ } ,
150+ } )
118151
119152 try {
120153 if ( cloudService . telemetryClient ) {
@@ -126,29 +159,6 @@ export async function activate(context: vscode.ExtensionContext) {
126159 )
127160 }
128161
129- const postStateListener = ( ) => ClineProvider . getVisibleInstance ( ) ?. postStateToWebview ( )
130-
131- cloudService . on ( "auth-state-changed" , postStateListener )
132- cloudService . on ( "settings-updated" , postStateListener )
133-
134- cloudService . on ( "user-info" , async ( { userInfo } ) => {
135- postStateListener ( )
136-
137- const bridgeConfig = await cloudService . cloudAPI ?. bridgeConfig ( ) . catch ( ( ) => undefined )
138-
139- if ( ! bridgeConfig ) {
140- outputChannel . appendLine ( "[CloudService] Failed to get bridge config" )
141- return
142- }
143-
144- ExtensionBridgeService . handleRemoteControlState (
145- userInfo ,
146- contextProxy . getValue ( "remoteControlEnabled" ) ,
147- { ...bridgeConfig , provider, sessionId : vscode . env . sessionId } ,
148- ( message : string ) => outputChannel . appendLine ( message ) ,
149- )
150- } )
151-
152162 // Add to subscriptions for proper cleanup on deactivate.
153163 context . subscriptions . push ( cloudService )
154164
0 commit comments