Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(eng-analytics): window comparison overview with merge queue section (#86561)

Raúl Negrón-Oteroc20e0c0cffed
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 38400785bc7c..ff45c6adf5ea 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -6265,9 +6265,9 @@ snapshots:
scenes-app-discussions--threads--light:
hash: v1.k794b7964.28ac830bf83be5cbb6d7a397d67c9b9c61711904a822de38402b82220b0f7a49.7wENY7hvo1-qAJwq5fcsvKGJsfRAF_vDkpnM8iqFZcc
scenes-app-engineering-analytics-repo-overview--repo-overview--dark:
- hash: v1.k794b7964.8e6b4034168c2ae8907ac92efb3941209867a95ef8388505b9bcb7a57830c243._1Y9xmZSpOpt_qzloETiebDiX0ROe1GBE2c00TKYaDM
+ hash: v1.k794b7964.93f0784927beb8f29f7060b98795fc4200dc169ef7f5da3fe255cf5e143c0ff3.-5znSrlummkvLSBLsYSKNzJ3Co4GxMNxsndYCtHeMms
scenes-app-engineering-analytics-repo-overview--repo-overview--light:
- hash: v1.k794b7964.4a0774ee6bc116b4fa7a71bcb3ede68edc930a93231ade9fbf72f16a5b9eba1c.OII3xJtYXX1Udah76yG4WxQE6d5Am0PRCSBrCfGDGcM
+ hash: v1.k794b7964.a7c7a2d6fefcf26234d5cacdbb217130930a6c25070affd05abe74d5bce3be76.20Bs4I2_GIprl6Dj7hDuA7yYpsl0aU8Z37Xv4brbh-4
scenes-app-engineering-analytics-run-activity-chart--default--dark:
hash: v1.k794b7964.7f17c5ac7c6862493f7c4d59e6e3c3146c42e3d7b08908ee1716d387c129ba64.lPsE9KrOSZee9wJq8zjqYnvk09numvEFWOn4mdCOgJE
scenes-app-engineering-analytics-run-activity-chart--default--light:
diff --git a/products/engineering_analytics/frontend/components/TrendCard.tsx b/products/engineering_analytics/frontend/components/TrendCard.tsx
deleted file mode 100644
index 1cf9aa1266dd..000000000000
--- a/products/engineering_analytics/frontend/components/TrendCard.tsx
+++ /dev/null
@@ -1,81 +0,0 @@
-// A stat-plus-trend card for the repo hub's Trends strip: lead with the current value and its change
-// across the window (the answer), over a sentiment-colored sparkline (the context). `goodWhenDown` colors
-// both the delta and the line green when the metric is falling (time-to-green, cost), red when rising.
-
-import { ReactNode } from 'react'
-
-import { LemonCard, LemonSkeleton } from '@posthog/lemon-ui'
-
-import { Sparkline } from 'lib/components/Sparkline'
-
-import type { TrendSeries } from '../lib/trends'
-import { DeltaBadge, percentChange } from './MetricTile'
-
-export function TrendCard({
- title,
- series,
- formatValue,
- renderTooltipValue,
- goodWhenDown = false,
- caption,
- loading = false,
- emptyText,
-}: {
- title: string
- series: TrendSeries | null
- /** Formats the headline (latest) value, e.g. minutes or USD. */
- formatValue: (value: number) => string
- renderTooltipValue: (value: number) => string
- goodWhenDown?: boolean
- caption: ReactNode
- loading?: boolean
- emptyText: string
-}): JSX.Element {
- const values = series?.values ?? []
- const latest = values.length ? values[values.length - 1] : null
- // Baseline is the first point — `trendSeries` guarantees values[0] is real data, not zero-fill. A
- // genuine leading 0 (e.g. a 0% pass rate at the window's start) is a valid baseline: percentChange
- // returns null off a zero baseline, so the card shows no delta rather than mis-baselining against
- // a later bucket.
- const first = values.length ? values[0] : null
- const deltaPct = percentChange(latest, first)
- // Line color follows the delta's sentiment so the card reads at a glance: green the good way, red the
- // bad way, muted when flat or without a baseline.
- const lineColor =
- deltaPct == null || deltaPct === 0 ? 'muted' : deltaPct < 0 === goodWhenDown ? 'success' : 'danger'
-
- return (
- <LemonCard hoverEffect={false} className="flex flex-col p-4">
- <h3 className="mb-1 text-xs font-semibold text-secondary">{title}</h3>
- {loading ? (
- <LemonSkeleton className="h-20 w-full" />
- ) : values.length ? (
- <>
- <div className="mb-1 flex items-baseline gap-2">
- <span className="text-2xl font-semibold leading-none tabular-nums">
- {formatValue(latest as number)}
- </span>
- <DeltaBadge
- value={deltaPct}
- goodWhenDown={goodWhenDown}
- vs="latest vs the start of the window"
- />
- </div>
- <Sparkline
- data={values}
- labels={series?.labels}
- name={title}
- type="line"
- color={lineColor}
- className="h-16 w-full"
- renderLabel={(label) => label}
- renderTooltipValue={renderTooltipValue}
- />
- </>
- ) : (
- <div className="flex h-20 items-center text-xs text-secondary">{emptyText}</div>
- )}
- <div className="mt-2 border-t border-primary pt-2 text-[11px] text-tertiary">{caption}</div>
- </LemonCard>
- )
-}
diff --git a/products/engineering_analytics/frontend/components/WindowComparisonCard.tsx b/products/engineering_analytics/frontend/components/WindowComparisonCard.tsx
new file mode 100644
index 000000000000..2c0bcaf6553a
--- /dev/null
+++ b/products/engineering_analytics/frontend/components/WindowComparisonCard.tsx
@@ -0,0 +1,186 @@
+// A window-comparison card for the repo hub's headline sections. Each metric's question is "this
+// window vs the previous window", a comparison of exactly two values, so the graphic is two labeled
+// horizontal bars on a shared zero-based scale rather than a time series: the daily buckets behind
+// these metrics are noise at this grain. Rates use a pass/fail split bar per window, where the
+// status colors are the data; a duration card can pin a p90 tick on each bar to show the tail on
+// the same scale as the median.
+
+import { ReactNode } from 'react'
+
+import { LemonCard, LemonSkeleton, Tooltip } from '@posthog/lemon-ui'
+
+import { DeltaBadge, percentChange, pointChange } from './MetricTile'
+
+function MagnitudeBar({
+ fraction,
+ current,
+ markerFraction,
+ markerTooltip,
+}: {
+ fraction: number
+ current: boolean
+ markerFraction?: number | null
+ markerTooltip?: string
+}): JSX.Element {
+ return (
+ <div className="relative h-2.5 flex-1 rounded-sm">
+ <div
+ className={`h-full rounded-sm ${current ? 'bg-[var(--data-color-1)]' : 'bg-[var(--muted)]'}`}
+ style={{ width: `${Math.max(fraction * 100, 2)}%` }}
+ />
+ {markerFraction != null && (
+ <Tooltip title={markerTooltip}>
+ <div
+ className="absolute -top-0.5 h-3.5 w-0.5 -translate-x-1/2 rounded-sm bg-[var(--text-3000)]"
+ style={{ left: `${markerFraction * 100}%` }}
+ />
+ </Tooltip>
+ )}
+ </div>
+ )
+}
+
+function SplitBar({ rate }: { rate: number }): JSX.Element {
+ const passedPercent = Math.round(rate * 100)
+ return (
+ <Tooltip title={`${passedPercent}% passed, ${100 - passedPercent}% failed`}>
+ <div className="flex h-2.5 flex-1 overflow-hidden rounded-sm">
+ <div className="h-full bg-success" style={{ width: `${rate * 100}%` }} />
+ <div className="h-full flex-1 bg-danger" />
+ </div>
+ </Tooltip>
+ )
+}
+
+function ComparisonRow({
+ label,
+ value,
+ max,
+ formatValue,
+ share,
+ current,
+ marker,
+ markerLabel,
+}: {
+ label: string
+ value: number
+ max: number
+ formatValue: (value: number) => string
+ /** Render the value as a pass/fail split of the whole bar instead of a length. */
+ share: boolean
+ current: boolean
+ marker?: number | null
+ markerLabel?: string
+}): JSX.Element {
+ return (
+ <div className="flex items-center gap-2">
+ <span className="w-24 shrink-0 text-[11px] text-tertiary">{label}</span>
+ {share ? (
+ <SplitBar rate={value} />
+ ) : (
+ <MagnitudeBar
+ fraction={max > 0 ? value / max : 0}
+ current={current}
+ markerFraction={marker != null && max > 0 ? marker / max : null}
+ markerTooltip={marker != null && markerLabel ? `${markerLabel} ${formatValue(marker)}` : undefined}
+ />
+ )}
+ <span className="w-12 shrink-0 text-right text-xs font-medium tabular-nums">{formatValue(value)}</span>
+ </div>
+ )
+}
+
+export function WindowComparisonCard({
+ title,
+ value,
+ previousValue,
+ formatValue,
+ goodWhenDown = false,
+ share = false,
+ deltaUnit,
+ tooltip,
+ marker,
+ markerPrevious,
+ markerLabel,
+ loading = false,
+ emptyText,
+}: {
+ title: string
+ /** This window's value. */
+ value: number | null | undefined
+ /** The previous window's value; without one the card shows this window's bar alone. */
+ previousValue: number | null | undefined
+ formatValue: (value: number) => string
+ goodWhenDown?: boolean
+ /** Rate mode: bars become a full-width pass/fail split instead of a length. */
+ share?: boolean
+ /** 'pt' renders the delta as percentage points; default is relative percent. */
+ deltaUnit?: 'pt'
+ /** Definition or methodology, shown on title hover. */
+ tooltip?: ReactNode
+ /** A companion figure (e.g. p90) pinned as a tick on each magnitude bar, on the same scale as
+ * the value. Ignored in `share` mode, which has no scale to pin against. */
+ marker?: number | null
+ markerPrevious?: number | null
+ markerLabel?: string
+ loading?: boolean
+ emptyText: string
+}): JSX.Element {
+ const max = Math.max(value ?? 0, previousValue ?? 0, marker ?? 0, markerPrevious ?? 0)
+ const delta = deltaUnit === 'pt' ? pointChange(value, previousValue) : percentChange(value, previousValue)
+
+ return (
+ <LemonCard hoverEffect={false} className="flex flex-col p-4">
+ <h3 className="mb-1 text-xs font-semibold text-secondary">
+ {tooltip ? (
+ <Tooltip title={tooltip}>
+ <span className="cursor-default">{title}</span>
+ </Tooltip>
+ ) : (
+ title
+ )}
+ </h3>
+ {loading ? (
+ <LemonSkeleton className="h-20 w-full" />
+ ) : value != null ? (
+ <>
+ <div className="mb-3 flex items-baseline gap-2">
+ <span className="text-2xl font-semibold leading-none tabular-nums">{formatValue(value)}</span>
+ <DeltaBadge
+ value={delta}
+ unit={deltaUnit ?? '%'}
+ goodWhenDown={goodWhenDown}
+ vs="vs the previous window"
+ />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <ComparisonRow
+ label="This window"
+ value={value}
+ max={max}
+ formatValue={formatValue}
+ share={share}
+ current
+ marker={marker}
+ markerLabel={markerLabel}
+ />
+ {previousValue != null && (
+ <ComparisonRow
+ label="Previous window"
+ value={previousValue}
+ max={max}
+ formatValue={formatValue}
+ share={share}
+ current={false}
+ marker={markerPrevious}
+ markerLabel={markerLabel}
+ />
+ )}
+ </div>
+ </>
+ ) : (
+ <div className="flex h-20 items-center text-xs text-secondary">{emptyText}</div>
+ )}
+ </LemonCard>
+ )
+}
diff --git a/products/engineering_analytics/frontend/lib/trends.test.ts b/products/engineering_analytics/frontend/lib/trends.test.ts
deleted file mode 100644
index 93b444f86185..000000000000
--- a/products/engineering_analytics/frontend/lib/trends.test.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-import { trendSeries } from './trends'
-
-describe('trendSeries', () => {
- const buckets = (values: (number | null)[]): { bucket_start: string; value: number | null }[] =>
- values.map((value, index) => ({ bucket_start: `2026-06-0${index + 1}T00:00:00Z`, value }))
-
- const read = (bucket: { value: number | null }): number | null => bucket.value
-
- it('is null when nothing was measured, so the card can show its empty state', () => {
- expect(trendSeries(buckets([null, null]), read, 'day')).toBeNull()
- expect(trendSeries([], read, 'day')).toBeNull()
- })
-
- it('drops leading empty buckets so the delta baselines against a measured value', () => {
- // Without the trim the card would baseline on a zero-filled bucket and report a false rise.
- expect(trendSeries(buckets([null, null, 10, 12]), read, 'day')).toEqual({
- values: [10, 12],
- labels: ['Jun 3', 'Jun 4'],
- })
- })
-
- it('carries the last value across a gap instead of dipping to zero', () => {
- expect(trendSeries(buckets([10, null, 12]), read, 'day')?.values).toEqual([10, 10, 12])
- })
-
- it('keeps a measured zero, which is a value rather than a gap', () => {
- expect(trendSeries(buckets([10, 0, 12]), read, 'day')?.values).toEqual([10, 0, 12])
- })
-
- it('labels hourly buckets with the time', () => {
- expect(trendSeries(buckets([10]), read, 'hour')?.labels).toEqual(['Jun 1 00:00'])
- })
-})
diff --git a/products/engineering_analytics/frontend/lib/trends.ts b/products/engineering_analytics/frontend/lib/trends.ts
deleted file mode 100644
index 757053400769..000000000000
--- a/products/engineering_analytics/frontend/lib/trends.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-import { dayjs } from 'lib/dayjs'
-
-/** A sparkline's plot: one value per label, oldest first, with no gaps left in either. */
-export interface TrendSeries {
- values: number[]
- labels: string[]
-}
-
-/** The API's bucketed series shape: oldest first, one bucket per interval across the window. */
-interface Bucketed {
- bucket_start: string
-}
-
-/**
- * A bucketed API series as a `TrendCard` plot, or null when no bucket carries a value — the card
- * then shows its own empty state instead of a flat line.
- *
- * Empty buckets are a gap in the measurement ("nothing merged", "no run to time"), never a zero, so
- * the two ways a gap can appear are both handled here rather than per metric: leading empty buckets
- * are dropped, so the line opens on real data and the card's delta baselines against a real value,
- * and a later gap carries the last known value forward instead of dipping to zero.
- */
-export function trendSeries<T extends Bucketed>(
- buckets: T[],
- value: (bucket: T) => number | null | undefined,
- granularity: string | undefined
-): TrendSeries | null {
- const firstMeasured = buckets.findIndex((bucket) => value(bucket) != null)
- if (firstMeasured === -1) {
- return null
- }
- const labelFormat = granularity === 'hour' ? 'MMM D HH:mm' : 'MMM D'
- const series: TrendSeries = { values: [], labels: [] }
- let carried = 0
- for (const bucket of buckets.slice(firstMeasured)) {
- carried = value(bucket) ?? carried
- series.values.push(carried)
- series.labels.push(dayjs(bucket.bucket_start).format(labelFormat))
- }
- return series
-}
diff --git a/products/engineering_analytics/frontend/scenes/RepoOverviewScene.stories.tsx b/products/engineering_analytics/frontend/scenes/RepoOverviewScene.stories.tsx
index f4681eea014b..935ceee28271 100644
--- a/products/engineering_analytics/frontend/scenes/RepoOverviewScene.stories.tsx
+++ b/products/engineering_analytics/frontend/scenes/RepoOverviewScene.stories.tsx
@@ -16,8 +16,8 @@ import type {
const SOURCES: GitHubSourceApi[] = [{ id: 'src-1', repo: 'PostHog/posthog', prefix: '' }]
-// One overview payload feeding the whole hub: the trend sparkline cards and the quill cost-per-merge
-// line chart. Each trend series carries a null bucket so the trim + carry-forward path is exercised.
+// One overview payload feeding the whole hub's window-comparison cards. The series arrays are empty
+// because the hub requests include_series=false; the aggregates carry everything the cards render.
const OVERVIEW: RepoOverviewApi = {
run_count: 1284,
run_count_prev: 1122,
@@ -25,7 +25,6 @@ const OVERVIEW: RepoOverviewApi = {
success_rate_prev: 0.82,
rerun_cycles: 41,
rerun_cycles_prev: 30,
- // Matches the cost_series merges below: 8 merges x 7 daily buckets.
merged_pr_count: 56,
merged_pr_count_prev: 49,
median_open_to_merge_seconds: 14 * 3600,
@@ -61,36 +60,15 @@ const OVERVIEW: RepoOverviewApi = {
median_time_to_green_seconds_prev: 9 * 60,
jobs_available: true,
default_branch: 'master',
+ cost_series: [],
cost_series_granularity: 'day',
- cost_series: [52.1, 47.8, 61.3, 58.9, 44.2, 49.5, 55.7].map((cost, i) => ({
- bucket_start: `2026-06-${25 + i}T00:00:00Z`,
- estimated_cost_usd: cost * 8,
- merges: 8,
- cost_per_merge_usd: cost,
- })),
- time_to_green_series: [540, 600, null, 660, 720, 900, 780].map((p50_seconds, i) => ({
- bucket_start: `2026-06-${25 + i}T00:00:00Z`,
- p50_seconds,
- })),
+ time_to_green_series: [],
time_to_green_series_granularity: 'day',
- success_rate_series: [0.82, 0.85, 0.8, null, 0.88, 0.79, 0.87].map((success_rate, i) => ({
- bucket_start: `2026-06-${25 + i}T00:00:00Z`,
- success_rate,
- })),
+ success_rate_series: [],
success_rate_series_granularity: 'day',
- open_to_merge_series: [14 * 3600, 16 * 3600, null, 12 * 3600, 15 * 3600, 18 * 3600, 13 * 3600].map(
- (p50_seconds, i) => ({
- bucket_start: `2026-06-${25 + i}T00:00:00Z`,
- p50_seconds,
- })
- ),
+ open_to_merge_series: [],
open_to_merge_series_granularity: 'day',
- ready_to_merge_series: [9 * 3600, 11 * 3600, null, 8 * 3600, 10 * 3600, 12 * 3600, 9 * 3600].map(
- (p50_seconds, i) => ({
- bucket_start: `2026-06-${25 + i}T00:00:00Z`,
- p50_seconds,
- })
- ),
+ ready_to_merge_series: [],
ready_to_merge_series_granularity: 'day',
}
diff --git a/products/engineering_analytics/frontend/scenes/RepoOverviewScene.tsx b/products/engineering_analytics/frontend/scenes/RepoOverviewScene.tsx
index 0bb11c8a3072..dc9c262b9279 100644
--- a/products/engineering_analytics/frontend/scenes/RepoOverviewScene.tsx
+++ b/products/engineering_analytics/frontend/scenes/RepoOverviewScene.tsx
@@ -1,5 +1,6 @@
-// The repo hub landing page: PRs needing attention, then windowed trends, master health, and
-// workflows as sections on one page.
+// The repo hub landing page: the window-scoped sections (CI health, merge queue, master health,
+// workflows) inside a panel whose rim carries the date filter, then the current-state PR backlog
+// below it.
import { useActions, useValues } from 'kea'
import { router } from 'kea-router'
@@ -17,9 +18,9 @@ import { formatAxisMinutes, hasEnoughRunActivity } from '../components/RunActivi
import { RunActivityMiniBars } from '../components/RunActivityMiniBars'
import { ScopeDateFilter, SourceScopeChip } from '../components/ScopeBar'
import { Section } from '../components/Section'
-import { TrendCard } from '../components/TrendCard'
+import { WindowComparisonCard } from '../components/WindowComparisonCard'
import { WorkflowHealthTable } from '../components/WorkflowHealthTable'
-import { compactHoursLabel, compactMinutes, compactUsd, percent } from '../lib/format'
+import { compactAgeLabel, compactHoursLabel, compactMinutes, compactUsd, percent } from '../lib/format'
import { githubCommitUrl } from '../lib/github'
import { HUB_PREVIEW_MAX } from '../lib/preview'
import { withCurrentScope, withScope } from '../lib/scope'
@@ -34,11 +35,6 @@ export function RepoOverviewScene(): JSX.Element {
repoActivityLoading,
repoActivityFailed,
attentionPrs,
- costPerMergeSeries,
- timeToGreenSeries,
- passRateSeries,
- openToMergeSeries,
- readyToMergeSeries,
jobsAvailable,
overviewDefaultBranch,
notConnected,
@@ -73,22 +69,27 @@ export function RepoOverviewScene(): JSX.Element {
// during the initial fetch would misread as a broken setup — hold it back while loading.
const overviewPending = overviewLoading && !overview
+ const asMinutes = (seconds: number | null | undefined): number | null => (seconds != null ? seconds / 60 : null)
+
// Cycle time is ready→merge wherever the backend can observe the draft/ready transitions. Without
// them it falls back to the coarse created→merged span and says so, rather than labelling one
// measure with the other's name.
- const cycleTime = readyToMergeSeries
- ? {
- title: 'Median PR ready→merge',
- series: readyToMergeSeries,
- caption:
- 'Median ready-for-review to merged time, bots and drafts excluded. Time as a draft is not counted.',
- }
- : {
- title: 'Median PR open→merge',
- series: openToMergeSeries,
- caption:
- 'Median created-to-merged time, bots and drafts excluded. Coarse: draft and ready time are fused.',
- }
+ const cycleTime =
+ overview?.median_ready_to_merge_seconds != null
+ ? {
+ title: 'Median time from ready for review to merge',
+ value: overview.median_ready_to_merge_seconds,
+ previousValue: overview.median_ready_to_merge_seconds_prev,
+ tooltip:
+ 'Median ready-for-review to merged time, bots and drafts excluded. Time as a draft is not counted.',
+ }
+ : {
+ title: 'Median time from open to merge',
+ value: overview?.median_open_to_merge_seconds,
+ previousValue: overview?.median_open_to_merge_seconds_prev,
+ tooltip:
+ 'Median created-to-merged time, bots and drafts excluded. Coarse: draft and ready time are fused.',
+ }
if (notConnected) {
return <ConnectGitHubSource />
@@ -106,178 +107,238 @@ export function RepoOverviewScene(): JSX.Element {
return (
<div className="flex flex-col gap-4">
- {/* Repo identity. The scope controls dock below the PR table, so the date filter visibly
- governs only the windowed surfaces beneath it. */}
<RepoEntityHeader repoFullName={activeSource?.repo || ''} />
- <Section id="prs" title="Pull requests needing attention">
- <LemonCard hoverEffect={false} className="overflow-hidden p-0">
- <PullRequestTable
- rows={shownPrs}
- loading={pullRequestsLoading}
- sourceId={sourceId}
- embedded
- pageSize={HUB_PREVIEW_MAX}
- emptyState="Nothing failing or stuck in the open backlog."
- dataAttr="engineering-analytics-attention-prs"
- />
- <div className="flex flex-wrap items-center justify-between gap-2 border-t border-primary px-4 py-2 text-[11px] text-tertiary">
- <span>
- Showing {shownPrs.length} of {humanFriendlyNumber(attentionPrs.length)} needing attention
- </span>
- <div className="flex items-center gap-3">
- {canShowMorePrs && (
- <LemonButton size="xsmall" onClick={showMorePrs}>
- Show more
- </LemonButton>
- )}
- <Link to={withCurrentScope(urls.engineeringAnalyticsPullRequestList(), sourceId)}>
- View all →
- </Link>
- </div>
- </div>
- </LemonCard>
- </Section>
-
- {/* The filter is the seam: everything above is current-state, everything below reflects its window. */}
- <div className="mt-1 flex flex-wrap items-center justify-end gap-2 border-t border-primary pt-4">
- {hubReloading && <Spinner className="text-secondary" />}
- <SourceScopeChip pickerOnly />
- <ScopeDateFilter />
- </div>
+ {/* The panel is the scope: the controls sit on its rim, and everything inside reflects
+ their window. The PR backlog below the panel is current-state, not windowed. */}
+ <div className="relative mt-4 rounded-lg border border-primary p-4">
+ <div className="absolute -top-4 right-3 flex flex-wrap items-center justify-end gap-2 bg-primary px-2">
+ {hubReloading && <Spinner className="text-secondary" />}
+ <SourceScopeChip pickerOnly />
+ <ScopeDateFilter />
+ </div>
+ <div className="flex flex-col gap-4 pt-2">
+ {/* The windowed headline metrics: each card compares this window against the previous
+ one directly (two values), not as a time series. CI cost is a window total, not a
+ rate, so its number lives on the Workflows section below. */}
+ <Section id="ci-health" title="CI health" busy={overviewLoading}>
+ <div className="grid grid-cols-1 gap-2 md:grid-cols-2">
+ <WindowComparisonCard
+ title="CI runs that passed"
+ value={overview?.success_rate}
+ previousValue={overview?.success_rate_prev}
+ formatValue={percent}
+ share
+ deltaUnit="pt"
+ loading={overviewPending}
+ tooltip="Share of completed CI runs that passed, all branches."
+ emptyText="Not enough completed CI runs in the window yet."
+ />
- {/* The windowed headline metrics, each a value + colored delta over a sentiment-colored sparkline.
- CI cost is a window total, not a rate, so its number lives on the Workflows section below. */}
- <Section id="trends" title="Trends" busy={overviewLoading}>
- <div className="grid grid-cols-1 gap-2 md:grid-cols-2">
- {/* CI health: share of completed runs that passed, all branches. */}
- <TrendCard
- title="Pass rate"
- series={passRateSeries}
- formatValue={(value) => percent(value)}
- renderTooltipValue={(value) => percent(value, 1)}
- loading={overviewPending}
- emptyText="Not enough completed CI runs in the window yet."
- caption="Share of completed CI runs that passed, all branches."
- />
+ <WindowComparisonCard
+ title="Median time from push to all checks green"
+ value={asMinutes(overview?.median_time_to_green_seconds)}
+ previousValue={asMinutes(overview?.median_time_to_green_seconds_prev)}
+ formatValue={formatAxisMinutes}
+ goodWhenDown
+ loading={overviewPending}
+ tooltip="Median time from a push until every workflow on it is green. Only fully green pushes count."
+ emptyText="No fully green PR pushes in the window yet."
+ />
- <TrendCard
- title="PR time to green"
- series={timeToGreenSeries}
- formatValue={formatAxisMinutes}
- renderTooltipValue={formatAxisMinutes}
- goodWhenDown
- loading={overviewPending}
- emptyText="No fully green PR pushes in the window yet."
- caption="Median time from a push until every workflow on it is green. Only fully green pushes count."
- />
+ <WindowComparisonCard
+ title={cycleTime.title}
+ value={cycleTime.value}
+ previousValue={cycleTime.previousValue}
+ formatValue={compactHoursLabel}
+ goodWhenDown
+ loading={overviewPending}
+ tooltip={cycleTime.tooltip}
+ emptyText="No PRs merged in the window yet."
+ />
- <TrendCard
- title={cycleTime.title}
- series={cycleTime.series}
- formatValue={compactHoursLabel}
- renderTooltipValue={compactHoursLabel}
- goodWhenDown
- loading={overviewPending}
- emptyText="No PRs merged in the window yet."
- caption={cycleTime.caption}
- />
+ <WindowComparisonCard
+ title="CI cost per merged PR"
+ value={overview?.cost_per_merge_usd}
+ previousValue={overview?.cost_per_merge_usd_prev}
+ formatValue={compactUsd}
+ goodWhenDown
+ loading={overviewPending}
+ emptyText={
+ !jobsAvailable
+ ? 'Cost appears once the job-level source is synced.'
+ : overview?.merged_pr_count === 0
+ ? 'Nothing merged in the window.'
+ : 'No costable jobs in the window.'
+ }
+ tooltip="Estimated Depot CI cost per merged PR. Per-workflow spend is in Workflows below."
+ />
+ </div>
+ </Section>
- <TrendCard
- title="Cost per merged PR"
- series={jobsAvailable ? costPerMergeSeries : null}
- formatValue={compactUsd}
- renderTooltipValue={compactUsd}
- goodWhenDown
- loading={overviewPending}
- emptyText={
- jobsAvailable
- ? 'No costable jobs in the window.'
- : 'Cost appears once the job-level source is synced.'
- }
- caption="Estimated Depot CI cost per merged PR, trailing-window ratio. Per-workflow spend is in Workflows below."
- />
- </div>
- </Section>
+ <Section id="merge-queue" title="Merge queue" busy={overviewLoading}>
+ {overview && overview.merge_queue_merged_pr_count === 0 ? (
+ <LemonCard hoverEffect={false} className="p-4 text-xs text-secondary">
+ No merge queue activity in the window.
+ </LemonCard>
+ ) : (
+ <div className="grid grid-cols-1 gap-2 md:grid-cols-3">
+ <WindowComparisonCard
+ title="Median time in the merge queue"
+ tooltip="From a PR's first merge queue gate run starting to the PR merging. Waiting before gate testing starts is not included. The tick marks the p90."
+ value={overview?.merge_queue_median_first_gate_to_merge_seconds}
+ previousValue={overview?.merge_queue_median_first_gate_to_merge_seconds_prev}
+ formatValue={compactAgeLabel}
+ goodWhenDown
+ marker={overview?.merge_queue_p90_first_gate_to_merge_seconds}
+ markerPrevious={overview?.merge_queue_p90_first_gate_to_merge_seconds_prev}
+ markerLabel="p90"
+ loading={overviewPending}
+ emptyText="No queue-landed merges in the window."
+ />
+ <WindowComparisonCard
+ title="Merges retried in the queue"
+ tooltip="Share of queue-landed merges that needed more than one gate attempt. Bisection branches count toward the attempt they investigate."
+ value={overview?.merge_queue_multi_attempt_merge_share}
+ previousValue={overview?.merge_queue_multi_attempt_merge_share_prev}
+ formatValue={percent}
+ deltaUnit="pt"
+ goodWhenDown
+ loading={overviewPending}
+ emptyText="No queue-landed merges in the window."
+ />
+ <WindowComparisonCard
+ title="Merges with a failed queue run"
+ tooltip="Share of queue-landed merges where at least one gate run failed before the merge. Derived from CI run conclusions, not the queue's own eviction records."
+ value={overview?.merge_queue_failed_gate_merge_share}
+ previousValue={overview?.merge_queue_failed_gate_merge_share_prev}
+ formatValue={percent}
+ deltaUnit="pt"
+ goodWhenDown
+ loading={overviewPending}
+ emptyText="No queue-landed merges in the window."
+ />
+ </div>
+ )}
+ </Section>
- <Section
- id="master"
- title={`${overviewDefaultBranch === 'main' ? 'Main' : 'Master'} health`}
- busy={repoActivityLoading}
- >
- {/* Hub preview: one bar per default-branch commit, height = CI duration, color = verdict — the
+ <Section
+ id="master"
+ title={`${overviewDefaultBranch === 'main' ? 'Main' : 'Master'} health`}
+ busy={repoActivityLoading}
+ >
+ {/* Hub preview: one bar per default-branch commit, height = CI duration, color = verdict — the
at-a-glance "is master healthy and fast lately" read without the full chart's weight. The
full scatter (start-time axis, in-flight band, zoom) lives on the workflow page. */}
- {hasEnoughRunActivity(activityRuns) ? (
- <RunActivityMiniBars
- runs={activityRuns}
- truncated={activityTruncated}
- title="CI duration per commit"
- noun="commit"
- onBarClick={(run) => {
- // Each bar is a whole commit (its workflows collapsed), so open the commit on
- // GitHub — all its checks — rather than one arbitrary workflow run.
- const [owner, repoName] = (activeSource?.repo || '').split('/')
- if (!run.headSha || !owner || !repoName) {
- return
- }
- window.open(githubCommitUrl(owner, repoName, run.headSha), '_blank', 'noopener,noreferrer')
- }}
- />
- ) : (
- <LemonCard hoverEffect={false} className="p-4 text-xs text-secondary">
- {repoActivityLoading
- ? 'Loading…'
- : repoActivityFailed
- ? `Couldn't load ${overviewDefaultBranch} activity. Refresh to retry.`
- : `Not enough completed runs on ${overviewDefaultBranch} in the window to chart yet.`}
- </LemonCard>
- )}
- </Section>
+ {hasEnoughRunActivity(activityRuns) ? (
+ <RunActivityMiniBars
+ runs={activityRuns}
+ truncated={activityTruncated}
+ title="CI duration per commit"
+ noun="commit"
+ onBarClick={(run) => {
+ // Each bar is a whole commit (its workflows collapsed), so open the commit on
+ // GitHub — all its checks — rather than one arbitrary workflow run.
+ const [owner, repoName] = (activeSource?.repo || '').split('/')
+ if (!run.headSha || !owner || !repoName) {
+ return
+ }
+ window.open(
+ githubCommitUrl(owner, repoName, run.headSha),
+ '_blank',
+ 'noopener,noreferrer'
+ )
+ }}
+ />
+ ) : (
+ <LemonCard hoverEffect={false} className="p-4 text-xs text-secondary">
+ {repoActivityLoading
+ ? 'Loading…'
+ : repoActivityFailed
+ ? `Couldn't load ${overviewDefaultBranch} activity. Refresh to retry.`
+ : `Not enough completed runs on ${overviewDefaultBranch} in the window to chart yet.`}
+ </LemonCard>
+ )}
+ </Section>
+
+ <Section
+ id="workflows"
+ title={jobsAvailable ? 'Top workflows by cost' : 'Busiest workflows'}
+ right={
+ jobsAvailable && overview?.estimated_cost_usd != null ? (
+ <Tooltip
+ title={`Estimated: ${compactMinutes(overview?.billable_minutes)} billable × runner-tier rate, across all workflows in the window.`}
+ >
+ <span className="cursor-default text-tertiary">
+ {compactUsd(overview.estimated_cost_usd)} total CI spend
+ </span>
+ </Tooltip>
+ ) : undefined
+ }
+ >
+ <LemonCard hoverEffect={false} className="overflow-hidden p-0">
+ <WorkflowHealthTable
+ rows={shownWorkflows}
+ loading={workflowHealthLoading}
+ sourceId={sourceId}
+ showCost={jobsAvailable}
+ embedded
+ compact
+ pageSize={HUB_PREVIEW_MAX}
+ emptyState="No workflow runs in the window."
+ />
+ <div className="flex flex-wrap items-center justify-between gap-2 border-t border-primary px-4 py-2 text-[11px] text-tertiary">
+ <span>
+ Showing top {shownWorkflows.length} of {workflowHealth.length} workflows
+ </span>
+ <div className="flex items-center gap-3">
+ {canShowMoreWorkflows && (
+ <LemonButton size="xsmall" onClick={showMoreWorkflows}>
+ Show more
+ </LemonButton>
+ )}
+ <Link
+ to={
+ // A bare link would reset the shared window / branch / repo scope (the filters
+ // logic re-hydrates from the URL on every route) — carry it, plus the source.
+ withScope(urls.engineeringAnalyticsWorkflows(), searchParams, sourceId)
+ }
+ >
+ View all →
+ </Link>
+ </div>
+ </div>
+ </LemonCard>
+ </Section>
+ </div>
+ </div>
<Section
- id="workflows"
- title={jobsAvailable ? 'Top workflows by cost' : 'Busiest workflows'}
- right={
- jobsAvailable && overview?.estimated_cost_usd != null ? (
- <Tooltip
- title={`Estimated: ${compactMinutes(overview?.billable_minutes)} billable × runner-tier rate, across all workflows in the window.`}
- >
- <span className="cursor-default text-tertiary">
- {compactUsd(overview.estimated_cost_usd)} total CI spend
- </span>
- </Tooltip>
- ) : undefined
- }
+ id="prs"
+ title="Pull requests needing attention"
+ note="Current open backlog. Not affected by the date range."
>
<LemonCard hoverEffect={false} className="overflow-hidden p-0">
- <WorkflowHealthTable
- rows={shownWorkflows}
- loading={workflowHealthLoading}
+ <PullRequestTable
+ rows={shownPrs}
+ loading={pullRequestsLoading}
sourceId={sourceId}
- showCost={jobsAvailable}
embedded
- compact
pageSize={HUB_PREVIEW_MAX}
- emptyState="No workflow runs in the window."
+ emptyState="Nothing failing or stuck in the open backlog."
+ dataAttr="engineering-analytics-attention-prs"
/>
<div className="flex flex-wrap items-center justify-between gap-2 border-t border-primary px-4 py-2 text-[11px] text-tertiary">
<span>
- Showing top {shownWorkflows.length} of {workflowHealth.length} workflows
+ Showing {shownPrs.length} of {humanFriendlyNumber(attentionPrs.length)} needing attention
</span>
<div className="flex items-center gap-3">
- {canShowMoreWorkflows && (
- <LemonButton size="xsmall" onClick={showMoreWorkflows}>
+ {canShowMorePrs && (
+ <LemonButton size="xsmall" onClick={showMorePrs}>
Show more
</LemonButton>
)}
- <Link
- to={
- // A bare link would reset the shared window / branch / repo scope (the filters
- // logic re-hydrates from the URL on every route) — carry it, plus the source.
- withScope(urls.engineeringAnalyticsWorkflows(), searchParams, sourceId)
- }
- >
+ <Link to={withCurrentScope(urls.engineeringAnalyticsPullRequestList(), sourceId)}>
View all →
</Link>
</div>
diff --git a/products/engineering_analytics/frontend/scenes/repoOverviewLogic.ts b/products/engineering_analytics/frontend/scenes/repoOverviewLogic.ts
index 882789c4d083..d7e021b27258 100644
--- a/products/engineering_analytics/frontend/scenes/repoOverviewLogic.ts
+++ b/products/engineering_analytics/frontend/scenes/repoOverviewLogic.ts
@@ -9,7 +9,6 @@ import { engineeringAnalyticsRepoOverview, engineeringAnalyticsRepoRunActivity }
import type { RepoOverviewApi, WorkflowRunActivityApi } from '../generated/api.schemas'
import { ciStatusOf } from '../lib/ci'
import { HUB_PREVIEW_MAX, HUB_PREVIEW_ROWS, HUB_PREVIEW_STEP } from '../lib/preview'
-import { type TrendSeries, trendSeries } from '../lib/trends'
import { engineeringAnalyticsFiltersLogic } from './engineeringAnalyticsFiltersLogic'
import { PullRequestRow, STUCK_AFTER_DAYS, engineeringAnalyticsLogic, isStuck } from './engineeringAnalyticsLogic'
import type { WorkflowHealthRow } from './engineeringAnalyticsLogic'
@@ -39,22 +38,17 @@ export interface repoOverviewLogicValues {
activityTruncated: boolean
attentionPrs: PullRequestRow[]
costByWorkflow: CostShareRow[]
- costPerMergeSeries: TrendSeries | null
draftCount: number
jobsAvailable: boolean
- openToMergeSeries: TrendSeries | null
otherCostWorkflowCount: number
overview: RepoOverviewApi | null
overviewDefaultBranch: string
overviewFailed: boolean
overviewLoading: boolean
- passRateSeries: TrendSeries | null
prPreviewCount: number
- readyToMergeSeries: TrendSeries | null
repoActivity: WorkflowRunActivityApi
repoActivityFailed: boolean
repoActivityLoading: boolean
- timeToGreenSeries: TrendSeries | null
workflowPreviewCount: number
}
@@ -109,11 +103,6 @@ export interface repoOverviewLogicMeta {
draftCount: (pullRequests: PullRequestRow[]) => number
costByWorkflow: (workflowHealth: WorkflowHealthRow[]) => CostShareRow[]
otherCostWorkflowCount: (workflowHealth: WorkflowHealthRow[]) => number
- costPerMergeSeries: (overview: RepoOverviewApi | null) => TrendSeries | null
- timeToGreenSeries: (overview: RepoOverviewApi | null) => TrendSeries | null
- passRateSeries: (overview: RepoOverviewApi | null) => TrendSeries | null
- openToMergeSeries: (overview: RepoOverviewApi | null) => TrendSeries | null
- readyToMergeSeries: (overview: RepoOverviewApi | null) => TrendSeries | null
}
}
@@ -157,6 +146,9 @@ export const repoOverviewLogic = kea<repoOverviewLogicType>([
await engineeringAnalyticsRepoOverview(projectId(), {
date_from: values.dateFrom ?? undefined,
date_to: values.dateTo ?? undefined,
+ // The hub renders window-vs-previous comparisons from the headline
+ // aggregates; skipping the chart series skips their query cost too.
+ include_series: false,
source_id: values.sourceId ?? undefined,
repo: values.scopeRepo ?? undefined,
}),
@@ -288,58 +280,6 @@ export const repoOverviewLogic = kea<repoOverviewLogicType>([
workflowHealth.filter((row) => (row.estimatedCostUsd ?? 0) > 0).length - TOP_COST_WORKFLOWS
),
],
- // The Trends strip, one selector per card. Each hands `trendSeries` the bucket list and the
- // measure to read off a bucket; gap and baseline handling is the same for all of them and
- // lives there.
- // Cost per merged PR is a trailing rolling ratio, so a gap means the whole trailing window
- // shipped nothing; carried forward like the rest, never drawn as $0 of CI.
- costPerMergeSeries: [
- (s) => [s.overview],
- (overview: RepoOverviewApi | null): TrendSeries | null =>
- trendSeries(
- overview?.cost_series ?? [],
- (bucket) => bucket.cost_per_merge_usd,
- overview?.cost_series_granularity
- ),
- ],
- // In minutes, the unit the card's formatter labels.
- timeToGreenSeries: [
- (s) => [s.overview],
- (overview: RepoOverviewApi | null): TrendSeries | null =>
- trendSeries(
- overview?.time_to_green_series ?? [],
- (bucket) => (bucket.p50_seconds == null ? null : bucket.p50_seconds / 60),
- overview?.time_to_green_series_granularity
- ),
- ],
- passRateSeries: [
- (s) => [s.overview],
- (overview: RepoOverviewApi | null): TrendSeries | null =>
- trendSeries(
- overview?.success_rate_series ?? [],
- (bucket) => bucket.success_rate,
- overview?.success_rate_series_granularity
- ),
- ],
- openToMergeSeries: [
- (s) => [s.overview],
- (overview: RepoOverviewApi | null): TrendSeries | null =>
- trendSeries(
- overview?.open_to_merge_series ?? [],
- (bucket) => bucket.p50_seconds,
- overview?.open_to_merge_series_granularity
- ),
- ],
- // Null when the backend can't observe ready→merge, and the scene falls back to openToMergeSeries.
- readyToMergeSeries: [
- (s) => [s.overview],
- (overview: RepoOverviewApi | null): TrendSeries | null =>
- trendSeries(
- overview?.ready_to_merge_series ?? [],
- (bucket) => bucket.p50_seconds,
- overview?.ready_to_merge_series_granularity
- ),
- ],
}),
listeners(({ actions }) => ({