-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
feat(settings): Disable AI settings when gen-ai-features flag is off #103387
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
feat(settings): Disable AI settings when gen-ai-features flag is off #103387
Conversation
When the organizations:gen-ai-features feature flag is disabled: - "Show Generative AI Features" toggle is disabled (grayed out) and set to off - "Enable AI Code Review" toggle is also disabled (grayed out) - Appropriate disabled reason messages are shown to users Changes: - Updated aiFeatureSettings.tsx to check feature flag and disable toggle - Updated preventAiSettings.tsx to check feature flag and show appropriate disabled reason - Added tests to verify behavior when feature flag is disabled - Updated existing tests to include feature flag where needed
The feature flag should only control whether the setting is editable, not what value is currently displayed. The defaultValue should always reflect the organization's actual hideAiFeatures setting.
The frontend receives feature flags without the 'organizations:' prefix. Changed from 'organizations:gen-ai-features' to 'gen-ai-features'.
- When feature flag is off, toggle shows as unchecked (off) regardless of org setting - Removed 'This feature is not available' tooltip - fields just gray out silently - Disabled tag only shows for specific reasons (self-hosted, non-US region) - Feature flag acts as master switch that overrides org settings in UI
Removes the async keyword from the test function that doesn't use any await expressions, fixing the eslint @typescript-eslint/require-await error.
066b0d5 to
2f562f0
Compare
When the gen-ai-features flag is disabled but the organization's enablePrReviewTestGeneration setting is true, the UI was incorrectly showing the checkbox as checked. This fix uses setValue to transform the initial display value to false when the feature flag is off, ensuring the UI accurately reflects that the feature is disabled. Also adds test coverage for this scenario.
… flag is off When the gen-ai-features flag is disabled, the "Show Generative AI Features" checkbox now displays as unchecked regardless of the organization's stored hideAiFeatures value. This provides a clearer UX indicating that AI features are not available. Changes: - Added setValue to hideAiFeatures field to force display value to false when flag is off - Updated preventAiSettings visibility logic to check initialData when flag is off to prevent setValue transformation from hiding the field - When flag is on, visibility uses current model value for dynamic toggling
…sabled When the gen-ai-features flag is disabled, force the "Show Generative AI Features" checkbox to display as unchecked, even if the organization's hideAiFeatures value in the database is true. This ensures the UI accurately reflects that AI features are disabled when the feature flag is off, preventing confusion where the toggle appears enabled but is actually disabled. Implementation uses setValue to transform the initial display value to false when the feature flag is off, while keeping the API submission logic unchanged via getValue.
| setValue: value => { | ||
| if (!hasFeatureFlag) { | ||
| return false; | ||
| } | ||
| return value; | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is necessary if it's already disabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the whole set value fn?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then it should be done in getValue I think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm that doesn't seem to work?
| return false; | ||
| } | ||
| return value; | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: setValue doesn't invert hideAiFeatures value correctly
The setValue function returns the raw value when the feature flag is enabled, but it should invert it to match the UI semantics. The field stores hideAiFeatures from the backend, but the UI displays "Show Generative AI Features" (the opposite). When hasFeatureFlag is true, setValue should return !value to invert the backend value to the UI value, just like defaultValue does with !organization.hideAiFeatures. Without this inversion, a backend value of hideAiFeatures: false (AI enabled) would incorrectly display as unchecked in the UI.
static/app/views/settings/organizationGeneralSettings/preventAiSettings.tsx
Outdated
Show resolved
Hide resolved
static/app/views/settings/organizationGeneralSettings/aiFeatureSettings.tsx
Outdated
Show resolved
Hide resolved
static/app/views/settings/organizationGeneralSettings/aiFeatureSettings.tsx
Show resolved
Hide resolved
❌ 3 Tests Failed:
View the top 3 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |

When the

organizations:gen-ai-featuresfeature flag is disabled, the "gen ai" setting is now disabled and set to "off" regardless of the org's setting value.