Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(preferences-model): add dev feature flag to bypass the incremental rollout check #4862

Merged
merged 3 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/atlas-service/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ export async function throwIfNotOk(

function throwIfAINotEnabled(atlasService: typeof AtlasService) {
if (
!preferences.getPreferences().cloudFeatureRolloutAccess?.GEN_AI_COMPASS ||
(!preferences.getPreferences().cloudFeatureRolloutAccess?.GEN_AI_COMPASS &&
!preferences.getPreferences().enableAIWithoutRolloutAccess) ||
!preferences.getPreferences().enableAIFeatures
) {
throw new Error(
Expand Down
13 changes: 13 additions & 0 deletions packages/compass-preferences-model/src/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type FeatureFlagDefinition = {

export type FeatureFlags = {
enableAIExperience: boolean;
enableAIWithoutRolloutAccess: boolean;
enableLgDarkmode: boolean;
enableOidc: boolean; // Not capitalized "OIDC" for spawn arg casing.
enableStageWizard: boolean;
Expand All @@ -38,6 +39,18 @@ export const featureFlags: Required<{
},
},

/**
* Temporary feature flag for bypassing our incremental rollout for ai access.
* Ticket to remove: COMPASS-7226
*/
enableAIWithoutRolloutAccess: {
stage: 'development',
description: {
short: 'Enable AI Features Without Rollout Access',
long: 'Bypass the public preview rollout access for the AI features in Compass. Do not use this feature with sensitive data.',
},
},

/**
* Currently Compass uses `darkreader` to globally change the views of
* Compass to a dark theme. Turning on this feature flag stops darkreader
Expand Down
10 changes: 9 additions & 1 deletion packages/compass-preferences-model/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,20 @@ export function capMaxTimeMSAtPreferenceLimit<T>(value: T): T | number {
}

export function useIsAIFeatureEnabled(React: ReactHooks) {
const enableAIWithoutRolloutAccess = usePreference(
'enableAIWithoutRolloutAccess',
React
);
const enableAIExperience = usePreference('enableAIExperience', React);
const isAIFeatureEnabled = usePreference(
'cloudFeatureRolloutAccess',
React
)?.GEN_AI_COMPASS;
const enableAIFeatures = usePreference('enableAIFeatures', React);

return enableAIExperience && isAIFeatureEnabled && enableAIFeatures;
return (
enableAIExperience &&
(enableAIWithoutRolloutAccess || isAIFeatureEnabled) &&
enableAIFeatures
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,19 @@ export function useShouldShowFeaturePreviewSettings(): boolean {
// - we are in a development environment or 'showDevFeatureFlags' is explicitly enabled
// - and there are feature flags in 'development' stage.
// - AI feature flag is enabled
const enableAIWithoutRolloutAccess = usePreference(
'enableAIWithoutRolloutAccess',
React
);
const enableAIExperience = usePreference('enableAIExperience', React);
const showDevFeatures = useShouldShowDevFeatures();
const showPreviewFeatures = useShouldShowPreviewFeatures();
return enableAIExperience || showPreviewFeatures || showDevFeatures;
return (
enableAIWithoutRolloutAccess ||
enableAIExperience ||
showPreviewFeatures ||
showDevFeatures
);
}

const atlasSettingsContainerStyles = css({
Expand Down Expand Up @@ -89,6 +98,7 @@ export default withPreferences(
state: RootState,
ownProps: {
enableAIExperience?: boolean;
enableAIWithoutRolloutAccess?: boolean;
cloudFeatureRolloutAccess?: UserPreferences['cloudFeatureRolloutAccess'];
}
) => {
Expand All @@ -97,10 +107,15 @@ export default withPreferences(
state.settings.settings.enableAIExperience ||
['authenticated', 'in-progress'].includes(state.atlasLogin.status) ||
ownProps.enableAIExperience ||
ownProps.enableAIWithoutRolloutAccess ||
ownProps.cloudFeatureRolloutAccess?.GEN_AI_COMPASS,
};
}
)(FeaturePreviewSettings),
['enableAIExperience', 'cloudFeatureRolloutAccess'],
[
'enableAIExperience',
'cloudFeatureRolloutAccess',
'enableAIWithoutRolloutAccess',
],
React
);