mirror of
https://github.com/coder/code-server.git
synced 2026-05-05 03:55:18 +02:00
* Update Code to 1.116.0 * Add copilot extension build Seems the vscode build requires this separately now. * Disable welcome popup A giant modal window asking you to sign in for AI features is blocking the tests. Rather than have to click through it, disable it. It looks like this has to be a user setting, so switch to that instead of machine (we used machine because user settings were in the browser, but they have been since moved back to disk). --------- Co-authored-by: Asher <ash@coder.com>
146 lines
5.3 KiB
Diff
146 lines
5.3 KiB
Diff
Add a notification that lets you know when an update is out
|
|
|
|
The easiest way to test this is probably to change the version in your
|
|
package.json and delete the last notification storage item.
|
|
|
|
1. change version in root `package.json`
|
|
2. Open DevTools > Application > Storage (top-level)
|
|
3. Click "Clear site data"
|
|
4. See update notification
|
|
|
|
Index: code-server/lib/vscode/src/vs/workbench/browser/client.ts
|
|
===================================================================
|
|
--- code-server.orig/lib/vscode/src/vs/workbench/browser/client.ts
|
|
+++ code-server/lib/vscode/src/vs/workbench/browser/client.ts
|
|
@@ -1,10 +1,16 @@
|
|
import { Disposable } from "../../base/common/lifecycle.js";
|
|
import { localize } from '../../nls.js';
|
|
+import { ILogService } from '../../platform/log/common/log.js';
|
|
import { INotificationService, Severity } from '../../platform/notification/common/notification.js';
|
|
+import { IProductService } from '../../platform/product/common/productService.js';
|
|
+import { IStorageService, StorageScope, StorageTarget } from '../../platform/storage/common/storage.js';
|
|
|
|
export class CodeServerClient extends Disposable {
|
|
constructor (
|
|
+ @ILogService private logService: ILogService,
|
|
@INotificationService private notificationService: INotificationService,
|
|
+ @IProductService private productService: IProductService,
|
|
+ @IStorageService private storageService: IStorageService,
|
|
) {
|
|
super();
|
|
}
|
|
@@ -71,5 +77,59 @@ export class CodeServerClient extends Di
|
|
},
|
|
});
|
|
}
|
|
+
|
|
+ if (this.productService.updateEndpoint) {
|
|
+ this.checkUpdates(this.productService.updateEndpoint)
|
|
+ }
|
|
+ }
|
|
+
|
|
+ private checkUpdates(updateEndpoint: string) {
|
|
+ const getUpdate = async (updateCheckEndpoint: string): Promise<void> => {
|
|
+ this.logService.debug('Checking for update...');
|
|
+
|
|
+ const response = await fetch(updateCheckEndpoint, {
|
|
+ headers: { Accept: 'application/json' },
|
|
+ });
|
|
+ if (!response.ok) {
|
|
+ throw new Error(response.statusText);
|
|
+ }
|
|
+ const json = await response.json();
|
|
+ if (json.error) {
|
|
+ throw new Error(json.error);
|
|
+ }
|
|
+ if (json.isLatest) {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ const lastNoti = this.storageService.getNumber('csLastUpdateNotification', StorageScope.APPLICATION);
|
|
+ if (lastNoti) {
|
|
+ // Only remind them again after 1 week.
|
|
+ const timeout = 1000 * 60 * 60 * 24 * 7;
|
|
+ const threshold = lastNoti + timeout;
|
|
+ if (Date.now() < threshold) {
|
|
+ return;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ this.storageService.store('csLastUpdateNotification', Date.now(), StorageScope.APPLICATION, StorageTarget.MACHINE);
|
|
+
|
|
+ this.notificationService.notify({
|
|
+ severity: Severity.Info,
|
|
+ message: `[code-server v${json.latest}](https://github.com/cdr/code-server/releases/tag/v${json.latest}) has been released!`,
|
|
+ });
|
|
+ };
|
|
+
|
|
+ const updateLoop = (): void => {
|
|
+ getUpdate(updateEndpoint)
|
|
+ .catch(error => {
|
|
+ this.logService.debug(`failed to check for update: ${error}`);
|
|
+ })
|
|
+ .finally(() => {
|
|
+ // Check again every 6 hours.
|
|
+ setTimeout(updateLoop, 1000 * 60 * 60 * 6);
|
|
+ });
|
|
+ };
|
|
+
|
|
+ updateLoop();
|
|
}
|
|
}
|
|
Index: code-server/lib/vscode/src/vs/base/common/product.ts
|
|
===================================================================
|
|
--- code-server.orig/lib/vscode/src/vs/base/common/product.ts
|
|
+++ code-server/lib/vscode/src/vs/base/common/product.ts
|
|
@@ -67,6 +67,7 @@ export type ExtensionVirtualWorkspaceSup
|
|
export interface IProductConfiguration {
|
|
readonly codeServerVersion?: string
|
|
readonly rootEndpoint?: string
|
|
+ readonly updateEndpoint?: string
|
|
|
|
readonly version: string;
|
|
readonly date?: string;
|
|
@@ -118,6 +119,7 @@ export interface IProductConfiguration {
|
|
readonly resourceUrlTemplate: string;
|
|
readonly nlsBaseUrl: string;
|
|
readonly accessSKUs?: string[];
|
|
+ readonly authorizationHeaderToken?: string;
|
|
};
|
|
|
|
readonly mcpGallery?: {
|
|
Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
|
|
===================================================================
|
|
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
|
|
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
|
|
@@ -360,6 +360,7 @@ export class WebClientServer {
|
|
const productConfiguration: Partial<Mutable<IProductConfiguration>> = {
|
|
codeServerVersion: this._productService.codeServerVersion,
|
|
rootEndpoint: rootBase,
|
|
+ updateEndpoint: !this._environmentService.args['disable-update-check'] ? rootBase + '/update/check' : undefined,
|
|
embedderIdentifier: 'server-distro',
|
|
extensionsGallery: this._productService.extensionsGallery,
|
|
};
|
|
Index: code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
|
|
===================================================================
|
|
--- code-server.orig/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
|
|
+++ code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
|
|
@@ -16,6 +16,8 @@ import { join } from '../../base/common/
|
|
import { ProtocolConstants } from '../../base/parts/ipc/common/ipc.net.js';
|
|
|
|
export const serverOptions: OptionDescriptions<Required<ServerParsedArgs>> = {
|
|
+ /* ----- code-server ----- */
|
|
+ 'disable-update-check': { type: 'boolean' },
|
|
|
|
/* ----- server setup ----- */
|
|
|
|
@@ -104,6 +106,8 @@ export const serverOptions: OptionDescri
|
|
};
|
|
|
|
export interface ServerParsedArgs {
|
|
+ /* ----- code-server ----- */
|
|
+ 'disable-update-check'?: boolean;
|
|
|
|
/* ----- server setup ----- */
|
|
|