Draft: Add statuses filter argument to duoWorkflowWorkflows query

Summary

Implements the statuses filter argument for the duoWorkflowWorkflows GraphQL query as described in issue #608884 (closed).

This allows filtering workflows by exact raw states, complementing the existing status_group filter which is coarser-grained.

Problem

Query.duoWorkflowWorkflows filters by status_group which bundles multiple raw states together. For example, AWAITING_INPUT includes three different states:

  • input_required (flow is resting between chat turns — no action needed)
  • plan_approval_required (flow is stuck until caller approves)
  • tool_call_approval_required (flow is stuck until caller approves)

Callers need to distinguish between these states without fetching each workflow individually.

Solution

Adds a statuses argument (plural, [DuoWorkflowStatus]) to the resolver, allowing exact-state filtering as a sibling to status_group.

Changes

  1. WorkflowsResolver (ee/app/graphql/resolvers/ai/duo_workflows/workflows_resolver.rb)
    • Add statuses argument of type [Types::Ai::DuoWorkflows::WorkflowStatusEnum]
    • Pass statuses to the WorkflowsFinder
  2. WorkflowsFinder (ee/app/finders/ai/duo_workflows/workflows_finder.rb)
    • Add resolve_statuses method that maps enum values to database status values
    • Uses the same pattern as resolve_status_group with state_machines[:status].states
  3. Workflow Model (ee/app/models/ai/duo_workflows/workflow.rb)
    • Add in_statuses scope to filter by exact status database values
  4. Tests
    • Add comprehensive specs in ee/spec/finders/ai/duo_workflows/workflows_finder_spec.rb
    • Add resolver tests in ee/spec/graphql/resolvers/ai/duo_workflows/workflows_resolver_spec.rb
    • Tests cover single status, multiple statuses, and specific awaiting_input substates

Example Usage

# Get only workflows awaiting approval (not just resting between turns)
query {
  duoWorkflowWorkflows(statuses: [PLAN_APPROVAL_REQUIRED, TOOL_CALL_APPROVAL_REQUIRED]) {
    nodes {
      id
      status
    }
  }
}

Closes #608884 (closed)

Merge request reports

Loading
Loading