Fix merge widget showing failed merge checks after clicking Merge
What does this MR do and why?
Fixes Part 1 of the linked issue: after clicking Merge, the merge widget flashed the mergeability checks again and showed two misleading failed checks ("Merge request must be open." and "Source branch exists and contains commits.") for a merge request that was being or already was merged, until the widget caught up and switched to the merged view.
Root cause: clicking Merge moves the widget state machine to MERGING, which hides the mergeability checks (mergeBlockedComponentVisible in mr_widget_options.vue). Background refreshes of the merge request state (Apollo poll or ActionCable push) call setState() in the store, and translateStateToMachine() re-derives an intermediate state such as readyToMerge. That state has no mapped transition, so the method fell back to forcing the machine back to IDLE. The widget returned to the ready-to-merge view and re-rendered the checks. When the merge completed, the refreshed mergeabilityChecks were computed against the merged merge request: not_open and commits_status both FAILED (the source branch is deleted by the merge itself), while conflict detection was still CHECKING. The next REST refresh then switched the widget to the merged view.
Changes:
translateStateToMachine()no longer forces the machine back toIDLEwhileMERGINGorAUTO_MERGEis active. Mapped transitions still go through, so a merged state completes the machine as before. Every merge outcome keeps its explicit transition (MERGE_FAILUREon failure,MERGEDvia refreshed data), so the machine cannot get stuck.setGraphqlData()now keepsisOpenin sync with the GraphQL state. REST stays the only source for merged details (merge user, metrics), but the open/merged state itself is authoritative in the GraphQL payload too; without this the machine could not complete theMERGEDtransition until a REST refresh, which would leave the widget on "Merging!" for instances without a working ActionCable.
Part 2 of the issue (the merge request list staying stale after browser Back) is a separate page-caching concern and is not addressed here.
References
- Issue: #633369 (closed)
Screenshots or screen recordings
| Before | After |
|---|---|
![]() |
The widget keeps showing the single "Merging!" state until the merged view takes over. No failed checks are rendered after the merge button is clicked. |
How to set up and validate locally
- In GDK, open a mergeable merge request with "Delete source branch" enabled.
- Click Merge and watch the widget: it stays in the "Merging!" state (no merge checks) until it switches to the merged view.
- Before this change, the merge checks re-appeared for a few seconds with "Merge request must be open." and "Source branch exists and contains commits." while the merge was in progress.
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.
