@@ -23,11 +23,6 @@ export interface BridgeOrchestratorOptions {
2323 isCloudAgent : boolean
2424}
2525
26- /**
27- * Central orchestrator for the extension bridge system.
28- * Coordinates communication between the VSCode extension and web application
29- * through WebSocket connections and manages extension/task channels.
30- */
3126export class BridgeOrchestrator {
3227 private static instance : BridgeOrchestrator | null = null
3328
@@ -85,7 +80,7 @@ export class BridgeOrchestrator {
8580 }
8681 }
8782
88- public static async connect ( options : BridgeOrchestratorOptions ) {
83+ private static async connect ( options : BridgeOrchestratorOptions ) {
8984 const instance = BridgeOrchestrator . instance
9085
9186 if ( ! instance ) {
@@ -103,13 +98,10 @@ export class BridgeOrchestrator {
10398 )
10499 }
105100 } else {
106- if (
107- instance . connectionState === ConnectionState . FAILED ||
108- instance . connectionState === ConnectionState . DISCONNECTED
109- ) {
110- console . log (
111- `[BridgeOrchestrator#connectOrDisconnect] Re-connecting... (state: ${ instance . connectionState } )` ,
112- )
101+ const connectionState = instance . socketTransport . getConnectionState ( )
102+
103+ if ( connectionState === ConnectionState . FAILED || connectionState === ConnectionState . DISCONNECTED ) {
104+ console . log ( `[BridgeOrchestrator#connectOrDisconnect] Re-connecting... (state: ${ connectionState } )` )
113105
114106 instance . reconnect ( ) . catch ( ( error ) => {
115107 console . error (
@@ -118,7 +110,7 @@ export class BridgeOrchestrator {
118110 } )
119111 } else {
120112 console . log (
121- `[BridgeOrchestrator#connectOrDisconnect] Already connected or connecting (state: ${ instance . connectionState } )` ,
113+ `[BridgeOrchestrator#connectOrDisconnect] Already connected or connecting (state: ${ connectionState } )` ,
122114 )
123115 }
124116 }
@@ -128,11 +120,10 @@ export class BridgeOrchestrator {
128120 const instance = BridgeOrchestrator . instance
129121
130122 if ( instance ) {
131- try {
132- console . log (
133- `[BridgeOrchestrator#connectOrDisconnect] Disconnecting... (state: ${ instance . connectionState } )` ,
134- )
123+ const connectionState = instance . socketTransport . getConnectionState ( )
135124
125+ try {
126+ console . log ( `[BridgeOrchestrator#connectOrDisconnect] Disconnecting... (state: ${ connectionState } )` )
136127 await instance . disconnect ( )
137128 } catch ( error ) {
138129 console . error (
@@ -237,28 +228,19 @@ export class BridgeOrchestrator {
237228 await this . extensionChannel . onReconnect ( socket )
238229 }
239230
240- // Shared API
241-
242- public get connectionState ( ) : ConnectionState {
243- return this . socketTransport . getConnectionState ( )
244- }
245-
246231 private async connect ( ) : Promise < void > {
247232 await this . socketTransport . connect ( )
248233 this . setupSocketListeners ( )
249234 }
250235
251- public async disconnect ( ) : Promise < void > {
236+ private async disconnect ( ) : Promise < void > {
252237 await this . extensionChannel . cleanup ( this . socketTransport . getSocket ( ) )
253238 await this . socketTransport . disconnect ( )
254239 BridgeOrchestrator . instance = null
255240 }
256241
257- public async reconnect ( ) : Promise < void > {
242+ private async reconnect ( ) : Promise < void > {
258243 await this . socketTransport . reconnect ( )
259-
260- // After a manual reconnect, we have a new socket instance
261- // so we need to set up listeners again.
262244 this . setupSocketListeners ( )
263245 }
264246}
0 commit comments