Skip to content

Commit

Permalink
add dev feature flag to bypass the incremental rollout check
Browse files Browse the repository at this point in the history
  • Loading branch information
Anemy committed Sep 18, 2023
1 parent 86b4aea commit 7d021f6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
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
8 changes: 7 additions & 1 deletion packages/compass-preferences-model/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,17 @@ 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;

return enableAIExperience && isAIFeatureEnabled;
return (
enableAIExperience && (enableAIWithoutRolloutAccess || isAIFeatureEnabled)
);
}
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
);

0 comments on commit 7d021f6

Please sign in to comment.