Add ciStageStatusUpdated GraphQL subscription for real-time stage updates
What does this MR do and why?
This MR adds a new GraphQL subscription ciStageStatusUpdated that triggers when a CI stage's status changes. This is the backend foundation for real-time pipeline stage status updates on the MR Pipelines page.
Problem
Currently, the MR pipeline mini graph only updates stage statuses through polling or page refresh. While we have real-time updates at the pipeline level (via ciPipelineStatusUpdated), individual stage status transitions (e.g., pending → running → success) are not pushed to the client in real-time.
Solution
Introduce a per-stage GraphQL subscription that triggers on every stage status transition. This allows the frontend to subscribe only to "alive" stages and receive immediate updates when their status changes, providing a more responsive user experience without increasing polling frequency.
Why per-stage instead of per-pipeline?
- Reduced payload size: Sending only the changed stage (~200 bytes) vs all stages (~400+ bytes)
- Fewer DB queries: Only fetch the single stage that changed
- Granular subscriptions: Frontend can subscribe/unsubscribe to individual stages based on their status
References
- Issue: #591338
- Parent epic: &14144
- Frontend Draft MR: !224757 (closed)
How to set up and validate locally
- Navigate to any merge request and run pipeline
- Get the stage ID of the last stage of that pipeline (you can find this in Rails console):
# Find a stage from a running pipeline pipeline = Ci::Pipeline.running.last stage = pipeline.stages.last stage.to_gid.to_s # => "gid://gitlab/Ci::Stage/12345" - Visit http://gdk.test:3000/-/graphql-explorer and start the subscription:
subscription { ciStageStatusUpdated(stageId: "gid://gitlab/Ci::Stage/12345") { id name detailedStatus { icon name tooltip } } } - Wait for the stage to complete all the jobs
- Watch the subscription data update in the GraphQL explorer
MR acceptance checklist Evaluate this MR against the MR acceptance checklist (https://docs.gitlab.com/development/code_review/#acceptance-checklist). It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.