Skip to content

Commit e1250b3

Browse files
author
Newton Der
committed
Use readdirSync, refresh other patches
1 parent e92d89f commit e1250b3

File tree

7 files changed

+46
-52
lines changed

7 files changed

+46
-52
lines changed

patched-vscode/build/npm/dirs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const dirs = [
4545
'extensions/sagemaker-terminal-crash-mitigation',
4646
'extensions/sagemaker-open-notebook-extension',
4747
'extensions/sagemaker-ui-dark-theme',
48-
'extensions/post-startup-notifications',
48+
'extensions/post-startup-notifications',
4949
'extensions/search-result',
5050
'extensions/simple-browser',
5151
'extensions/tunnel-forwarding',

patched-vscode/src/vs/server/node/webClientServer.ts

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -114,31 +114,25 @@ const APP_ROOT = dirname(FileAccess.asFileUri('').fsPath);
114114
* If activity is detected (i.e., if any PTY device file was modified within the CHECK_INTERVAL), this function
115115
* updates the last activity timestamp.
116116
*/
117-
const checkTerminalActivity = (idleFilePath: string) => {
118-
fs.readdir('/dev/pts', (err, files) => {
119-
if (err) {
120-
console.error('Error reading /dev/pts directory:', err);
121-
return;
122-
}
123-
117+
function checkTerminalActivity(idleFilePath: string) {
118+
try {
119+
const files: string[] = fs.readdirSync('/dev/pts');
124120
const now = new Date();
125-
const activityDetected = files.some((file) => {
121+
122+
const activityDetected = files.some((file: string) => {
126123
const filePath = path.join('/dev/pts', file);
127-
try {
128-
const stats = fs.statSync(filePath);
129-
const mtime = new Date(stats.mtime).getTime();
130-
return now.getTime() - mtime < CHECK_INTERVAL;
131-
} catch (error) {
132-
console.error('Error reading file stats:', error);
133-
return false;
134-
}
124+
const stats = fs.statSync(filePath);
125+
const mtime = new Date(stats.mtime).getTime();
126+
return now.getTime() - mtime < CHECK_INTERVAL;
135127
});
136128

137129
if (activityDetected) {
138130
fs.writeFileSync(idleFilePath, now.toISOString());
139131
}
140-
});
141-
};
132+
} catch (err) {
133+
console.error('Error checking terminal activity:', err);
134+
}
135+
}
142136

143137
export class WebClientServer {
144138

patches/custom-extensions-marketplace.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Index: sagemaker-code-editor/vscode/src/vs/server/node/webClientServer.ts
9898
===================================================================
9999
--- sagemaker-code-editor.orig/vscode/src/vs/server/node/webClientServer.ts
100100
+++ sagemaker-code-editor/vscode/src/vs/server/node/webClientServer.ts
101-
@@ -370,14 +370,7 @@ export class WebClientServer {
101+
@@ -364,14 +364,7 @@ export class WebClientServer {
102102
const productConfiguration = {
103103
rootEndpoint: base,
104104
embedderIdentifier: 'server-distro',

patches/display-language.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ Index: sagemaker-code-editor/vscode/src/vs/server/node/webClientServer.ts
304304
import { CharCode } from 'vs/base/common/charCode';
305305
import { IExtensionManifest } from 'vs/platform/extensions/common/extensions';
306306

307-
@@ -362,6 +363,8 @@ export class WebClientServer {
307+
@@ -395,6 +396,8 @@ export class WebClientServer {
308308
callbackRoute: this._callbackRoute
309309
};
310310

@@ -313,15 +313,15 @@ Index: sagemaker-code-editor/vscode/src/vs/server/node/webClientServer.ts
313313
const nlsBaseUrl = this._productService.extensionsGallery?.nlsBaseUrl;
314314
const values: { [key: string]: string } = {
315315
WORKBENCH_WEB_CONFIGURATION: asJSON(workbenchWebConfiguration),
316-
@@ -370,6 +373,7 @@ export class WebClientServer {
316+
@@ -403,6 +406,7 @@ export class WebClientServer {
317317
WORKBENCH_NLS_BASE_URL: vscodeBase + (nlsBaseUrl ? `${nlsBaseUrl}${!nlsBaseUrl.endsWith('/') ? '/' : ''}${this._productService.commit}/${this._productService.version}/` : ''),
318318
BASE: base,
319319
VS_BASE: vscodeBase,
320320
+ NLS_CONFIGURATION: asJSON(nlsConfiguration),
321321
};
322322

323323
if (useTestResolver) {
324-
@@ -401,7 +405,7 @@ export class WebClientServer {
324+
@@ -434,7 +438,7 @@ export class WebClientServer {
325325
`frame-src 'self' https://*.vscode-cdn.net data:;`,
326326
'worker-src \'self\' data: blob:;',
327327
'style-src \'self\' \'unsafe-inline\';',

patches/sagemaker-extensions-sync.patch

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,25 @@ Index: sagemaker-code-editor/vscode/build/gulpfile.extensions.js
99
+ 'extensions/sagemaker-extensions-sync/tsconfig.json',
1010
'extensions/sagemaker-terminal-crash-mitigation/tsconfig.json',
1111
'extensions/sagemaker-open-notebook-extension/tsconfig.json',
12-
'extensions/tunnel-forwarding/tsconfig.json',
12+
'extensions/sagemaker-ui-dark-theme/tsconfig.json',
1313
Index: sagemaker-code-editor/vscode/build/npm/dirs.js
1414
===================================================================
1515
--- sagemaker-code-editor.orig/vscode/build/npm/dirs.js
1616
+++ sagemaker-code-editor/vscode/build/npm/dirs.js
17-
@@ -40,6 +40,7 @@ const dirs = [
17+
@@ -40,11 +40,12 @@ const dirs = [
1818
'extensions/php-language-features',
1919
'extensions/references-view',
2020
'extensions/sagemaker-extension',
2121
+ 'extensions/sagemaker-extensions-sync',
2222
'extensions/sagemaker-idle-extension',
2323
'extensions/sagemaker-terminal-crash-mitigation',
2424
'extensions/sagemaker-open-notebook-extension',
25+
'extensions/sagemaker-ui-dark-theme',
26+
- 'extensions/post-startup-notifications',
27+
+ 'extensions/post-startup-notifications',
28+
'extensions/search-result',
29+
'extensions/simple-browser',
30+
'extensions/tunnel-forwarding',
2531
Index: sagemaker-code-editor/vscode/extensions/sagemaker-extensions-sync/.vscodeignore
2632
===================================================================
2733
--- /dev/null

patches/sagemaker-idle-extension.patch

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ Index: sagemaker-code-editor/vscode/src/vs/server/node/webClientServer.ts
247247
import * as path from 'path';
248248
import * as http from 'http';
249249
import * as url from 'url';
250-
@@ -91,8 +93,47 @@ export async function serveFile(filePath
250+
@@ -91,8 +93,41 @@ export async function serveFile(filePath
251251
}
252252
}
253253

@@ -266,52 +266,46 @@ Index: sagemaker-code-editor/vscode/src/vs/server/node/webClientServer.ts
266266
+ * If activity is detected (i.e., if any PTY device file was modified within the CHECK_INTERVAL), this function
267267
+ * updates the last activity timestamp.
268268
+ */
269-
+const checkTerminalActivity = (idleFilePath: string) => {
270-
+ fs.readdir('/dev/pts', (err, files) => {
271-
+ if (err) {
272-
+ console.error('Error reading /dev/pts directory:', err);
273-
+ return;
274-
+ }
275-
+
269+
+function checkTerminalActivity(idleFilePath: string) {
270+
+ try {
271+
+ const files: string[] = fs.readdirSync('/dev/pts');
276272
+ const now = new Date();
277-
+ const activityDetected = files.some((file) => {
273+
+
274+
+ const activityDetected = files.some((file: string) => {
278275
+ const filePath = path.join('/dev/pts', file);
279-
+ try {
280-
+ const stats = fs.statSync(filePath);
281-
+ const mtime = new Date(stats.mtime).getTime();
282-
+ return now.getTime() - mtime < CHECK_INTERVAL;
283-
+ } catch (error) {
284-
+ console.error('Error reading file stats:', error);
285-
+ return false;
286-
+ }
276+
+ const stats = fs.statSync(filePath);
277+
+ const mtime = new Date(stats.mtime).getTime();
278+
+ return now.getTime() - mtime < CHECK_INTERVAL;
287279
+ });
288280
+
289281
+ if (activityDetected) {
290282
+ fs.writeFileSync(idleFilePath, now.toISOString());
291283
+ }
292-
+ });
293-
+};
284+
+ } catch (err) {
285+
+ console.error('Error checking terminal activity:', err);
286+
+ }
287+
+}
294288
+
295289
export class WebClientServer {
296290

297291
private readonly _webExtensionResourceUrlTemplate: URI | undefined;
298-
@@ -100,6 +141,7 @@ export class WebClientServer {
292+
@@ -100,6 +135,7 @@ export class WebClientServer {
299293
private readonly _staticRoute: string;
300294
private readonly _callbackRoute: string;
301295
private readonly _webExtensionRoute: string;
302296
+ private readonly _idleRoute: string;
303297

304298
constructor(
305299
private readonly _connectionToken: ServerConnectionToken,
306-
@@ -115,6 +157,7 @@ export class WebClientServer {
300+
@@ -115,6 +151,7 @@ export class WebClientServer {
307301
this._staticRoute = `${serverRootPath}/static`;
308302
this._callbackRoute = `${serverRootPath}/callback`;
309303
this._webExtensionRoute = `${serverRootPath}/web-extension-resource`;
310304
+ this._idleRoute = '/api/idle';
311305
}
312306

313307
/**
314-
@@ -132,6 +175,9 @@ export class WebClientServer {
308+
@@ -132,6 +169,9 @@ export class WebClientServer {
315309
if (pathname === this._basePath) {
316310
return this._handleRoot(req, res, parsedUrl);
317311
}
@@ -321,7 +315,7 @@ Index: sagemaker-code-editor/vscode/src/vs/server/node/webClientServer.ts
321315
if (pathname === this._callbackRoute) {
322316
// callback support
323317
return this._handleCallback(res);
324-
@@ -451,6 +497,33 @@ export class WebClientServer {
318+
@@ -451,6 +491,33 @@ export class WebClientServer {
325319
});
326320
return void res.end(data);
327321
}

patches/sagemaker-ui-post-startup.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,23 @@ Index: sagemaker-code-editor/vscode/src/vs/server/node/webClientServer.ts
2121
/**
2222
* Return an error to the client.
2323
*/
24-
@@ -142,6 +147,7 @@ export class WebClientServer {
24+
@@ -136,6 +141,7 @@ export class WebClientServer {
2525
private readonly _callbackRoute: string;
2626
private readonly _webExtensionRoute: string;
2727
private readonly _idleRoute: string;
2828
+ private readonly _postStartupScriptRoute: string;
2929

3030
constructor(
3131
private readonly _connectionToken: ServerConnectionToken,
32-
@@ -158,6 +164,7 @@ export class WebClientServer {
32+
@@ -152,6 +158,7 @@ export class WebClientServer {
3333
this._callbackRoute = `${serverRootPath}/callback`;
3434
this._webExtensionRoute = `${serverRootPath}/web-extension-resource`;
3535
this._idleRoute = '/api/idle';
3636
+ this._postStartupScriptRoute = '/api/poststartup';
3737
}
3838

3939
/**
40-
@@ -186,6 +193,9 @@ export class WebClientServer {
40+
@@ -180,6 +187,9 @@ export class WebClientServer {
4141
// extension resource support
4242
return this._handleWebExtensionResource(req, res, parsedUrl);
4343
}
@@ -47,7 +47,7 @@ Index: sagemaker-code-editor/vscode/src/vs/server/node/webClientServer.ts
4747

4848
return serveError(req, res, 404, 'Not found.');
4949
} catch (error) {
50-
@@ -524,6 +534,41 @@ export class WebClientServer {
50+
@@ -518,6 +528,41 @@ export class WebClientServer {
5151
serveError(req, res, 500, error.message)
5252
}
5353
}

0 commit comments

Comments
 (0)