66import * as vscode from 'vscode'
77import * as nls from 'vscode-nls'
88import { SagemakerConstants } from './explorer/constants'
9- import { SagemakerParentNode } from './explorer/sagemakerParentNode '
9+ import { SagemakerStudioNode } from './explorer/sagemakerStudioNode '
1010import { DomainKeyDelimiter } from './utils'
1111import { startVscodeRemote } from '../../shared/extensions/ssh'
1212import { getLogger } from '../../shared/logger/logger'
@@ -30,15 +30,16 @@ import {
3030 SpaceStatus ,
3131} from './constants'
3232import { SagemakerUnifiedStudioSpaceNode } from '../../sagemakerunifiedstudio/explorer/nodes/sageMakerUnifiedStudioSpaceNode'
33+ import { node } from 'webpack'
3334
3435const localize = nls . loadMessageBundle ( )
3536
36- export async function filterSpaceAppsByDomainUserProfiles ( parentNode : SagemakerParentNode ) : Promise < void > {
37- if ( parentNode . domainUserProfiles . size === 0 ) {
38- // if parentNode has not been expanded, domainUserProfiles will be empty
37+ export async function filterSpaceAppsByDomainUserProfiles ( studioNode : SagemakerStudioNode ) : Promise < void > {
38+ if ( studioNode . domainUserProfiles . size === 0 ) {
39+ // if studioNode has not been expanded, domainUserProfiles will be empty
3940 // if so, this will attempt to populate domainUserProfiles
40- await parentNode . updateChildren ( )
41- if ( parentNode . domainUserProfiles . size === 0 ) {
41+ await studioNode . updateChildren ( )
42+ if ( studioNode . domainUserProfiles . size === 0 ) {
4243 getLogger ( ) . info ( SagemakerConstants . NoSpaceToFilter )
4344 void vscode . window . showInformationMessage ( SagemakerConstants . NoSpaceToFilter )
4445 return
@@ -47,7 +48,7 @@ export async function filterSpaceAppsByDomainUserProfiles(parentNode: SagemakerP
4748
4849 // Sort by domain name and user profile
4950 const sortedDomainUserProfiles = new Map (
50- [ ...parentNode . domainUserProfiles ] . sort ( ( a , b ) => {
51+ [ ...studioNode . domainUserProfiles ] . sort ( ( a , b ) => {
5152 const domainNameA = a [ 1 ] . domain . DomainName || ''
5253 const domainNameB = b [ 1 ] . domain . DomainName || ''
5354
@@ -58,7 +59,7 @@ export async function filterSpaceAppsByDomainUserProfiles(parentNode: SagemakerP
5859 } )
5960 )
6061
61- const previousSelection = await parentNode . getSelectedDomainUsers ( )
62+ const previousSelection = await studioNode . getSelectedDomainUsers ( )
6263 const items : ( vscode . QuickPickItem & { key : string } ) [ ] = [ ]
6364
6465 for ( const [ key , userMetadata ] of sortedDomainUserProfiles ) {
@@ -84,8 +85,8 @@ export async function filterSpaceAppsByDomainUserProfiles(parentNode: SagemakerP
8485
8586 const newSelection = result . map ( ( r ) => r . key )
8687 if ( newSelection . length !== previousSelection . size || newSelection . some ( ( key ) => ! previousSelection . has ( key ) ) ) {
87- parentNode . saveSelectedDomainUsers ( newSelection )
88- await vscode . commands . executeCommand ( 'aws.refreshAwsExplorerNode' , parentNode )
88+ studioNode . saveSelectedDomainUsers ( newSelection )
89+ await vscode . commands . executeCommand ( 'aws.refreshAwsExplorerNode' , studioNode )
8990 }
9091}
9192
@@ -97,6 +98,9 @@ export async function deeplinkConnect(
9798 token : string ,
9899 domain : string ,
99100 appType ?: string ,
101+ workspaceName ?: string ,
102+ namespace ?: string ,
103+ eksClusterArn ?: string ,
100104 isSMUS : boolean = false
101105) {
102106 getLogger ( ) . debug (
@@ -108,17 +112,34 @@ export async function deeplinkConnect(
108112 isSMUS
109113 )
110114
115+ getLogger ( ) . info (
116+ `sm:deeplinkConnect:
117+ domain: ${ domain } ,
118+ appType: ${ appType } ,
119+ workspaceName: ${ workspaceName } ,
120+ namespace: ${ namespace } ,
121+ eksClusterArn: ${ eksClusterArn } `
122+ )
123+
124+ getLogger ( ) . info (
125+ `sm:deeplinkConnect: domain: ${ domain } , appType: ${ appType } , workspaceName: ${ workspaceName } , namespace: ${ namespace } , eksClusterArn: ${ eksClusterArn } `
126+ )
127+
111128 if ( isRemoteWorkspace ( ) ) {
112129 void vscode . window . showErrorMessage ( ConnectFromRemoteWorkspaceMessage )
113130 return
114131 }
115132
116133 try {
134+ let connectionType = 'sm_dl'
135+ if ( domain === '' ) {
136+ connectionType = 'sm_hp'
137+ }
117138 const remoteEnv = await prepareDevEnvConnection (
118139 connectionIdentifier ,
119140 ctx . extensionContext ,
120- 'sm_dl' ,
121- isSMUS ,
141+ connectionType ,
142+ isSMUS /* isSMUS */ ,
122143 undefined /* node */ ,
123144 session ,
124145 wsUrl ,
@@ -127,13 +148,20 @@ export async function deeplinkConnect(
127148 appType
128149 )
129150
130- await startVscodeRemote (
131- remoteEnv . SessionProcess ,
132- remoteEnv . hostname ,
133- '/home/sagemaker-user' ,
134- remoteEnv . vscPath ,
135- 'sagemaker-user'
136- )
151+ try {
152+ await startVscodeRemote (
153+ remoteEnv . SessionProcess ,
154+ remoteEnv . hostname ,
155+ '/home/sagemaker-user' ,
156+ remoteEnv . vscPath ,
157+ 'sagemaker-user'
158+ )
159+ } catch ( remoteErr : any ) {
160+ throw new ToolkitError (
161+ `Failed to establish remote connection: ${ remoteErr . message } . Check Remote-SSH logs for details.` ,
162+ { cause : remoteErr , code : remoteErr . code || 'RemoteConnectionFailed' }
163+ )
164+ }
137165 } catch ( err : any ) {
138166 getLogger ( ) . error (
139167 'sm:OpenRemoteConnect: Unable to connect to target space with arn: %s error: %s isSMUS: %s' ,
@@ -143,6 +171,9 @@ export async function deeplinkConnect(
143171 )
144172
145173 if ( ! [ RemoteSessionError . MissingExtension , RemoteSessionError . ExtensionVersionTooLow ] . includes ( err . code ) ) {
174+ void vscode . window . showErrorMessage (
175+ `Remote connection failed: ${ err . message || 'Unknown error' } . Check Output > Log (Window) for details.`
176+ )
146177 throw err
147178 }
148179 }
0 commit comments