From 51583429834a284f24f6a34c2f97e4743c57178a Mon Sep 17 00:00:00 2001 From: Fabio Zadrozny Date: Fri, 9 Aug 2024 13:54:52 -0300 Subject: [PATCH] Minor change getting packages in the environment. --- sema4ai/vscode-client/src/common.ts | 39 ++++++++++++++--------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/sema4ai/vscode-client/src/common.ts b/sema4ai/vscode-client/src/common.ts index 81109916..64774b57 100644 --- a/sema4ai/vscode-client/src/common.ts +++ b/sema4ai/vscode-client/src/common.ts @@ -41,34 +41,37 @@ export const isActionPackage = (entry: PackageEntry | LocalPackageMetadataInfo) return entry.filePath.endsWith("package.yaml"); }; -export async function getWorkspacePackages(): Promise { +export async function getWorkspacePackages(): Promise { const [actionResultListLocalRobots, actionResultListAgents] = (await Promise.all([ vscode.commands.executeCommand(roboCommands.SEMA4AI_LOCAL_LIST_ROBOTS_INTERNAL), vscode.commands.executeCommand(roboCommands.SEMA4AI_LOCAL_LIST_AGENT_PACKAGES_INTERNAL), ])) as [ActionResult, ActionResult]; + let localRobots: any[]; if (!actionResultListLocalRobots.success) { feedbackRobocorpCodeError("ACT_LIST_ROBOT"); - window.showErrorMessage( - "Error listing robots: " + actionResultListLocalRobots.message + " (Package creation will proceed)." - ); + window.showErrorMessage("Error listing robots: " + actionResultListLocalRobots.message); - return null; // This shouldn't happen, but let's proceed as if there were no Robots in the workspace. + localRobots = []; + } else { + localRobots = actionResultListLocalRobots.result; } - - if (!actionResultListAgents) { + + let localAgents: any[]; + if (!actionResultListAgents.success) { feedbackRobocorpCodeError("ACT_LIST_AGENTS"); - window.showErrorMessage( - "Error listing agents: " + actionResultListAgents.message + " (Package creation will proceed)." - ); - - return null; + window.showErrorMessage("Error listing agents: " + actionResultListAgents.message); + + // This shouldn't happen, but let's proceed as if there were no Agents in the workspace. + localAgents = []; + } else { + localAgents = actionResultListAgents.result; } return { - agentPackages: actionResultListAgents.result || [], - taskActionPackages: actionResultListLocalRobots.result || [], + agentPackages: localAgents, + taskActionPackages: localRobots, }; } @@ -79,11 +82,7 @@ export async function areTherePackagesInWorkspace(): Promise { return false; } - const packagesInfo: LocalPackageMetadataInfo[] = [ - ...workspacePackages.taskActionPackages, - ...workspacePackages.agentPackages, - ]; - return packagesInfo && packagesInfo.length > 0; + return workspacePackages.taskActionPackages.length > 0 && workspacePackages.agentPackages.length > 0; } export async function getPackageTargetDirectory( @@ -136,7 +135,7 @@ export async function getPackageTargetDirectory( return ws.uri.fsPath; } -export async function getPackageDirectoryName(prompt: string, defaultName: string = "Example"): Promise { +export async function getPackageDirectoryName(prompt: string): Promise { const name = await window.showInputBox({ "value": "Example", "prompt": prompt,