Skip to content

Lead Time breakdown missing time when review events are absent #696

@hhaiyang

Description

@hhaiyang

Description:

The Lead Time for Changes breakdown loses time between ready-for-review and merge when review or approval events are missing from a PR.

The three middle components (First Response Time, Rework Time, Merge Time) depend on chained anchor events — first review and approval. When those events don't exist, all three resolve to zero and the elapsed time vanishes from the breakdown. This is confusing — the PR table shows a real lead time, but the breakdown suggests no time was spent in review, rework, or merge. Teams looking at the breakdown to understand where time goes get a misleading picture. As a consequence, the five breakdown components no longer sum to the total lead time.

Image

The issue affects any PR where the review chain is incomplete:

Scenario First Response Time Rework Time Merge Time Time lost
Review + Approval ready→review ✅ review→approval ✅ approval→merge ✅ None
Review, no Approval ready→review ✅ 0 0 review→merge
No Review, no Approval 0 0 0 ready→merge

Steps to reproduce:

  1. Open a PR and mark it ready for review
  2. Merge the PR without any reviews or approvals
  3. Wait for the next sync cycle
  4. Open the Lead Time breakdown in the team view
  5. Compare the sum of the five breakdown components against the per-PR lead time in the PR table

Expected behavior:

The full elapsed time between ready-for-review and merge is accounted for in the breakdown. The five components (First Commit to Open, First Response Time, Rework Time, Merge Time, Merge to Deploy) sum to the total lead time.

For example, a PR that is ready for review at Mon 09:00 and merged at Wed 09:00 with no reviews should show 48h attributed to a sub-component.

Actual behavior:

First Response Time, Rework Time, and Merge Time are all zero. The 48h between ready-for-review and merge is missing from the breakdown entirely.

Example: First Commit to Open = 1h, First Response Time = 0, Rework Time = 0, Merge Time = 0, Merge to Deploy = 1h → Total = 2h (48h missing).

Server Setup Information:

  • Deployment Method: docker (middlewareeng/middleware:latest)

Additional context

Suggested fix: Each component's end-anchor should fall through to the next available event in the chain, with merge as the final fallback:

Scenario First Response Time Rework Time Merge Time
Review + Approval ready→review review→approval approval→merge
Review, no Approval ready→review review→merge 0
No Review, no Approval ready→merge 0 0

This requires no new components, data model changes, or UI changes. It's semantically accurate ("time waiting for first response" is exactly what happened when no review ever came) and reconciles the math for all scenarios.

Related: #207 (tracks surfacing unreviewed PRs as a feature). This issue is specifically about the lead time breakdown components not summing to the total when review events are absent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions