Link the merge request management page in the Duo-only review note

What does this MR do and why?

Closes #956 (closed)

When a contributor requests a review from GitLab Duo only, the note invites them to come back to the merge request management page to request a human review. This MR adds a link to that page, so they can find it directly from the note.

Since !3114 (merged), @gitlab-bot ready posts the same note, so both paths now include the link. To build it the same way in both places, I moved the URL helper from BotReviewRequestsController into ManageableConcern:

Before:

flowchart LR
  subgraph who["Review requested from"]
    direction TB
    page["Manage MR page"]
    bot["gitlab-bot ready"]
  end

  subgraph ctrl["Controllers"]
    direction TB
    mmr["ManageMergeRequestController"]
    brr["BotReviewRequestsController<br/>private page_url"]
  end

  nb["NoteBuilder.request_review<br/>no page_url"]
  dp["NoteBuilder.duo_pending<br/>page_url:"]
  note("Duo-only note:<br/>Then, come back to the merge request<br/>management page to request a human review.")
  pending("Duo pending note:<br/>GitLab Duo has not finished its review yet.<br/>Once it has, request the review again and<br/>a human reviewer will be suggested.<br/>If Duo does not finish, ask for help on the<br/>[manage merge request page](link).")

  page --> mmr
  bot --> brr
  mmr --> nb
  brr -- "Duo not a reviewer yet" --> nb
  brr -- "Duo not finished" --> dp
  nb --> note
  dp --> pending

  classDef missing fill:#ffebe9,stroke:#cf222e,stroke-width:2px,color:#82071e
  classDef result fill:#dafbe1,stroke:#1a7f37,stroke-width:2px,color:#0f3d1e
  class note missing
  class pending result

After:

flowchart LR
  subgraph who["Review requested from"]
    direction TB
    page["Manage MR page"]
    bot["gitlab-bot ready"]
  end

  subgraph ctrl["Controllers"]
    direction TB
    mmr["ManageMergeRequestController"]
    brr["BotReviewRequestsController"]
  end

  url[["ManageableConcern<br/>merge_request_page_url"]]
  nb["NoteBuilder.request_review<br/>page_url:"]
  dp["NoteBuilder.duo_pending<br/>page_url:, unchanged"]
  note("Duo-only note:<br/>Then, come back to the<br/>[merge request management page](link)<br/>to request a human review.")
  pending("Duo pending note:<br/>GitLab Duo has not finished its review yet.<br/>Once it has, request the review again and<br/>a human reviewer will be suggested.<br/>If Duo does not finish, ask for help on the<br/>[manage merge request page](link).")

  page --> mmr
  bot --> brr
  url -.-> mmr
  url -.-> brr
  mmr --> nb
  brr -- "Duo not a reviewer yet" --> nb
  brr -- "Duo not finished" --> dp
  nb --> note
  dp --> pending

  classDef changed fill:#ddf4ff,stroke:#0969da,stroke-width:2px,color:#0a3069
  classDef result fill:#dafbe1,stroke:#1a7f37,stroke-width:2px,color:#0f3d1e
  class url,nb changed
  class note,pending result

Validation steps

Run the specs that cover both paths:

bundle exec rspec spec/services/review_requests/note_builder_spec.rb spec/requests/api/v1/manage_merge_request_controller_spec.rb spec/requests/api/v1/bot_review_requests_controller_spec.rb

/cc @leetickett-gitlab

Edited by Salim Zidane

Merge request reports

Loading
Loading