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.

chore(engineering-analytics): trim verbose comments in scenes and lib (#67105)

Raúl Negrón-Otero24a048fcd148
diff --git a/products/engineering_analytics/frontend/lib/ci.ts b/products/engineering_analytics/frontend/lib/ci.ts
index b3e060d07d70..bed19ab944e5 100644
--- a/products/engineering_analytics/frontend/lib/ci.ts
+++ b/products/engineering_analytics/frontend/lib/ci.ts
@@ -1,8 +1,6 @@
-// Pure derivation of a PR's CI verdict from its workflow-run rollup. The rollup
-// is workflow-level (collapsed to the latest run per workflow on the PR's
-// head_sha) — NOT per-check. A run that has not completed is "running"
-// (unsettled), never a pass/fail verdict. Shared by the logic's selectors and
-// the CI badge so the two never drift.
+// Pure derivation of a PR's CI verdict from its workflow-run rollup (latest run per workflow on the PR's
+// head_sha, NOT per-check). An incomplete run is "running", never a pass/fail. Shared by the logic's
+// selectors and the CI badge so the two never drift.
export type CIStatus = 'passing' | 'failing' | 'running' | 'none'
diff --git a/products/engineering_analytics/frontend/lib/jobs.ts b/products/engineering_analytics/frontend/lib/jobs.ts
index 0d41ecef5016..7e993f7c1a52 100644
--- a/products/engineering_analytics/frontend/lib/jobs.ts
+++ b/products/engineering_analytics/frontend/lib/jobs.ts
@@ -1,5 +1,4 @@
-/** Cache key for a run's jobs — keyed by attempt so a re-run's attempts don't overwrite each other.
- * Shared by the logics that lazily load jobs and the RunsTable that reads the cache. */
+/** Cache key for a run's jobs, keyed by attempt so a re-run's attempts don't overwrite each other. */
export function jobCacheKey(runId: number, runAttempt: number | null): string {
return `${runId}:${runAttempt ?? 'latest'}`
}
diff --git a/products/engineering_analytics/frontend/lib/lifecycle.ts b/products/engineering_analytics/frontend/lib/lifecycle.ts
index e31193569999..82668f695066 100644
--- a/products/engineering_analytics/frontend/lib/lifecycle.ts
+++ b/products/engineering_analytics/frontend/lib/lifecycle.ts
@@ -1,6 +1,5 @@
-// Collapses a PR's raw lifecycle events (opened, ci_started, ci_finished, merged,
-// closed — one pair per workflow run, so dozens per PR) into the few facts the
-// drill-in panel renders: milestones plus a verdict rollup with failures called out.
+// Collapses a PR's raw lifecycle events (opened, ci_started, ci_finished, merged, closed — dozens per
+// PR) into the facts the drill-in panel renders: milestones plus a verdict rollup.
import type { PRLifecycleEventApi } from '../generated/api.schemas'
@@ -49,8 +48,8 @@ export function isDecisiveFailure(conclusion: string | null): boolean {
}
/**
- * ci_finished detail is "workflow name: conclusion" (the name itself may contain ": "), assembled
- * by backend/logic/queries/pr_lifecycle.py from structured fields the API then flattens.
+ * ci_finished detail is "workflow name: conclusion" (the name may contain ": "), flattened by the API
+ * from structured backend fields.
* TODO: expose workflow/conclusion as structured fields on PRLifecycleEventApi and delete this parse.
*/
function parseFinishedDetail(detail: string | null | undefined): { workflow: string; conclusion: string | null } {
@@ -65,9 +64,8 @@ function parseFinishedDetail(detail: string | null | undefined): { workflow: str
}
/**
- * Pairs ci_started / ci_finished events into per-workflow runs with durations.
- * Pairing is FIFO by workflow name (re-runs of the same workflow pair in order);
- * a finish without a matching start (events outside the window) still yields a row.
+ * Pairs ci_started / ci_finished events into per-workflow runs with durations, FIFO by workflow name.
+ * A finish without a matching start (events outside the window) still yields a row.
*/
export function workflowRuns(events: PRLifecycleEventApi[]): WorkflowRun[] {
const runs: WorkflowRun[] = []
diff --git a/products/engineering_analytics/frontend/lib/runHealth.ts b/products/engineering_analytics/frontend/lib/runHealth.ts
index 78bb051b4858..b24d87422e86 100644
--- a/products/engineering_analytics/frontend/lib/runHealth.ts
+++ b/products/engineering_analytics/frontend/lib/runHealth.ts
@@ -1,6 +1,5 @@
-// Rolls a flat list of one workflow's runs up into the health facts the verdict header renders. Kept
-// separate from the kea logic so both the workflow-runs page and (later) the PR page can derive the same
-// summary, and so the math is unit-testable without a logic harness.
+// Rolls a flat list of one workflow's runs into the health facts the verdict header renders. Separate
+// from the kea logic so both pages can share it and the math is unit-testable.
import { isDecisiveFailure } from './lifecycle'
@@ -91,10 +90,9 @@ export function percentileSorted(sortedAsc: number[], q: number): number | null
}
/**
- * Verdict + headline stats for one workflow's runs. State mirrors the run tables: the latest settled run
- * failing is "failing"; an otherwise-passing workflow whose decisive-failure rate is elevated is
- * "degraded"; everything else is "healthy". Durations and rates are over completed runs only — a run that
- * hasn't settled is excluded, never counted as a failure.
+ * Verdict + headline stats for one workflow's runs. State: latest settled run failing → "failing";
+ * elevated decisive-failure rate → "degraded"; else "healthy". Durations and rates are over completed
+ * runs only — an unsettled run is excluded, never counted as a failure.
*/
export function computeHealthSummary(runs: HealthRun[]): HealthSummary {
const completed = runs.filter((run) => run.conclusion !== null)
@@ -149,17 +147,16 @@ export function computeHealthSummary(runs: HealthRun[]): HealthSummary {
}
/**
- * Fleet verdict + rollups across all workflows in the window (the all-workflows page). State is the
- * worst the fleet is right now: every settled workflow red is "failing"; any red or flaky is "degraded";
- * otherwise "healthy". Runs and cost are summed across workflows; cost is null until any row carries it.
+ * Fleet verdict + rollups across all workflows in the window. State is the worst the fleet is now: every
+ * settled workflow red → "failing"; any red or flaky → "degraded"; else "healthy". Runs and cost are
+ * summed across workflows; cost is null until a row carries it.
*/
export function computeFleetSummary(rows: FleetRow[]): FleetSummary {
const workflowCount = rows.length
const settledWorkflows = rows.filter((row) => row.latestRunFailed != null).length
const failingNow = rows.filter((row) => row.latestRunFailed === true).length
- // Flaky = currently green but below the success-rate floor AND it has actually failed in the window.
- // The `lastFailureAt` gate keeps this aligned with the single-workflow verdict: a low success rate that
- // comes from skips/cancels (no decisive failures) reads as healthy, not flaky.
+ // Flaky = currently green, below the success-rate floor, AND actually failed in the window. The
+ // lastFailureAt gate keeps a low success rate from skips/cancels (no real failures) reading as flaky.
const flakyNow = rows.filter(
(row) =>
row.latestRunFailed === false &&
@@ -178,8 +175,7 @@ export function computeFleetSummary(rows: FleetRow[]): FleetSummary {
let state: WorkflowState
if (workflowCount === 0 || settledWorkflows === 0) {
- // Workflows exist but none has a completed run yet — no evidence either way, same as the
- // single-workflow "unknown".
+ // Workflows exist but none settled yet — no evidence either way, same as single-workflow "unknown".
state = 'unknown'
} else if (failingNow > 0 && failingNow === settledWorkflows) {
state = 'failing'
diff --git a/products/engineering_analytics/frontend/lib/runStatus.ts b/products/engineering_analytics/frontend/lib/runStatus.ts
index 05e42344095e..630515c9bca2 100644
--- a/products/engineering_analytics/frontend/lib/runStatus.ts
+++ b/products/engineering_analytics/frontend/lib/runStatus.ts
@@ -5,9 +5,8 @@ import { capitalizeFirstLetter } from 'lib/utils/strings'
import { isPassingConclusion } from './lifecycle'
/**
- * A workflow run's conclusion as a labeled tag. `null` conclusion means the run is still in progress.
- * Decisive failures (failure / timed_out) are danger; success is green; other passing outcomes
- * (skipped / neutral / cancelled) are muted; anything else (e.g. action_required) is a warning.
+ * A workflow run's conclusion as a labeled tag. `null` = still in progress. Decisive failures
+ * (failure / timed_out) are danger; success green; other passing outcomes muted; else warning.
*/
export function verdictTag(conclusion: string | null): { label: string; type: LemonTagType } {
if (conclusion === null) {
diff --git a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsPullRequests.tsx b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsPullRequests.tsx
index d01f70d2c7bf..c090de07086b 100644
--- a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsPullRequests.tsx
+++ b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsPullRequests.tsx
@@ -51,9 +51,8 @@ export function EngineeringAnalyticsPullRequests(): JSX.Element {
refresh,
} = useActions(engineeringAnalyticsLogic)
- // A 400 means no GitHub source is connected — prompt to connect. A non-400 failure of this
- // scene's data (cards or the PR list) is shown as a generic, retryable error, never the
- // misleading "connect" state, and never because an endpoint this scene doesn't render failed.
+ // A 400 means no GitHub source — prompt to connect. A non-400 failure of this scene's data (cards or
+ // the PR list) shows a retryable error, never the misleading "connect" state.
if (notConnected) {
return <ConnectGitHubSource />
}
diff --git a/products/engineering_analytics/frontend/scenes/WorkflowRunsScene.tsx b/products/engineering_analytics/frontend/scenes/WorkflowRunsScene.tsx
index c6565fe91a01..bb9ce21848fa 100644
--- a/products/engineering_analytics/frontend/scenes/WorkflowRunsScene.tsx
+++ b/products/engineering_analytics/frontend/scenes/WorkflowRunsScene.tsx
@@ -48,8 +48,8 @@ function RunnerCostTable({ costs }: { costs: WorkflowRunnerCostApi[] }): JSX.Ele
render: (_, cost) => <BillableBadge minutes={cost.billable_minutes} costUsd={cost.estimated_cost_usd} />,
},
]
- // Where the money goes — one stacked bar over the table, a segment per tier sized by its $ share.
- // Free (GitHub-hosted) runners are $0, so they don't take a slice; the bar reads as "billable spend".
+ // One stacked bar over the table, a segment per tier sized by its $ share. Free (GitHub-hosted)
+ // runners are $0, so they don't take a slice; the bar reads as "billable spend".
const costSegments = costs.map((cost, i) => ({
key: `${cost.provider}:${cost.runner_label}`,
label: cost.runner_label || cost.provider,
@@ -76,8 +76,8 @@ function RunnerCostTable({ costs }: { costs: WorkflowRunnerCostApi[] }): JSX.Ele
)
}
-// The window floors finished runs (the endpoint requires a date_from), so "all time" is out; relative
-// windows + Custom only. Covers a CI-health "right now" (24h) through a monthly-ish spend window.
+// The endpoint requires a date_from (floors finished runs), so "all time" is out — relative windows +
+// Custom only, from a 24h "right now" view through a monthly-ish spend window.
const WORKFLOW_DATE_OPTIONS = dateMapping.filter(({ key }) =>
[
'Custom',
diff --git a/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.ts b/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.ts
index e53a65cc5496..8a6b213b7a6e 100644
--- a/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.ts
+++ b/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.ts
@@ -28,15 +28,13 @@ import { type FleetSummary, computeFleetSummary } from '../lib/runHealth'
import { engineeringAnalyticsFiltersLogic } from './engineeringAnalyticsFiltersLogic'
import type { engineeringAnalyticsLogicType } from './engineeringAnalyticsLogicType'
-// Safety bound on the PR table (mirrors the endpoint's server-side limit). Surfaced
-// in copy when hit so a truncated list is never mistaken for the whole picture.
+// Mirrors the endpoint's server-side limit; surfaced in copy when hit so a truncated list reads as truncated.
export const PR_TABLE_LIMIT = 1000
-// The workflow-health endpoint returns the top workflows by run count (`workflow_health.py` `_LIMIT`).
-// When hit, the fleet header labels its totals as "top N" so they're never read as the whole fleet.
+// Top workflows by run count (`workflow_health.py` `_LIMIT`); when hit, the header labels totals "top N".
export const WORKFLOW_HEALTH_LIMIT = 100
-// The endpoints are project-scoped; the generated client takes the id as a string.
+// Project-scoped endpoints; the generated client takes the id as a string.
const projectId = (): string => String(ApiConfig.getCurrentProjectId())
export type PRState = 'open' | 'closed' | 'merged'
@@ -70,7 +68,7 @@ export interface PullRequestRow {
pending: number
/** CI triggers in the PR's window: distinct head SHAs across its workflow runs. Fork PRs unattributed. */
pushes: number
- /** Workflow runs attributed to this PR that were a 2nd+ attempt (a re-run). */
+ /** Workflow runs attributed to this PR that were a 2nd+ attempt. */
rerunCycles: number
/** Estimated CI cost (USD) over the PR's jobs (billable runners). Null when no cost / source unsynced. */
estimatedCostUsd: number | null
@@ -97,8 +95,8 @@ export interface WorkflowHealthBucket {
successes: number
/** Decisive failures only (failure / timed_out); excludes skipped, cancelled, action_required. */
failures: number
- /** Pre-formatted sparkline label; when set, used verbatim instead of formatting bucketStart by time
- * (push buckets aren't time-aligned, so they carry their own "Push N (sha)" label). */
+ /** Pre-formatted sparkline label; used verbatim when set — push buckets aren't time-aligned, so they
+ * carry their own "Push N (sha)" label. */
label?: string
}
@@ -149,9 +147,8 @@ function formatBucket(bucketStart: string, granularity: WorkflowGranularity): st
}
/**
- * Series for the run-status sparkline. Each bar is stacked: total height is completed runs (volume)
- * and the red portion is decisive failures, so the red *fraction* reads as the failure rate — 1% is a
- * sliver, 50% is half-red — which length encodes accurately (unlike shade). Skipped, cancelled, and
+ * Run-status sparkline series. Each bar is stacked: total height is completed runs (volume), the red
+ * portion is decisive failures, so the red fraction reads as the failure rate. Skipped, cancelled, and
* action_required runs are not failures.
*/
export function workflowFailureSeries(
@@ -190,9 +187,8 @@ export function prKeyOf(row: Pick<PullRequestRow, 'repoOwner' | 'repoName' | 'nu
return `${row.repoOwner}/${row.repoName}#${row.number}`
}
-/** Map an API PR list item to the table row shape — shared by the PR list and the author page so both
- * feed the same PullRequestTable. ?? fallbacks degrade gracefully when a new frontend briefly hits an
- * older backend whose response predates the cost/push fields. */
+/** Map an API PR list item to the table row — shared by the PR list and author page. ?? fallbacks degrade
+ * gracefully when a new frontend hits an older backend predating the cost/push fields. */
export function toPullRequestRow(it: PullRequestListItemApi): PullRequestRow {
return {
number: it.number,
@@ -469,11 +465,10 @@ export function quarantineRequestErrorMessage(error: unknown): string {
}
/**
- * Per-loader outcome. The endpoints all resolve the same GitHub source, so a 400
- * (GitHubSourceNotConnectedError) means "connect a source" for every scene; any other
- * failure is a genuine error scoped to the loader that hit it. Tracked per loader so a
- * 500 on one endpoint drives only the scenes that read it — not, say, an error banner on
- * the PR list because workflow health failed.
+ * Per-loader outcome. All endpoints resolve the same GitHub source, so a 400
+ * (GitHubSourceNotConnectedError) means "connect a source" for every scene; any other failure is a
+ * genuine error scoped to the loader that hit it, so a 500 on one endpoint doesn't error a scene that
+ * doesn't read it.
*/
export type LoaderStatus = 'ok' | 'notConnected' | 'error'
@@ -561,21 +556,18 @@ export const engineeringAnalyticsLogic: LogicWrapper<engineeringAnalyticsLogicTy
p50Seconds: it.p50_seconds,
p95Seconds: it.p95_seconds,
lastFailureAt: it.last_failure_at,
- // Defensive ?? null: a new frontend can briefly hit an older backend
- // whose response predates this field — degrade to "unknown", not crash.
+ // ?? fallbacks: a new frontend can briefly hit an older backend predating
+ // these fields — degrade, don't crash.
latestRunFailed: it.latest_run_failed ?? null,
latestRunConclusion: it.latest_run_conclusion ?? null,
- // Defensive ?? 'day': older backends predate adaptive bucketing.
+ // ?? 'day': older backends predate adaptive bucketing.
granularity: (it.granularity ?? 'day') as WorkflowGranularity,
- // ?? []: a new frontend can briefly hit an older backend whose response
- // predates the buckets field during a rolling deploy — degrade, don't crash.
buckets: (it.buckets ?? []).map((b) => ({
bucketStart: b.bucket_start,
runCount: b.run_count,
completed: b.completed,
successes: b.successes,
- // Defensive ?? 0: a new frontend can briefly hit an older backend whose
- // response predates this field — degrade to 0, don't compute NaN bars.
+ // ?? 0: don't compute NaN bars when the field is absent.
failures: b.failures ?? 0,
})),
billableMinutes: it.billable_minutes ?? null,
@@ -668,13 +660,11 @@ export const engineeringAnalyticsLogic: LogicWrapper<engineeringAnalyticsLogicTy
resetFilters: () => DEFAULT_FILTERS.stuckOnly,
},
],
- // Which connected GitHub source to read; null = the backend default (oldest connected).
- // URL-synced via `source` so it survives tab switches and deep-links into a PR's detail.
+ // Which GitHub source to read; null = backend default (oldest connected). URL-synced via
+ // `?source=` so it survives tab switches and deep-links into a PR's detail.
sourceId: [null as string | null, { setSourceId: (_, { sourceId }) => sourceId }],
- // Per-loader status. Each endpoint resolves the same GitHub source, so any one 400 means
- // "not connected" for every scene; a non-400 failure is a per-loader error. Tracked
- // separately (rather than off cards alone) so notConnected and the scene error states can
- // each react to the loaders that actually feed them — see the selectors below.
+ // Per-loader status, tracked separately (not off cards alone) so notConnected and the per-scene
+ // error states each react only to the loaders that feed them — see the selectors below.
cardsStatus: [
'ok' as LoaderStatus,
{
@@ -711,8 +701,8 @@ export const engineeringAnalyticsLogic: LogicWrapper<engineeringAnalyticsLogicTy
resetQuarantineFilters: () => DEFAULT_QUARANTINE_FILTERS.owner,
},
],
- // The quarantine endpoint only 400s when there is no GitHub source AND no local
- // checkout (production without a source); a failed load is that canary.
+ // The quarantine endpoint only 400s when there's no GitHub source AND no local checkout
+ // (prod without a source); a failed load is that signal.
quarantineLoadFailed: [
false,
{
@@ -747,8 +737,7 @@ export const engineeringAnalyticsLogic: LogicWrapper<engineeringAnalyticsLogicTy
loadWorkflowHealthFailure: (_, { errorObject }) => loaderStatusFromError(errorObject),
},
],
- // Cost & performance lens: surfaces per-PR pushes / re-runs / estimated cost. Transient
- // (no persisted/stateful UI in this phase, per SPEC).
+ // Cost & performance lens: surfaces per-PR pushes / re-runs / estimated cost. Transient (not persisted).
costLensEnabled: [true, { setCostLensEnabled: (_, { enabled }) => enabled }],
}),
@@ -758,8 +747,7 @@ export const engineeringAnalyticsLogic: LogicWrapper<engineeringAnalyticsLogicTy
(s) => [s.workflowHealth],
(workflowHealth): FleetSummary => computeFleetSummary(workflowHealth),
],
- // The endpoint caps at the top workflows by run count; when hit, the header's totals cover only
- // those, so it labels them as "top N" rather than fleet-wide.
+ // Endpoint caps at top workflows by run count; when hit, the header labels totals "top N", not fleet-wide.
fleetTruncated: [
(s) => [s.workflowHealth],
(workflowHealth): boolean => workflowHealth.length >= WORKFLOW_HEALTH_LIMIT,
@@ -813,23 +801,23 @@ export const engineeringAnalyticsLogic: LogicWrapper<engineeringAnalyticsLogicTy
(cardsLoading, pullRequestsLoading, workflowHealthLoading, quarantineLoading): boolean =>
cardsLoading || pullRequestsLoading || workflowHealthLoading || quarantineLoading,
],
- // No GitHub source connected: a 400 from any endpoint (they share source resolution).
- // Drives the "connect a source" state on every scene, regardless of which loaders it renders.
+ // No GitHub source: a 400 from any endpoint (shared source resolution). Drives the "connect a
+ // source" state on every scene, regardless of which loaders it renders.
notConnected: [
(s) => [s.cardsStatus, s.pullRequestsStatus, s.workflowHealthStatus],
(cardsStatus, pullRequestsStatus, workflowHealthStatus): boolean =>
[cardsStatus, pullRequestsStatus, workflowHealthStatus].includes('notConnected'),
],
- // Genuine (non-400) failure of a loader the PR scene renders (cards + the PR list). A 500
- // here shows the retryable error; a failure of only workflow health does not, so the PR
- // list isn't hidden behind an error it doesn't depend on.
+ // Non-400 failure of a loader the PR scene renders (cards + PR list) → retryable error. A
+ // workflow-health-only failure doesn't, so the PR list isn't hidden behind an error it
+ // doesn't depend on.
pullRequestsLoadError: [
(s) => [s.cardsStatus, s.pullRequestsStatus],
(cardsStatus, pullRequestsStatus): boolean => cardsStatus === 'error' || pullRequestsStatus === 'error',
],
- // Genuine (non-400) failure of the only loader the Workflows scene renders. Decoupled from
- // cards so workflow health failing surfaces an error there (not a misleading empty table),
- // and a cards-only failure doesn't error a scene whose own data loaded fine.
+ // Non-400 failure of the only loader the Workflows scene renders. Decoupled from cards so its
+ // own failure shows an error (not a misleading empty table), and a cards-only failure doesn't
+ // error a scene whose data loaded fine.
workflowHealthLoadError: [
(s) => [s.workflowHealthStatus],
(workflowHealthStatus): boolean => workflowHealthStatus === 'error',
@@ -892,7 +880,7 @@ export const engineeringAnalyticsLogic: LogicWrapper<engineeringAnalyticsLogicTy
actions.loadWorkflowHealth()
actions.loadQuarantine()
},
- // Cards, the PR list, workflow health, and the quarantine repo are all per-source — reload them all.
+ // Cards, PR list, workflow health, and quarantine are all per-source — reload them all.
setSourceId: () => actions.refresh(),
// The shared window and branch scope workflow health; reload it when either changes.
[engineeringAnalyticsFiltersLogic.actionTypes.setDateRange]: () => {