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.

fix(eng-analytics): show load errors on detail pages (#103924)

Raúl Negrón-Oterob69e908be199
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index c7b9934ba6b9..00ac8e84f82f 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -7937,13 +7937,17 @@ snapshots:
scenes-app-engineering-analytics-lead-time-box-plot--horizontal-log-scale--light:
hash: v1.k794b7964.bc3a9455717626ef2f9541e03740bd0027c89139cd54ba4eb57a883d0e222667.OlAdmRvrHHSpGH8a2jHqV60Z957X8hIrNlcY9Duvv9A
scenes-app-engineering-analytics-pull-request--merged--dark:
- hash: v1.k794b7964.dbb2f22e3a1ec8dce071c7900199afec5c337766c3aeb2535d9848e6971596e3.GPFOe8jqc-PMF5uYBemiRSF20PT9l4S_79RtlxbKeVc
+ hash: v1.k794b7964.acc240273e3c622972e1653ba4f16f6040e76979ea082d6f66a0fa2f89ae29bc.zZBjgKQts14dqKAy3Yhh8MU3Y8lFcIiJ7QkYDoFDkzo
scenes-app-engineering-analytics-pull-request--merged--light:
- hash: v1.k794b7964.3e0b817b32bfc1caed0ae893b36b9222a0143c492c64dc32c56204d159a5b5b9.rzKobY8gpb_2i9jJU3w3pyvtcatmW8FF75bxFsRNzvQ
+ hash: v1.k794b7964.c925dfc7c1a140b4ac6bb86e227e730c5922402d9869b39721e2e3be3adb090f.ZzSuEdrpXj0QvyUsVJsZAgP5Oy3fgpSkPWdak_ppSSg
scenes-app-engineering-analytics-pull-request--out-of-the-merge-queue--dark:
- hash: v1.k794b7964.bef18c2700ce93e8a28cb7a4871af8feeab4ff4f3e4784c4a1d064a74d242496.zZ_wftKLSMvrUpOczRzk8zoq3Q9-phnA_6862tU0PWw
+ hash: v1.k794b7964.35ee45735fdf0dcb12e2d67cb5b9b9cd1aaba455ce97738daf2dd916466c9e0b.uv8aAw7tKaVObN2jrVxLo2UK30qPTiqoRFVJ4P6pm24
scenes-app-engineering-analytics-pull-request--out-of-the-merge-queue--light:
- hash: v1.k794b7964.9822550d77266ce69ecde7738f580a3d18c6537ce386f1f57d42ce5119038b1f.vxcYv5zCHX2lBZem4rKymrSVk7QLCZ7pQ3673cMsV6U
+ hash: v1.k794b7964.07c8c7ca126fa2f0440103062315898d3bf6e34025e2f70ca6c912f9ceb0f4ad.6OoSv6aB1RglnwxoetlMdIC7cUkatAQB1qLExL5aK0A
+ scenes-app-engineering-analytics-pull-request--section-load-errors--dark:
+ hash: v1.k794b7964.76de14a4ffa422e5a5ea57a8f0453aa2047e8ac8f62d3bd2b2bbab71ed6034db.EYERMxdXe3SOe9gdm9yVBgfY7xXbZ_owZNWZ1LWtpQ0
+ scenes-app-engineering-analytics-pull-request--section-load-errors--light:
+ hash: v1.k794b7964.121cb409bd657c5e22b632034121b25d2b785dd5499955ebc59cd0271f4db7b6.ImnAMo179ievhgIRtD_9DG4DurcdVNczCHigsbbEVGo
scenes-app-engineering-analytics-repo-overview--repo-overview--dark:
hash: v1.k794b7964.1a470083e7a94ff46652f4368277eae5d35c927d65b58685e43ce34881e1e728.SEm3E8XvqrTHtJNRhVGX-9aaaw6xdWyzTNb_mw6c380
scenes-app-engineering-analytics-repo-overview--repo-overview--light:
@@ -7977,13 +7981,25 @@ snapshots:
scenes-app-engineering-analytics-test-health--trunk-quarantine-debt-owners-unavailable--light:
hash: v1.k794b7964.8916de545edf558f799cc98ee4a901c19ba00fe7d0bb4f5312266705755e3e70.EO6V5mC_JCbSh5ZRrmyU09RT-hFV9f4Mtu_JkZ9m5Ng
scenes-app-engineering-analytics-workflow--workflow-detail--dark:
- hash: v1.k794b7964.6006fb352b7c6b99693920a87332ff4fe2538a212272220a5904b467d4077847.3WqPziRcgrLwnPk4QJJhhb5htu3lvDlFw6oPTSTH9EA
+ hash: v1.k794b7964.22bf886859816ee11d232317ca59554e06fd9708011d78d00ea8f071dd3d7c9a.UyFkQYvasBL9ER7I1qlztCTuqpP7FZ6FtlaauK-77Uc
scenes-app-engineering-analytics-workflow--workflow-detail--light:
- hash: v1.k794b7964.448cbb34351e454b1c757276f0a1cd4adbbf75cd49ce5b5b4798b7337adb17f6.2NNp6tvvHqHZ0OAshF5F_V_ZRoi05nMkTKvNrmI_GIE
+ hash: v1.k794b7964.090828c0b039102802079fb8f9ac6b9b968ccf23bf67ecdd09fbdc8ac8863eaf.GUwG8v-K4ZtwwRbfwtalN_wzkGYNN5C7qCd9jsa-SzQ
scenes-app-engineering-analytics-workflow--workflow-detail-scoped-to-pull-requests--dark:
- hash: v1.k794b7964.4e8fd2714f511643ded70d2b2e9ea1f9a5e2576bcedd977c09fb16a994f1e5a6.TH6pCFrAcllciQRZ8vBRkuO9w4rqkrHm5kitFbI1958
+ hash: v1.k794b7964.f9af7dfa88306ebff94da2e8f4bfc5c9f97ac7a80120c86e5658b48d238369ee.L2oQBtMNTOfq-qHUpqPflbws_HUvay6oIx1GaF8YJD4
scenes-app-engineering-analytics-workflow--workflow-detail-scoped-to-pull-requests--light:
- hash: v1.k794b7964.4ee4fad21f2516698c0191d14e0a5b5bd2df7078c01a6a27ec48bdb795b5ffd0.ILk7MWSpAnYT629N-B4L2Cuke3QOTRobPp52cZMt12w
+ hash: v1.k794b7964.57df8858f99e0ca154f05d7d6cfc07fabd811863825f45668c306bb4d24bb6f5.O5MORnJ71031Dz5qFaaas50e6V9SG1oKoPvvwOfVNBw
+ scenes-app-engineering-analytics-workflow--workflow-detail-section-load-errors--dark:
+ hash: v1.k794b7964.6c8d54637d7ea1593573c4fe61da7d2bd5beabf4f64ef874f5f02b57af707cb7.svL4STO-Lw-ehnOdqGsnVBKrEEIHeMVPDdPPQGIqRmA
+ scenes-app-engineering-analytics-workflow--workflow-detail-section-load-errors--light:
+ hash: v1.k794b7964.f545b566e1bc0fc20f142a01be178fd34b5ff0ff8b5d3860369a780485d5a6b2.bcPmmTjQS5QNi-QGg0EsEoQ763V8mr9exW1wZSoJbSs
+ scenes-app-engineering-analytics-workflow-run--failed-run--dark:
+ hash: v1.k794b7964.a00911d6c52b4049f604b641659b6fdcfbda71c715e1bbcb937eb2e5d8f7af25.Cn8V_cwoSpfwEXevukgCHuTVDB8Fpcid4fxJ2GZI7kc
+ scenes-app-engineering-analytics-workflow-run--failed-run--light:
+ hash: v1.k794b7964.67de5687f7a25b3a2ecd710aaa119d73d9187fa1eb08ef3ac124aeb033c1a648.pJQTg4VwETVX5q6D8e85bipscOSKpq8syvXnIdPK1sc
+ scenes-app-engineering-analytics-workflow-run--jobs-and-logs-load-errors--dark:
+ hash: v1.k794b7964.5511ee7856a856085ceb33bc00887b8db15923dd81a89647f8c3560ad1368e5f.Hu8V3ge_4aXm6BKNHrndiSyU-m5NsRHojTeUAASOvFU
+ scenes-app-engineering-analytics-workflow-run--jobs-and-logs-load-errors--light:
+ hash: v1.k794b7964.8d6bf7c0f4238aa5be869b4182bf75ca1c1acecadcb6091318286f4513b2f8d0.nT4uFXeozIsR2wryuF0Wzmdg5A2Lus5xSA5npxN7cqE
scenes-app-engineering-analytics-workflows--workflow-list--dark:
hash: v1.k794b7964.a6574f63289438debc52ecec13b02dbe441bc929a8d6f710da3186331cd8d1eb.KpORwpMNnIj4CILhscu52yveUkN_65SPEzYkBUAaumU
scenes-app-engineering-analytics-workflows--workflow-list--light:
diff --git a/products/engineering_analytics/frontend/components/CIAnalyticsLoadError.tsx b/products/engineering_analytics/frontend/components/CIAnalyticsLoadError.tsx
index 0cefe93c8180..6b580a810938 100644
--- a/products/engineering_analytics/frontend/components/CIAnalyticsLoadError.tsx
+++ b/products/engineering_analytics/frontend/components/CIAnalyticsLoadError.tsx
@@ -2,16 +2,30 @@ import { LemonButton } from '@posthog/lemon-ui'
/**
* Retryable error state for the engineering analytics scenes. Unlike ConnectGitHubSource, shown when a
- * source is connected but its data endpoints failed — so a connected team isn't wrongly told to connect one.
+ * source is connected but its data endpoints failed, so a connected team isn't wrongly told to connect one.
*/
-export function CIAnalyticsLoadError({ onRetry }: { onRetry: () => void }): JSX.Element {
+export function CIAnalyticsLoadError({
+ onRetry,
+ loading = false,
+ title = "Couldn't load engineering analytics",
+ description = "A GitHub source is connected, but loading its data failed. Retry, or check the source's sync status.",
+}: {
+ onRetry: () => void
+ loading?: boolean
+ title?: string
+ description?: string
+}): JSX.Element {
return (
- <div className="flex flex-col items-center gap-2 py-12 text-center">
- <span className="font-medium text-danger">Couldn't load engineering analytics</span>
- <span className="max-w-md text-sm text-secondary">
- A GitHub source is connected, but loading its data failed. Retry, or check the source's sync status.
- </span>
- <LemonButton type="primary" size="small" onClick={onRetry}>
+ <div className="flex flex-col items-center gap-2 py-8 text-center">
+ <span className="font-medium text-danger">{title}</span>
+ <span className="max-w-md text-sm text-secondary">{description}</span>
+ <LemonButton
+ type="primary"
+ size="small"
+ onClick={onRetry}
+ loading={loading}
+ disabledReason={loading ? 'Retrying' : undefined}
+ >
Retry
</LemonButton>
</div>
diff --git a/products/engineering_analytics/frontend/components/FailureLogs.tsx b/products/engineering_analytics/frontend/components/FailureLogs.tsx
index 5af4586db284..9834e2782ea4 100644
--- a/products/engineering_analytics/frontend/components/FailureLogs.tsx
+++ b/products/engineering_analytics/frontend/components/FailureLogs.tsx
@@ -1,18 +1,19 @@
// CI failure log excerpts grouped by failed job. Lines come pre-thinned from the backend; omission
// markers (original_line == null) render muted so the elision is visible, never silent.
-import { LemonTag } from '@posthog/lemon-ui'
+import { LemonSkeleton, LemonTag } from '@posthog/lemon-ui'
import { cn } from 'lib/utils/css-classes'
import type { CIJobFailureLogApi } from '../generated/api.schemas'
+import { CIAnalyticsLoadError } from './CIAnalyticsLoadError'
function JobFailureLog({ job, jobName }: { job: CIJobFailureLogApi; jobName?: string }): JSX.Element {
return (
<div className="overflow-hidden rounded border border-primary bg-surface-primary">
<div className="flex items-center gap-2 border-b border-primary px-3 py-2 text-xs font-semibold">
<LemonTag type="danger" size="small">
- {job.conclusion === 'timed_out' ? 'TIMED OUT' : 'FAILED'}
+ {job.conclusion === 'timed_out' ? 'Timed out' : 'Failed'}
</LemonTag>
<span className="truncate font-mono">{jobName ?? `job ${job.job_id}`}</span>
{job.branch && <span className="font-mono font-normal text-tertiary">· {job.branch}</span>}
@@ -52,26 +53,30 @@ function JobFailureLog({ job, jobName }: { job: CIJobFailureLogApi; jobName?: st
export function FailureLogGroups({
logs,
loading,
+ onRetry,
jobNames,
+ errorDescription = 'Retry, or open the run on GitHub to read its logs.',
+ emptyText = 'No failure logs. Nothing failed, or the logs have aged out of retention.',
}: {
logs: { jobs: CIJobFailureLogApi[]; logs_available: boolean } | 'unavailable' | null | undefined
loading: boolean
- /** job_id → display name, when the caller has the run's jobs loaded — logs only carry ids. */
+ onRetry: () => void
+ /** job_id → display name, when the caller has the run's jobs loaded, because logs only carry ids. */
jobNames?: Record<number, string>
+ errorDescription?: string
+ emptyText?: string
}): JSX.Element {
- if (logs === 'unavailable') {
- return <div className="px-1 py-2 text-xs text-secondary">Failure logs are unavailable.</div>
- }
- if (logs == null) {
- return <div className="px-1 py-2 text-xs text-secondary">{loading ? 'Loading failure logs…' : '—'}</div>
+ if (loading) {
+ return <LemonSkeleton className="h-24 w-full" />
}
- if (!logs.logs_available || logs.jobs.length === 0) {
+ if (logs === 'unavailable') {
return (
- <div className="px-1 py-2 text-xs text-secondary">
- No failure logs. Nothing failed, or the logs have aged out of retention.
- </div>
+ <CIAnalyticsLoadError title="Couldn't load failure logs" description={errorDescription} onRetry={onRetry} />
)
}
+ if (logs == null || !logs.logs_available || logs.jobs.length === 0) {
+ return <div className="px-1 py-2 text-xs text-secondary">{emptyText}</div>
+ }
return (
<div className="flex flex-col gap-2">
{logs.jobs.map((job) => (
diff --git a/products/engineering_analytics/frontend/components/GroupedJobsTable.tsx b/products/engineering_analytics/frontend/components/GroupedJobsTable.tsx
index c620bf4efc76..9d6de6872453 100644
--- a/products/engineering_analytics/frontend/components/GroupedJobsTable.tsx
+++ b/products/engineering_analytics/frontend/components/GroupedJobsTable.tsx
@@ -1,8 +1,8 @@
// A run's jobs with matrix shards rolled up (lib/jobGroups, the same rule as the backend's SQL
-// de-shard); failing groups sort first and name their failed shards. Groups expand via the caret only —
-// links inside rows must stay clickable.
+// de-shard); failing groups sort first and name their failed shards. Groups expand via the caret only,
+// because links inside rows must stay clickable.
-import { LemonTable, LemonTag } from '@posthog/lemon-ui'
+import { LemonSkeleton, LemonTable, LemonTag } from '@posthog/lemon-ui'
import { dayjs } from 'lib/dayjs'
import { humanFriendlyDuration } from 'lib/utils/durations'
@@ -151,7 +151,13 @@ export function GroupedJobsTable({
embedded?: boolean
}): JSX.Element {
if (jobs == null) {
- return <div className="px-3 py-2 text-xs text-secondary">{loading ? 'Loading jobs…' : 'No job data yet.'}</div>
+ return loading ? (
+ <div className="flex flex-col gap-2 px-3 py-2">
+ <LemonSkeleton className="h-4 w-full" repeat={3} />
+ </div>
+ ) : (
+ <div className="px-3 py-2 text-xs text-secondary">No job data yet.</div>
+ )
}
if (jobs.length === 0) {
return (
@@ -266,7 +272,6 @@ export function GroupedJobsTable({
render: (_, group) => resultTag(group),
},
]}
- emptyState="No jobs."
nouns={['job group', 'job groups']}
/>
)
diff --git a/products/engineering_analytics/frontend/scenes/PullRequestDetailScene.stories.tsx b/products/engineering_analytics/frontend/scenes/PullRequestDetailScene.stories.tsx
index 80796f199b05..59a482233cf2 100644
--- a/products/engineering_analytics/frontend/scenes/PullRequestDetailScene.stories.tsx
+++ b/products/engineering_analytics/frontend/scenes/PullRequestDetailScene.stories.tsx
@@ -317,3 +317,16 @@ export const OutOfTheMergeQueue: Story = {
}),
],
}
+
+export const SectionLoadErrors: Story = {
+ render: () => <App />,
+ parameters: { testOptions: { waitForSelector: '#ea-section-pr-runs' } },
+ decorators: [
+ mswDecorator({
+ get: {
+ 'api/projects/:team_id/engineering_analytics/pr_runs/': () => [500, null],
+ 'api/projects/:team_id/engineering_analytics/pull_request_timelines/': () => [500, null],
+ },
+ }),
+ ],
+}
diff --git a/products/engineering_analytics/frontend/scenes/PullRequestDetailScene.tsx b/products/engineering_analytics/frontend/scenes/PullRequestDetailScene.tsx
index a575993de2d6..140b747fb5a8 100644
--- a/products/engineering_analytics/frontend/scenes/PullRequestDetailScene.tsx
+++ b/products/engineering_analytics/frontend/scenes/PullRequestDetailScene.tsx
@@ -22,6 +22,7 @@ import { urls } from 'scenes/urls'
import { SceneContent } from '~/layout/scenes/components/SceneContent'
import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
+import { CIAnalyticsLoadError } from '../components/CIAnalyticsLoadError'
import { EntityHeader, VerdictPill } from '../components/EntityHeader'
import { FailureLogGroups } from '../components/FailureLogs'
import { GroupedJobsTable } from '../components/GroupedJobsTable'
@@ -58,13 +59,13 @@ export const scene: SceneExport<PullRequestDetailLogicProps> = {
}),
}
-// Stable per-row key — re-runs share a runId, so start time disambiguates attempts. Used for rowKey and
+// 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 ?? ''}`
}
-/** The runs of one workflow on this PR, one row per push × attempt — jobs live on the run page. */
+/** The runs of one workflow on this PR, one row per push × attempt. Jobs live on the run page. */
function PerPushRunsTable({
runs,
runCostByKey,
@@ -257,7 +258,7 @@ function PrWorkflowsTable({
const latest = latestByWorkflow.get(workflowName)
return latest?.conclusion != null && !isPassingConclusion(latest.conclusion)
}
- // Failing workflows first — the order a reviewer triages in — then alphabetical.
+ // Failing workflows first, because that is the order a reviewer triages in, then alphabetical.
const orderedRows = [...rows].sort(
(a, b) =>
Number(isWorkflowFailing(b.workflowName)) - Number(isWorkflowFailing(a.workflowName)) ||
@@ -379,7 +380,6 @@ function PrWorkflowsTable({
),
}}
pagination={{ pageSize: 10 }}
- emptyState="No CI runs match."
nouns={['workflow', 'workflows']}
/>
)
@@ -397,6 +397,7 @@ export function PullRequestDetailScene(): JSX.Element {
prRunsLoading,
prRunsFailed,
prCost,
+ prCostFailed,
prCostLoading,
pushes,
rerunCycles,
@@ -417,7 +418,7 @@ export function PullRequestDetailScene(): JSX.Element {
timelinesFailed,
timeline,
} = useValues(pullRequestDetailLogic)
- const { loadLifecycle, loadPrRuns, loadTimelines, setWorkflowFilter, setRunExpanded } =
+ const { loadLifecycle, loadPrCost, loadPrRuns, loadTimelines, loadFailureLogs, setWorkflowFilter, setRunExpanded } =
useActions(pullRequestDetailLogic)
const pullRequest = lifecycle?.pull_request
@@ -428,6 +429,7 @@ export function PullRequestDetailScene(): JSX.Element {
const passed = runs.filter((run) => run.conclusion !== null && isPassingConclusion(run.conclusion)).length
const failed = runs.filter((run) => run.conclusion !== null && !isPassingConclusion(run.conclusion)).length
const running = runs.filter((run) => run.conclusion === null).length
+ const visiblePrCost = prCostFailed || prCostLoading ? null : prCost
const latestRound = commitGroups[0] ? pushRoundOf(commitGroups[0].headSha, commitGroups[0].runs) : null
const tilesLoading = prRunsLoading && commitGroups.length === 0
@@ -435,14 +437,12 @@ export function PullRequestDetailScene(): JSX.Element {
return (
<SceneContent className="pb-16">
<SceneTitleSection name="Pull request" resourceType={{ type: 'health' }} />
- <div className="flex items-center gap-3">
- <span className="text-secondary">
- Couldn't load this pull request. It may not exist in the connected GitHub source.
- </span>
- <LemonButton type="secondary" size="small" onClick={loadLifecycle} loading={lifecycleLoading}>
- Retry
- </LemonButton>
- </div>
+ <CIAnalyticsLoadError
+ title="Couldn't load this pull request"
+ description="It may not exist in the connected GitHub source. Retry, or check the source's sync status."
+ onRetry={loadLifecycle}
+ loading={lifecycleLoading}
+ />
</SceneContent>
)
}
@@ -560,7 +560,7 @@ export function PullRequestDetailScene(): JSX.Element {
<MetricTile
label="Pushes"
tooltip="Commits that triggered CI on this pull request."
- value={`${pushes}`}
+ value={prRunsFailed ? '—' : `${pushes}`}
sub={
rerunCycles > 0 ? (
<span className="font-semibold text-warning-dark">+{rerunCycles} re-runs</span>
@@ -571,24 +571,34 @@ export function PullRequestDetailScene(): JSX.Element {
<MetricTile
label="CI cost"
tooltip={
- prCost?.jobs_available
+ visiblePrCost?.jobs_available
? `${compactUsd(
- (prCost.estimated_cost_usd ?? 0) / Math.max(1, pushes)
- )} per push${prCost.unsettled_jobs > 0 ? ` · ${pluralize(prCost.unsettled_jobs, 'unsettled job')} excluded` : ''}.`
- : 'Available once the job-level source is synced.'
+ (visiblePrCost.estimated_cost_usd ?? 0) / Math.max(1, pushes)
+ )} per push${visiblePrCost.unsettled_jobs > 0 ? ` · ${pluralize(visiblePrCost.unsettled_jobs, 'unsettled job')} excluded` : ''}.`
+ : prCostFailed
+ ? 'Loading CI cost failed.'
+ : 'Available once the job-level source is synced.'
+ }
+ value={visiblePrCost?.jobs_available ? compactUsd(visiblePrCost.estimated_cost_usd) : '—'}
+ sub={
+ prCostFailed ? (
+ <LemonButton size="xsmall" onClick={loadPrCost} loading={prCostLoading}>
+ Retry
+ </LemonButton>
+ ) : visiblePrCost?.jobs_available ? undefined : (
+ 'Job-level source not synced'
+ )
}
- value={prCost?.jobs_available ? compactUsd(prCost.estimated_cost_usd) : '—'}
- sub={prCost?.jobs_available ? undefined : 'Job-level source not synced'}
- loading={prCostLoading && !prCost}
+ loading={prCostLoading}
/>
- {prCost?.llm_spend && (
+ {visiblePrCost?.llm_spend && (
<MetricTile
label="LLM spend"
tooltip="Token spend from AI coding/review sessions on this PR's branch, including spend from the same session before the branch was created."
- value={compactUsd(prCost.llm_spend.cost_usd)}
+ value={compactUsd(visiblePrCost.llm_spend.cost_usd)}
sub={`${compactCount(
- prCost.llm_spend.input_tokens + prCost.llm_spend.output_tokens
- )} tokens · ${pluralize(prCost.llm_spend.generations, 'generation')}`}
+ visiblePrCost.llm_spend.input_tokens + visiblePrCost.llm_spend.output_tokens
+ )} tokens · ${pluralize(visiblePrCost.llm_spend.generations, 'generation')}`}
/>
)}
</div>
@@ -599,14 +609,11 @@ export function PullRequestDetailScene(): JSX.Element {
<Section id="pr-timeline" title="Lifecycle">
{timelinesFailed ? (
- <div className="flex items-center gap-3">
- <span className="text-sm text-secondary">
- Couldn't load the timeline for this pull request.
- </span>
- <LemonButton type="secondary" size="small" onClick={loadTimelines} loading={timelinesLoading}>
- Retry
- </LemonButton>
- </div>
+ <CIAnalyticsLoadError
+ title="Couldn't load the timeline for this pull request"
+ onRetry={loadTimelines}
+ loading={timelinesLoading}
+ />
) : !timelines ? (
<LemonSkeleton className="h-40 w-full" />
) : timeline ? (
@@ -654,12 +661,11 @@ export function PullRequestDetailScene(): JSX.Element {
{prRunsLoading && commitGroups.length === 0 ? (
<LemonSkeleton className="h-24 w-full" />
) : prRunsFailed ? (
- <div className="flex items-center gap-3">
- <span className="text-sm text-secondary">Couldn't load CI runs for this pull request.</span>
- <LemonButton type="secondary" size="small" onClick={loadPrRuns} loading={prRunsLoading}>
- Retry
- </LemonButton>
- </div>
+ <CIAnalyticsLoadError
+ title="Couldn't load CI runs for this pull request"
+ onRetry={loadPrRuns}
+ loading={prRunsLoading}
+ />
) : commitGroups.length === 0 ? (
<div className="text-sm text-secondary">No CI runs attributed to this pull request yet.</div>
) : filteredPrWorkflowRows.length === 0 ? (
@@ -670,7 +676,7 @@ export function PullRequestDetailScene(): JSX.Element {
filteredRuns={filteredRuns}
failingJobLabelByWorkflow={failingJobLabelByWorkflow}
runCostByKey={runCostByKey}
- showCost={prCost?.jobs_available ?? false}
+ showCost={visiblePrCost?.jobs_available ?? false}
loading={prRunsLoading}
repoOwner={repoOwner}
repoName={repoName}
@@ -685,11 +691,15 @@ export function PullRequestDetailScene(): JSX.Element {
{failed > 0 && (
<Section id="pr-failures" title="Failures">
- <FailureLogGroups logs={failureLogs} loading={failureLogsLoading} />
+ <FailureLogGroups
+ logs={failureLogs}
+ loading={failureLogsLoading}
+ onRetry={loadFailureLogs}
+ errorDescription="Retry, or open one of the failed runs on GitHub to read its logs."
+ emptyText="No failure logs. Fork runs may not be linked to this pull request, nothing failed, or the logs have aged out of retention."
+ />
</Section>
)}
-
- <div className="text-xs text-tertiary">Review and comment activity isn't tracked yet.</div>
</SceneContent>
)
}
diff --git a/products/engineering_analytics/frontend/scenes/WorkflowRunDetailScene.stories.tsx b/products/engineering_analytics/frontend/scenes/WorkflowRunDetailScene.stories.tsx
new file mode 100644
index 000000000000..11a4667fe938
--- /dev/null
+++ b/products/engineering_analytics/frontend/scenes/WorkflowRunDetailScene.stories.tsx
@@ -0,0 +1,119 @@
+import { Meta, StoryObj } from '@storybook/react'
+
+import { FEATURE_FLAGS } from 'lib/constants'
+import { App } from 'scenes/App'
+import { urls } from 'scenes/urls'
+
+import { mswDecorator } from '~/mocks/browser'
+
+import type { RunFailureLogsApi, WorkflowJobApi, WorkflowRunDetailApi } from '../generated/api.schemas'
+
+const REPO = { provider: 'github', owner: 'PostHog', name: 'posthog' }
+const RUN_ID = 880163
+const STARTED_AT = '2026-07-01T11:12:00Z'
+
+const RUN: WorkflowRunDetailApi = {
+ repo: REPO,
+ id: RUN_ID,
+ workflow_name: 'Backend CI',
+ head_sha: 'c0ffee880163',
+ head_branch: 'feat/run-scope-groups',
+ status: 'completed',
+ conclusion: 'failure',
+ run_started_at: STARTED_AT,
+ updated_at: '2026-07-01T11:40:00Z',
+ duration_seconds: 1680,
+ run_attempt: 1,
+ pr_number: 4820,
+ commit_pr_number: null,
+ is_merge_queue: false,
+}
+
+function job(id: number, name: string, conclusion: string, startMinute: number, minutes: number): WorkflowJobApi {
+ const startedAt = new Date(Date.parse(STARTED_AT) + startMinute * 60_000).toISOString()
+ return {
+ id,
+ run_id: RUN_ID,
+ name,
+ status: 'completed',
+ conclusion,
+ started_at: startedAt,
+ completed_at: new Date(Date.parse(startedAt) + minutes * 60_000).toISOString(),
+ duration_seconds: minutes * 60,
+ runner_provider: 'self_hosted',
+ runner_label: 'depot-ubuntu-16',
+ estimated_cost_usd: minutes * 0.032,
+ }
+}
+
+// A matrix group with one failed shard and a passing single job.
+const JOBS: WorkflowJobApi[] = [
+ job(1, 'Python tests (1/3)', 'success', 1, 18),
+ job(2, 'Python tests (2/3)', 'failure', 1, 22),
+ job(3, 'Python tests (3/3)', 'success', 1, 17),
+ job(4, 'Migrations', 'success', 0.5, 4),
+]
+
+const FAILURE_LOGS: RunFailureLogsApi = {
+ run_id: RUN_ID,
+ logs_available: true,
+ truncated: false,
+ jobs: [
+ {
+ job_id: 2,
+ run_id: RUN_ID,
+ conclusion: 'failure',
+ branch: 'feat/run-scope-groups',
+ original_total_lines: 4210,
+ line_count: 3,
+ truncated: false,
+ lines: [
+ { original_line: 3988, text: 'FAILED posthog/api/test/test_example.py::TestExample::test_scope' },
+ { original_line: null, text: '... 12 lines omitted ...' },
+ { original_line: 4001, text: 'AssertionError: expected 3 run groups, got 2' },
+ ],
+ },
+ ],
+}
+
+const meta: Meta = {
+ component: App,
+ title: 'Scenes-App/Engineering Analytics/Workflow Run',
+ parameters: {
+ layout: 'fullscreen',
+ viewMode: 'story',
+ mockDate: '2026-07-02',
+ featureFlags: [FEATURE_FLAGS.ENGINEERING_ANALYTICS],
+ pageUrl: urls.engineeringAnalyticsWorkflowRun('PostHog', 'posthog', RUN_ID),
+ },
+ decorators: [
+ mswDecorator({
+ get: {
+ 'api/projects/:team_id/engineering_analytics/workflow_run/': RUN,
+ 'api/projects/:team_id/engineering_analytics/workflow_jobs/': JOBS,
+ 'api/projects/:team_id/engineering_analytics/run_failure_logs/': FAILURE_LOGS,
+ },
+ }),
+ ],
+}
+export default meta
+
+type Story = StoryObj<typeof meta>
+
+export const FailedRun: Story = {
+ render: () => <App />,
+ parameters: { testOptions: { waitForSelector: '#ea-section-jobs' } },
+}
+
+export const JobsAndLogsLoadErrors: Story = {
+ render: () => <App />,
+ parameters: { testOptions: { waitForSelector: '#ea-section-jobs' } },
+ decorators: [
+ mswDecorator({
+ get: {
+ 'api/projects/:team_id/engineering_analytics/workflow_jobs/': () => [500, null],
+ 'api/projects/:team_id/engineering_analytics/run_failure_logs/': () => [500, null],
+ },
+ }),
+ ],
+}
diff --git a/products/engineering_analytics/frontend/scenes/WorkflowRunDetailScene.tsx b/products/engineering_analytics/frontend/scenes/WorkflowRunDetailScene.tsx
index 4738f383064e..1e676c7e00ff 100644
--- a/products/engineering_analytics/frontend/scenes/WorkflowRunDetailScene.tsx
+++ b/products/engineering_analytics/frontend/scenes/WorkflowRunDetailScene.tsx
@@ -14,12 +14,14 @@ import { urls } from 'scenes/urls'
import { SceneContent } from '~/layout/scenes/components/SceneContent'
import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
+import { CIAnalyticsLoadError } from '../components/CIAnalyticsLoadError'
import { EntityHeader, VerdictPill } from '../components/EntityHeader'
import { FailureLogGroups } from '../components/FailureLogs'
import { GroupedJobsTable } from '../components/GroupedJobsTable'
import { MetricTile } from '../components/MetricTile'
import { formatCost, formatMinutes, runPrNumber } from '../components/runTables'
import { RepoScopeChip, ScopeBar } from '../components/ScopeBar'
+import { Section } from '../components/Section'
import { githubCommitUrl, githubRunUrl } from '../lib/github'
import { isDecisiveFailure } from '../lib/lifecycle'
import { verdictTag } from '../lib/runStatus'
@@ -45,12 +47,13 @@ export function WorkflowRunDetailScene(): JSX.Element {
sourceId,
jobs,
jobsLoading,
+ jobsFailed,
runCost,
isValidRunId,
failureLogs,
failureLogsLoading,
} = useValues(workflowRunDetailLogic)
- const { loadRun } = useActions(workflowRunDetailLogic)
+ const { loadRun, loadJobs, loadFailureLogs } = useActions(workflowRunDetailLogic)
const { searchParams } = useValues(router)
if (!isValidRunId) {
@@ -95,19 +98,18 @@ export function WorkflowRunDetailScene(): JSX.Element {
: null
// The logs endpoint only carries job ids; the run's loaded jobs supply the names.
const jobNamesById = Object.fromEntries((jobs ?? []).map((job) => [job.id, job.name]))
+ const jobsPending = jobsLoading && !jobs
if (loadFailed) {
return (
<SceneContent className="pb-16">
<SceneTitleSection name="Workflow run" resourceType={{ type: 'health' }} />
- <div className="flex items-center gap-3">
- <span className="text-secondary">
- Couldn't load this workflow run. It may not exist in the connected GitHub source.
- </span>
- <LemonButton type="secondary" size="small" onClick={loadRun} loading={runLoading}>
- Retry
- </LemonButton>
- </div>
+ <CIAnalyticsLoadError
+ title="Couldn't load this workflow run"
+ description="It may not exist in the connected GitHub source. Retry, or check the source's sync status."
+ onRetry={loadRun}
+ loading={runLoading}
+ />
</SceneContent>
)
}
@@ -231,8 +233,14 @@ export function WorkflowRunDetailScene(): JSX.Element {
label="Queue time"
tooltip="From run started to the first job starting."
value={queueSeconds != null ? humanFriendlyDuration(queueSeconds) : '—'}
+ loading={jobsPending}
+ />
+ <MetricTile
+ label="Jobs"
+ tooltip={jobRollupLabel}
+ value={jobs ? `${jobs.length}` : '—'}
+ loading={jobsPending}
/>
- <MetricTile label="Jobs" tooltip={jobRollupLabel} value={jobs ? `${jobs.length}` : '—'} />
<MetricTile
label="Estimated cost"
tooltip={
@@ -242,22 +250,36 @@ export function WorkflowRunDetailScene(): JSX.Element {
? ` · ${pluralize(runCost.unsettledJobs, 'unsettled job')} excluded`
: ''
}.`
- : 'Available once the job-level source is synced.'
+ : jobsFailed
+ ? "Couldn't load this run's jobs."
+ : 'Available once the job-level source is synced.'
}
value={runCost ? formatCost(runCost.estimatedCostUsd) : '—'}
+ loading={jobsPending}
/>
</div>
- <div className="flex flex-col gap-2">
- <h3 className="mb-0">Jobs</h3>
- <GroupedJobsTable jobs={jobs} loading={jobsLoading} />
- </div>
+ <Section id="jobs" title="Jobs">
+ {jobsFailed ? (
+ <CIAnalyticsLoadError
+ title="Couldn't load this run's jobs"
+ onRetry={loadJobs}
+ loading={jobsLoading}
+ />
+ ) : (
+ <GroupedJobsTable jobs={jobs} loading={jobsLoading} />
+ )}
+ </Section>
{isDecisiveFailure(run.conclusion) && (
- <div className="flex flex-col gap-2">
- <h3 className="mb-0">Failure logs</h3>
- <FailureLogGroups logs={failureLogs} loading={failureLogsLoading} jobNames={jobNamesById} />
- </div>
+ <Section id="failure-logs" title="Failure logs">
+ <FailureLogGroups
+ logs={failureLogs}
+ loading={failureLogsLoading}
+ onRetry={loadFailureLogs}
+ jobNames={jobNamesById}
+ />
+ </Section>
)}
</>
) : (
diff --git a/products/engineering_analytics/frontend/scenes/WorkflowRunsScene.stories.tsx b/products/engineering_analytics/frontend/scenes/WorkflowRunsScene.stories.tsx
index 0c68581ad0a9..20ab5f8c7d12 100644
--- a/products/engineering_analytics/frontend/scenes/WorkflowRunsScene.stories.tsx
+++ b/products/engineering_analytics/frontend/scenes/WorkflowRunsScene.stories.tsx
@@ -198,3 +198,18 @@ export const WorkflowDetailScopedToPullRequests: Story = {
render: () => <App />,
parameters: { pageUrl: `${WORKFLOW_URL}?run_scope=pull_request` },
}
+
+// Each windowed section reads its own endpoint, so one failed read errors that section and leaves the rest.
+export const WorkflowDetailSectionLoadErrors: Story = {
+ render: () => <App />,
+ parameters: { pageUrl: WORKFLOW_URL },
+ decorators: [
+ mswDecorator({
+ get: {
+ 'api/projects/:team_id/engineering_analytics/workflow_run_activity/': () => [500, null],
+ 'api/projects/:team_id/engineering_analytics/workflow_runner_costs/': () => [500, null],
+ 'api/projects/:team_id/engineering_analytics/job_aggregates/': () => [500, null],
+ },
+ }),
+ ],
+}
diff --git a/products/engineering_analytics/frontend/scenes/WorkflowRunsScene.tsx b/products/engineering_analytics/frontend/scenes/WorkflowRunsScene.tsx
index 402fd1d7de39..80952000fd3b 100644
--- a/products/engineering_analytics/frontend/scenes/WorkflowRunsScene.tsx
+++ b/products/engineering_analytics/frontend/scenes/WorkflowRunsScene.tsx
@@ -2,7 +2,16 @@ import { useActions, useValues } from 'kea'
import { router } from 'kea-router'
import { IconExternal, IconGear } from '@posthog/icons'
-import { LemonBanner, LemonButton, LemonTable, LemonTableColumns, LemonTag, Link } from '@posthog/lemon-ui'
+import {
+ LemonBanner,
+ LemonButton,
+ LemonSkeleton,
+ LemonTable,
+ LemonTableColumns,
+ LemonTag,
+ Link,
+ Tooltip,
+} from '@posthog/lemon-ui'
import { TZLabel } from 'lib/components/TZLabel'
import { LemonCard } from 'lib/lemon-ui/LemonCard'
@@ -16,11 +25,12 @@ import { urls } from 'scenes/urls'
import { SceneContent } from '~/layout/scenes/components/SceneContent'
import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
+import { CIAnalyticsLoadError } from '../components/CIAnalyticsLoadError'
import { EntityHeader, VerdictPill } from '../components/EntityHeader'
import { GroupedJobsTable } from '../components/GroupedJobsTable'
import { JobAggregatesTable } from '../components/JobAggregatesTable'
import { MetricTile } from '../components/MetricTile'
-import { RunActivityChart } from '../components/RunActivityChart'
+import { RunActivityChart, hasEnoughRunActivity } from '../components/RunActivityChart'
import { RunConclusionTag } from '../components/runTables'
import { RepoScopeChip, ScopeBar, WorkflowScopeChip, WorkflowScopeControls } from '../components/ScopeBar'
import { ScopePanel } from '../components/ScopePanel'
@@ -39,10 +49,11 @@ function RunnerTierCard({ costs }: { costs: WorkflowRunnerCostApi[] }): JSX.Elem
const totalCost = costs.reduce((sum, cost) => sum + (cost.estimated_cost_usd ?? 0), 0)
return (
<LemonCard hoverEffect={false} className="p-4">
- <div className="mb-1 flex items-baseline gap-2">
- <h3 className="mb-0 text-xs font-semibold text-secondary">By runner tier</h3>
- <LemonTag type="warning">estimate · wall-clock × reference rate</LemonTag>
- </div>
+ <h3 className="mb-1 text-xs font-semibold text-secondary">
+ <Tooltip title="Estimated: billable minutes × runner-tier rate. The tier comes from the job's runner labels. GitHub-hosted runners are free for open source.">
+ <span className="cursor-default">By runner tier</span>
+ </Tooltip>
+ </h3>
{costs.map((cost) => (
<ShareRow
key={`${cost.provider}:${cost.runner_label}`}
@@ -53,7 +64,7 @@ function RunnerTierCard({ costs }: { costs: WorkflowRunnerCostApi[] }): JSX.Elem
</span>
}
sub={`${humanFriendlyNumber(cost.job_count)} jobs`}
- value={cost.estimated_cost_usd != null ? compactUsd(cost.estimated_cost_usd) : 'free'}
+ value={cost.estimated_cost_usd != null ? compactUsd(cost.estimated_cost_usd) : 'Free'}
valueSub={
cost.estimated_cost_usd != null
? `${compactMinutes(cost.billable_minutes)} billable`
@@ -63,10 +74,6 @@ function RunnerTierCard({ costs }: { costs: WorkflowRunnerCostApi[] }): JSX.Elem
color={cost.estimated_cost_usd != null ? 'var(--brand-blue)' : 'var(--muted)'}
/>
))}
- <div className="mt-2 border-t border-primary pt-2 text-[11px] text-tertiary">
- Tier parsed from job labels; rate ladder in the cost model. GitHub-hosted runners are free for open
- source.
- </div>
</LemonCard>
)
}
@@ -90,7 +97,9 @@ export function WorkflowRunsScene(): JSX.Element {
runsLoading,
runnerCosts,
runnerCostsLoading,
+ runnerCostsFailed,
runActivityLoading,
+ runActivityFailed,
runJobs,
runJobsLoading,
expandedRunKeys,
@@ -108,10 +117,12 @@ export function WorkflowRunsScene(): JSX.Element {
activityTruncated,
jobAggregates,
jobAggregatesLoading,
+ jobAggregatesFailed,
masterConclusion,
queueP50Seconds,
} = useValues(workflowRunsLogic)
- const { loadRuns, setRunExpanded } = useActions(workflowRunsLogic)
+ const { loadRuns, loadRunActivity, loadRunnerCosts, loadJobAggregates, setRunExpanded } =
+ useActions(workflowRunsLogic)
const { searchParams } = useValues(router)
const githubUrl = githubWorkflowUrl(repoOwner, repoName, workflowName)
@@ -269,14 +280,12 @@ export function WorkflowRunsScene(): JSX.Element {
return (
<SceneContent className="pb-16">
<SceneTitleSection name="Workflow" resourceType={{ type: 'health' }} />
- <div className="flex items-center gap-3">
- <span className="text-secondary">
- Couldn't load this workflow's runs. It may not exist in the connected GitHub source.
- </span>
- <LemonButton type="secondary" size="small" onClick={loadRuns} loading={runsLoading}>
- Retry
- </LemonButton>
- </div>
+ <CIAnalyticsLoadError
+ title="Couldn't load this workflow's runs"
+ description="It may not exist in the connected GitHub source. Retry, or check the source's sync status."
+ onRetry={loadRuns}
+ loading={runsLoading}
+ />
</SceneContent>
)
}
@@ -367,6 +376,7 @@ export function WorkflowRunsScene(): JSX.Element {
label="Estimated median queue time"
tooltip="Estimated median wait from job created to started: each job's median, weighted by how often the job ran."
value={queueP50Seconds != null ? humanFriendlyDuration(queueP50Seconds) : '—'}
+ sub={jobAggregatesFailed ? "Couldn't load" : undefined}
loading={jobAggregatesLoading}
/>
<MetricTile
@@ -378,30 +388,69 @@ export function WorkflowRunsScene(): JSX.Element {
? costSummary.estimatedCostUsd / healthSummary.totalRuns
: null
)} per run.`
- : 'Available once the job-level source is synced.'
+ : runnerCostsFailed
+ ? undefined
+ : 'Available once the job-level source is synced.'
}
value={costSummary?.estimatedCostUsd != null ? compactUsd(costSummary.estimatedCostUsd) : '—'}
- sub={costSummary?.estimatedCostUsd != null ? undefined : 'Job-level source not synced'}
+ sub={
+ costSummary?.estimatedCostUsd != null
+ ? undefined
+ : runnerCostsFailed
+ ? "Couldn't load"
+ : 'Job-level source not synced'
+ }
loading={runnerCostsLoading || workflowHealthLoading}
/>
</div>
<Section id="health" title="Health" busy={healthBusy}>
- <RunActivityChart runs={activityRuns} truncated={activityTruncated} />
+ {runActivityFailed ? (
+ <CIAnalyticsLoadError
+ title="Couldn't load run activity"
+ onRetry={loadRunActivity}
+ loading={runActivityLoading}
+ />
+ ) : hasEnoughRunActivity(activityRuns) ? (
+ <RunActivityChart runs={activityRuns} truncated={activityTruncated} />
+ ) : runActivityLoading ? (
+ <LemonSkeleton className="h-80 w-full" />
+ ) : (
+ <LemonCard hoverEffect={false} className="p-4 text-xs text-secondary">
+ Not enough completed runs in the window to chart yet. Widen the date range or the run scope.
+ </LemonCard>
+ )}
</Section>
<Section id="jobs" title="Jobs">
- <JobAggregatesTable
- aggregates={jobAggregates}
- loading={jobAggregatesLoading}
- totalCostUsd={costSummary?.estimatedCostUsd ?? null}
- />
+ {jobAggregatesFailed ? (
+ <CIAnalyticsLoadError
+ title="Couldn't load jobs"
+ onRetry={loadJobAggregates}
+ loading={jobAggregatesLoading}
+ />
+ ) : (
+ <JobAggregatesTable
+ aggregates={jobAggregates}
+ loading={jobAggregatesLoading}
+ totalCostUsd={costSummary?.estimatedCostUsd ?? null}
+ />
+ )}
</Section>
<Section id="cost" title="Cost" busy={costBusy}>
- {runnerCosts.length > 0 ? (
+ {runnerCostsFailed ? (
+ <CIAnalyticsLoadError
+ title="Couldn't load cost"
+ onRetry={loadRunnerCosts}
+ loading={runnerCostsLoading}
+ />
+ ) : runnerCosts.length > 0 ? (
<RunnerTierCard costs={runnerCosts} />
+ ) : runnerCostsLoading ? (
+ <LemonSkeleton className="h-40 w-full" />
) : (
- <span className="text-xs text-secondary">
- No cost data. The job-level source isn't synced, or nothing ran in the window.
- </span>
+ <LemonCard hoverEffect={false} className="p-4 text-xs text-secondary">
+ No cost data. The job-level source isn't synced, or nothing ran in the window. Widen the
+ date range, or check the source's sync status.
+ </LemonCard>
)}
</Section>
<Section id="runs" title="Runs">
diff --git a/products/engineering_analytics/frontend/scenes/pullRequestDetailLogic.ts b/products/engineering_analytics/frontend/scenes/pullRequestDetailLogic.ts
index 54a3a6fdf9f4..1e47d5de01f0 100644
--- a/products/engineering_analytics/frontend/scenes/pullRequestDetailLogic.ts
+++ b/products/engineering_analytics/frontend/scenes/pullRequestDetailLogic.ts
@@ -176,6 +176,7 @@ export interface pullRequestDetailLogicValues {
lifecycleLoading: boolean
loadFailed: boolean
prCost: PRCostSummaryApi | null
+ prCostFailed: boolean
prCostLoading: boolean
prRuns: WorkflowRunDetailApi[]
prRunsFailed: boolean
@@ -481,6 +482,14 @@ export const pullRequestDetailLogic = kea<pullRequestDetailLogicType>([
loadPrRunsFailure: () => true,
},
],
+ prCostFailed: [
+ false,
+ {
+ loadPrCost: () => false,
+ loadPrCostSuccess: () => false,
+ loadPrCostFailure: () => true,
+ },
+ ],
timelinesFailed: [false, { loadTimelines: () => false, loadTimelinesFailure: () => true }],
expandedRunKeys: [
[] as string[],
diff --git a/products/engineering_analytics/frontend/scenes/workflowRunDetailLogic.ts b/products/engineering_analytics/frontend/scenes/workflowRunDetailLogic.ts
index fd7d54a45ec7..9d58743a20bc 100644
--- a/products/engineering_analytics/frontend/scenes/workflowRunDetailLogic.ts
+++ b/products/engineering_analytics/frontend/scenes/workflowRunDetailLogic.ts
@@ -32,6 +32,7 @@ export interface workflowRunDetailLogicValues {
failureLogsLoading: boolean
isValidRunId: boolean
jobs: WorkflowJobApi[] | null
+ jobsFailed: boolean
jobsLoading: boolean
loadFailed: boolean
run: WorkflowRunDetailApi | null
@@ -125,8 +126,8 @@ export const workflowRunDetailLogic = kea<workflowRunDetailLogicType>([
}),
},
],
- // null = not loaded, [] = source unsynced. Scoped to the run's actual attempt (loaded first) —
- // the backend's omitted-attempt fallback would otherwise show an older attempt's jobs/costs.
+ // null = not loaded, [] = source unsynced. Scoped to the run's actual attempt (loaded first),
+ // because the backend's omitted-attempt fallback would otherwise show an older attempt's jobs/costs.
jobs: [
null as WorkflowJobApi[] | null,
{
@@ -167,6 +168,14 @@ export const workflowRunDetailLogic = kea<workflowRunDetailLogicType>([
loadRunFailure: () => true,
},
],
+ jobsFailed: [
+ false,
+ {
+ loadJobs: () => false,
+ loadJobsSuccess: () => false,
+ loadJobsFailure: () => true,
+ },
+ ],
}),
selectors({
@@ -174,12 +183,12 @@ export const workflowRunDetailLogic = kea<workflowRunDetailLogicType>([
() => [(_, p: WorkflowRunDetailLogicProps) => p.sourceId],
(sourceId: string | null): string | null => sourceId,
],
- // Summed from the already-loaded jobs — no extra query.
+ // Summed from the already-loaded jobs, so no extra query.
runCost: [
(s) => [s.jobs],
(jobs: WorkflowJobApi[] | null): RunCostSummary | null => (jobs ? summarizeRunCost(jobs) : null),
],
- // A non-numeric path segment yields NaN — the scene shows a clean "not found" instead of a load error.
+ // A non-numeric path segment yields NaN, so the scene shows a clean "not found" instead of a load error.
isValidRunId: [
() => [(_, p: WorkflowRunDetailLogicProps) => p.runId],
(runId: number): boolean => Number.isFinite(runId),
@@ -212,7 +221,7 @@ export const workflowRunDetailLogic = kea<workflowRunDetailLogicType>([
// Load jobs only once the run is in, so they can be scoped to the run's real attempt.
loadRunSuccess: () => {
actions.loadJobs()
- // Failure logs only exist for failed runs — skip the query otherwise.
+ // Failure logs only exist for failed runs, so skip the query otherwise.
if (isDecisiveFailure(values.run?.conclusion ?? null)) {
actions.loadFailureLogs()
}
diff --git a/products/engineering_analytics/frontend/scenes/workflowRunsLogic.test.ts b/products/engineering_analytics/frontend/scenes/workflowRunsLogic.test.ts
index 23b9f0eb2bdc..ae59525d6e1c 100644
--- a/products/engineering_analytics/frontend/scenes/workflowRunsLogic.test.ts
+++ b/products/engineering_analytics/frontend/scenes/workflowRunsLogic.test.ts
@@ -115,22 +115,65 @@ describe('workflowRunsLogic', () => {
buckets: [],
},
])
+ mockRunnerCosts.mockResolvedValue([
+ {
+ provider: 'self_hosted',
+ runner_label: 'depot-ubuntu-16',
+ job_count: 10,
+ billable_minutes: 100,
+ estimated_cost_usd: 3.2,
+ },
+ ])
+ mockJobAggregates.mockResolvedValue([
+ {
+ job_name: 'Python tests',
+ job_count: 10,
+ shard_count: 1,
+ runs_in: 10,
+ run_share: 1,
+ queue_p50_seconds: 30,
+ p50_seconds: 600,
+ p95_seconds: 900,
+ failure_rate: 0,
+ retry_job_count: 0,
+ billable_minutes: 100,
+ estimated_cost_usd: 3.2,
+ },
+ ])
logic = workflowRunsLogic({ repoOwner: 'PostHog', repoName: 'posthog', workflowName: 'CI', sourceId: null })
logic.mount()
- await expectLogic(logic).toDispatchActions(['loadWorkflowHealthSuccess'])
+ await expectLogic(logic).toDispatchActionsInAnyOrder([
+ 'loadWorkflowHealthSuccess',
+ 'loadRunnerCostsSuccess',
+ 'loadJobAggregatesSuccess',
+ ])
expect(logic.values.healthSummary.totalRuns).toBe(4000)
expect(logic.values.healthSummary.passRate).toBe(0.974)
expect(logic.values.healthSummary.state).toBe('healthy')
+ expect(logic.values.costSummary?.estimatedCostUsd).toBe(3.2)
+ expect(logic.values.queueP50Seconds).toBe(30)
- // A failed reload must not keep showing the previous window's 4000 runs under the fallback banner.
+ // A failed reload must not keep showing the previous window's figures under an error state.
mockWorkflowHealth.mockRejectedValue(new Error('network down'))
+ mockRunnerCosts.mockRejectedValue(new Error('network down'))
+ mockJobAggregates.mockRejectedValue(new Error('network down'))
const filters = engineeringAnalyticsFiltersLogic()
unmountFilters = filters.mount()
filters.actions.setDateRange('-7d', null)
- await expectLogic(logic).toDispatchActions(['loadWorkflowHealthFailure'])
+ await expectLogic(logic).toDispatchActionsInAnyOrder([
+ 'loadWorkflowHealthFailure',
+ 'loadRunnerCostsFailure',
+ 'loadJobAggregatesFailure',
+ ])
- expect(logic.values.workflowHealthFailed).toBe(true)
+ expect(logic.values).toMatchObject({
+ workflowHealthFailed: true,
+ runnerCostsFailed: true,
+ jobAggregatesFailed: true,
+ costSummary: null,
+ queueP50Seconds: null,
+ })
expect(logic.values.healthSummary.totalRuns).toBe(0)
expect(logic.values.healthSummary.state).toBe('unknown')
})
diff --git a/products/engineering_analytics/frontend/scenes/workflowRunsLogic.ts b/products/engineering_analytics/frontend/scenes/workflowRunsLogic.ts
index f917662fa275..bb09b9bdcc86 100644
--- a/products/engineering_analytics/frontend/scenes/workflowRunsLogic.ts
+++ b/products/engineering_analytics/frontend/scenes/workflowRunsLogic.ts
@@ -70,6 +70,7 @@ export interface workflowRunsLogicValues {
expandedRunKeys: string[]
healthSummary: HealthSummary
jobAggregates: WorkflowJobAggregateApi[]
+ jobAggregatesFailed: boolean
jobAggregatesLoading: boolean
loadFailed: boolean
masterConclusion: string | null
@@ -77,11 +78,13 @@ export interface workflowRunsLogicValues {
repoName: string
repoOwner: string
runActivity: WorkflowRunActivityApi
+ runActivityFailed: boolean
runActivityLoading: boolean
runJobs: Record<string, WorkflowJobApi[]>
runJobsLoading: boolean
runRows: WorkflowRunRow[]
runnerCosts: WorkflowRunnerCostApi[]
+ runnerCostsFailed: boolean
runnerCostsLoading: boolean
runs: WorkflowRunDetailApi[]
runsLoading: boolean
@@ -369,6 +372,15 @@ export const workflowRunsLogic = kea<workflowRunsLogicType>([
workflowHealth: {
loadWorkflowHealthFailure: () => null,
},
+ runActivity: {
+ loadRunActivityFailure: () => ({ points: [], truncated: false, limit: 0 }),
+ },
+ runnerCosts: {
+ loadRunnerCostsFailure: () => [],
+ },
+ jobAggregates: {
+ loadJobAggregatesFailure: () => [],
+ },
workflowHealthFailed: [
false,
{
@@ -377,6 +389,30 @@ export const workflowRunsLogic = kea<workflowRunsLogicType>([
loadWorkflowHealthFailure: () => true,
},
],
+ runActivityFailed: [
+ false,
+ {
+ loadRunActivity: () => false,
+ loadRunActivitySuccess: () => false,
+ loadRunActivityFailure: () => true,
+ },
+ ],
+ runnerCostsFailed: [
+ false,
+ {
+ loadRunnerCosts: () => false,
+ loadRunnerCostsSuccess: () => false,
+ loadRunnerCostsFailure: () => true,
+ },
+ ],
+ jobAggregatesFailed: [
+ false,
+ {
+ loadJobAggregates: () => false,
+ loadJobAggregatesSuccess: () => false,
+ loadJobAggregatesFailure: () => true,
+ },
+ ],
expandedRunKeys: [
[] as string[],
{
@@ -481,7 +517,7 @@ export const workflowRunsLogic = kea<workflowRunsLogicType>([
if (runnerCosts.length === 0) {
return null
}
- // Free runners report null — a bare sum would turn "no cost data" into a misleading $0.00.
+ // Free runners report null, so a bare sum would turn "no cost data" into a misleading $0.00.
const hasBillable = runnerCosts.some((cost) => cost.billable_minutes != null)
const hasEstimatedCost = runnerCosts.some((cost) => cost.estimated_cost_usd != null)
return {