Skip to content

Conversation

@arunbhati
Copy link

DESCRIPTION
• Add support for redirecting to SMUS portal during VSCode session renewal • Detect SMUS environment using SERVICE_NAME variable • Update metadata handling to support SMUS portal URL construction

MOTIVATION
• Enable users to renew VSCode sessions through SMUS portal • Improve session renewal experience for SMUS users

TESTING
• Verified with local VSCode server
• Tested for both SMUS and SageMaker AI with manually cookie population and metadata file creation

BACKWARD COMPATIBILITY
• Maintains existing behavior for non-SMUS environments • Silent failure handling prevents disruption of current flows

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

ResourceArn?: string
ResourceName?: string
AppImageVersion?: string
AdditionalMetadata?: {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Uneven spacings

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting, I'm actually not able to see that, can you please add more details on where exactly you are seeing it
Screenshot 2025-03-26 at 2 52 17 PM

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Was using more than tab (4 space). Hence called it.

const sagemakerCookie: SagemakerCookie = r as SagemakerCookie

initialize(sagemakerCookie);
updateStatusItemWithMetadata(context);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any issues with SM AI if we move this out of this code block scope?

Copy link
Contributor

@aws-asolidu aws-asolidu Mar 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be okay, but I would rather set the smusRedirectUrl seperately from updateStatusItemWithMetadata, I feel like we're overloading this func. Refactor fecthing jsonData into a helper function

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion, I am adding helper function in next revision.

sagemaker-idle-extension.patch
terminal-crash-mitigation.patch
sagemaker-open-notebook-extension.patch
sagemaker-extension-smus-support.patch

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any strong reason why not have it in sagemaker-extension.diff itself and have it in separate patch?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

patches are feature based

Copy link

@bharathGuntamadugu bharathGuntamadugu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do test this in both SMUS and SM AI world and add unit tests accordingly.

DataZoneDomainRegion: !!DataZoneDomainRegion,
DataZoneProjectId: !!DataZoneProjectId
});
return null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the SMUS session renewal UX if we're unable to generate the url?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If SMUS URL is not generated then User get redirected to AWS Console sign in page (default Redirect URL return by LL). Basically user would need to manually generate VSCode link from SMUS portal. Ideally we should have monitoring to detect such cases in which we can't generate URLs.

Screenshot 2025-03-26 at 2 59 23 PM

* Constructs the SMUS portal URL using domain, region, and project information
* Returns null if not in SMUS environment or if required fields are missing
*/
export const getSmusVscodePortalUrl = (metadata: SagemakerMetadata): string | null => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why can't we follow existing pattern of setting redirect url in cookies?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redirect url is set by LooseLeaf, do you mean LL return Redirect URL of SMUS for SMUS use cases?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank for setting "Redirect URL" suggestion from LooseLeaf side. This looks like a better long term solution. It will need to good amount of research to make sure it doesn't impact any other functionality and also "Redirect URL" is generic solution for all IDEs so updating it could have impact on other IDEs in unexpected way. I'll suggest we do it in incremental way. First we use current short term way (this PR) and then we see if we can get "Redirect URL" updated from LL side as long term way.

Copy link
Contributor

@aws-asolidu aws-asolidu Mar 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good, please create a tracking issue for this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sagemaker-idle-extension.patch
terminal-crash-mitigation.patch
sagemaker-open-notebook-extension.patch
sagemaker-extension-smus-support.patch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

patches are feature based

@arunbhati arunbhati changed the base branch from main to feature/smus March 26, 2025 21:27
@arunbhati arunbhati force-pushed the feature/smus-sagemaker-extension branch from 097a7ba to 965cfe3 Compare March 26, 2025 21:44
** Description **
• Add support for redirecting to SMUS portal during VSCode session renewal • Detect SMUS environment using SERVICE_NAME variable • Update metadata handling to support SMUS portal URL construction

** Motivation **
• Enable users to renew VSCode sessions through SMUS portal • Improve session renewal experience for SMUS users

** Testing **
• Verified with local VSCode server
• Tested for both SMUS and SageMaker AI with manually cookie population and metadata file creation

** Backward compatibility **
• Maintains existing behavior for non-SMUS environments • Silent failure handling prevents disruption of current flows
@arunbhati arunbhati force-pushed the feature/smus-sagemaker-extension branch from 965cfe3 to 3983b4d Compare March 26, 2025 21:49
return JSON.parse(data) as SagemakerResourceMetadata;
} catch (error) {
// fail silently not to block users
console.error('Error reading metadata file:', error);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: we should move all these logs to output channel. like #110 (comment)

ResourceArn?: string
ResourceName?: string
AppImageVersion?: string
AdditionalMetadata?: {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Was using more than tab (4 space). Hence called it.

@aws-asolidu aws-asolidu merged commit c9e64a3 into aws:feature/smus Mar 28, 2025
austinjang2 pushed a commit to austinjang2/sagemaker-code-editor that referenced this pull request Sep 11, 2025
…nsion

feat(session): add SageMaker Unified Studio portal redirect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants