Skip to content

Commit 71c53cc

Browse files
committed
feat: Add SageMaker UI Dark Theme extension
**Description** - Adding SageMaker UI Dark Theme system extension - This extension allows the "Default Dark Modern" theme to be enabled in SageMaker Unified Studio by default. - Checks against the SERVICE_NAME=SageMakerUnifiedStudio environment variable to dynamically apply. - If user settings or workspace settings have workbench.colorTheme set, Default Dark Modern does not get applied. - This allows user to set their own theme if they choose. - Provides extension output in Output View in SageMaker Unified Studio (Disabled in SageMaker AI). **Testing Done** - Tested locally with ENV variable SERVICE_NAME=SageMakerUnifiedStudio set and unset. - Confirmed Default Dark Modern theme applies and provides logging output when ENV variable is set. - Confirmed SageMaker AI experience is unaffected.
1 parent 914e854 commit 71c53cc

File tree

13 files changed

+403
-1
lines changed

13 files changed

+403
-1
lines changed

patched-vscode/build/gulpfile.extensions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const compilations = [
6464
'extensions/sagemaker-idle-extension/tsconfig.json',
6565
'extensions/sagemaker-terminal-crash-mitigation/tsconfig.json',
6666
'extensions/sagemaker-open-notebook-extension/tsconfig.json',
67+
'extensions/sagemaker-ui-dark-theme/tsconfig.json',
6768
'extensions/tunnel-forwarding/tsconfig.json',
6869
'extensions/typescript-language-features/test-workspace/tsconfig.json',
6970
'extensions/typescript-language-features/web/tsconfig.json',

patched-vscode/build/npm/dirs.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const dirs = [
4343
'extensions/sagemaker-idle-extension',
4444
'extensions/sagemaker-terminal-crash-mitigation',
4545
'extensions/sagemaker-open-notebook-extension',
46+
'extensions/sagemaker-ui-dark-theme',
4647
'extensions/search-result',
4748
'extensions/simple-browser',
4849
'extensions/tunnel-forwarding',
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.vscode/**
2+
.vscode-test/**
3+
out/test/**
4+
out/**
5+
test/**
6+
src/**
7+
tsconfig.json
8+
out/test/**
9+
out/**
10+
cgmanifest.json
11+
yarn.lock
12+
preview-src/**
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# SageMaker UI Dark Theme
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright Amazon.com Inc. or its affiliates. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
//@ts-check
7+
8+
'use strict';
9+
10+
const withBrowserDefaults = require('../shared.webpack.config').browser;
11+
12+
module.exports = withBrowserDefaults({
13+
context: __dirname,
14+
entry: {
15+
extension: './src/extension.ts'
16+
},
17+
});
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright Amazon.com Inc. or its affiliates. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
//@ts-check
7+
8+
'use strict';
9+
10+
const withDefaults = require('../shared.webpack.config');
11+
12+
module.exports = withDefaults({
13+
context: __dirname,
14+
resolve: {
15+
mainFields: ['module', 'main']
16+
},
17+
entry: {
18+
extension: './src/extension.ts',
19+
}
20+
});
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"name": "sagemaker-ui-dark-theme",
3+
"displayName": "SageMaker UI Dark Theme",
4+
"description": "SageMaker UI Dark Theme",
5+
"extensionKind": [
6+
"workspace"
7+
],
8+
"version": "1.0.0",
9+
"publisher": "sagemaker",
10+
"license": "MIT",
11+
"engines": {
12+
"vscode": "^1.70.0"
13+
},
14+
"main": "./out/extension",
15+
"categories": [
16+
"Other"
17+
],
18+
"activationEvents": [
19+
"onStartupFinished"
20+
],
21+
"capabilities": {
22+
"virtualWorkspaces": true,
23+
"untrustedWorkspaces": {
24+
"supported": true
25+
}
26+
},
27+
"contributes": {
28+
"configuration": {
29+
"type": "object",
30+
"title": "SageMaker UI Dark Theme",
31+
"properties": {}
32+
},
33+
"commands": [
34+
]
35+
},
36+
"scripts": {
37+
"compile": "gulp compile-extension:sagemaker-ui-dark-theme",
38+
"watch": "npm run build-preview && gulp watch-extension:sagemaker-ui-dark-theme",
39+
"vscode:prepublish": "npm run build-ext",
40+
"build-ext": "node ../../node_modules/gulp/bin/gulp.js --gulpfile ../../build/gulpfile.extensions.js compile-extension:sagemaker-ui-dark-theme ./tsconfig.json"
41+
},
42+
"dependencies": {
43+
},
44+
"repository": {
45+
}
46+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import * as vscode from 'vscode';
2+
3+
const SERVICE_NAME_ENV_KEY = 'SERVICE_NAME';
4+
const SERVICE_NAME_ENV_VALUE = 'SageMakerUnifiedStudio';
5+
const DEFAULT_THEME = 'Default Dark Modern';
6+
7+
let outputChannel: vscode.OutputChannel;
8+
9+
export function activate() {
10+
// Check if in SageMaker Unified Studio
11+
const envValue = process.env[SERVICE_NAME_ENV_KEY];
12+
if (!envValue || envValue !== SERVICE_NAME_ENV_VALUE) {
13+
return;
14+
}
15+
16+
const config = vscode.workspace.getConfiguration();
17+
const themeConfig = config.inspect('workbench.colorTheme');
18+
outputChannel = vscode.window.createOutputChannel('SageMaker UI Dark Theme');
19+
20+
outputChannel.appendLine(`Current theme configuration: ${JSON.stringify(themeConfig, null, 2)}`);
21+
22+
// Check if theme is only set at default level
23+
if (themeConfig?.globalValue === undefined &&
24+
themeConfig?.workspaceValue === undefined &&
25+
themeConfig?.workspaceFolderValue === undefined) {
26+
27+
outputChannel.appendLine('Theme only set at default level, applying theme update');
28+
29+
// Update the configuration
30+
Promise.resolve(
31+
config.update('workbench.colorTheme', DEFAULT_THEME, vscode.ConfigurationTarget.Global)
32+
.then(() => {
33+
outputChannel.appendLine(`Theme configuration updated to ${DEFAULT_THEME}`);
34+
// Reload to apply theme
35+
return vscode.commands.executeCommand('workbench.action.reloadWindow');
36+
})
37+
.then(() => outputChannel.appendLine('Theme applied successfully'))
38+
)
39+
.catch((error) => {
40+
outputChannel.appendLine(`Failed to apply theme: ${error}`);
41+
});
42+
} else {
43+
outputChannel.appendLine('Theme already configured in user or workspace settings, not overriding');
44+
}
45+
}
46+
47+
export function deactivate() {
48+
if (outputChannel) {
49+
outputChannel.dispose();
50+
}
51+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "../tsconfig.base.json",
3+
"compilerOptions": {
4+
"outDir": "./out"
5+
},
6+
"include": [
7+
"src/**/*",
8+
"../../src/vscode-dts/vscode.d.ts"
9+
]
10+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+

0 commit comments

Comments
 (0)