Add field presenter variant concept for context-aware rendering

What does this MR do and why?

Adds a field presenter variant concept for context-aware rendering in list displays. This is the third MR in a stack that adds CodeSuggestion analytics support to the GitLab UI.

What Changed

  • FieldPresenter variant prop: added a variant prop to FieldPresenter that allows presenter resolution to be context-aware. The presentersByFieldKey map now supports variant keys (lowercase, e.g. compact) alongside typename keys (PascalCase). Variant matches take precedence over typename matches, with default as the fallback. For example, the user field key uses UserAvatarPresenter when the item typename is DuoCodeSuggestionsAggregationResponseDimensions, but the compact variant overrides this to use UserPresenter instead.
  • ListPresenter: conditionally renders a title heading only when a title field is present (supporting analytics data which has no title), and passes variant="compact" to field presenters for non-title fields
  • DataPresenter: removed the mode prop and analytics-specific routing, since ListPresenter now handles both standard and analytics list displays through the variant mechanism

MR Stack

  1. !233396 (merged) — Backend + GLQL pipeline
  2. !233397 (merged) — Analytics presenters
  3. This MR — Field presenter variants for context-aware list rendering

References

Screenshots or screen recordings

Scenario GLQL query Output
Every metric and dimension - list image image
Every metric and dimension - ordered list Google_Chrome_Beta_2026-04-27_14.50.20 image
In the Data Analyst Agent Requires a lot of cajoling until Data Analyst agent integration for CodeSuggesti... (#592264) is complete Google_Chrome_Beta_2026-03-20_11.59.02 Google_Chrome_Beta_2026-03-20_11.59.29
With feature flag disabled Google_Chrome_Beta_2026-03-19_23.28.55 Google_Chrome_Beta_2026-03-19_23.29.02
Trying to use it outside analytics mode Google_Chrome_Beta_2026-03-19_23.31.18 Google_Chrome_Beta_2026-03-19_23.31.18
Trying to use fields Google_Chrome_Beta_2026-03-19_23.32.04 image
Trying to use dimensions or metrics in standard mode image image

How to set up and validate locally

Prerequisites

  • Setup clickhouse
  • Make sure to run migrations: bundle exec rake gitlab:clickhouse:migrate
  • Enable clickhouse analytics: echo "Gitlab::CurrentSettings.current_application_settings.update(use_clickhouse_for_analytics: true)" | rails c
  • Seed test data: FILTER=ai_usage_stats bundle exec rake db:seed_fu

UI Testing

  1. Navigate to a seeded projects issue or merge request (by default this is the toolbox group), and go to a markdown enabled field (comments or descriptions for instance)

  2. Test that without the feature flag enabled, the CodeSuggestion type returns an error:

    mode: analytics
    display: orderedList
    query: type = CodeSuggestion and timestamp >= -30d
    dimensions: language
    metrics: totalCount, acceptanceRate
    sort: totalCount desc
    limit: 10
  3. Enable the feature flag: echo "Feature.enable(:glql_code_suggestion_analytics_aggregation)" | rails c

  4. Refresh the page, test that the query no longer errors and returns results

  5. Now test other variants like: Ide comparison by language

    mode: analytics
    display: list
    query: type = CodeSuggestion and language in ("ruby", "javascript", "python")
    dimensions: language, ideName
    metrics: totalCount, acceptedCount, rejectedCount, acceptanceRate
    sort: acceptanceRate desc

    Recent activity

    mode: analytics
    display: orderedList
    query: type = CodeSuggestion and timestamp >= -7d
    dimensions: language
    metrics: totalCount, usersCount, suggestionSizeSum
    sort: usersCount desc
    limit: 5

    User-specific

    mode: analytics
    display: list
    query: type = CodeSuggestion and user = 2 and timestamp >= -14d
    dimensions: language, ideName
    metrics: totalCount, acceptanceRate, acceptedCount
    sort: totalCount desc
  6. Also verify that percentage presenters like acceptanceRate show as percentages

  7. Also verify that number presenters like totalCount format according to your browser language (e.g. 1,234 or 1.234)

Rest API endpoint

Test the /api/v4/glql REST API endpoint:

# Get a personal access token from GitLab UI: User Settings > Access Tokens

curl -H "PRIVATE-TOKEN: your_token" \
  -H "Content-Type: application/json" \
  -d '{
    "glql_yaml": "query: type = CodeSuggestion and language = \"ruby\"\nmode: \"analytics\"\ndimensions: \"language\"\nmetrics: \"totalCount, acceptanceRate\"\nproject: \"toolbox/gitlab-smoke-tests\""
  }' \
  http://gdk.test:8080/api/v4/glql            
Edited by Robert Hunt

Merge request reports

Loading