Skip to content

Provide helpful message when slash command not used correctly in IDEs

What does this MR do and why?

Display a helpful message when a user uses the slash command (/explain, /refactor, /test) in Duo Chat, without selecting any code or providing additional input. This implementation applies to the following environments:

  • Web IDE
  • VS Code

Note: The behavior of GitLab Web for slash commands differs and will be handled in a separate ticket.

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
image.png image.png

How to set up and validate locally

Testing in VS Code

Set up VS Code

  1. Open VS Code and install the GitLab extension.
  2. In GitLab extension settings, add your local GDK: URL http://127.0.0.1:3000 with an local API token (AI and API scope).

Test Duo Chat

  1. Type /explain in Duo Chat without selecting code. You should see the following message about no code being selected:

    Your request does not seems to contain code to explain. To explain code select the lines of code in your editor and then type the command /explain in the chat. You may add additional instructions after this comment. If you have no code to select, you can also simply add the code after the command.

  2. Select code, type /explain in Duo Chat. You should get an explanation of the selected code.

  3. Type /explain, paste code in Duo Chat. You should get an explanation of the pasted code.

Testing in Web IDE

  1. Open GitLab Web IDE and navigate to a code file.
  2. Repeat the steps from "Test Duo Chat" and ensure the results are the same.

Testing on GitLab Web

  1. Navigate to a code file on GitLab Web.

  2. Type /explain in Duo Chat without selecting code. You should see the original message about no code being selected:

    There is no code inside the <selected_code></selected_code> tags provided. Please provide the actual code you would like me to explain.

Related to gitlab-vscode-extension#1215

Edited by Eva Kadlecová

Merge request reports