Skip to content

refactor: add state manager to LS suggestions + react to enabled

Description

This MR adds state manager to the LS integration. It also introduces a middleware that:

  • prevents "standard" completion requests from being sent at all
  • prevents inline completion requests from being sent if the code suggestions are disabled

What is left to implement after this MR:

  • tracking loading and error states
  • introduce a "no account" state

Related Issues

Resolves #1088 (closed)

Partially implements: #1052 (closed)

How has this been tested?

  1. Disable code suggestions in your settings and make sure you use the LS implementation

    {
      "gitlab.aiAssistedCodeSuggestions.enabled": false,
      "gitlab.featureFlags.languageServer":true,
    }
  2. See that suggestions are disabled in the status bar

    • image
  3. Click the status bar icon

    • see that the gitlab.aiAssistedCodeSuggestions.enabled value changed in your settings.json to true
    • see suggestion enabled in you status bar
      • image
  4. Click the status bar icon again

    • see code suggestions were disabled only for this session
    • image
    • go to JS/TS file and see that no suggestions are coming in
  5. Click again to enable

  6. Go to a JSON file

    • see that the language is unsupported
    • image
  7. Go to JS file and type something in

    • see suggestions coming in

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation
  • Chore (Related to CI or Packaging to platforms)
  • Test gap
Edited by Tomas Vik (OOO back on 2024-06-18)

Merge request reports