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:
-
BE: subscription fires too early.
AfterCreateServicecallsmark_as_uncheckedwhich firesmerge_request_merge_status_updated, butprepared_atis stillnilat that point. The FE subscription handler checkspreparedAtand ignores the event. Whenprepared_atis finally set, no subscription fires. -
FE:
signals.jsdoesn't re-fetch on preparation complete. When the subscription fires withpreparedAtset,signals.jsemitsEVT_MR_PREPAREDbut notEVT_MR_DIFF_GENERATED— so tab counts are never updated (page only reloads ifrapid_diffsis enabled). -
FE: broken selector in
page.js. The selector.js-commits-count .gl-badge-contentlooks for.gl-badge-contentinside.js-commits-count, but the actual DOM is the inverse:.js-commits-countsits insidePajamas::BadgeComponentwhich renders.gl-badge-content. SocommitsCountBadgewas alwaysnulland the DOM update never fired.
Fixes:
- Fire
merge_request_merge_status_updatedagain onceprepared_atis set (after_create_service.rb). - When the subscription fires with
preparedAtset, re-query the MR for fresh data and emitEVT_MR_DIFF_GENERATED(signals.js). - Fix the selector to
.js-commits-countdirectly (page.js).
MR acceptance checklist
- I have evaluated the MR acceptance checklist for this MR.
Related issues
Related to #598021