@@ -9,64 +9,80 @@ import { INotificationService } from './services/notificationService';
99import { ILogService } from './services/logService' ;
1010
1111export interface SSHConnectionParams {
12- workspaceId : string ;
13- instanceId : string ;
14- gitpodHost : string ;
15- debugWorkspace ?: boolean ;
16- connType ?: 'local-app' | 'local-ssh' | 'ssh-gateway' ;
12+ workspaceId : string ;
13+ instanceId : string ;
14+ gitpodHost : string ;
15+ debugWorkspace ?: boolean ;
16+ connType ?: 'local-app' | 'local-ssh' | 'ssh-gateway' ;
1717}
1818
1919export interface WorkspaceRestartInfo {
20- workspaceId : string ;
21- gitpodHost : string ;
20+ workspaceId : string ;
21+ gitpodHost : string ;
2222}
2323
2424export class NoRunningInstanceError extends Error {
25- constructor ( readonly workspaceId : string , readonly phase ?: string ) {
26- super ( `Failed to connect to ${ workspaceId } Gitpod workspace, workspace not running: ${ phase } ` ) ;
27- }
25+ code = 'NoRunningInstanceError' ;
26+ constructor ( readonly workspaceId : string , readonly phase ?: string ) {
27+ super ( `Failed to connect to ${ workspaceId } Gitpod workspace, workspace not running: ${ phase } ` ) ;
28+ }
2829}
2930
3031export class NoSSHGatewayError extends Error {
31- constructor ( readonly host : string ) {
32- super ( `SSH gateway not configured for this Gitpod Host ${ host } ` ) ;
33- }
32+ code = 'NoSSHGatewayError' ;
33+ constructor ( readonly host : string ) {
34+ super ( `SSH gateway not configured for this Gitpod Host ${ host } ` ) ;
35+ }
36+ }
37+
38+ export class NoExtensionIPCServerError extends Error {
39+ code = 'NoExtensionIPCServer' ;
40+ constructor ( ) {
41+ super ( 'NoExtensionIPCServer' ) ;
42+ }
43+ }
44+
45+ export class NoLocalSSHSupportError extends Error {
46+ code = 'NoLocalSSHSupport' ;
47+ constructor ( ) {
48+ super ( 'NoLocalSSHSupport' ) ;
49+ }
3450}
3551
3652export const SSH_DEST_KEY = 'ssh-dest:' ;
3753
3854export function getGitpodRemoteWindowConnectionInfo ( context : vscode . ExtensionContext ) : { remoteAuthority : string ; connectionInfo : SSHConnectionParams } | undefined {
39- const remoteUri = vscode . workspace . workspaceFile || vscode . workspace . workspaceFolders ?. [ 0 ] . uri ;
40- if ( vscode . env . remoteName === 'ssh-remote' && context . extension . extensionKind === vscode . ExtensionKind . UI && remoteUri ) {
41- const [ , sshDestStr ] = remoteUri . authority . split ( '+' ) ;
42- const connectionInfo = context . globalState . get < SSHConnectionParams > ( `${ SSH_DEST_KEY } ${ sshDestStr } ` ) ;
43- if ( connectionInfo ) {
44- return { remoteAuthority : remoteUri . authority , connectionInfo } ;
45- }
46- }
55+ const remoteUri = vscode . workspace . workspaceFile || vscode . workspace . workspaceFolders ?. [ 0 ] . uri ;
56+ if ( vscode . env . remoteName === 'ssh-remote' && context . extension . extensionKind === vscode . ExtensionKind . UI && remoteUri ) {
57+ const [ , sshDestStr ] = remoteUri . authority . split ( '+' ) ;
58+ const connectionInfo = context . globalState . get < SSHConnectionParams > ( `${ SSH_DEST_KEY } ${ sshDestStr } ` ) ;
59+ if ( connectionInfo ) {
60+ return { remoteAuthority : remoteUri . authority , connectionInfo } ;
61+ }
62+ }
4763
48- return undefined ;
64+ return undefined ;
4965}
5066
5167export async function showWsNotRunningDialog ( workspaceId : string , gitpodHost : string , flow : UserFlowTelemetryProperties , notificationService : INotificationService , logService : ILogService ) {
52- const msg = `Workspace ${ workspaceId } is not running. Please restart the workspace.` ;
53- logService . error ( msg ) ;
68+ const msg = `Workspace ${ workspaceId } is not running. Please restart the workspace.` ;
69+ logService . error ( msg ) ;
5470
55- const workspaceUrl = new URL ( gitpodHost ) ;
56- workspaceUrl . pathname = '/start' ;
57- workspaceUrl . hash = workspaceId ;
71+ const workspaceUrl = new URL ( gitpodHost ) ;
72+ workspaceUrl . pathname = '/start' ;
73+ workspaceUrl . hash = workspaceId ;
5874
59- const openUrl = 'Restart workspace' ;
60- const resp = await notificationService . showErrorMessage ( msg , { id : 'ws_not_running' , flow, modal : true } , openUrl ) ;
61- if ( resp === openUrl ) {
62- const opened = await vscode . env . openExternal ( vscode . Uri . parse ( workspaceUrl . toString ( ) ) ) ;
63- if ( opened ) {
64- vscode . commands . executeCommand ( 'workbench.action.closeWindow' ) ;
65- }
66- }
75+ const openUrl = 'Restart workspace' ;
76+ const resp = await notificationService . showErrorMessage ( msg , { id : 'ws_not_running' , flow, modal : true } , openUrl ) ;
77+ if ( resp === openUrl ) {
78+ const opened = await vscode . env . openExternal ( vscode . Uri . parse ( workspaceUrl . toString ( ) ) ) ;
79+ if ( opened ) {
80+ vscode . commands . executeCommand ( 'workbench.action.closeWindow' ) ;
81+ }
82+ }
6783}
6884
6985export function getLocalSSHDomain ( gitpodHost : string ) : string {
70- const scope = vscode . env . appName . includes ( 'Insiders' ) ? 'vsi' : 'vss' ;
71- return `${ scope } .` + ( new URL ( gitpodHost ) ) . hostname ;
86+ const scope = vscode . env . appName . includes ( 'Insiders' ) ? 'vsi' : 'vss' ;
87+ return `${ scope } .` + ( new URL ( gitpodHost ) ) . hostname ;
7288}
0 commit comments