@@ -107,6 +107,10 @@ export default class RemoteConnector extends Disposable {
107107 super ( ) ;
108108
109109 this . releaseStaleLocks ( ) ;
110+
111+ if ( vscode . env . remoteName && context . extension . extensionKind === vscode . ExtensionKind . UI ) {
112+ this . _register ( vscode . commands . registerCommand ( 'gitpod.api.autoTunnel' , this . autoTunnelCommand . bind ( this ) ) ) ;
113+ }
110114 }
111115
112116 private releaseStaleLocks ( ) : void {
@@ -662,6 +666,8 @@ export default class RemoteConnector extends Disposable {
662666 if ( password ) {
663667 await this . showSSHPasswordModal ( password ) ;
664668 }
669+
670+ this . telemetry . sendTelemetryEvent ( 'vscode_desktop_ssh' , { kind : 'gateway' , status : 'connected' , ...params } ) ;
665671 } catch ( e ) {
666672 this . telemetry . sendTelemetryEvent ( 'vscode_desktop_ssh' , { kind : 'gateway' , status : 'failed' , reason : e . toString ( ) , ...params } ) ;
667673 if ( e instanceof NoSSHGatewayError ) {
@@ -700,6 +706,8 @@ export default class RemoteConnector extends Disposable {
700706 const localAppDestData = await this . getWorkspaceLocalAppSSHDestination ( params ) ;
701707 sshDestination = localAppDestData . localAppSSHDest ;
702708 localAppSSHConfigPath = localAppDestData . localAppSSHConfigPath ;
709+
710+ this . telemetry . sendTelemetryEvent ( 'vscode_desktop_ssh' , { kind : 'local-app' , status : 'connected' , ...params } ) ;
703711 } catch ( e ) {
704712 this . logger . error ( `Failed to connect ${ params . workspaceId } Gitpod workspace:` , e ) ;
705713 if ( e instanceof LocalAppError ) {
@@ -726,8 +734,6 @@ export default class RemoteConnector extends Disposable {
726734
727735 await this . updateRemoteSSHConfig ( usingSSHGateway , localAppSSHConfigPath ) ;
728736
729- await this . context . globalState . update ( sshDestination ! , { ...params , usingSSHGateway } ) ;
730-
731737 vscode . commands . executeCommand (
732738 'vscode.openFolder' ,
733739 vscode . Uri . parse ( `vscode-remote://ssh-remote+${ sshDestination } ${ uri . path || '/' } ` ) ,
@@ -742,7 +748,7 @@ export default class RemoteConnector extends Disposable {
742748 const configKey = `config/${ authority } ` ;
743749 const localAppconfig = this . context . globalState . get < LocalAppConfig > ( configKey ) ;
744750 if ( ! localAppconfig || checkRunning ( localAppconfig . pid ) !== true ) {
745- // Do nothing if we are using SSH gateway and local app is not running
751+ // Do nothing if we are using SSH gateway
746752 return ;
747753 }
748754 }
@@ -760,53 +766,4 @@ export default class RemoteConnector extends Disposable {
760766 this . logger . error ( 'Failed to disable auto tunneling:' , e ) ;
761767 }
762768 }
763-
764- public async checkRemoteConnectionSuccessful ( ) {
765- const isRemoteExtensionHostRunning = async ( ) => {
766- try {
767- // Invoke command from gitpot-remote extension to test if connection is successful
768- await vscode . commands . executeCommand ( '__gitpod.getGitpodRemoteLogsUri' ) ;
769- return true ;
770- } catch {
771- return false ;
772- }
773- } ;
774-
775- const remoteUri = vscode . workspace . workspaceFile || vscode . workspace . workspaceFolders ?. [ 0 ] . uri ;
776- if ( vscode . env . remoteName === 'ssh-remote' && this . context . extension . extensionKind === vscode . ExtensionKind . UI && remoteUri ) {
777- const [ , sshDestStr ] = remoteUri . authority . split ( '+' ) ;
778- const sshDest : { user : string ; hostName : string } = JSON . parse ( Buffer . from ( sshDestStr , 'hex' ) . toString ( 'utf8' ) ) ;
779- const gitpodHost = vscode . workspace . getConfiguration ( 'gitpod' ) . get < string > ( 'host' ) ! ;
780- const host = new URL ( gitpodHost ) . host ;
781- const connectionSuccessful = sshDest . hostName . endsWith ( host ) && await isRemoteExtensionHostRunning ( ) ;
782-
783- const connectionInfo = this . context . globalState . get < SSHConnectionParams & { usingSSHGateway : boolean } > ( sshDestStr ) ;
784- if ( connectionInfo ) {
785- const kind = connectionInfo . usingSSHGateway ? 'gateway' : 'local-app' ;
786- if ( connectionSuccessful ) {
787- this . telemetry . sendTelemetryEvent ( 'vscode_desktop_ssh' , {
788- kind,
789- status : 'connected' ,
790- instanceId : connectionInfo . instanceId ,
791- workspaceId : connectionInfo . workspaceId ,
792- gitpodHost : connectionInfo . gitpodHost
793- } ) ;
794- } else {
795- this . telemetry . sendTelemetryEvent ( 'vscode_desktop_ssh' , {
796- kind,
797- status : 'failed' ,
798- reason : 'remote-ssh extension: connection failed' ,
799- instanceId : connectionInfo . instanceId ,
800- workspaceId : connectionInfo . workspaceId ,
801- gitpodHost : connectionInfo . gitpodHost
802- } ) ;
803- }
804- await this . context . globalState . update ( remoteUri . authority , undefined ) ;
805- }
806-
807- return connectionSuccessful ;
808- }
809-
810- return false ;
811- }
812769}
0 commit comments