diff --git a/packages/core/src/awsService/sagemaker/commands.ts b/packages/core/src/awsService/sagemaker/commands.ts index 64266c556e1..522b29273d4 100644 --- a/packages/core/src/awsService/sagemaker/commands.ts +++ b/packages/core/src/awsService/sagemaker/commands.ts @@ -133,6 +133,16 @@ export async function stopSpace( ctx: vscode.ExtensionContext, sageMakerClient?: SagemakerClient ) { + await tryRefreshNode(node) + if (node.getStatus() === 'Stopped' || node.getStatus() === 'Stopping') { + void vscode.window.showWarningMessage(`Space ${node.spaceApp.SpaceName} is already in Stopped/Stopping state.`) + return + } else if (node.getStatus() === 'Starting') { + void vscode.window.showWarningMessage( + `Space ${node.spaceApp.SpaceName} is in Starting state. Wait until it is Running to attempt stop again.` + ) + return + } const spaceName = node.spaceApp.SpaceName! const confirmed = await showConfirmationMessage({ prompt: `You are about to stop this space. Any active resource will also be stopped. Are you sure you want to stop the space?`, @@ -179,7 +189,7 @@ export async function openRemoteConnect( void vscode.window.showErrorMessage(ConnectFromRemoteWorkspaceMessage) return } - + await tryRefreshNode(node) if (node.getStatus() === 'Stopped') { // In case of SMUS, we pass in a SM Client and for SM AI, it creates a new SM Client. const client = sageMakerClient ? sageMakerClient : new SagemakerClient(node.regionCode)