Read the repository sidebar's package and image count from statistics
What does this MR do and why?
Fixes the Packages/Images figure in the hosted repository sidebar. The sidebar rendered artifactsCount. AR counts that as versions (Maven, npm) or manifests (Docker, OCI). So a Maven repository with one package at two versions showed "2 Packages" next to a table with one row, and a local Docker repository with 2 images showed 49 (its manifests). The figure now reads the live packagesCount (Maven, npm) or imagesCount (Docker, OCI) from the statistics field that Step 2 added. The label stays "Package(s)"/"Image(s)" and now pluralizes on the same count.
This is Step 3 of 3 of the plan, and the step that changes what users see.
Steps 1 and 2 have merged (!259559 (merged), !259594 (merged)), so this MR targets master and reads the statistics field Step 2 added.
Behavior:
- The statistics are read in their own document,
get_repository_statistics.query.graphql, not in the detail query. The detail query's error hook replaces the whole page with an alert, and a statistics failure must only drop the figure. - The statistics read goes out as its own request, never batched with the detail read. A batched request answers only once its slowest operation has, and AR's live count can be the slow one, so batching would hold back first paint and the artifact table.
- The detail page picks the family's count (
imagesCountfor Docker and OCI,packagesCountfor Maven and npm) and hands the sidebar a singlehostedArtifactsCount, the same way it hands overupstreamRepositoriesCounton a virtual repository. A failed read sets ahasStatisticsErrorflag, as the page's other three queries do, and the count reads null while it is set. - The statistics read is skipped until the detail read shows a hosted repository, so remote and virtual pages make no statistics request. The cost is that on a first visit the figure appears one round trip after the stats block. The plan accepts this: no skeleton, no live-region announcement. The query uses
CACHE_AND_NETWORKwithnotifyOnNetworkStatusChange, so a revisit shows the cached figure at once. - A null or failed read omits only the figure. Size and Downloads still render, no alert is shown, and the page stays out of its error state. It never falls back to
artifactsCount. A count of 0 renders as "0 Packages". - Remote repositories keep
artifactsCountwith the "cached" labels, unchanged, because AR serves statistics for hosted repositories only. That remote mislabel is tracked in #632276. Virtual repositories are unchanged. - After an accepted delete on a hosted repository, the artifact table refetches the statistics document outside its awaited refetch pair and drops that refetch's rejection. A slow or failed count never keeps the row pending or turns an accepted delete into a failure alert. The success toast still shows.
Cost, accepted: the statistics query resolves the repository again, so a hosted page load makes three Artifact Registry repository reads instead of two, and so does a hosted delete. It cannot share the detail read's request-scoped cache, because it goes out as its own request and does not select userPermissions. That is the price of keeping the live count off first paint.
The new query marks statistics @gl_introduced(version: "19.5.0"), as the plan has it, matching the field's experiment milestone in Step 2. The repository id keeps 19.5.0 too, because that field shipped in 19.5. The backend field shipped in Step 2's separate MR, which covers Danger's multiversion-compatibility rule.
No new strings, so no locale/gitlab.pot change. The change is behind artifact_registry_ui, so there is no changelog trailer until the flag defaults on.
Size: 754 added and 56 removed lines. 645 added lines are specs and the fixture generator; the source change is 109 added lines across the query, the detail page, the sidebar, the table, and the story. The feature spec in ee/spec/features/artifact_registry/repositories_spec.rb checks the rendered "2 Packages" end to end, with the statistics read stubbed for that exact repository.
References
- Plan (merged): https://gitlab.com/gitlab-org/ops/artifact-registry/-/blob/main/docs/plans/monolith/2026-09-28-repository-sidebar-counts.md (Step 3), approved in gitlab-org/ops/artifact-registry!3000 (merged)
- Spec: https://gitlab.com/gitlab-org/ops/artifact-registry/-/blob/main/docs/specs/monolith/S05-repository-detail.md (Sidebar stats table hosted row, Error cases, and the Remote/virtual acceptance criteria for the kind-dependent figure and the null-or-failed read)
- Builds on !259559 (merged) (Step 1) and !259594 (merged) (Step 2), both merged
- Follow-up for the repeated fixture setup: #634501 (closed)
- Closes #628241 (closed), which now covers the hosted half only. The remote half moved to #632276.
Screenshots or screen recordings
A hosted Docker repository on a local Artifact Registry, holding 2 images (alpine and busybox) and 49 manifests (tags, an untagged manifest, a 17-child index, and referrers).
| Before | After |
|---|---|
![]() |
![]() |
| The sidebar says "49 Images" beside a two-row table. | The sidebar says "2 Images", matching the table. |
In the After capture the page sent getArtifactRegistryRepositoryStatistics as its own request, a single operation rather than part of a batch, and the console showed no errors.
How to set up and validate locally
-
Check out this branch in the GDK and restart it (
gdk restart), with a running Artifact Registry and an organization whose registry is activated. -
In
bin/rails console, enable the flag:Feature.enable(:artifact_registry_ui) -
Open a hosted Docker or OCI repository that has more manifests than images (for example an image with a multi-arch index or referrers):
<gdk url>/o/<organization path>/-/artifact_registry/<registry handle>/repositories/<repository name>. The sidebar shows the image count, matching the number of rows in the table. Onmasterit showed the manifest count. -
Open a hosted Maven or npm repository with one package at two versions. The sidebar shows "1 Package".
-
Open a remote repository. The sidebar still shows "N Packages cached" or "N Images cached", and the browser network panel shows no
getArtifactRegistryRepositoryStatisticsrequest. -
Delete an artifact from a hosted repository's table. The toast appears and the figure updates without a reload.
Plan and spec amendments
- This MR says
Closesfor #628241 (closed), where the plan's Dependencies section says no step closes it. The plan assumed the remote half would stay on that issue; it moved to #632276 (blocked by gitlab-org/ops/artifact-registry#1530 (closed)), so this MR fixes everything the issue now asks for. The plan's and S05's "tracked on 628241" references to the remote half get repointed in a separate AR docs MR. - The plan's Step 3 gives the sidebar a nullable
statisticsobject prop. After review it takes a singlehostedArtifactsCountinstead, and the detail page picks the family's count. Behavior is unchanged: the hosted figure is the live count, a null or failed read omits it, and remote still readsartifactsCount.
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.

