Skip to content

Commit

Permalink
Remove experimental features from extension and migrate old settings
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistock committed Nov 19, 2024
1 parent 6bdc52d commit e6003ea
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 64 deletions.
5 changes: 0 additions & 5 deletions vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,6 @@
"configuration": {
"title": "Ruby LSP",
"properties": {
"rubyLsp.enableExperimentalFeatures": {
"description": "Enable experimental and under development features",
"type": "boolean",
"default": false
},
"rubyLsp.enabledFeatures": {
"description": "List of enabled LSP features",
"type": "object",
Expand Down
3 changes: 0 additions & 3 deletions vscode/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,6 @@ function collectClientOptions(
errorHandler: new ClientErrorHandler(workspaceFolder, telemetry),
initializationOptions: {
enabledFeatures,
experimentalFeaturesEnabled: configuration.get(
"enableExperimentalFeatures",
),
featuresConfiguration: configuration.get("featuresConfiguration"),
formatter: configuration.get("formatter"),
linters: configuration.get("linters"),
Expand Down
17 changes: 17 additions & 0 deletions vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export async function activate(context: vscode.ExtensionContext) {
return;
}

await migrateExperimentalFeaturesSetting();

const logger = await createLogger(context);
context.subscriptions.push(logger);

Expand All @@ -36,6 +38,21 @@ export async function deactivate(): Promise<void> {
await extension.deactivate();
}

// Remove after ~2 months. This code migrates the old experimental features setting to the new feature flag rollout
// setting
async function migrateExperimentalFeaturesSetting() {
const config = vscode.workspace.getConfiguration("rubyLsp");
const experimentalFeatures = config.get("enableExperimentalFeatures");

if (experimentalFeatures) {
// Remove the old setting
await config.update("enableExperimentalFeatures", undefined, true);

// Add the new one
await config.update("featureFlags", { all: true }, true);
}
}

async function createLogger(context: vscode.ExtensionContext) {
let sender;

Expand Down
24 changes: 0 additions & 24 deletions vscode/src/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,29 +119,6 @@ export class ServerStatus extends StatusItem {
}
}

export class ExperimentalFeaturesStatus extends StatusItem {
constructor() {
super("experimentalFeatures");

const experimentalFeaturesEnabled =
vscode.workspace
.getConfiguration("rubyLsp")
.get("enableExperimentalFeatures") === true;
const message = experimentalFeaturesEnabled
? "Experimental features enabled"
: "Experimental features disabled";

this.item.name = "Ruby LSP Experimental Features";
this.item.text = message;
this.item.command = {
title: experimentalFeaturesEnabled ? "Disable" : "Enable",
command: Command.ToggleExperimentalFeatures,
};
}

refresh(_workspace: WorkspaceInterface): void {}
}

export class FeaturesStatus extends StatusItem {
constructor() {
super("features");
Expand Down Expand Up @@ -225,7 +202,6 @@ export class StatusItems {
this.items = [
new RubyVersionStatus(),
new ServerStatus(),
new ExperimentalFeaturesStatus(),
new FeaturesStatus(),
new FormatterStatus(),
new AddonsStatus(),
Expand Down
8 changes: 8 additions & 0 deletions vscode/src/test/suite/common.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ suite("Common", () => {
});

test("maintains enabled state when increasing rollout percentage", () => {
const stub = sandbox.stub(vscode.workspace, "getConfiguration").returns({
get: () => {
return { all: undefined };
},
} as any);

// For the fake machine of 42 in base 16 and the name `fakeFeature`, the feature flag activation percetange is
// 0.357. For every percetange below that, the feature should appear as disabled
[0.25, 0.3, 0.35].forEach((percentage) => {
Expand All @@ -45,6 +51,8 @@ suite("Common", () => {
(FEATURE_FLAGS as any).fakeFeature = percentage;
assert.strictEqual(featureEnabled("fakeFeature" as any), true);
});

stub.restore();
});

test("returns false if user opted out of specific feature", () => {
Expand Down
32 changes: 0 additions & 32 deletions vscode/src/test/suite/status.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { Ruby } from "../../ruby";
import {
RubyVersionStatus,
ServerStatus,
ExperimentalFeaturesStatus,
StatusItem,
FeaturesStatus,
FormatterStatus,
Expand All @@ -21,7 +20,6 @@ suite("StatusItems", () => {
let ruby: Ruby;
let status: StatusItem;
let workspace: WorkspaceInterface;
let formatter: string;

afterEach(() => {
status.dispose();
Expand Down Expand Up @@ -145,36 +143,6 @@ suite("StatusItems", () => {
});
});

suite("ExperimentalFeaturesStatus", () => {
beforeEach(() => {
ruby = {} as Ruby;
workspace = {
ruby,
lspClient: {
addons: [],
state: State.Running,
formatter,
serverVersion: "1.0.0",
sendRequest: <T>() => Promise.resolve([] as T),
degraded: false,
},
error: false,
};
status = new ExperimentalFeaturesStatus();
status.refresh(workspace);
});

test("Status is initialized with the right values", () => {
assert.match(status.item.text, /Experimental features (dis|en)abled/);
assert.strictEqual(status.item.name, "Ruby LSP Experimental Features");
assert.match(status.item.command?.title!, /Enable|Disable/);
assert.strictEqual(
status.item.command!.command,
Command.ToggleExperimentalFeatures,
);
});
});

suite("FeaturesStatus", () => {
beforeEach(() => {
ruby = {} as Ruby;
Expand Down

0 comments on commit e6003ea

Please sign in to comment.