Skip to content

Commit 234672b

Browse files
committed
Make workspace agent always defined
1 parent 817df2b commit 234672b

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

src/commands.ts

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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,6 +594,21 @@ 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 === undefined) {
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) {
@@ -597,12 +617,6 @@ export class Commands {
597617
}
598618
folderPath = agent.expanded_directory;
599619
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;
606620
}
607621

608622
await openWorkspace(
@@ -677,7 +691,7 @@ async function openWorkspace(
677691
baseUrl: string,
678692
workspaceOwner: string,
679693
workspaceName: string,
680-
workspaceAgent: string | undefined,
694+
workspaceAgent: string,
681695
folderPath: string | undefined,
682696
openRecent: boolean | undefined,
683697
) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy