Add GraphQL query for Duo Chat Included Projects

What does this MR do and why?

This adds a new GraphQL Query (aiChatIncludedProjects) for projects that can be included by the current user in a Duo Chat context, ie, in the /include <repository> Duo Chat command.

New Resolver: Resolvers::Ai::Chat::IncludedProjectsResolver

This GraphQL API is backed by a new resolver, which queries:

  • projects contributed to by the user within the last month
  • THEN projects visited by the user within the last month
  • THEN remaining projects that the logged in is authorized for

...up to the maximum results count of 10.

The reason for this approach to sorting is so that when the user searches for projects on the /include <repository> command on Duo Chat, the projects that the user has recently interacted with are displayed first. Furthermore, the /include <repository> command on Duo Chat needs a compact list of projects, which is why we limit the results to 10.

New Finder: UserRelevantProjectsFinder

The resolver makes use of a new finder, UserRelevantProjectsFinder, which returns a list of projects that satisfy a specific set of relevance conditions.

This very specific set of conditions is the reason why we are introducing a new finder instead of using or updating an existing finder. There is no one single existing finder that provides what is needed, and we would otherwise have to update 3 different finders if we don't introduce a new one that unifies the required conditions.

Rationale for multi-step queries

The multi-query approach is implemented because we can't have a performant query with all these conditions combined.

The resolver does the multiple queries (up to 3) since each query is performant enough, so we don't need to involve the Frontend/Language Server. This also allows us to easily swap out to an Advanced Search finder in case we want to create an Advanced Search index that includes the different relevance categories (recently contributed, recently visited, search term, and so on).

References

  • Issue: Introduce a new Search Projects API endpoint fo... (#554661)

  • Epic for the /include <repository> command on Duo Chat: Duo Chat Integration - IDE (&17300) (this is implemented on the Language Server / Frontend)

  • Illustration of the /include <repository> feature on Duo Chat

    Currently, when the user types on the "search" box, the Language Server searches through projects on the local workspace.

    Expand for screenshot

    Screenshot_2025-12-10_at_15.40.05

    This MR will provide an API for the Language Server to search projects on the backend.

Screenshots or screen recordings

Screenshot_2025-12-10_at_15.16.25

How to set up and validate locally

Example query on local GDK

query DuoIncludedProjects {
  aiChatIncludedProjects(search: "git") 
  {
    nodes {
      id
      name
      path
      fullPath
      visibility
    }
  }
}

DB Lab Query Plans

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #554661

Edited by Pam Artiaga

Merge request reports

Loading