Skip to content

Commit 47e5f5f

Browse files
committed
💄
1 parent 0a14758 commit 47e5f5f

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

components/server/src/oauth-server/oauth-controller.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { URL } from "url";
1616
import { Config } from "../config";
1717
import { clientRepository, createAuthorizationServer } from "./oauth-authorization-server";
1818
import { inMemoryDatabase, toolboxClient } from "./db";
19-
import { getExperimentsClientForBackend } from "@gitpod/gitpod-protocol/lib/experiments/configcat-server";
19+
import { getFeatureFlagEnableExperimentalJBTB } from "../util/featureflags";
2020

2121
@injectable()
2222
export class OAuthController {
@@ -149,11 +149,7 @@ export class OAuthController {
149149
}
150150

151151
if (clientID === toolboxClient.id) {
152-
const enableExperimentalJBTB = await getExperimentsClientForBackend().getValueAsync(
153-
"enable_experimental_jbtb",
154-
false,
155-
{ user },
156-
);
152+
const enableExperimentalJBTB = await getFeatureFlagEnableExperimentalJBTB(user.id);
157153
if (!enableExperimentalJBTB) {
158154
res.sendStatus(400);
159155
return false;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* Copyright (c) 2024 Gitpod GmbH. All rights reserved.
3+
* Licensed under the GNU Affero General Public License (AGPL).
4+
* See License.AGPL.txt in the project root for license information.
5+
*/
6+
7+
import { getExperimentsClientForBackend } from "@gitpod/gitpod-protocol/lib/experiments/configcat-server";
8+
9+
export async function getFeatureFlagEnableExperimentalJBTB(userId: string): Promise<boolean> {
10+
return getExperimentsClientForBackend().getValueAsync("enable_experimental_jbtb", false, {
11+
user: { id: userId },
12+
});
13+
}

components/server/src/workspace/workspace-starter.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ import { ctxIsAborted, runWithRequestContext, runWithSubjectId } from "../util/r
136136
import { SubjectId } from "../auth/subject-id";
137137
import { ApplicationError, ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error";
138138
import { IDESettingsVersion } from "@gitpod/gitpod-protocol/lib/ide-protocol";
139+
import { getFeatureFlagEnableExperimentalJBTB } from "../util/featureflags";
139140

140141
export interface StartWorkspaceOptions extends Omit<GitpodServer.StartWorkspaceOptions, "ideSettings"> {
141142
excludeFeatureFlags?: NamedWorkspaceFeatureFlag[];
@@ -301,16 +302,11 @@ export class WorkspaceStarter {
301302

302303
let ideSettings = options.ideSettings;
303304

304-
const enableExperimentalJBTB = await getExperimentsClientForBackend().getValueAsync(
305-
"enable_experimental_jbtb",
306-
false,
307-
{ user },
308-
);
309-
310305
// if no explicit ideSettings are passed, we use the one from the last workspace instance
311306
if (lastValidWorkspaceInstance) {
312307
const ideConfig = lastValidWorkspaceInstance.configuration?.ideConfig;
313308
if (ideConfig?.ide) {
309+
const enableExperimentalJBTB = await getFeatureFlagEnableExperimentalJBTB(user.id);
314310
const preferToolbox = !enableExperimentalJBTB
315311
? false
316312
: ideSettings?.preferToolbox ??
@@ -922,11 +918,7 @@ export class WorkspaceStarter {
922918
};
923919
if (ideConfig.ideSettings && ideConfig.ideSettings.trim() !== "") {
924920
try {
925-
const enableExperimentalJBTB = await getExperimentsClientForBackend().getValueAsync(
926-
"enable_experimental_jbtb",
927-
false,
928-
{ user },
929-
);
921+
const enableExperimentalJBTB = await getFeatureFlagEnableExperimentalJBTB(user.id);
930922
const ideSettings: IDESettings = JSON.parse(ideConfig.ideSettings);
931923
configuration.ideConfig!.ide = ideSettings.defaultIde;
932924
configuration.ideConfig!.useLatest = !!ideSettings.useLatestVersion;

0 commit comments

Comments
 (0)