New merge request page: Pipelines tab badge count can differ from the pipelines list

Problem

On the new merge request page, the Pipelines tab badge and the pipelines list can show different counts.

  • The server renders the badge from Ci::PipelinesForMergeRequestFinder, in set_pipeline_variables. It counts the pipelines of every commit in the new merge request.
  • After !266261 (closed), the list shows the pipelines of the source branch head commit only.
  • The list updates the badge with the update-pipelines-count event, but only after the user opens the tab.

Examples

  • The source branch has two commits, and each commit has a pipeline. The badge shows 2. When the user opens the tab, the list shows one pipeline and the badge changes to 1.
  • The head commit has no pipeline yet, and older commits have three. The badge shows 3 over the empty state. The badge does not change, for two reasons:
    • The pipelines.count watcher in commit_pipelines_list.vue does not fire when the count stays at 0.
    • initPipelineCountListener ignores a count of 0.

Possible fixes

  • Count only the head commit pipelines on the server for the new merge request page, so the badge matches the list.
  • Or list the pipelines of the source branch (ref), so the list is closer to the server count.

Decide this after the mr_pipelines_graphql flag removal is done.

References