Post duo_mention_started progress note as a reply in the mention thread

What does this MR do and why?

When a user mentions @GitLabDuo in a merge request thread, a "started mention session…" progress system note is created as a standalone top-level note. This caused two problems:

  1. Wrong placement — the note appeared at the bottom of the page, not inline in the thread where the user typed the mention.
  2. Note didn't disappear in real-time — the frontend's fetchUpdatedNotes scopes its search for the progress note to the bot reply's discussion. Because duo_mention_started was a standalone note in its own discussion (not inside the human mention thread), the scoped search missed it and the note persisted until page refresh.

Solution: duo_mention_started now accepts discussion as an argument which creates the system note as a reply inside that discussion thread — the same pattern used by duo_code_review_chat_started. on_flow_started in the GitlabDuoNote adapter loads the discussion from the callback context and passes it through.

This makes the progress note appear inline in the mention thread and lets the existing frontend scoped-search logic find and remove it automatically when the reply arrives.

How to set up and validate locally

  1. Enable the feature flag for your user: Feature.enable(:ai_duo_mention_messaging_adapter, User.find_by_username('your-username'))
  2. Open an MR on a project with the DAP code review flow enabled.
  3. Post a comment mentioning @GitLabDuo with a question or task such as @GitLabDuo what is this MR about?
  4. Observe that the "GitLab Duo started mention session..." progress note appears inline in the thread, not as a standalone note at the top of the activity feed.
  5. Once the workflow completes, verify the progress note disappears and is replaced by the bot's reply without requiring a page refresh.

Screenshots

Before After (running) After (finished)
before after_1 after_2

Screen Recording (end-to-end)

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.

References

Edited by Kinshuk Singh (PTO June 4-19)

Merge request reports

Loading