@@ -90,7 +90,12 @@ func (a *App) SSH(ctx context.Context, sshArgs []string, opts sshOptions) (err e
9090 a .errLogger .Printf ("Debug file located at: %s" , debugLogger .Name ())
9191 }
9292
93- session , err := openSSHSession (ctx , a , opts .codespace , liveshareLogger )
93+ codespace , err := getOrChooseCodespace (ctx , a .apiClient , opts .codespace )
94+ if err != nil {
95+ return fmt .Errorf ("get or choose codespace: %w" , err )
96+ }
97+
98+ session , err := openSSHSession (ctx , a , codespace , liveshareLogger )
9499 if err != nil {
95100 return fmt .Errorf ("error connecting to codespace: %w" , err )
96101 }
@@ -209,7 +214,12 @@ func (a *App) printOpenSSHConfig(ctx context.Context, opts configOptions) error
209214
210215 sshUser , ok := sshUsers [cs .Repository .FullName ]
211216 if ! ok {
212- session , err := openSSHSession (ctx , a , cs .Name , nil )
217+ codespace , err := a .apiClient .GetCodespace (ctx , cs .Name , true )
218+ if err != nil {
219+ return fmt .Errorf ("getting full codespace details: %w" , err )
220+ }
221+
222+ session , err := openSSHSession (ctx , a , codespace , nil )
213223 if err != nil {
214224 fmt .Fprintf (os .Stderr , "error connecting to codespace: %v\n " , err )
215225
@@ -262,12 +272,7 @@ type codespaceSSHConfig struct {
262272 GHExec string // path used for invoking the current `gh` binary
263273}
264274
265- func openSSHSession (ctx context.Context , a * App , csName string , liveshareLogger * log.Logger ) (* liveshare.Session , error ) {
266- codespace , err := getOrChooseCodespace (ctx , a .apiClient , csName )
267- if err != nil {
268- return nil , fmt .Errorf ("get or choose codespace: %w" , err )
269- }
270-
275+ func openSSHSession (ctx context.Context , a * App , codespace * api.Codespace , liveshareLogger * log.Logger ) (* liveshare.Session , error ) {
271276 // TODO(josebalius): We can fetch the user in parallel to everything else
272277 // we should convert this call and others to happen async
273278 user , err := a .apiClient .GetUser (ctx )
0 commit comments