@@ -66,35 +66,43 @@ export class RemoteSession extends Disposable {
66
66
this . usePublicApi = await this . experiments . getUsePublicAPI ( this . connectionInfo . gitpodHost ) ;
67
67
this . logService . info ( `Going to use ${ this . usePublicApi ? 'public' : 'server' } API` ) ;
68
68
69
- let instanceId : string ;
70
69
if ( this . usePublicApi ) {
71
70
this . workspaceState = new WorkspaceState ( this . connectionInfo . workspaceId , this . sessionService , this . logService ) ;
72
- await this . workspaceState . initialize ( ) ;
73
- if ( ! this . workspaceState . instanceId || ! this . workspaceState . isWorkspaceRunning ) {
74
- throw new NoRunningInstanceError ( this . connectionInfo . workspaceId , this . workspaceState . workspaceData . phase ) ;
75
- }
71
+ this . workspaceState . initialize ( )
72
+ . then ( ( ) => {
73
+ if ( ! this . workspaceState ! . instanceId || ! this . workspaceState ! . isWorkspaceRunning ) {
74
+ vscode . commands . executeCommand ( 'workbench.action.remote.close' ) ;
75
+ return ;
76
+ }
77
+ const instanceId = this . workspaceState ! . instanceId ;
78
+ if ( instanceId !== this . connectionInfo . instanceId ) {
79
+ this . logService . info ( `Updating workspace ${ this . connectionInfo . workspaceId } latest instance id ${ this . connectionInfo . instanceId } => ${ instanceId } ` ) ;
80
+ this . connectionInfo . instanceId = instanceId ;
81
+ }
82
+
83
+ const { sshDestStr } = getGitpodRemoteWindowConnectionInfo ( this . context ) ! ;
84
+ this . context . globalState . update ( `${ SSH_DEST_KEY } ${ sshDestStr } ` , { ...this . connectionInfo } as SSHConnectionParams ) ;
85
+ } ) ;
76
86
77
87
this . _register ( this . workspaceState . onWorkspaceWillStop ( async ( ) => {
78
88
await this . remoteService . saveRestartInfo ( ) ;
79
89
vscode . commands . executeCommand ( 'workbench.action.remote.close' ) ;
80
90
} ) ) ;
81
- instanceId = this . workspaceState . instanceId ;
82
91
} else {
83
92
const workspaceInfo = await withServerApi ( this . sessionService . getGitpodToken ( ) , this . connectionInfo . gitpodHost , service => service . server . getWorkspace ( this . connectionInfo . workspaceId ) , this . logService ) ;
84
93
if ( ! workspaceInfo . latestInstance || workspaceInfo . latestInstance ?. status ?. phase === 'stopping' || workspaceInfo . latestInstance ?. status ?. phase === 'stopped' ) {
85
94
throw new NoRunningInstanceError ( this . connectionInfo . workspaceId , workspaceInfo . latestInstance ?. status ?. phase ) ;
86
95
}
87
- instanceId = workspaceInfo . latestInstance . id ;
88
- }
96
+ const instanceId = workspaceInfo . latestInstance . id ;
97
+ if ( instanceId !== this . connectionInfo . instanceId ) {
98
+ this . logService . info ( `Updating workspace ${ this . connectionInfo . workspaceId } latest instance id ${ this . connectionInfo . instanceId } => ${ instanceId } ` ) ;
99
+ this . connectionInfo . instanceId = instanceId ;
100
+ }
89
101
90
- if ( instanceId !== this . connectionInfo . instanceId ) {
91
- this . logService . info ( `Updating workspace ${ this . connectionInfo . workspaceId } latest instance id ${ this . connectionInfo . instanceId } => ${ instanceId } ` ) ;
92
- this . connectionInfo . instanceId = instanceId ;
102
+ const { sshDestStr } = getGitpodRemoteWindowConnectionInfo ( this . context ) ! ;
103
+ this . context . globalState . update ( `${ SSH_DEST_KEY } ${ sshDestStr } ` , { ...this . connectionInfo } as SSHConnectionParams ) ;
93
104
}
94
105
95
- const { sshDestStr } = getGitpodRemoteWindowConnectionInfo ( this . context ) ! ;
96
- await this . context . globalState . update ( `${ SSH_DEST_KEY } ${ sshDestStr } ` , { ...this . connectionInfo } as SSHConnectionParams ) ;
97
-
98
106
this . heartbeatManager = new HeartbeatManager ( this . connectionInfo , this . workspaceState , this . sessionService , this . logService , this . telemetryService ) ;
99
107
100
108
this . remoteService . initializeRemoteExtensions ( ) ;
0 commit comments