: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(replay-vision): say why a recording was skipped instead of "not scanned" (#95318)
Kim Svatos Duganfe44a24c4874
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 8e4f5a249c9e..02308cb0f8c2 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -8405,9 +8405,9 @@ snapshots:scenes-app-replay-vision--scanner-observations--light:hash: v1.k794b7964.f0551bd49f4f37ff94a346960a244b02dbdbe6798826c7c53c4d5541ebe99e74.7zBopcC7VvU8XUZehEBxzdUHTxfM1m64uoZcBXkMlXoscenes-app-replay-vision--scanner-on-demand--dark:- hash: v1.k794b7964.2a0ea0198da6166d9fb3daf278d4de9b3ec80a0e8b9234cf8a831c12424fb7d0.awEhTQe1f-gzSwOsUJz_uv7FaRwajBLmO-pgng3Gs9U+ hash: v1.k794b7964.e3c55f635fcc957d786bf810c6be7f7ba8da1287a4390314893282062f43e108._oT0AUvPgnwHst_b6VX6Op2av3k5NsOyjnquUcgTB4cscenes-app-replay-vision--scanner-on-demand--light:- hash: v1.k794b7964.d6b1a876ab50b940e9bcbe27164922f5c564a01c25c56bbc8955255a2d47173f.DOdeCbLwHWJmW1H1uAYkxdvHS2rpSR6froY4FXuOW7s+ hash: v1.k794b7964.ee354fdd1202a3489ea67393713b268bbfe711e771102c975aeab4921a61f9f7.MP0HrALcb5hmcbxbIRroM0f93rHw-v6_egWPGV-CL9Yscenes-app-replay-vision--scanner-scan-drought--dark:hash: v1.k794b7964.47963d3ee2fc2934b80cfd51b0db411baf326710d528c8995ed7eecbae4d6faa.zV2CxUwodEqwEiQT5_Tr3XAFLhkhAGTY3z8LUm97USoscenes-app-replay-vision--scanner-scan-drought--light:diff --git a/products/replay_vision/frontend/components/ObservationsDock.tsx b/products/replay_vision/frontend/components/ObservationsDock.tsxindex 07cdd01da638..d8c45c640a0c 100644--- a/products/replay_vision/frontend/components/ObservationsDock.tsx+++ b/products/replay_vision/frontend/components/ObservationsDock.tsx@@ -19,6 +19,7 @@ import { visionQuotaLogic } from '../logics/visionQuotaLogic'import { getReplayVisionEditDisabledReason } from '../utils/accessControl'import { BUILT_IN_SUMMARY_LABEL, dockObservations, isUnsuccessfulScan } from '../utils/observation'import { quotaUx } from '../utils/quotaProjection'+import { ScanBlock, recordingScanBlock } from '../utils/scanEligibility'import { VisionDocsLink, visionDocsUrl } from './DocsLink'import { ObservationDockCard } from './ObservationCard'@@ -37,7 +38,7 @@ export function ObservationsDock(): JSX.Element | null {}/** Runs whichever summarizer `resolveSummarizer` settles on, and lets the user pick another. */-function SummarizeButton({ sessionId }: { sessionId: string }): JSX.Element {+function SummarizeButton({ sessionId, scanBlock }: { sessionId: string; scanBlock: ScanBlock | null }): JSX.Element {const logic = observationsDockLogic({ sessionId })const { summarizing, defaultSummarizer, summarizerScanners } = useValues(logic)const { summarize, summarizeWith } = useActions(logic)@@ -50,11 +51,15 @@ function SummarizeButton({ sessionId }: { sessionId: string }): JSX.Element {const inFlightDisabledReason = summarizing ? 'A summary is already running' : null// Both paths are scanner writes: an inline scan mints a scanner, and `observe` is a write action on// the scanner it runs. Each also exposes recording contents, so both need recording read as well.- const builtInDisabledReason = inFlightDisabledReason ?? getReplayVisionEditDisabledReason() ?? quotaDisabledReason+ // A recording the scan-time gate would refuse is refused for every summarizer, so it blocks the+ // button and each menu row rather than spending a scan that comes back ineligible.+ const builtInDisabledReason =+ inFlightDisabledReason ?? getReplayVisionEditDisabledReason() ?? scanBlock?.reason ?? quotaDisabledReason// Object-level, so a scanner this user cannot edit is disabled rather than answering with a 403.const scannerDisabledReason = (scanner: ReplayScannerApi): string | null | undefined =>inFlightDisabledReason ??getReplayVisionEditDisabledReason(scanner.user_access_level as AccessControlLevel | null) ??+ scanBlock?.reason ??quotaDisabledReason// Nobody could tell which summarizer the button used, so it says so.const label = defaultSummarizer ? `Summarize with ${defaultSummarizer.name}` : 'Summarize this recording'@@ -178,10 +183,11 @@ function ObservationsDockContent({ sessionId }: { sessionId: string }): JSX.Elemconst { setDockOpen, retryObservation } = useActions(logic)// sessionRecordingPlayerLogic is keyed by playerKey+sessionRecordingId; seek the exact mounted// player by its bound props rather than a propless default instance.- const { logicProps } = useValues(sessionRecordingPlayerLogic)+ const { logicProps, sessionPlayerMetaData } = useValues(sessionRecordingPlayerLogic)const seekToTime = (ms: number): void => {sessionRecordingPlayerLogic.findMounted(logicProps)?.actions.seekToTime(ms)}+ const scanBlock = recordingScanBlock(sessionPlayerMetaData)const dockRef = useRef<HTMLDivElement>(null)const resizerProps: ResizerLogicProps = {@@ -212,8 +218,18 @@ function ObservationsDockContent({ sessionId }: { sessionId: string }): JSX.Elem>{dockOpen && <Resizer {...resizerProps} />}<div className="flex items-center gap-2 lg:gap-3 h-11 px-3 shrink-0">- <SummarizeButton sessionId={sessionId} />+ <SummarizeButton sessionId={sessionId} scanBlock={scanBlock} /><SummarizeExplainer />+ {scanBlock &&+ !hasContent && (+ // Collapsed with nothing to expand, the disabled button's tooltip is the only place+ // the skip is explained, so the bar says it outright.+ <Tooltip title={scanBlock.reason}>+ <span className="ml-auto text-muted text-xs truncate" data-attr="vision-dock-skipped">+ Skipped: {scanBlock.label.toLowerCase()}+ </span>+ </Tooltip>+ )}{hasContent && (<div className="ml-auto flex items-center gap-2 min-w-0">{!dockOpen && unsuccessfulCount > 0 && (@@ -241,6 +257,13 @@ function ObservationsDockContent({ sessionId }: { sessionId: string }): JSX.Elem<div className="flex items-center gap-2 text-muted py-4"><Spinner /> Loading summaries…</div>+ ) : shown.length === 0 && scanBlock ? (+ <div className="text-muted text-sm py-4">+ Replay vision skipped this recording, so it has no summary. {scanBlock.reason}{' '}+ <VisionDocsLink page="observations" dataAttr="vision-skipped-docs-link-dock">+ Learn how observations work+ </VisionDocsLink>+ </div>) : shown.length === 0 ? (<div className="text-muted text-sm py-4">No summary yet. Summarize this recording to generate one.{' '}diff --git a/products/replay_vision/frontend/components/PlayerSidebarObservationsTab.tsx b/products/replay_vision/frontend/components/PlayerSidebarObservationsTab.tsxindex e49ff97f22e2..a0ee2c745aee 100644--- a/products/replay_vision/frontend/components/PlayerSidebarObservationsTab.tsx+++ b/products/replay_vision/frontend/components/PlayerSidebarObservationsTab.tsx@@ -11,6 +11,7 @@ import type { ReplayScannerApi } from '../generated/api.schemas'import { observationsDockLogic } from '../logics/observationsDockLogic'import { visionQuotaLogic } from '../logics/visionQuotaLogic'import { quotaUx } from '../utils/quotaProjection'+import { ScanBlock, recordingScanBlock } from '../utils/scanEligibility'import { visionSurfaceShown } from '../utils/visionSurface'import { ObservationDockCard } from './ObservationCard'import { ScannerTypeBadge } from './ScannerTypeBadge'@@ -27,10 +28,12 @@ export function PlayerSidebarObservationsTab(): JSX.Element | null {function ScannerPicker({sessionId,+ scanBlock,type = 'primary',placement = 'bottom-start',}: {sessionId: string+ scanBlock: ScanBlock | nulltype?: 'primary' | 'secondary'placement?: 'bottom-start' | 'top-start'}): JSX.Element {@@ -100,7 +103,7 @@ function ScannerPicker({icon={<IconEye />}sideIcon={<IconChevronDown />}loading={observing}- disabledReason={quotaDisabledReason}+ disabledReason={scanBlock?.reason ?? quotaDisabledReason}tooltip={quotaTooltip}data-attr="vision-scan-recording">@@ -115,10 +118,11 @@ function ObservationsTabContent({ sessionId }: { sessionId: string }): JSX.Elemeconst { observations, observationsLoading, retryingObservationIds } = useValues(logic)const { retryObservation } = useActions(logic)// The player logic is keyed; seek the exact mounted instance, not a propless default- const { logicProps } = useValues(sessionRecordingPlayerLogic)+ const { logicProps, sessionPlayerMetaData } = useValues(sessionRecordingPlayerLogic)const seekToTime = (ms: number): void => {sessionRecordingPlayerLogic.findMounted(logicProps)?.actions.seekToTime(ms)}+ const scanBlock = recordingScanBlock(sessionPlayerMetaData)return (<div className="flex flex-col flex-1 min-h-0" data-attr="vision-observations-tab">@@ -128,10 +132,23 @@ function ObservationsTabContent({ sessionId }: { sessionId: string }): JSX.Eleme</div>) : observations.length === 0 ? (<div className="flex flex-col flex-1 items-center justify-center gap-2 p-4 text-center">- <p className="text-muted text-sm mb-0">- No observations yet. Pick a scanner to run on this recording.- </p>- <ScannerPicker sessionId={sessionId} />+ {scanBlock ? (+ // No scanner can clear the gate for this recording, so offering the picker would+ // only lead to an ineligible result.+ <>+ <p className="text-muted text-sm mb-0" data-attr="vision-observations-tab-skipped">+ Replay vision skipped this recording, so it has no summary.+ </p>+ <p className="text-muted text-xs mb-0">{scanBlock.reason}</p>+ </>+ ) : (+ <>+ <p className="text-muted text-sm mb-0">+ No observations yet. Pick a scanner to run on this recording.+ </p>+ <ScannerPicker sessionId={sessionId} scanBlock={scanBlock} />+ </>+ )}</div>) : (<div className="flex-1 overflow-y-auto p-2 space-y-2">@@ -145,7 +162,12 @@ function ObservationsTabContent({ sessionId }: { sessionId: string }): JSX.Eleme/>))}<div className="flex justify-center">- <ScannerPicker sessionId={sessionId} type="secondary" placement="top-start" />+ <ScannerPicker+ sessionId={sessionId}+ scanBlock={scanBlock}+ type="secondary"+ placement="top-start"+ /></div></div>)}diff --git a/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx b/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsxindex 3f5c49c82e7c..ef808b6813bc 100644--- a/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx+++ b/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx@@ -398,6 +398,58 @@ const observationsTrend = {],}+// Recordings for the on-demand picker, one per status the list can show: a session the scanner+// already observed, one it has not reached, and two the eligibility gate refuses.+const recording = (overrides: Record<string, any>): Record<string, any> => ({+ distinct_id: 'user_8f3k2j',+ viewed: false,+ viewers: [],+ recording_duration: 240,+ active_seconds: 95,+ inactive_seconds: 145,+ start_time: '2026-05-11T09:00:00Z',+ end_time: '2026-05-11T09:04:00Z',+ click_count: 18,+ keypress_count: 9,+ mouse_activity_count: 64,+ console_log_count: 0,+ console_warn_count: 0,+ console_error_count: 0,+ start_url: 'https://app.example.com/checkout',+ person: {+ id: 1001,+ name: '[email protected]',+ distinct_ids: ['user_8f3k2j'],+ properties: { email: '[email protected]' },+ created_at: '2026-05-01T00:00:00Z',+ uuid: '00000000-0000-0000-0000-0000000000f1',+ },+ snapshot_source: 'web',+ ongoing: false,+ ...overrides,+})++const onDemandRecordings = [+ // Already observed: shares a session id with the succeeded observation above.+ recording({ id: '01966b3f-70a1-7c52-a4d5-3f9b2e8c1d07' }),+ recording({ id: '01966b3f-70a1-7c52-a4d5-3f9b2e8c1e01' }),+ // Over the active-time ceiling, so the scan-time gate would refuse it.+ recording({+ id: '01966b3f-70a1-7c52-a4d5-3f9b2e8c1e02',+ recording_duration: 10_800,+ active_seconds: 4_320,+ inactive_seconds: 6_480,+ end_time: '2026-05-11T12:00:00Z',+ }),+ recording({+ id: '01966b3f-70a1-7c52-a4d5-3f9b2e8c1e03',+ recording_duration: 9,+ active_seconds: 6,+ inactive_seconds: 3,+ end_time: '2026-05-11T09:00:09Z',+ }),+]+const paginated = (names: string[]): Record<string, any> => ({count: names.length,next: null,@@ -440,6 +492,8 @@ const meta: Meta = {evaluation_session_cap: 25,},'/api/projects/:team_id/vision/observations/:id/': observationDetail,+ '/api/environments/:team_id/session_recordings/': { results: onDemandRecordings, has_next: false },+ '/api/environments/:team_id/session_recordings/matching_events': { results: [] },'/api/projects/:team_id/signals/scout/configs/': [],'/api/projects/:team_id/signals/scout/runs/recent-per-scout/': [],'/api/projects/:team_id/signals/scout/runs/findings/summary/': [],diff --git a/products/replay_vision/frontend/replay_scanners/components/ScannerRunTab.tsx b/products/replay_vision/frontend/replay_scanners/components/ScannerRunTab.tsxindex 9393a1454bf1..b3a69037f363 100644--- a/products/replay_vision/frontend/replay_scanners/components/ScannerRunTab.tsx+++ b/products/replay_vision/frontend/replay_scanners/components/ScannerRunTab.tsx@@ -2,7 +2,7 @@ import { BindLogic, useActions, useValues } from 'kea'import { useEffect, useRef, useState } from 'react'import { IconEye, IconPlay } from '@posthog/icons'-import { LemonButton, LemonInput, LemonTable, Link, Spinner } from '@posthog/lemon-ui'+import { LemonButton, LemonInput, LemonTable, LemonTag, Link, Spinner, Tooltip } from '@posthog/lemon-ui'import { TZLabel } from 'lib/components/TZLabel'import { LemonTableColumns } from 'lib/lemon-ui/LemonTable'@@ -22,6 +22,7 @@ import { SessionRecordingType } from '~/types'import { ObservationStatusTag } from '../../components/ObservationCard'import { getReplayVisionEditDisabledReason } from '../../utils/accessControl'+import { recordingScanBlock } from '../../utils/scanEligibility'import { replayScannerLogic } from '../replayScannerLogic'import { IN_PROGRESS_STATUSES, scannerRunTabLogic } from '../scannerRunTabLogic'@@ -143,7 +144,28 @@ function RecordingsList({ scannerId }: { scannerId: string }): JSX.Element {if (pendingId === recording.id) {return <ObservationStatusTag status="running" errorReason={null} />}- return <span className="text-muted italic">Not scanned</span>+ // Skipped, not merely unscanned: this recording can't clear the scan-time gate, so the+ // scheduled run passed it over and an on-demand scan would land on the same answer.+ const scanBlock = recordingScanBlock(recording)+ if (scanBlock) {+ return (+ <Tooltip+ title={+ <div className="flex flex-col gap-1">+ <div>{scanBlock.label}</div>+ <div className="text-xs opacity-80">{scanBlock.reason}</div>+ </div>+ }+ >+ <LemonTag type="muted">Skipped</LemonTag>+ </Tooltip>+ )+ }+ return (+ <Tooltip title="This scanner hasn't run on this recording yet. Scheduled runs only cover recordings that match the scanner's triggers and sampling, so scan it here to get a result now.">+ <span className="text-muted italic">Not scanned</span>+ </Tooltip>+ )},},{@@ -174,6 +196,9 @@ function RecordingsList({ scannerId }: { scannerId: string }): JSX.Element {</LemonButton>)} else {+ // The gate would refuse this recording, so the button says why rather than spending+ // a scan that comes back ineligible.+ const scanBlock = recordingScanBlock(recording)content = (<LemonButtonfullWidth@@ -183,6 +208,7 @@ function RecordingsList({ scannerId }: { scannerId: string }): JSX.Element {icon={<IconPlay />}disabledReason={editDisabledReason ??+ scanBlock?.reason ??(scanning? 'Scan in progress…': pendingId && pendingId !== recording.id@@ -223,11 +249,15 @@ function RecordingsList({ scannerId }: { scannerId: string }): JSX.Element {bulkSelection={{noun: ['recording', 'recordings'],// Only not-yet-scanned rows are selectable — a scanned or in-flight session has nothing- // to (re)scan, matching the per-row button that swaps to "View observation".- isRowSelectable: (recording) =>- observationBySession[recording.id] || pendingId === recording.id- ? { disabledReason: 'Already scanned' }- : true,+ // to (re)scan, matching the per-row button that swaps to "View observation". Rows the+ // gate would refuse are out too, so a bulk run can't spend scans on them.+ isRowSelectable: (recording) => {+ if (observationBySession[recording.id] || pendingId === recording.id) {+ return { disabledReason: 'Already scanned' }+ }+ const scanBlock = recordingScanBlock(recording)+ return scanBlock ? { disabledReason: scanBlock.reason } : true+ },renderActions: ({ selectedKeys, selectedCount, clearSelection }) => (<LemonButtontype="primary"diff --git a/products/replay_vision/frontend/replay_scanners/types.ts b/products/replay_vision/frontend/replay_scanners/types.tsindex c0680c2c10cc..4ccdc1854297 100644--- a/products/replay_vision/frontend/replay_scanners/types.ts+++ b/products/replay_vision/frontend/replay_scanners/types.ts@@ -251,6 +251,10 @@ export function ineligibleKindDescription(kind: IneligibleKind): string {return INELIGIBLE_KINDS[kind].description}+export function ineligibleKindLabel(kind: IneligibleKind): string {+ return INELIGIBLE_KINDS[kind].label+}+export const DEFAULT_PROVIDER = 'google'export const DEFAULT_MODEL: ScannerModelEnumApi = ScannerModelEnumApi.Gemini3FlashPreviewdiff --git a/products/replay_vision/frontend/utils/scanEligibility.test.ts b/products/replay_vision/frontend/utils/scanEligibility.test.tsnew file mode 100644index 000000000000..43abe251c9fa--- /dev/null+++ b/products/replay_vision/frontend/utils/scanEligibility.test.ts@@ -0,0 +1,33 @@+import { SessionRecordingType } from '~/types'++import { recordingScanBlock } from './scanEligibility'++describe('recordingScanBlock', () => {+ const recording = (partial: Partial<SessionRecordingType>): SessionRecordingType =>+ ({ id: 'session-1', recording_duration: 300, active_seconds: 120, ...partial }) as SessionRecordingType++ it('clears a recording the gate accepts', () => {+ expect(recordingScanBlock(recording({}))).toBeNull()+ })++ it('has nothing to say without metadata', () => {+ expect(recordingScanBlock(null)).toBeNull()+ expect(recordingScanBlock(recording({ recording_duration: undefined, active_seconds: undefined }))).toBeNull()+ })++ it.each([+ ['too_long', { recording_duration: 10800, active_seconds: 4200 }],+ ['too_short', { recording_duration: 8, active_seconds: 8 }],+ ['too_inactive', { recording_duration: 600, active_seconds: 4 }],+ ])('blocks %s recordings with the numbers behind it', (kind, metadata) => {+ const block = recordingScanBlock(recording(metadata))+ expect(block?.kind).toEqual(kind)+ expect(block?.reason).toContain('Replay vision')+ })++ it('holds off on the minimums while a recording is still going', () => {+ expect(recordingScanBlock(recording({ recording_duration: 8, active_seconds: 4, ongoing: true }))).toBeNull()+ // Active time only grows, so the maximum still applies.+ expect(recordingScanBlock(recording({ active_seconds: 4200, ongoing: true }))?.kind).toEqual('too_long')+ })+})diff --git a/products/replay_vision/frontend/utils/scanEligibility.ts b/products/replay_vision/frontend/utils/scanEligibility.tsnew file mode 100644index 000000000000..76aa433e64c1--- /dev/null+++ b/products/replay_vision/frontend/utils/scanEligibility.ts@@ -0,0 +1,60 @@+import { humanFriendlyDuration } from 'lib/utils/durations'++import { SessionRecordingType } from '~/types'++import { IneligibleKind, ineligibleKindLabel } from '../replay_scanners/types'++// Mirror: keep in sync with products/replay_vision/backend/session_limits.py, which the scan-time gate reads.+const MIN_SESSION_DURATION_S = 15+const MIN_ACTIVE_SECONDS_S = 10+const MAX_ACTIVE_SECONDS_S = 3600++export interface ScanBlock {+ kind: IneligibleKind+ /** Short label for a status cell. */+ label: string+ /** Why this recording cannot be scanned, in terms of its own numbers. Stands alone as a tooltip. */+ reason: string+}++type ScannableRecording = Pick<SessionRecordingType, 'recording_duration' | 'active_seconds' | 'ongoing'>++function block(kind: IneligibleKind, reason: string): ScanBlock {+ return { kind, label: ineligibleKindLabel(kind), reason }+}++/**+ * Whether the scan-time eligibility gate will refuse this recording, decided from the metadata the+ * recordings list and the player already hold. Null means we cannot tell from here, so the scan stays+ * on offer and the backend remains the authority. A recording that is still going can still grow past+ * the minimums, so only the maximum applies to it.+ */+export function recordingScanBlock(recording: ScannableRecording | null | undefined): ScanBlock | null {+ if (!recording) {+ return null+ }+ const activeSeconds = recording.active_seconds+ const duration = recording.recording_duration+ if (typeof activeSeconds === 'number' && activeSeconds > MAX_ACTIVE_SECONDS_S) {+ return block(+ 'too_long',+ `This recording has ${humanFriendlyDuration(activeSeconds)} of active time, and Replay vision can scan up to ${humanFriendlyDuration(MAX_ACTIVE_SECONDS_S)}.`+ )+ }+ if (recording.ongoing) {+ return null+ }+ if (typeof duration === 'number' && duration < MIN_SESSION_DURATION_S) {+ return block(+ 'too_short',+ `This recording is ${humanFriendlyDuration(duration)} long, and Replay vision needs at least ${humanFriendlyDuration(MIN_SESSION_DURATION_S)}.`+ )+ }+ if (typeof activeSeconds === 'number' && activeSeconds < MIN_ACTIVE_SECONDS_S) {+ return block(+ 'too_inactive',+ `This recording has ${humanFriendlyDuration(activeSeconds)} of active time, and Replay vision needs at least ${humanFriendlyDuration(MIN_ACTIVE_SECONDS_S)}.`+ )+ }+ return null+}