Fix chat problem when instance setting is off

What does this MR do and why?

This fix addresses a bug in the Duo feature availability check logic. Previously, we were incorrectly checking the application setting 'duo_features_enabled' to determine if Duo should be available in a project. This approach didn't account for the instance-level configuration where Duo could be disabled by default but explicitly enabled for specific projects.

The corrected logic now properly checks if Duo features are banned at the instance level instead. This means that:

  1. When Duo is disabled by default on the instance, projects can still opt in to use it unless explicitly banned.
  2. The project-level Duo setting is respected regardless of the instance default configuration.
  3. Only when Duo is explicitly banned at the instance level will it be unavailable to all projects.

This change ensures that projects can successfully enable and use Duo features even when Duo is disabled by default at the instance level, aligning with our expected behavior for granular feature controls.

Technical implementation detail: We've updated the feature availability check to use lock_duo_features_enabled? instead of duo_features_enabled? to properly respect the instance-level configuration while maintaining project-level autonomy.

References

Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

on master:

  1. switch your instance to self-managed mode
  2. make sure you have chat working properly
  3. go to Admin> Gitlab Duo > configuration
  4. Switch duo off by default, save
  5. go to project with duo enabled - the chat breadcrumb should not be visible

on this branch:

  1. switch your instance to self-managed mode
  2. make sure you have chat working properly
  3. go to Admin> Gitlab Duo > configuration
  4. Switch duo off by default, save
  5. go to project with duo enabled - the chat breadcrumb should be visible

Additional check on this branch:

  1. switch your instance to self-managed mode
  2. make sure you have chat working properly
  3. go to Admin> Gitlab Duo > configuration
  4. Switch duo to always off, save
  5. restart gdk
  6. go to project with duo enabled - the chat breadcrumb should not be visible

Note: without restarting gdk, the chat breadcrumb is disabled, but it is visible. I assume it's some caching issue. Something we may want to investigate.

Related to #510624 (closed)

Merge request reports

Loading