Draft: Draft: Refactor GitlabNote adapter to use system-note lifecycle (alternative to !235039)

What does this MR do and why?

This is an alternative approach to MR !235039 (closed) (!235039 (closed)) for side-by-side comparison. See the proposal comment at !235039 (comment 3395313223) for the full rationale and trade-offs.

Summary

Refactors Ai::Messaging::Adapters::GitlabNote to use a system-note lifecycle that mirrors the already-merged GitlabDuoNote adapter, replacing the editable progress-note UX (🔄 Processing → has started).

Lifecycle change

Phase MR !235039 (closed) (progress note) This MR (system note)
on_request_received Creates a 🔄 progress note Validates project/noteable/note exist; returns ServiceResponse.success
on_flow_started Edits progress note to Posts a duo_mention_started system note; stores started_note_id
deliver_result Posts reply note Destroys started system note, posts reply note
deliver_error Posts reply note Destroys started system note, posts error reply note

Key changes

  1. GitlabNote adapter refactored to mirror GitlabDuoNote's lifecycle:

    • manages_system_notes? = true suppresses default CreateWorkflowService system notes
    • on_flow_started posts a duo_mention_started system note via IssuablesService, authored as the configured service account
    • deliver_result/deliver_error destroy the started system note before posting the reply
  2. duo_mention_started lifted from MergeRequestsService to IssuablesService so it works for Issue, MR, AND WorkItem noteables (not just MR). The i18n key is renamed from DuoCodeReview| to Ai| since the message is no longer code-review specific.

  3. GitlabDuoNote updated to call IssuablesService#duo_mention_started instead of MergeRequestsService#duo_mention_started (one-line change to which service it instantiates).

  4. WorkItem support: GitlabNote supports Issue, MR, AND WorkItem — a key feature vs. GitlabDuoNote which only supports Issue+MR.

Consolidation follow-up

GitlabNote and GitlabDuoNote remain separate classes in this MR. Consolidation (e.g., GitlabDuoNote < GitlabNote inheritance) is a deliberate follow-up so each step is easy to review.

References

Screenshots or screen recordings

Before (MR !235039 (closed)) After (this MR)
🔄 Processing note appears immediately, then updates to has started started mention session N system note appears, disappears when final reply arrives

How to set up and validate locally

  1. Set up a service account and flow trigger for @mention flows (see MR !235039 (closed) for setup instructions)
  2. @mention the service account in an issue comment, MR discussion, or work item comment
  3. Observe: no progress note appears immediately (unlike !235039 (closed))
  4. When the flow starts: a system note started mention session N and will let you know when it's finished appears
  5. When the flow completes: the system note disappears and the final reply note appears in the discussion

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.

Merge request reports

Loading