Fix MR tab counts not auto-updating after initial MR creation

What does this MR do and why?

Fixes MR tab counts (Commits, Changes) staying as - after initial MR creation until the user manually refreshes the page.

Root cause — three separate issues compounding:

  1. BE: subscription fires too early. AfterCreateService calls mark_as_unchecked which fires merge_request_merge_status_updated, but prepared_at is still nil at that point. The FE subscription handler checks preparedAt and ignores the event. When prepared_at is finally set, no subscription fires.

  2. FE: signals.js doesn't re-fetch on preparation complete. When the subscription fires with preparedAt set, signals.js emits EVT_MR_PREPARED but not EVT_MR_DIFF_GENERATED — so tab counts are never updated (page only reloads if rapid_diffs is enabled).

  3. FE: broken selector in page.js. The selector .js-commits-count .gl-badge-content looks for .gl-badge-content inside .js-commits-count, but the actual DOM is the inverse: .js-commits-count sits inside Pajamas::BadgeComponent which renders .gl-badge-content. So commitsCountBadge was always null and the DOM update never fired.

Fixes:

  1. Fire merge_request_merge_status_updated again once prepared_at is set (after_create_service.rb).
  2. When the subscription fires with preparedAt set, re-query the MR for fresh data and emit EVT_MR_DIFF_GENERATED (signals.js).
  3. Fix the selector to .js-commits-count directly (page.js).

MR acceptance checklist

  • I have evaluated the MR acceptance checklist for this MR.

Related to #598021

Edited by Marc Shaw

Merge request reports

Loading