@@ -444,17 +444,18 @@ index d0f6e6b18a..1966fd297d 100644
444444-
445445diff --git a/src/vs/server/browser/client.ts b/src/vs/server/browser/client.ts
446446new file mode 100644
447- index 0000000000..3a62205b38
447+ index 0000000000..1e6bca3b52
448448--- /dev/null
449449+++ b/src/vs/server/browser/client.ts
450- @@ -0,0 +1,162 @@
450+ @@ -0,0 +1,224 @@
451451+ import { Emitter } from 'vs/base/common/event';
452452+ import { URI } from 'vs/base/common/uri';
453453+ import { localize } from 'vs/nls';
454454+ import { Extensions, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry';
455455+ import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
456456+ import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
457457+ import { ILocalizationsService } from 'vs/platform/localizations/common/localizations';
458+ + import { ILogService } from 'vs/platform/log/common/log';
458459+ import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
459460+ import { Registry } from 'vs/platform/registry/common/platform';
460461+ import { PersistentConnectionEventType } from 'vs/platform/remote/common/remoteAgentConnection';
@@ -575,6 +576,67 @@ index 0000000000..3a62205b38
575576+ }
576577+ });
577578+ }
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();
578640+ };
579641+
580642+ export interface Query {
@@ -2968,7 +3030,7 @@ index bbb72e9511..0785d3391d 100644
29683030- registerSingleton(IExtensionStoragePaths, class extends NotImplementedProxy(IExtensionStoragePaths) { whenReady = Promise.resolve(); });
29693031+ registerSingleton(IExtensionStoragePaths, ExtensionStoragePaths);
29703032diff --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
29723034--- a/src/vs/workbench/services/extensions/worker/extensionHostWorkerMain.ts
29733035+++ b/src/vs/workbench/services/extensions/worker/extensionHostWorkerMain.ts
29743036@@ -14,7 +14,11 @@
@@ -2978,8 +3040,8 @@ index 79455414c0..a407593b4d 100644
29783040- catchError: true
29793041+ catchError: true,
29803042+ 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`,
29833045+ }
29843046 });
29853047
0 commit comments