: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
fix(exports): surface pending status for slow video exports (#60546)
posthog[bot]3b1233f0067f
diff --git a/frontend/src/layout/navigation-3000/sidepanel/panels/exports/SidePanelExports.tsx b/frontend/src/layout/navigation-3000/sidepanel/panels/exports/SidePanelExports.tsxindex 89870a597cef..e4b17a2ea768 100644--- a/frontend/src/layout/navigation-3000/sidepanel/panels/exports/SidePanelExports.tsx+++ b/frontend/src/layout/navigation-3000/sidepanel/panels/exports/SidePanelExports.tsx@@ -4,6 +4,7 @@ import { IconDownload, IconPencil, IconRefresh, IconWarning } from '@posthog/icoimport { LemonButton, LemonSelect, LemonSkeleton, Spinner, lemonToast } from '@posthog/lemon-ui'import { downloadExportedAsset, exportedAssetBlob } from 'lib/components/ExportButton/exporter'+import { getExportDisabledReason, getExportPendingLabel } from 'lib/components/ExportButton/exportStatus'import { ScreenShotEditor } from 'lib/components/TakeScreenshot/ScreenShotEditor'import { takeScreenshotLogic } from 'lib/components/TakeScreenshot/takeScreenshotLogic'import { dayjs } from 'lib/dayjs'@@ -78,12 +79,8 @@ function ExportRow({ asset }: { asset: ExportedAssetType }): JSX.Element {const isNotDownloaded = freshUndownloadedExports.some((fresh) => fresh.id === asset.id)const stillCalculating = !asset.has_content && !asset.exception- let disabledReason: string | undefined = undefined- if (asset.exception) {- disabledReason = asset.exception- } else if (!asset.has_content) {- disabledReason = 'Export not ready yet'- }+ const disabledReason = getExportDisabledReason(asset)+ const pendingLabel = getExportPendingLabel(asset)return (<div className="flex justify-between mt-2 gap-2 border rounded bg-fill-primary items-center">@@ -107,6 +104,11 @@ function ExportRow({ asset }: { asset: ExportedAssetType }): JSX.Element {row limit</span>)}+ {stillCalculating && pendingLabel && (+ <span className="text-xs text-secondary mt-1 block" data-attr="export-pending-label">+ {pendingLabel}+ </span>+ )}</div></div><div className="flex gap-2 mr-2">diff --git a/frontend/src/lib/components/ExportButton/exportStatus.test.ts b/frontend/src/lib/components/ExportButton/exportStatus.test.tsnew file mode 100644index 000000000000..0e1d63171e06--- /dev/null+++ b/frontend/src/lib/components/ExportButton/exportStatus.test.ts@@ -0,0 +1,102 @@+import { ExportedAssetType, ExporterFormat } from '~/types'++import {+ getExportDisabledReason,+ getExportPendingLabel,+ getExportPendingStatus,+ isLongRunningExportFormat,+} from './exportStatus'++const baseAsset = (overrides: Partial<ExportedAssetType> = {}): ExportedAssetType => ({+ id: 1,+ export_format: ExporterFormat.CSV,+ has_content: false,+ filename: 'export.csv',+ created_at: '2026-05-11T19:00:00Z',+ ...overrides,+})++describe('exportStatus', () => {+ describe('isLongRunningExportFormat', () => {+ it.each([+ [true, ExporterFormat.MP4],+ [true, ExporterFormat.WEBM],+ [true, ExporterFormat.GIF],+ [false, ExporterFormat.PNG],+ [false, ExporterFormat.CSV],+ [false, ExporterFormat.PDF],+ ])('returns %s for format %s', (expected, format) => {+ expect(isLongRunningExportFormat(format)).toBe(expected)+ })++ it('returns false for missing format', () => {+ expect(isLongRunningExportFormat(undefined)).toBe(false)+ expect(isLongRunningExportFormat(null)).toBe(false)+ })+ })++ describe('getExportPendingStatus', () => {+ it('returns null when the asset has content', () => {+ expect(getExportPendingStatus(baseAsset({ has_content: true }))).toBeNull()+ })++ it('returns null when the asset has an exception', () => {+ expect(getExportPendingStatus(baseAsset({ exception: 'boom' }))).toBeNull()+ })++ it.each([ExporterFormat.MP4, ExporterFormat.WEBM, ExporterFormat.GIF])(+ 'returns rendering_video for pending long-running format %s',+ (format) => {+ expect(getExportPendingStatus(baseAsset({ export_format: format }))).toBe('rendering_video')+ }+ )++ it('returns pending for other in-progress formats', () => {+ expect(getExportPendingStatus(baseAsset({ export_format: ExporterFormat.CSV }))).toBe('pending')+ })+ })++ describe('getExportPendingLabel', () => {+ it.each([ExporterFormat.MP4, ExporterFormat.WEBM, ExporterFormat.GIF])(+ 'returns a video-specific message for %s',+ (format) => {+ expect(getExportPendingLabel(baseAsset({ export_format: format }))).toBe(+ 'Rendering video — usually takes several minutes'+ )+ }+ )++ it('returns a generic message for non-video pending exports', () => {+ expect(getExportPendingLabel(baseAsset({ export_format: ExporterFormat.CSV }))).toBe('Preparing export…')+ })++ it('returns null once the asset is ready', () => {+ expect(getExportPendingLabel(baseAsset({ has_content: true }))).toBeNull()+ })+ })++ describe('getExportDisabledReason', () => {+ it('surfaces the exception message when present', () => {+ expect(getExportDisabledReason(baseAsset({ exception: 'rasterize failed' }))).toBe('rasterize failed')+ })++ it('returns undefined when the asset is downloadable', () => {+ expect(getExportDisabledReason(baseAsset({ has_content: true }))).toBeUndefined()+ })++ it.each([ExporterFormat.MP4, ExporterFormat.WEBM, ExporterFormat.GIF])(+ 'returns a video-specific reason for pending %s exports',+ (format) => {+ expect(getExportDisabledReason(baseAsset({ export_format: format }))).toBe(+ 'Video export is still rendering — this usually takes several minutes'+ )+ }+ )++ it('falls back to the generic reason for other formats', () => {+ expect(getExportDisabledReason(baseAsset({ export_format: ExporterFormat.PDF }))).toBe(+ 'Export not ready yet'+ )+ })+ })+})diff --git a/frontend/src/lib/components/ExportButton/exportStatus.ts b/frontend/src/lib/components/ExportButton/exportStatus.tsnew file mode 100644index 000000000000..76c5287b7ea1--- /dev/null+++ b/frontend/src/lib/components/ExportButton/exportStatus.ts@@ -0,0 +1,43 @@+import { ExportedAssetType, ExporterFormat } from '~/types'++const LONG_RUNNING_FORMATS = new Set<ExporterFormat>([ExporterFormat.MP4, ExporterFormat.WEBM, ExporterFormat.GIF])++export function isLongRunningExportFormat(format: ExporterFormat | undefined | null): boolean {+ return !!format && LONG_RUNNING_FORMATS.has(format)+}++export type ExportPendingStatus = 'rendering_video' | 'pending'++export function getExportPendingStatus(asset: ExportedAssetType): ExportPendingStatus | null {+ if (asset.has_content || asset.exception) {+ return null+ }+ if (isLongRunningExportFormat(asset.export_format)) {+ return 'rendering_video'+ }+ return 'pending'+}++export function getExportPendingLabel(asset: ExportedAssetType): string | null {+ const status = getExportPendingStatus(asset)+ if (status === 'rendering_video') {+ return 'Rendering video — usually takes several minutes'+ }+ if (status === 'pending') {+ return 'Preparing export…'+ }+ return null+}++export function getExportDisabledReason(asset: ExportedAssetType): string | undefined {+ if (asset.exception) {+ return asset.exception+ }+ if (asset.has_content) {+ return undefined+ }+ if (isLongRunningExportFormat(asset.export_format)) {+ return 'Video export is still rendering — this usually takes several minutes'+ }+ return 'Export not ready yet'+}diff --git a/frontend/src/lib/components/ExportButton/exportsLogic.test.ts b/frontend/src/lib/components/ExportButton/exportsLogic.test.tsnew file mode 100644index 000000000000..93eef766d717--- /dev/null+++ b/frontend/src/lib/components/ExportButton/exportsLogic.test.ts@@ -0,0 +1,45 @@+import { ExportedAssetType, ExporterFormat } from '~/types'++import { pickPollDelayMs } from './exportsLogic'++const asset = (overrides: Partial<ExportedAssetType> = {}): ExportedAssetType => ({+ id: 1,+ export_format: ExporterFormat.CSV,+ has_content: false,+ filename: 'export.csv',+ created_at: '2026-05-11T19:00:00Z',+ ...overrides,+})++describe('pickPollDelayMs', () => {+ it('returns the default delay when nothing is pending', () => {+ expect(pickPollDelayMs([asset({ has_content: true })])).toBe(10000)+ })++ it('returns the default delay when at least one pending asset is fast', () => {+ expect(+ pickPollDelayMs([+ asset({ id: 1, export_format: ExporterFormat.MP4 }),+ asset({ id: 2, export_format: ExporterFormat.CSV }),+ ])+ ).toBe(10000)+ })++ it('backs off when every pending asset is a long-running format', () => {+ expect(+ pickPollDelayMs([+ asset({ id: 1, export_format: ExporterFormat.MP4 }),+ asset({ id: 2, export_format: ExporterFormat.WEBM }),+ ])+ ).toBe(30000)+ })++ it('ignores assets that already have content or an exception when deciding', () => {+ expect(+ pickPollDelayMs([+ asset({ id: 1, export_format: ExporterFormat.CSV, has_content: true }),+ asset({ id: 2, export_format: ExporterFormat.MP4 }),+ ])+ ).toBe(30000)+ })+})diff --git a/frontend/src/lib/components/ExportButton/exportsLogic.ts b/frontend/src/lib/components/ExportButton/exportsLogic.tsindex e7901605587b..b7db78b7c092 100644--- a/frontend/src/lib/components/ExportButton/exportsLogic.ts+++ b/frontend/src/lib/components/ExportButton/exportsLogic.ts@@ -4,6 +4,7 @@ import { router } from 'kea-router'import api from 'lib/api'import { TriggerExportProps, downloadBlob, downloadExportedAsset } from 'lib/components/ExportButton/exporter'+import { isLongRunningExportFormat } from 'lib/components/ExportButton/exportStatus'import { dayjs } from 'lib/dayjs'import { lemonToast } from 'lib/lemon-ui/LemonToast'import { delay } from 'lib/utils'@@ -18,6 +19,20 @@ import { APIErrorType, CohortType, ExportContext, ExportedAssetType, ExporterForimport type { exportsLogicType } from './exportsLogicType'const POLL_DELAY_MS = 10000+// Long-running formats (e.g. MP4 session-replay renders) can take 30+ minutes,+// so polling every 10s produces unhelpful timeout noise. Back off when the+// pending queue is dominated by long-running formats.+const LONG_RUNNING_POLL_DELAY_MS = 30000++export const pickPollDelayMs = (pendingAssets: ExportedAssetType[]): number => {+ const pending = pendingAssets.filter((asset) => !asset.has_content && !asset.exception)+ if (pending.length === 0) {+ return POLL_DELAY_MS+ }+ return pending.every((asset) => isLongRunningExportFormat(asset.export_format))+ ? LONG_RUNNING_POLL_DELAY_MS+ : POLL_DELAY_MS+}const isLocalExport = (context: ExportContext | undefined): context is LocalExportContext =>!!(context && 'localData' in context)@@ -111,7 +126,7 @@ export const exportsLogic = kea<exportsLogicType>([// Check if any exports haven't completedconst donePolling = exportsLogic.values.exports.every((asset) => asset.has_content || asset.exception)if (!donePolling) {- await breakpoint(POLL_DELAY_MS)+ await breakpoint(pickPollDelayMs(exportsLogic.values.exports))actions.loadExports()return}diff --git a/frontend/src/scenes/exports/ExportsScene.tsx b/frontend/src/scenes/exports/ExportsScene.tsxindex 40f1cb120183..89d1a4d95bae 100644--- a/frontend/src/scenes/exports/ExportsScene.tsx+++ b/frontend/src/scenes/exports/ExportsScene.tsx@@ -6,6 +6,7 @@ import { LemonTableColumns } from '@posthog/lemon-ui'import { downloadExportedAsset, exportedAssetBlob } from 'lib/components/ExportButton/exporter'import { exportsLogic } from 'lib/components/ExportButton/exportsLogic'+import { getExportDisabledReason, getExportPendingLabel } from 'lib/components/ExportButton/exportStatus'import { takeScreenshotLogic } from 'lib/components/TakeScreenshot/takeScreenshotLogic'import { dayjs } from 'lib/dayjs'import { humanFriendlyNumber } from 'lib/utils'@@ -32,12 +33,8 @@ function ExportActions({ asset }: { asset: ExportedAssetType }): JSX.Element {const isNotDownloaded = freshUndownloadedExports.some((fresh) => fresh.id === asset.id)const stillCalculating = !asset.has_content && !asset.exception- let disabledReason: string | undefined = undefined- if (asset.exception) {- disabledReason = asset.exception- } else if (!asset.has_content) {- disabledReason = 'Export not ready yet'- }+ const disabledReason = getExportDisabledReason(asset)+ const pendingLabel = getExportPendingLabel(asset)const handleEdit = async (): Promise<void> => {const r = await exportedAssetBlob(asset)@@ -49,7 +46,12 @@ function ExportActions({ asset }: { asset: ExportedAssetType }): JSX.Element {}return (- <div className="flex gap-2 justify-end">+ <div className="flex gap-2 justify-end items-center">+ {stillCalculating && pendingLabel && (+ <span className="text-xs text-secondary" data-attr="export-pending-label">+ {pendingLabel}+ </span>+ )}{asset.export_format === ExporterFormat.PNG && (<LemonButtontooltip="Edit"