@@ -444,17 +444,18 @@ index d0f6e6b18a..1966fd297d 100644
444
444
-
445
445
diff --git a/src/vs/server/browser/client.ts b/src/vs/server/browser/client.ts
446
446
new file mode 100644
447
- index 0000000000..3a62205b38
447
+ index 0000000000..1e6bca3b52
448
448
--- /dev/null
449
449
+++ b/src/vs/server/browser/client.ts
450
- @@ -0,0 +1,162 @@
450
+ @@ -0,0 +1,224 @@
451
451
+ import { Emitter } from 'vs/base/common/event';
452
452
+ import { URI } from 'vs/base/common/uri';
453
453
+ import { localize } from 'vs/nls';
454
454
+ import { Extensions, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry';
455
455
+ import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
456
456
+ import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
457
457
+ import { ILocalizationsService } from 'vs/platform/localizations/common/localizations';
458
+ + import { ILogService } from 'vs/platform/log/common/log';
458
459
+ import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
459
460
+ import { Registry } from 'vs/platform/registry/common/platform';
460
461
+ import { PersistentConnectionEventType } from 'vs/platform/remote/common/remoteAgentConnection';
@@ -575,6 +576,67 @@ index 0000000000..3a62205b38
575
576
+ }
576
577
+ });
577
578
+ }
579
+ +
580
+ + const applyUpdate = async (): Promise<void> => {
581
+ + (services.get(ILogService) as ILogService).debug("Applying update...");
582
+ +
583
+ + const response = await fetch("./update/apply", {
584
+ + headers: { "content-type": "application/json" },
585
+ + });
586
+ + if (response.status !== 200) {
587
+ + throw new Error("Unexpected response");
588
+ + }
589
+ +
590
+ + const json = await response.json();
591
+ + if (!json.isLatest) {
592
+ + throw new Error("Update failed");
593
+ + }
594
+ +
595
+ + (services.get(INotificationService) as INotificationService).info(`Updated to ${json.version}`);
596
+ + };
597
+ +
598
+ + const getUpdate = async (): Promise<void> => {
599
+ + (services.get(ILogService) as ILogService).debug("Checking for update...");
600
+ +
601
+ + const response = await fetch("./update", {
602
+ + headers: { "content-type": "application/json" },
603
+ + });
604
+ + if (response.status !== 200) {
605
+ + throw new Error("unexpected response");
606
+ + }
607
+ +
608
+ + const json = await response.json();
609
+ + if (json.isLatest) {
610
+ + return;
611
+ + }
612
+ +
613
+ + (services.get(INotificationService) as INotificationService).notify({
614
+ + severity: Severity.Info,
615
+ + message: `code-server has an update: ${json.version}`,
616
+ + actions: {
617
+ + primary: [{
618
+ + id: 'update',
619
+ + label: 'Apply Update',
620
+ + tooltip: '',
621
+ + class: undefined,
622
+ + enabled: true,
623
+ + checked: true,
624
+ + dispose: () => undefined,
625
+ + run: applyUpdate,
626
+ + }],
627
+ + }
628
+ + });
629
+ + };
630
+ +
631
+ + const updateLoop = (): void => {
632
+ + getUpdate().catch((error) => {
633
+ + (services.get(ILogService) as ILogService).warn(error);
634
+ + }).finally(() => {
635
+ + setTimeout(updateLoop, 300000);
636
+ + });
637
+ + };
638
+ +
639
+ + updateLoop();
578
640
+ };
579
641
+
580
642
+ export interface Query {
@@ -2968,7 +3030,7 @@ index bbb72e9511..0785d3391d 100644
2968
3030
- registerSingleton(IExtensionStoragePaths, class extends NotImplementedProxy(IExtensionStoragePaths) { whenReady = Promise.resolve(); });
2969
3031
+ registerSingleton(IExtensionStoragePaths, ExtensionStoragePaths);
2970
3032
diff --git a/src/vs/workbench/services/extensions/worker/extensionHostWorkerMain.ts b/src/vs/workbench/services/extensions/worker/extensionHostWorkerMain.ts
2971
- index 79455414c0..a407593b4d 100644
3033
+ index 79455414c0..8931c1355a 100644
2972
3034
--- a/src/vs/workbench/services/extensions/worker/extensionHostWorkerMain.ts
2973
3035
+++ b/src/vs/workbench/services/extensions/worker/extensionHostWorkerMain.ts
2974
3036
@@ -14,7 +14,11 @@
@@ -2978,8 +3040,8 @@ index 79455414c0..a407593b4d 100644
2978
3040
- catchError: true
2979
3041
+ catchError: true,
2980
3042
+ paths: {
2981
- + '@coder/node-browser': `.. /node_modules/@coder/node-browser/out/client/client.js`,
2982
- + '@coder/requirefs': `.. /node_modules/@coder/requirefs/out/requirefs.js`,
3043
+ + '@coder/node-browser': `{{BASE}}/static/{{COMMIT}}/lib/vscode /node_modules/@coder/node-browser/out/client/client.js`,
3044
+ + '@coder/requirefs': `{{BASE}}/static/{{COMMIT}}/lib/vscode /node_modules/@coder/requirefs/out/requirefs.js`,
2983
3045
+ }
2984
3046
});
2985
3047
0 commit comments