@@ -436,6 +436,9 @@ export class Commands {
436436 if ( ! baseUrl ) {
437437 throw new Error ( "You are not logged in" ) ;
438438 }
439+ if ( treeItem . primaryAgentName === undefined ) {
440+ return ;
441+ }
439442 await openWorkspace (
440443 baseUrl ,
441444 treeItem . workspaceOwner ,
@@ -524,6 +527,8 @@ export class Commands {
524527 let folderPath : string | undefined ;
525528 let openRecent : boolean | undefined ;
526529
530+ let workspace : Workspace | undefined ;
531+
527532 const baseUrl = this . restClient . getAxiosInstance ( ) . defaults . baseURL ;
528533 if ( ! baseUrl ) {
529534 throw new Error ( "You are not logged in" ) ;
@@ -570,7 +575,7 @@ export class Commands {
570575 } ) ;
571576 } ) ;
572577 quickPick . show ( ) ;
573- const workspace = await new Promise < Workspace | undefined > ( ( resolve ) => {
578+ workspace = await new Promise < Workspace | undefined > ( ( resolve ) => {
574579 quickPick . onDidHide ( ( ) => {
575580 resolve ( undefined ) ;
576581 } ) ;
@@ -589,20 +594,31 @@ export class Commands {
589594 }
590595 workspaceOwner = workspace . owner_name ;
591596 workspaceName = workspace . name ;
597+ } else {
598+ workspaceOwner = args [ 0 ] as string ;
599+ workspaceName = args [ 1 ] as string ;
600+ workspaceAgent = args [ 2 ] as string | undefined ;
601+ folderPath = args [ 3 ] as string | undefined ;
602+ openRecent = args [ 4 ] as boolean | undefined ;
603+ }
604+
605+ if ( ! workspaceAgent ) {
606+ if ( workspace === undefined ) {
607+ workspace = await this . restClient . getWorkspaceByOwnerAndName (
608+ workspaceOwner ,
609+ workspaceName ,
610+ ) ;
611+ }
592612
593613 const agent = await this . maybeAskAgent ( workspace ) ;
594614 if ( ! agent ) {
595615 // User declined to pick an agent.
596616 return ;
597617 }
598- folderPath = agent . expanded_directory ;
618+ if ( ! folderPath ) {
619+ folderPath = agent . expanded_directory ;
620+ }
599621 workspaceAgent = agent . name ;
600- } else {
601- workspaceOwner = args [ 0 ] as string ;
602- workspaceName = args [ 1 ] as string ;
603- workspaceAgent = args [ 2 ] as string | undefined ;
604- folderPath = args [ 3 ] as string | undefined ;
605- openRecent = args [ 4 ] as boolean | undefined ;
606622 }
607623
608624 await openWorkspace (
@@ -677,7 +693,7 @@ async function openWorkspace(
677693 baseUrl : string ,
678694 workspaceOwner : string ,
679695 workspaceName : string ,
680- workspaceAgent : string | undefined ,
696+ workspaceAgent : string ,
681697 folderPath : string | undefined ,
682698 openRecent : boolean | undefined ,
683699) {
0 commit comments