Loading
Expose duo_session_id on the note REST payload
What does this MR do and why?
Backend work to unblock FE: Add session link to agent reply comments (MRs) (#606457 - closed) • Allison Villa • 19.4
- Add a scoped association in
EE::Noteso the serializer (EE::NoteEntity) can reach theduo_workflows_workflow_notesrow linking a note to its session. - Preload it in
inc_relations_for_view(inee/app/models/ee/note.rb) so a notes page fetches those links in one query instead of one per comment. - Expose
duo_session_idinEE::NoteEntityon any note with a linked session, readingnote_duo_metadataorduo_workflows_workflow_notes.
No schema changes have been added (and no migrations needed), the field reads links that already exist, so it'll populate for agent comments created before this MR too
References
Related to
- BE: Add session link to agent reply comments (M... (#606456 - closed) • Allison Villa • 19.3 • Needs attention
- FE: Add session link to agent reply comments (MRs) (#606457 - closed) • Allison Villa • 19.4
Screenshots or screen recordings
No UI changes in this MR
How to set up and validate locally
- Prerequisite: Have GitLab Duo set up in your GDK
- Have a Duo-enabled group and project in your GDK created by the Duo setup above
- Prerequisite: Have GitLab Runner working
@mentionan agent on an MR and ask it a question- In your rails console, confirm the agent's reply exposes
duo_session_id, read from theduo_workflows_workflow_noteslink:
note = Ai::DuoWorkflows::WorkflowNote.link_type_created.last.note
req = EntityRequest.new(current_user: note.author, noteable: note.noteable)
NoteEntity.new(note, request: req).as_json[:duo_session_id]- Confirm the same for a note linked through
note_duo_metadata(Duo Code Review's summary comment, or theduo_mention_startedprogress note):
note = Notes::NoteDuoMetadata.last.note
req = EntityRequest.new(current_user: note.author, noteable: note.noteable)
NoteEntity.new(note, request: req).as_json[:duo_session_id]- Confirm an ordinary comment omits the key entirely rather than sending
null:
note = Note.where(system: false).where.missing(:duo_metadata)
.where.not(id: Ai::DuoWorkflows::WorkflowNote.pluck(:note_id)).last
req = EntityRequest.new(current_user: note.author, noteable: note.noteable)
NoteEntity.new(note, request: req).as_json.key?(:duo_session_id)
#=> false- In a separate terminal, tail the log and load a merge request with agent comments in the browser:
tail -f log/development.log | grep duo_workflows_workflow_notesThe preload should issue one query with note_id IN (...), not one per comment.
Work items are unaffected b/c their notes come through GraphQL and need their own backend change (#606455 (closed)).
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.
Edited by Allison Villa