Do not allow merge request summarization if no code changes
What does this MR do and why?
This change adds a feature to show helpful tooltips when the "Summarize code changes" button is disabled in merge requests.
Previously, the AI-powered summarization button would simply be hidden or shown based on user permissions. Now, when the button cannot be used, it becomes disabled and displays a tooltip explaining why - such as "Source branch not available", "Target branch not available", or "No changes between source and target branch."
The implementation adds a new property called unavailabilityReason
that gets passed from the backend to the frontend components. The backend logic checks various conditions like missing branches or identical source/target branches to determine the appropriate error message. The frontend then uses this information to disable the button and show the explanatory tooltip when users hover over it.
This improves the user experience by providing clear feedback about why the summarization feature isn't available, rather than leaving users confused about a missing or non-functional button. The change includes proper testing to ensure the tooltip behavior works correctly in different scenarios.
References
Fixes GitLab Duo summarize code changes endlessly loa... (#577181 - closed)
Screenshots or screen recordings
How to set up and validate locally
- Create new branch
test-fix
off themain
branch of a project - Start a new merge request setting the source to
test-fix
and target tomain
- Check the
Summarize code changes
. It should be disabled and a tooltip is shown explaining why
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.
Related to #577181 (closed)