src/vs/workbench/contrib/update/browser/update.ts/SwitchProductQualityContribution/registerGlobalActivityActions
class SwitchProductQualityContribution:	private registerGlobalActivityActions(): void {
		const quality = this.productService.quality;
		const productQualityChangeHandler = this.environmentService.options?.productQualityChangeHandler;
		if (productQualityChangeHandler && (quality === 'stable' || quality === 'insider')) {
			const newQuality = quality === 'stable' ? 'insider' : 'stable';
			const commandId = `update.switchQuality.${newQuality}`;
			const isSwitchingToInsiders = newQuality === 'insider';
			registerAction2(class SwitchQuality extends Action2 {
				constructor() {
					super({
						id: commandId,
						title: isSwitchingToInsiders ? nls.localize('switchToInsiders', "Switch to Insiders Version...") : nls.localize('switchToStable', "Switch to Stable Version..."),
						precondition: IsWebContext,
						menu: {
							id: MenuId.GlobalActivity,
							when: IsWebContext,
							group: '7_update',
						}
					});
				}

				async run(accessor: ServicesAccessor): Promise<void> {
					const dialogService = accessor.get(IDialogService);
					const userDataAutoSyncEnablementService = accessor.get(IUserDataAutoSyncEnablementService);
					const userDataSyncStoreManagementService = accessor.get(IUserDataSyncStoreManagementService);
					const storageService = accessor.get(IStorageService);
					const userDataSyncWorkbenchService = accessor.get(IUserDataSyncWorkbenchService);
					const userDataSyncService = accessor.get(IUserDataSyncService);

					const selectSettingsSyncServiceDialogShownKey = 'switchQuality.selectSettingsSyncServiceDialogShown';
					const userDataSyncStore = userDataSyncStoreManagementService.userDataSyncStore;
					let userDataSyncStoreType: UserDataSyncStoreType | undefined;
					if (userDataSyncStore && isSwitchingToInsiders && userDataAutoSyncEnablementService.isEnabled()
						&& !storageService.getBoolean(selectSettingsSyncServiceDialogShownKey, StorageScope.GLOBAL, false)) {
						userDataSyncStoreType = await this.selectSettingsSyncService(dialogService);
						if (!userDataSyncStoreType) {
							return;
						}
						storageService.store(selectSettingsSyncServiceDialogShownKey, true, StorageScope.GLOBAL, StorageTarget.USER);
						if (userDataSyncStoreType === 'stable') {
							// Update the stable service type in the current window, so that it uses stable service after switched to insiders version (after reload).
							await userDataSyncStoreManagementService.switch(userDataSyncStoreType);
						}
					}

					const res = await dialogService.confirm({
						type: 'info',
						message: nls.localize('relaunchMessage', "Changing the version requires a reload to take effect"),
						detail: newQuality === 'insider' ?
							nls.localize('relaunchDetailInsiders', "Press the reload button to switch to the nightly pre-production version of VSCode.") :
							nls.localize('relaunchDetailStable', "Press the reload button to switch to the monthly released stable version of VSCode."),
						primaryButton: nls.localize('reload', "&&Reload")
					});

					if (res.confirmed) {
						const promises: Promise<any>[] = [];

						// If sync is happening wait until it is finished before reload
						if (userDataSyncService.status === SyncStatus.Syncing) {
							promises.push(Event.toPromise(Event.filter(userDataSyncService.onDidChangeStatus, status => status !== SyncStatus.Syncing)));
						}

						// Synchronise the store type option in insiders service, so that other clients using insiders service are also updated.
						if (isSwitchingToInsiders) {
							promises.push(userDataSyncWorkbenchService.synchroniseUserDataSyncStoreType());
						}

						await Promises.settled(promises);

						productQualityChangeHandler(newQuality);
					} else {
						// Reset
						if (userDataSyncStoreType) {
							storageService.remove(selectSettingsSyncServiceDialogShownKey, StorageScope.GLOBAL);
						}
					}
				}

				private async selectSettingsSyncService(dialogService: IDialogService): Promise<UserDataSyncStoreType | undefined> {
					const res = await dialogService.show(
						Severity.Info,
						nls.localize('selectSyncService.message', "Choose the settings sync service to use after changing the version"),
						[
							nls.localize('use insiders', "Insiders"),
							nls.localize('use stable', "Stable (current)"),
							nls.localize('cancel', "Cancel"),
						],
						{
							detail: nls.localize('selectSyncService.detail', "The Insiders version of VS Code will synchronize your settings, keybindings, extensions, snippets and UI State using separate insiders settings sync service by default."),
							cancelId: 2
						}
					);
					return res.choice === 0 ? 'insiders' : res.choice === 1 ? 'stable' : undefined;
				}
			});
		}
	}