Add agent presence for notes

What does this MR do and why?

Add agent presence for notes via GraphQL. When an AI agent posts a comment, we want to show a label saying which agent wrote it and who set it loose. The existing data only shows up if you're already allowed to open the agent's session, so most people would see nothing, and it misses comments from Duo Code Review entirely. This MR adds a small, safe summary that everyone who can read the comment can see, without exposing the full session itself.

References

Closes #629909 (closed)

How to set up and validate locally

  1. In your GDK, on your Top Level Group: Feature.enable(:agent_presence_consolidation, Group.find_by_full_path('gitlab-duo'))
  2. Start a developer flow on a work item within that TLG, e.g. @duo-developer-gitlab-duo - How many fingers am I holding up?
  3. When the flow finishes, get the Note ID from one of the Flow's created comments, by hovering over the timestamp for that note
  4. Run this GraphQL query for that Note ID:

query notePresence {
  note(id: "gid://gitlab/Note/11698") {
    id
    body
    author { 
      id
      username
    }
    agentPresence {
      sessionId
      agentName
      agentCatalogWebPath
      sourceType
      sourceLink
      user {
        id
        username
        name
        avatarUrl
        webPath
      }
      userPermissions {
        readDuoWorkflow
      }
    }
  }
}
  1. If you want to test the permissions for the source link, set this on the workflow above:
wf = Ai::DuoWorkflows::Workflow.find(workflow_id)
wf.update(source_type: :slack, source_link: "www.google.com")
  1. The graphql query will return sourceLink if you have access to the workflow, and it will be null if not.

Ai::DuoWorkflows::WorkflowNote.created_for_notes

SELECT "duo_workflows_workflow_notes".* FROM "duo_workflows_workflow_notes"
WHERE "duo_workflows_workflow_notes"."link_type" = 1
  AND "duo_workflows_workflow_notes"."note_id" IN (3938913935, 3938670805, 3935964589, 3940687384)
ORDER BY "duo_workflows_workflow_notes"."id" ASC

Execution Plan

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 Roman Eisner

Merge request reports

Loading
Loading