Skip to content

Commit

Permalink
Enable profiles by default except web+remote (#171812)
Browse files Browse the repository at this point in the history
#116740 Enable profiles by default except web+remote
  • Loading branch information
sandy081 authored Jan 20, 2023
1 parent 42a307e commit 5936a4e
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 135 deletions.
4 changes: 2 additions & 2 deletions src/vs/code/electron-main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ import { FilePolicyService } from 'vs/platform/policy/common/filePolicyService';
import { DisposableStore } from 'vs/base/common/lifecycle';
import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity';
import { UriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentityService';
import { PROFILES_ENABLEMENT_CONFIG } from 'vs/platform/userDataProfile/common/userDataProfile';
import { ILoggerMainService, LoggerMainService } from 'vs/platform/log/electron-main/loggerService';
import { LogService } from 'vs/platform/log/common/logService';

Expand Down Expand Up @@ -258,7 +257,8 @@ class CodeMain {
configurationService.initialize()
]);

userDataProfilesMainService.setEnablement(productService.quality !== 'stable' || configurationService.getValue(PROFILES_ENABLEMENT_CONFIG));
// Initialize user data profiles after initializing the state
userDataProfilesMainService.init();
}

private async claimInstance(logService: ILogService, environmentMainService: IEnvironmentMainService, lifecycleMainService: ILifecycleMainService, instantiationService: IInstantiationService, productService: IProductService, retry: boolean): Promise<NodeIPCServer> {
Expand Down
5 changes: 3 additions & 2 deletions src/vs/code/node/cliProcessMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ import { OneDataSystemAppender } from 'vs/platform/telemetry/node/1dsAppender';
import { buildTelemetryMessage } from 'vs/platform/telemetry/node/telemetry';
import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity';
import { UriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentityService';
import { IUserDataProfile, IUserDataProfilesService, PROFILES_ENABLEMENT_CONFIG } from 'vs/platform/userDataProfile/common/userDataProfile';
import { IUserDataProfile, IUserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile';
import { UserDataProfilesService } from 'vs/platform/userDataProfile/node/userDataProfile';
import { resolveMachineId } from 'vs/platform/telemetry/node/telemetryUtils';
import { ExtensionsProfileScannerService } from 'vs/platform/extensionManagement/node/extensionsProfileScannerService';
Expand Down Expand Up @@ -171,7 +171,8 @@ class CliMain extends Disposable {
configurationService.initialize()
]);

userDataProfilesService.setEnablement(productService.quality !== 'stable' || configurationService.getValue(PROFILES_ENABLEMENT_CONFIG));
// Initialize user data profiles after initializing the state
userDataProfilesService.init();

// URI Identity
services.set(IUriIdentityService, new UriIdentityService(fileService));
Expand Down
18 changes: 10 additions & 8 deletions src/vs/platform/userDataProfile/common/userDataProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ export function isUserDataProfile(thing: unknown): thing is IUserDataProfile {
);
}

export const PROFILES_ENABLEMENT_CONFIG = 'workbench.experimental.settingsProfiles.enabled';

export type DidChangeProfilesEvent = { readonly added: readonly IUserDataProfile[]; readonly removed: readonly IUserDataProfile[]; readonly updated: readonly IUserDataProfile[]; readonly all: readonly IUserDataProfile[] };

export type WillCreateProfileEvent = {
Expand Down Expand Up @@ -178,7 +176,7 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf

readonly _serviceBrand: undefined;

protected enabled: boolean = false;
protected enabled: boolean = true;
readonly profilesHome: URI;

get defaultProfile(): IUserDataProfile { return this.profiles[0]; }
Expand Down Expand Up @@ -214,6 +212,10 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf
this.profilesHome = joinPath(this.environmentService.userRoamingDataHome, 'profiles');
}

init(): void {
this._profilesObject = undefined;
}

setEnablement(enabled: boolean): void {
if (this.enabled !== enabled) {
this._profilesObject = undefined;
Expand Down Expand Up @@ -288,7 +290,7 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf

async createProfile(id: string, name: string, options?: IUserDataProfileOptions, workspaceIdentifier?: IAnyWorkspaceIdentifier): Promise<IUserDataProfile> {
if (!this.enabled) {
throw new Error(`Profiles are disabled. Enable them via the '${PROFILES_ENABLEMENT_CONFIG}' setting.`);
throw new Error(`Profiles are disabled in the current environment.`);
}

const profile = await this.doCreateProfile(id, name, options);
Expand Down Expand Up @@ -338,7 +340,7 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf

async updateProfile(profileToUpdate: IUserDataProfile, options: IUserDataProfileUpdateOptions): Promise<IUserDataProfile> {
if (!this.enabled) {
throw new Error(`Profiles are disabled. Enable them via the '${PROFILES_ENABLEMENT_CONFIG}' setting.`);
throw new Error(`Profiles are disabled in the current environment.`);
}

let profile = this.profiles.find(p => p.id === profileToUpdate.id);
Expand All @@ -354,7 +356,7 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf

async removeProfile(profileToRemove: IUserDataProfile): Promise<void> {
if (!this.enabled) {
throw new Error(`Profiles are disabled. Enable them via the '${PROFILES_ENABLEMENT_CONFIG}' setting.`);
throw new Error(`Profiles are disabled in the current environment.`);
}
if (profileToRemove.isDefault) {
throw new Error('Cannot remove default profile');
Expand Down Expand Up @@ -405,7 +407,7 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf

async setProfileForWorkspace(workspaceIdentifier: IAnyWorkspaceIdentifier, profileToSet: IUserDataProfile): Promise<void> {
if (!this.enabled) {
throw new Error(`Profiles are disabled. Enable them via the '${PROFILES_ENABLEMENT_CONFIG}' setting.`);
throw new Error(`Profiles are disabled in the current environment.`);
}

const profile = this.profiles.find(p => p.id === profileToSet.id);
Expand All @@ -418,7 +420,7 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf

unsetWorkspace(workspaceIdentifier: IAnyWorkspaceIdentifier, transient?: boolean): void {
if (!this.enabled) {
throw new Error(`Profiles are disabled. Enable them via the '${PROFILES_ENABLEMENT_CONFIG}' setting.`);
throw new Error(`Profiles are disabled in the current environment.`);
}

this.updateWorkspaceAssociation(workspaceIdentifier, undefined, transient);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,6 @@ export class UserDataProfilesMainService extends UserDataProfilesService impleme
super(stateMainService, uriIdentityService, environmentService, fileService, logService);
}

override setEnablement(enabled: boolean): void {
super.setEnablement(enabled);
if (!this.enabled) {
// reset
this.saveStoredProfiles([]);
this.saveStoredProfileAssociations({});
}
}

getAssociatedEmptyWindows(): IEmptyWorkspaceIdentifier[] {
const emptyWindows: IEmptyWorkspaceIdentifier[] = [];
for (const id of this.profilesObject.emptyWindows.keys()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ suite('UserDataProfileService (Common)', () => {

environmentService = new TestEnvironmentService(joinPath(ROOT, 'User'));
testObject = new InMemoryUserDataProfilesService(environmentService, fileService, new UriIdentityService(fileService), logService);
testObject.setEnablement(true);
});

teardown(() => disposables.clear());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ suite('UserDataProfileMainService', () => {

testObject = new UserDataProfilesMainService(stateService, new UriIdentityService(fileService), environmentService, fileService, logService);
await stateService.init();
testObject.setEnablement(true);
});

teardown(() => disposables.clear());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ export class UserDataSyncClient extends Disposable {

const userDataProfilesService = new InMemoryUserDataProfilesService(environmentService, fileService, uriIdentityService, logService);
this.instantiationService.stub(IUserDataProfilesService, userDataProfilesService);
userDataProfilesService.setEnablement(true);

const storageService = new TestStorageService(userDataProfilesService.defaultProfile);
this.instantiationService.stub(IStorageService, this._register(storageService));
Expand Down
22 changes: 1 addition & 21 deletions src/vs/workbench/browser/web.main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IProgressService } from 'vs/platform/progress/common/progress';
import { DelayedLogChannel } from 'vs/workbench/services/output/common/delayedLogChannel';
import { dirname, joinPath } from 'vs/base/common/resources';
import { IUserDataProfilesService, PROFILES_ENABLEMENT_CONFIG } from 'vs/platform/userDataProfile/common/userDataProfile';
import { IUserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile';
import { NullPolicyService } from 'vs/platform/policy/common/policy';
import { IRemoteExplorerService, TunnelSource } from 'vs/workbench/services/remote/common/remoteExplorerService';
import { DisposableTunnel, TunnelProtocol } from 'vs/platform/tunnel/common/tunnel';
Expand All @@ -82,7 +82,6 @@ import { UserDataProfileService } from 'vs/workbench/services/userDataProfile/co
import { IUserDataProfileService } from 'vs/workbench/services/userDataProfile/common/userDataProfile';
import { BrowserUserDataProfilesService } from 'vs/platform/userDataProfile/browser/userDataProfile';
import { timeout } from 'vs/base/common/async';
import { ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
import { rendererLogId } from 'vs/workbench/common/logConstants';
import { LogService } from 'vs/platform/log/common/logService';

Expand Down Expand Up @@ -293,19 +292,9 @@ export class BrowserMain extends Disposable {
// User Data Profiles
const userDataProfilesService = new BrowserUserDataProfilesService(environmentService, fileService, uriIdentityService, logService);
serviceCollection.set(IUserDataProfilesService, userDataProfilesService);
let isProfilesEnablementConfigured = false;
if (environmentService.remoteAuthority) {
// Always Disabled in web with remote connection
userDataProfilesService.setEnablement(false);
} else {
if (productService.quality === 'stable') {
// Enabled from Config
userDataProfilesService.setEnablement(window.localStorage.getItem(PROFILES_ENABLEMENT_CONFIG) === 'true');
isProfilesEnablementConfigured = true;
} else {
// Always Enabled
userDataProfilesService.setEnablement(true);
}
}

const currentProfile = userDataProfilesService.getProfileForWorkspace(workspace) ?? userDataProfilesService.defaultProfile;
Expand Down Expand Up @@ -334,15 +323,6 @@ export class BrowserMain extends Disposable {
})
]);

if (isProfilesEnablementConfigured) {
userDataProfilesService.setEnablement(!!configurationService.getValue(PROFILES_ENABLEMENT_CONFIG));
this._register(configurationService.onDidChangeConfiguration(e => {
if (e.source !== ConfigurationTarget.DEFAULT && e.affectsConfiguration(PROFILES_ENABLEMENT_CONFIG)) {
window.localStorage.setItem(PROFILES_ENABLEMENT_CONFIG, !!configurationService.getValue(PROFILES_ENABLEMENT_CONFIG) ? 'true' : 'false');
}
}));
}

// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//
// NOTE: Please do NOT register services here. Use `registerSingleton()`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ interface IConfiguration extends IWindowsConfiguration {
editor?: { accessibilitySupport?: 'on' | 'off' | 'auto' };
security?: { workspace?: { trust?: { enabled?: boolean } } };
window: IWindowSettings & { experimental?: { windowControlsOverlay?: { enabled?: boolean }; useSandbox?: boolean } };
workbench?: { experimental?: { settingsProfiles?: { enabled?: boolean } }; enableExperiments?: boolean };
workbench?: { enableExperiments?: boolean };
extensions?: { experimental?: { useUtilityProcess?: boolean } };
_extensionsGallery?: { enablePPE?: boolean };
}
Expand All @@ -45,7 +45,6 @@ export class SettingsChangeRelauncher extends Disposable implements IWorkbenchCo
'update.mode',
'editor.accessibilitySupport',
'security.workspace.trust.enabled',
'workbench.experimental.settingsProfiles.enabled',
'workbench.enableExperiments',
'_extensionsGallery.enablePPE'
];
Expand All @@ -60,7 +59,6 @@ export class SettingsChangeRelauncher extends Disposable implements IWorkbenchCo
private readonly updateMode = new ChangeObserver('string');
private accessibilitySupport: 'on' | 'off' | 'auto' | undefined;
private readonly workspaceTrustEnabled = new ChangeObserver('boolean');
private readonly profilesEnabled = new ChangeObserver('boolean');
private readonly experimentsEnabled = new ChangeObserver('boolean');
private readonly enablePPEExtensionsGallery = new ChangeObserver('boolean');

Expand Down Expand Up @@ -127,9 +125,6 @@ export class SettingsChangeRelauncher extends Disposable implements IWorkbenchCo
processChanged(this.workspaceTrustEnabled.handleChange(config?.security?.workspace?.trust?.enabled));
}

// Profiles
processChanged(this.productService.quality === 'stable' && this.profilesEnabled.handleChange(config.workbench?.experimental?.settingsProfiles?.enabled));

// Experiments
processChanged(this.experimentsEnabled.handleChange(config.workbench?.enableExperiments));

Expand Down
Loading

0 comments on commit 5936a4e

Please sign in to comment.