Skip to content

UX: Enable Code Suggestions on the instance level (SM)

Aleksei Lipniagov requested to merge 412436-add-token-fe into master

What does this MR do and why?

Adds UI for enabling Code Suggestions and setting AI Access Token in Admin Instance Settings.

See #413522 (closed)

UI/UX approach

I was heavily inspired by the existing similar logic in the AWS key settings:

Screenshot_2023-06-01_at_16.08.40

This is the case of user input token that needs to stay hidden similar to what we need. There are some other cases with the hidden token (SCIM), but there the token is generated by the server and shown to the user once; so it's quite different.

My motivation to use the existing solution was to make sure we meet %16.1 goal and simplify the FE effort during the first iteration. The UI is not exactly the most convenient, from my perspective, and could be improved. Also, we expect to move away from setting PAT with UI (see &10604 (comment 1419499296)), so this is a temporal solution (my rough prediction: will last 2-6 milestones).

What could be improved (in a follow-up, may require FE engineer support):

  • When I click into ***** field, it preserves the "stars" in the input. It's not very elegant.
  • Maybe grey out the input if the checkbox is unchecked (although I don't see any examples we're doing that in AppSettings currently)

I opened a follow-up issue - #414407- we decide to improve these types of fields across the settings.

Screenshots or screen recordings

To Be Updated

First time:

Screenshot_2023-06-06_at_19.16.30

The token is set:

Screenshot_2023-06-06_at_19.16.53

When we tick the checkbox but do not set the token:

Screenshot_2023-06-06_at_19.17.11

How to set up and validate locally

  1. Visit http://localhost:3000/admin/application_settings/general
  2. Scroll down to the AI Access Token section
  3. Check the checkbox
  4. Update the token
  5. Check it in the rails console:
::Gitlab::CurrentSettings.reload.ai_access_token

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #412436 (closed)

Edited by Aleksei Lipniagov

Merge request reports