Commit 7e37fe28 authored by Rohan Satkar's avatar Rohan Satkar 🥷 Committed by Enrique Alcántara
Browse files

refactor: remove languageServer feature flag

parent 2b73af05
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -20,12 +20,11 @@ See the [official documentation](https://code.visualstudio.com/api/language-exte

## Update your VS Code settings

To work with Language Server, add these properties to your VS Code's user or
To work with Language Server, add this property to your VS Code's user or
workspace settings (`settings.json`):

```json
{
  "gitlab.featureFlags.languageServer": true,
  "gitlab.duoCodeSuggestions.enabled": true
}
```
+0 −2
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ describe('SettingsStateDiagnosticsRenderer', () => {

      expect(result).toHaveLength(1);
      expect(result[0].title).toBe('GitLab Duo Agent Platform settings');
      expect(result[0].content).toContain('### Feature flags');
      expect(result[0].content).toContain('### JSON Settings');
    });

@@ -42,7 +41,6 @@ describe('SettingsStateDiagnosticsRenderer', () => {

      expect(result).toHaveLength(1);
      expect(result[0].title).toBe('GitLab Duo Agent Platform settings');
      expect(result[0].content).toContain('### Feature flags');
      expect(result[0].content).not.toContain('### JSON Settings');
    });

+1 −8
Original line number Diff line number Diff line
@@ -14,10 +14,6 @@ import { LanguageServerFeatureStateProvider } from '../language_server/language_
import { QuickChatCommentThreadService } from '../quick_chat/comment_thread_service';
import { QuickChatResponseProcessor } from '../quick_chat/response_processor';
import { QuickChatGutterIcon } from '../quick_chat/quick_chat_gutter_icon';
import {
  FeatureFlag,
  getLocalFeatureFlagService,
} from '../feature_flags/local_feature_flag_service';
import { GitLabChatController } from './gitlab_chat_controller';
import { COMMAND_OPEN_GITLAB_CHAT, openGitLabChat } from './commands/open_gitlab_chat';
import {
@@ -83,10 +79,7 @@ export const activateChat = async (
  aiContextManager: AIContextManager,
  languageServerFeatureStateProvider?: LanguageServerFeatureStateProvider,
) => {
  if (
    getLocalFeatureFlagService().isEnabled(FeatureFlag.LanguageServer) &&
    languageServerFeatureStateProvider
  ) {
  if (languageServerFeatureStateProvider) {
    const chatStateManager = new ChatStateManager(languageServerFeatureStateProvider);
    context.subscriptions.push(
      chatStateManager,
+6 −60
Original line number Diff line number Diff line
@@ -213,38 +213,6 @@ describe('Code suggestions state manager', () => {
      },
    ];

    const supportedLanguagePolicy = {
      mutation: async () => {
        languagePolicyMock.engaged = true;
        jest.mocked(languagePolicyMock.onEngagedChange).mock.calls[0][0](true);
      },
      expectedState: VisibleCodeSuggestionsState.UNSUPPORTED_LANGUAGE,
    };

    const disabledByProjectPolicy = {
      mutation: () => {
        projectDisabledPolicyMock.engaged = true;
        jest.mocked(projectDisabledPolicyMock.onEngagedChange).mock.calls[0][0](true);
      },
      expectedState: VisibleCodeSuggestionsState.DISABLED_BY_PROJECT,
    };

    const licenseAvailablePolicy = {
      mutation: () => {
        licensePolicyMock.engaged = true;
        jest.mocked(licensePolicyMock.onEngagedChange).mock.calls[0][0](true);
      },
      expectedState: VisibleCodeSuggestionsState.NO_LICENSE,
    };

    const minGitlabVersionPolicy = {
      mutation: () => {
        minimalGitLabVersionPolicyMock.engaged = true;
        jest.mocked(minimalGitLabVersionPolicyMock.onEngagedChange).mock.calls[0][0](true);
      },
      expectedState: VisibleCodeSuggestionsState.UNSUPPORTED_GITLAB_VERSION,
    };

    const lsPolicy = {
      mutation: async () => {
        languageServerPolicyMock.engaged = true;
@@ -253,26 +221,16 @@ describe('Code suggestions state manager', () => {
      expectedState: VisibleCodeSuggestionsState.UNSUPPORTED_LANGUAGE,
    };

    const getMissingAccountPolicy = (isLsEnabled: boolean) => {
    const getMissingAccountPolicy = () => {
      return {
        mutation: async () => {
          missingAccountPolicyMock.engaged = true;
          // When LS is enabled the first (index 0) call triggers state manager state change
          // But when ths LS is disabled, AccountPolicy is dependency for the MinGitLabVersionPolicy
          // so its first engage change triggers emitting event on the combined policy
          // only the second one (index 1) triggers state manager state change
          const mockCallNumber = isLsEnabled ? 0 : 1;
          jest.mocked(missingAccountPolicyMock.onEngagedChange).mock.calls[mockCallNumber][0](true);
          jest.mocked(missingAccountPolicyMock.onEngagedChange).mock.calls[0][0](true);
        },
        expectedState: VisibleCodeSuggestionsState.NO_ACCOUNT,
      };
    };

    describe.each`
      enabled  | msg
      ${true}  | ${'Language Server feature flag is enabled'}
      ${false} | ${'Language Server feature flag is disabled'}
    `('when $msg', ({ enabled }) => {
    let mutations: {
      mutation: StateMutation;
      expectedState: VisibleCodeSuggestionsState;
@@ -282,26 +240,15 @@ describe('Code suggestions state manager', () => {
      mockedPolicies.forEach(policy => {
        jest.mocked(policy).onEngagedChange.mockClear();
      });
        const accountPolicy = getMissingAccountPolicy(enabled);
        const clientOrLSPolicies = enabled
          ? [lsPolicy, accountPolicy]
          : [
              supportedLanguagePolicy,
              disabledByProjectPolicy,
              licenseAvailablePolicy,
              minGitlabVersionPolicy,
              accountPolicy,
            ];
        const availableFeatureStateManager = enabled
          ? languageServerFeatureStateProvider
          : undefined;
      const accountPolicy = getMissingAccountPolicy();
      const lsPolicies = [lsPolicy, accountPolicy];

      mutations = [...mutationsFromLeastImportant];
        mutations.splice(2, 0, ...clientOrLSPolicies);
      mutations.splice(2, 0, ...lsPolicies);
      stateManager = new CodeSuggestionsStateManager(
        platformManager,
        context,
          availableFeatureStateManager,
        languageServerFeatureStateProvider,
      );
      await stateManager.init();
    });
@@ -329,7 +276,6 @@ describe('Code suggestions state manager', () => {
      }
    });
  });
  });

  describe('Loading state', () => {
    it('handles parallel operations', () => {
+1 −8
Original line number Diff line number Diff line
@@ -3,10 +3,6 @@ import { SUGGESTIONS_API_ERROR, SUGGESTIONS_NO_CREDITS } from '@gitlab-org/gitla
import { GitLabPlatformManager } from '../platform/gitlab_platform';
import { log } from '../log';
import { LanguageServerFeatureStateProvider } from '../language_server/language_server_feature_state_provider';
import {
  FeatureFlag,
  getLocalFeatureFlagService,
} from '../feature_flags/local_feature_flag_service';
import { diffEmitter } from '../utils/diff_emitter';
import {
  GitLabPlatformManagerForCodeSuggestions,
@@ -116,10 +112,7 @@ export class CodeSuggestionsStateManager {

  async init() {
    try {
      if (
        getLocalFeatureFlagService().isEnabled(FeatureFlag.LanguageServer) &&
        this.#languageServerFeatureStateProvider
      ) {
      if (this.#languageServerFeatureStateProvider) {
        this.#policies.push(
          new LanguageServerPolicy(
            this.#languageServerFeatureStateProvider,
Loading