Loading
Add categorized suggested questions to Duo Chat context presets
Backend for the Duo Chat empty state redesign (design): aiChatContextPresets gains a questionCategories experiment field that groups suggested questions by category, with the current page's context first.
- New
AiChatQuestionCategoryGraphQL type andquestionCategoriesfield (experiment, 19.4), resolved alongside the existing flatquestions. Gitlab::Duo::Chat::DefaultQuestions#categoriesreturns a contextual category first, then six static ones:get_started,development,work_items,merge_requests,pipelines,security.keynames the type of page a category describes (issue,merge_request,blob,wiki, and so on), andcontextualmarks the single category about the current resource, so clients pick an icon without parsing the title.- Titles are always present and translated on the backend, so no client redefines them. Resources with a reference are titled with it, the rest after the page.
allowed_to_use?and the route lookup are memoized, so one instance serving bothexecuteandcategorieschecks entitlement and resolves the route once per request.- No feature flag: additive experiment field; the flat
questionspath is unchanged.
Rendered by the empty state MR later in this stack:
How to test
This MR is backend only. The rendered UI lands in a later MR in this stack. Verify the response through GraphiQL at /-/graphql-explorer.
query {
aiChatContextPresets(url: "http://gdk.test:3000/<group>/<project>/-/blob/master/README.md") {
questions
questionCategories {
key
title
contextual
questions
}
}
}Edit the arguments to exercise each scenario:
- No arguments: six static categories, no contextual category.
urlpointing at a project blob page, for examplehttp://gdk.test:3000/<group>/<project>/-/blob/master/README.md: ablobcontextual category first, followed by the static ones.urlpointing at a project or group wiki page: awikicontextual category first.resourceIdset to an issue or merge request global ID, for examplegid://gitlab/Issue/1: a contextual category first withkeyset toissueormerge_requestandtitleset to the reference (#1,!1).urlpointing at a project overview page (no page-specific list matches): static categories only, no contextual category.
Every category now has a non-null title. At most one category has contextual: true.
Stacked on !248168 (merged).
Edited by Nick Leonard
