: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(engineering-analytics): dedicated GitHub-colored PR status column (#67103)
Raúl Negrón-Oterof56f39cc623d
diff --git a/products/engineering_analytics/frontend/components/PullRequestStateTag.tsx b/products/engineering_analytics/frontend/components/PullRequestStateTag.tsxnew file mode 100644index 000000000000..02a64b6aa080--- /dev/null+++ b/products/engineering_analytics/frontend/components/PullRequestStateTag.tsx@@ -0,0 +1,27 @@+import { IconPullRequest, IconXCircle } from '@posthog/icons'+import { LemonTag, LemonTagType } from '@posthog/lemon-ui'++import { PRState } from '../scenes/engineeringAnalyticsLogic'++// GitHub's state palette: open green, draft grey, merged purple, closed red. Draft is a lens over open+// PRs, so it gets its own entry though it isn't a PRState.+const STATE_CONFIG: Record<PRState | 'draft', { label: string; type: LemonTagType; icon: JSX.Element }> = {+ open: { label: 'Open', type: 'success', icon: <IconPullRequest /> },+ draft: { label: 'Draft', type: 'muted', icon: <IconPullRequest /> },+ merged: { label: 'Merged', type: 'completion', icon: <IconPullRequest /> },+ closed: { label: 'Closed', type: 'danger', icon: <IconXCircle /> },+}++export function PullRequestStateTag({ state, isDraft }: { state: PRState; isDraft: boolean }): JSX.Element {+ // Fall back to a muted tag of the raw value if the API ever sends a state outside the enum.+ const { label, type, icon } = STATE_CONFIG[state === 'open' && isDraft ? 'draft' : state] ?? {+ label: state,+ type: 'muted' as LemonTagType,+ icon: <IconPullRequest />,+ }+ return (+ <LemonTag type={type} icon={icon}>+ {label}+ </LemonTag>+ )+}diff --git a/products/engineering_analytics/frontend/components/PullRequestTable.tsx b/products/engineering_analytics/frontend/components/PullRequestTable.tsxindex e9075f14b853..4147949ca6ab 100644--- a/products/engineering_analytics/frontend/components/PullRequestTable.tsx+++ b/products/engineering_analytics/frontend/components/PullRequestTable.tsx@@ -1,7 +1,5 @@-// The PR list table, shared by the main PR list (Overview tab) and the author page (same list, scoped-// to one author). Both feed `PullRequestRow[]`; the columns, row → detail navigation, and cost lens are-// identical — only the author column (redundant on the author page) and the default sort differ, passed-// in by the caller.+// The PR list table, shared by the main PR list (Overview tab) and the author page (scoped to one+// author). Only the author column and default sort differ per caller.import { combineUrl, router } from 'kea-router'import { ReactNode } from 'react'@@ -18,6 +16,15 @@ import { githubPrUrl } from '../lib/github'import { PullRequestRow, prKeyOf } from '../scenes/engineeringAnalyticsLogic'import { BillableBadge } from './BillableBadge'import { CIStatusTag } from './CIStatusTag'+import { PullRequestStateTag } from './PullRequestStateTag'++/** The PR's detail page, carrying the active source so it opens scoped to the same one. */+function detailUrlOf(row: PullRequestRow, sourceId: string | null): string {+ return combineUrl(+ urls.engineeringAnalyticsPullRequest(row.repoOwner, row.repoName, row.number),+ sourceId ? { source: sourceId } : {}+ ).url+}export interface PullRequestTableProps {rows: PullRequestRow[]@@ -49,18 +56,21 @@ export function PullRequestTable({key: 'title',render: (_, row) => (<div className="flex flex-col gap-0.5">- <Link- to={githubPrUrl(row.repoOwner, row.repoName, row.number)}- target="_blank"- className="font-medium"- >- {row.title}- </Link>+ <div className="flex items-center gap-2">+ <PullRequestStateTag state={row.state} isDraft={row.isDraft} />+ <Link to={detailUrlOf(row, sourceId)} className="font-medium">+ {row.title}+ </Link>+ </div><div className="flex items-center gap-1.5 text-xs text-secondary">- <span className="font-mono">+ <Link+ to={githubPrUrl(row.repoOwner, row.repoName, row.number)}+ target="_blank"+ targetBlankIcon+ className="font-mono text-secondary"+ >{row.repoOwner}/{row.repoName} #{row.number}- </span>- {row.isDraft && <LemonTag type="muted">draft</LemonTag>}+ </Link>{row.labels.slice(0, 3).map((label) => (<LemonTag key={label} type="option">{label}@@ -181,13 +191,9 @@ export function PullRequestTable({loading={loading}defaultSorting={defaultSorting}onRow={(row) => {- // Carry the selected source so the PR's detail page reads the same one.- const detailUrl = combineUrl(- urls.engineeringAnalyticsPullRequest(row.repoOwner, row.repoName, row.number),- sourceId ? { source: sourceId } : {}- ).url+ const detailUrl = detailUrlOf(row, sourceId)return {- // Inner links (PR title → GitHub, author → author page) keep their own behavior.+ // Inner links (#id → GitHub, author → author page) keep their own behavior.onClick: (e: React.MouseEvent) => {if ((e.target as HTMLElement).closest('a, button')) {returndiff --git a/products/engineering_analytics/frontend/scenes/PullRequestDetailScene.tsx b/products/engineering_analytics/frontend/scenes/PullRequestDetailScene.tsxindex af9e8798ec3a..ca0652abd036 100644--- a/products/engineering_analytics/frontend/scenes/PullRequestDetailScene.tsx+++ b/products/engineering_analytics/frontend/scenes/PullRequestDetailScene.tsx@@ -3,15 +3,7 @@ import { combineUrl } from 'kea-router'import { Fragment, ReactNode } from 'react'import { IconExternal } from '@posthog/icons'-import {- LemonButton,- LemonInput,- LemonSkeleton,- LemonTableColumns,- LemonTag,- LemonTagType,- Link,-} from '@posthog/lemon-ui'+import { LemonButton, LemonInput, LemonSkeleton, LemonTableColumns, LemonTag, Link } from '@posthog/lemon-ui'import { TZLabel } from 'lib/components/TZLabel'import { dayjs } from 'lib/dayjs'@@ -25,6 +17,7 @@ import { urls } from 'scenes/urls'import { SceneContent } from '~/layout/scenes/components/SceneContent'import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'+import { PullRequestStateTag } from '../components/PullRequestStateTag'import { RunJobsTable, RunsTable, formatCost } from '../components/runTables'import { StatTile } from '../components/StatTile'import { WorkflowHealthTable } from '../components/WorkflowHealthTable'@@ -50,12 +43,6 @@ export const scene: SceneExport<PullRequestDetailLogicProps> = {}),}-const STATE_TAG: Record<string, { label: string; type: LemonTagType }> = {- open: { label: 'Open', type: 'primary' },- merged: { label: 'Merged', type: 'success' },- closed: { label: 'Closed', type: 'danger' },-}-function gapBetween(from: string, to: string): string {const seconds = dayjs(to).diff(dayjs(from), 'second')return seconds <= 0 ? '<1s' : humanFriendlyDuration(seconds, { maxUnits: 2 })@@ -89,21 +76,19 @@ function roundStart(group: PrCommitRuns): string | null {return starts.length ? starts.reduce((min, at) => (at < min ? at : min)) : group.latestStart}-// Fixed row heights so the dots and connectors line up across columns regardless of label/pill-// height — the previous free-flow layout drifted out of alignment and read as glitchy.+// Fixed row heights so dots and connectors line up across columns regardless of label/pill height.const ROW_LABEL = 'flex h-5 items-center'const ROW_DOT = 'flex h-3 items-center'const ROW_SUB = 'flex h-4 items-center'-// Cap how many push nodes the strip draws so it always fits on one line (no horizontal scroll, ever).-// Older pushes collapse into a single "+N earlier" node; every round stays reachable in the list below.+// Cap push nodes so the strip fits on one line; older pushes collapse into a "+N earlier" node, and+// every round stays reachable in the list below.const MAX_PUSH_NODES = 4/**- * Horizontal lifecycle timeline: dots are milestones, the pill above each connector is the gap- * between them — where the hours actually went. Chronological — a PR's head-SHA runs can start (and- * finish) after the merge. Each push (CI round) is its own node, red when that round had a failure;- * clicking it jumps to that round's run table below.+ * Horizontal lifecycle timeline: dots are milestones, the pill above each connector is the gap between+ * them. Chronological — a PR's head-SHA runs can start (and finish) after the merge. Each push is its own+ * node, red when that round had a failure; clicking it jumps to that round's run table below.*/function LifecycleStrip({ summary, openedAt, commitGroups }: LifecycleStripProps): JSX.Element {const nodes: TimelineNode[] = [@@ -115,9 +100,8 @@ function LifecycleStrip({ summary, openedAt, commitGroups }: LifecycleStripPropssublabel: <TZLabel time={openedAt} />,},]- // Only the most recent pushes get their own node; the rest collapse into one summary node so the- // strip never needs to scroll. commitGroups is newest-first. Don't collapse a single straggler —- // a "+1 earlier" node saves nothing, so only summarize when at least two would be hidden.+ // Only recent pushes get their own node; the rest collapse into one summary node so the strip never+ // scrolls. commitGroups is newest-first. Don't collapse a single straggler — "+1 earlier" saves nothing.const collapseOlder = commitGroups.length > MAX_PUSH_NODES + 1const shownRounds = collapseOlder ? commitGroups.slice(0, MAX_PUSH_NODES) : commitGroupsconst hiddenRounds = collapseOlder ? commitGroups.slice(MAX_PUSH_NODES) : []@@ -193,9 +177,8 @@ function LifecycleStrip({ summary, openedAt, commitGroups }: LifecycleStripPropsconst connector = (dashed: boolean | undefined): string =>dashed ? 'w-full border-t border-dashed border-border-bold' : 'h-px w-full bg-border-bold'- // Connector widths are proportional to real elapsed time, so the strip reads as a timeline —- // a long review wait visibly dominates a quick queue. Floor each segment so a near-instant gap- // still draws a visible connector instead of collapsing to nothing.+ // Connector widths are proportional to elapsed time, so the strip reads as a timeline. Floor each+ // segment so a near-instant gap still draws a visible connector instead of collapsing to nothing.const totalSeconds = Math.max(1, dayjs(nodes[nodes.length - 1].at).diff(dayjs(nodes[0].at), 'second'))const minGrow = totalSeconds * 0.04@@ -273,11 +256,9 @@ function LifecycleStrip({ summary, openedAt, commitGroups }: LifecycleStripProps}function MetaRow({ pullRequest, sourceId }: { pullRequest: PullRequestApi; sourceId: string | null }): JSX.Element {- const stateTag = STATE_TAG[pullRequest.state] ?? { label: pullRequest.state, type: 'muted' as LemonTagType }return (<div className="flex flex-wrap items-center gap-x-3 gap-y-1 text-sm">- <LemonTag type={stateTag.type}>{stateTag.label}</LemonTag>- {pullRequest.is_draft && <LemonTag type="muted">draft</LemonTag>}+ <PullRequestStateTag state={pullRequest.state} isDraft={pullRequest.is_draft} /><span className="flex items-center gap-1.5">{pullRequest.author.avatar_url && (<img src={pullRequest.author.avatar_url} alt="" className="h-5 w-5 shrink-0 rounded-full" />@@ -301,8 +282,8 @@ function MetaRow({ pullRequest, sourceId }: { pullRequest: PullRequestApi; sourc)}-// Stable per-row key — re-runs share a runId, so the start time disambiguates attempt rows. Used for-// both LemonTable's rowKey and the expand-state set, so expanding one attempt doesn't open the others.+// Stable per-row key — re-runs share a runId, so start time disambiguates attempts. Used for rowKey and+// the expand-state set, so expanding one attempt doesn't open the others.function runRowKey(run: WorkflowRun): string {return `${run.workflow}@${run.startedAt ?? run.finishedAt ?? run.runId ?? ''}`}@@ -317,8 +298,8 @@ const VERDICT_LEGEND: { key: 'passed' | 'failed' | 'running'; dot: string; label{ key: 'running', dot: 'bg-warning', label: 'running' },]-// Stroke straight from the same CSS vars the verdict dots / LemonTags use (bg-success = var(--success)),-// so the donut arc matches the legend dots beside it and the StatusDots in the run tables exactly.+// Stroke from the same CSS vars the verdict dots / LemonTags use, so the donut matches the legend dots+// and the run-table StatusDots exactly.const DONUT_STROKE: Record<'passed' | 'failed' | 'running', string> = {passed: 'var(--success)',failed: 'var(--danger)',@@ -389,16 +370,15 @@ interface PrSummaryCardsProps {commits: numbersummary: LifecycleSummary | nullopenedAt: string- // First load: the cards are fed by three loaders (lifecycle / runs / cost) that resolve at- // different times, so without this they'd pop in one at a time. Show a full skeleton row instead.+ // First load: three loaders (lifecycle / runs / cost) resolve at different times; without this the+ // cards pop in one at a time. Show a full skeleton row instead.loading: boolean}/**- * Headline stats for a PR's CI: a verdict donut over all commits, billable runner minutes + estimated- * cost (when the job-level source is synced), CI triggers, and how long the PR has been open. Cost is- * provider-neutral and explicitly an estimate — the chip spells out the model (wall-clock × reference- * rate) and unsettled jobs are called out as excluded.+ * Headline stats for a PR's CI: verdict donut over all commits, billable runner minutes + estimated cost+ * (when the job-level source is synced), CI triggers, and time open. Cost is an estimate — the chip spells+ * out the model (wall-clock × reference rate) and excludes unsettled jobs.*/function PrSummaryCards({cost,@@ -629,9 +609,9 @@ export function PullRequestDetailScene(): JSX.Element {commits={commitGroups.length}summary={summary}openedAt={summary?.openedAt ?? pullRequest?.created_at ?? ''}- // Skeleton the whole row until the structural data (lifecycle + runs) is in — covers the- // initial frame before afterMount fires too. The cost card then fills on its own once- // prCost resolves. The loadFailed branch returns earlier, so !lifecycle can't hang here.+ // Skeleton the whole row until lifecycle + runs are in (covers the frame before+ // afterMount fires). The cost card fills on its own once prCost resolves. loadFailed+ // returns earlier, so !lifecycle can't hang here.loading={!lifecycle || (prRunsLoading && runs.length === 0)}/></div>