Skip to content

Use source attribute in Ai Action mutation

What does this MR do and why?

To distinguish between request origins, a new source attribute was added to the AI Action mutation.

I have already updated the slash command tools to use this new attribute. Until necessary changes are implemented on the frontend, we’ll continue using the old implementation as well to ensure everything works as expected.

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.

How to set up and validate locally

  1. Run GDK and go to the GraphQl explorer.
  2. Run the following query:
mutation chat($question: String!, $resourceId: AiModelID!, $agentVersionId: AiAgentVersionID, $clientSubscriptionId: String, $currentFileContext: AiCurrentFileInput) {
  aiAction(
    input: {chat: {resourceId: $resourceId, content: $question, agentVersionId: $agentVersionId, currentFile: $currentFileContext}, clientSubscriptionId: $clientSubscriptionId, source: "vs_code_extension"}
  ) {
    requestId
    errors
    __typename
  }
}

With variables:

{
  "question": "/explain",
  "resourceId": "gid://gitlab/Issue/17",
  "clientSubscriptionId": "02280262-f810-4670-8062-324fae5c9955"
}
  1. From the Rails console check the last message:
Gitlab::Llm::ChatStorage.new(User.first).messages.last
  1. Ensure it contains the following content:

"Your request does not seem 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."

Related to gitlab-vscode-extension#1431

Edited by Eva Kadlecová

Merge request reports