generated from amazon-archives/__template_MIT-0
-
Notifications
You must be signed in to change notification settings - Fork 33
PR6: webview, local-storage, sagemaker-integration #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
aws-spenceng
merged 3 commits into
aws:staging_1.83.1
from
aws-spenceng:staging_1.83.1-pr6
Mar 8, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import { Disposable } from 'vs/base/common/lifecycle'; | ||
| import { CommandsRegistry } from 'vs/platform/commands/common/commands'; | ||
| import { MenuId, MenuRegistry } from "vs/platform/actions/common/actions"; | ||
| import { localize } from "vs/nls"; | ||
| import { ILogService } from "vs/platform/log/common/log"; | ||
|
|
||
| export class SagemakerServerClient extends Disposable { | ||
| constructor ( | ||
| @ILogService private logService: ILogService | ||
| ) { | ||
| super(); | ||
|
|
||
| this.logService.debug('Initializing SagemakerServerClient...'); | ||
| this.registerSagemakerCommands(); | ||
| } | ||
|
|
||
| static LOGOUT_COMMAND_ID = 'sagemaker.logout'; | ||
| static COOKIE_COMMAND_ID = 'sagemaker.parseCookies'; | ||
|
|
||
| private registerSagemakerCommands() { | ||
| const authMode: string | undefined = this.getCookieValue('authMode'); | ||
| const expiryTime: string | undefined = this.getCookieValue('expiryTime'); | ||
| const studioUserProfileName: string | undefined = this.getCookieValue('studioUserProfileName') | ||
| const ssoExpiryTimestamp: string | undefined = this.getCookieValue('ssoExpiryTimestamp') | ||
| const redirectURL: string | undefined = this.getCookieValue('redirectURL') | ||
|
|
||
| this.logService.debug('Registering sagemaker commands...'); | ||
|
|
||
| CommandsRegistry.registerCommand(SagemakerServerClient.COOKIE_COMMAND_ID, () => { | ||
| return { | ||
| authMode: authMode, | ||
| expiryTime: expiryTime, | ||
| ssoExpiryTimestamp: ssoExpiryTimestamp, | ||
| studioUserProfileName: studioUserProfileName, | ||
| redirectURL: redirectURL | ||
| }; | ||
| }); | ||
|
|
||
| CommandsRegistry.registerCommand(SagemakerServerClient.LOGOUT_COMMAND_ID, () => { | ||
| const currentUrl = new URL(window.location.href); | ||
| const hostname = currentUrl.hostname; | ||
| const pathComponents = currentUrl.pathname.split('/'); | ||
| const logoutUrl = `https://${hostname}/${pathComponents[1]}/${pathComponents[2]}/logout`; | ||
| window.location.href = logoutUrl; | ||
| }); | ||
|
|
||
| for (const menuId of [MenuId.CommandPalette, MenuId.MenubarHomeMenu]) { | ||
| MenuRegistry.appendMenuItem(menuId, { | ||
| command: { | ||
| id: SagemakerServerClient.LOGOUT_COMMAND_ID, | ||
| title: localize('logout', "{0}: Log out", 'Sagemaker'), | ||
| }, | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| private getCookieValue(name: string): string | undefined { | ||
| const match = document.cookie.match('(^|[^;]+)\\s*' + name + '\\s*=\\s*([^;]+)'); // See https://stackoverflow.com/a/25490531 | ||
| return match ? match.pop() : undefined; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| Make storage local to the remote server | ||
|
|
||
| This solves two problems: | ||
| 1. Extensions running in the browser (like Vim) might use these paths | ||
| directly instead of using the file service and most likely can't write | ||
| to `/User` on disk. | ||
| 2. Settings will be stored in the file system instead of in browser | ||
| storage. Using browser storage makes sharing or seeding settings | ||
| between browsers difficult. We may want to revisit this once/if we get | ||
| settings sync. | ||
|
|
||
| Unfortunately this does not affect state which uses a separate method with | ||
| IndexedDB and does not appear nearly as easy to redirect to disk. | ||
|
|
||
| To test install the Vim extension and make sure something that uses file storage | ||
| works (history recall for example) and change settings from the UI and on disk | ||
| while making sure they appear on the other side. | ||
|
|
||
| Index: sagemaker-code-editor/vscode/src/vs/server/node/webClientServer.ts | ||
| =================================================================== | ||
| --- sagemaker-code-editor.orig/vscode/src/vs/server/node/webClientServer.ts | ||
| +++ sagemaker-code-editor/vscode/src/vs/server/node/webClientServer.ts | ||
| @@ -332,6 +332,7 @@ export class WebClientServer { | ||
| const workbenchWebConfiguration = { | ||
| remoteAuthority, | ||
| webviewEndpoint: vscodeBase + this._staticRoute + '/out/vs/workbench/contrib/webview/browser/pre', | ||
| + userDataPath: this._environmentService.userDataPath, | ||
| _wrapWebWorkerExtHostInIframe, | ||
| developmentOptions: { enableSmokeTestDriver: this._environmentService.args['enable-smoke-test-driver'] ? true : undefined, logLevel: this._logService.getLevel() }, | ||
| settingsSyncOptions: !this._environmentService.isBuilt && this._environmentService.args['enable-sync'] ? { enabled: true } : undefined, | ||
| Index: sagemaker-code-editor/vscode/src/vs/workbench/browser/web.api.ts | ||
| =================================================================== | ||
| --- sagemaker-code-editor.orig/vscode/src/vs/workbench/browser/web.api.ts | ||
| +++ sagemaker-code-editor/vscode/src/vs/workbench/browser/web.api.ts | ||
| @@ -276,6 +276,11 @@ export interface IWorkbenchConstructionO | ||
| */ | ||
| readonly configurationDefaults?: Record<string, any>; | ||
|
|
||
| + /** | ||
| + * Path to the user data directory. | ||
| + */ | ||
| + readonly userDataPath?: string | ||
| + | ||
| //#endregion | ||
|
|
||
| //#region Profile options | ||
| Index: sagemaker-code-editor/vscode/src/vs/workbench/services/environment/browser/environmentService.ts | ||
| =================================================================== | ||
| --- sagemaker-code-editor.orig/vscode/src/vs/workbench/services/environment/browser/environmentService.ts | ||
| +++ sagemaker-code-editor/vscode/src/vs/workbench/services/environment/browser/environmentService.ts | ||
| @@ -102,7 +102,14 @@ export class BrowserWorkbenchEnvironment | ||
| get logFile(): URI { return joinPath(this.windowLogsPath, 'window.log'); } | ||
|
|
||
| @memoize | ||
| - get userRoamingDataHome(): URI { return URI.file('/User').with({ scheme: Schemas.vscodeUserData }); } | ||
| + get userRoamingDataHome(): URI { return joinPath(URI.file(this.userDataPath).with({ scheme: Schemas.vscodeRemote }), 'User'); } | ||
| + | ||
| + get userDataPath(): string { | ||
| + if (!this.options.userDataPath) { | ||
| + throw new Error('userDataPath was not provided to the browser'); | ||
| + } | ||
| + return this.options.userDataPath; | ||
| + } | ||
|
|
||
| @memoize | ||
| get argvResource(): URI { return joinPath(this.userRoamingDataHome, 'argv.json'); } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we want to change this? the date too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the
commitanddatenecessary here? @aws-prayagsoriginal source code: https://github.com/microsoft/vscode/blob/f1b07bd25dfad64b0167beb15359ae573aecd2cc/src/vs/platform/product/common/product.ts#L65
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should revisit this - let's track in a github issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tracking issue here: #14