: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(replay-vision): general UI updates for overview pages (#62539)
Hayne Ryu84fe804be675
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 581937c83f7e..b37993d53e64 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -5747,9 +5747,9 @@ snapshots:scenes-app-promoted-product--intent-with-product--light:hash: v1.k794b7964.a520d81ca3c66ae61e8fa10602ed5f40da3d97bee4efd9daf03009c238a8b0dc.Ruf-wJ_f_UjycVlKd7vE_z2t-r_SY8cC5bO-NSR0Ao4scenes-app-replay-vision--scanners-list--dark:- hash: v1.k794b7964.799b429ca99dca7adb8cdd95f91e011bd63158763e8a16605da222f8523dc844.3Rnmy2I38dZUyEx1G59wDeho1bwV-oWF8EMtJIQmpeE+ hash: v1.k794b7964.b46d148cb8d9443426fed34b834bb1c5d7c103d70130dc9e50229ce299dd6a8e.madlZ-FFyoU5KZuEtmAMLDlpPhkJd9rERHqVaco4TkQscenes-app-replay-vision--scanners-list--light:- hash: v1.k794b7964.7d5fe1b0fee217479a9ac2b87cf5bf86f167d246c88a136694706ff951866637.bY8VMFOdL1WFJqfU6IrUkYl1Y7k4_LcEjwHYTjHSS1c+ hash: v1.k794b7964.498983062797fa546436034f824fbae467678dc342e693c140389b615804679f.YxqzOmHvrqE9h81CC2VMBT_NHuwvvdyMqMdO1BUVR-kscenes-app-revenue-analytics--revenue-analytics-dashboard--dark:hash: v1.k794b7964.7c2a90fe3c3a969c054186bb666664efa891d65d411a546539a968518938ea71.OoOKh-Mc_IiPWTgIV4QNPtACZXPPktfU7bjGk-q-uLEscenes-app-revenue-analytics--revenue-analytics-dashboard--light:diff --git a/products/replay_vision/backend/api/observation_stats.py b/products/replay_vision/backend/api/observation_stats.pyindex 0e9c1bbbdba1..23b0e0ade21d 100644--- a/products/replay_vision/backend/api/observation_stats.py+++ b/products/replay_vision/backend/api/observation_stats.py@@ -16,16 +16,23 @@ from django.utils import timezonefrom products.replay_vision.backend.models.replay_observation import ObservationStatus, ReplayObservationfrom products.replay_vision.backend.models.replay_scanner import ReplayScanner, ScannerType-_RECENT_DAYS = 14+_DEFAULT_RECENT_DAYS = 14+_MAX_RECENT_DAYS = 365_HISTOGRAM_BUCKET_TARGET = 21_TOP_TAGS = 10-def compute_observation_stats(scanner: ReplayScanner, queryset: QuerySet[ReplayObservation]) -> dict[str, Any]:+def compute_observation_stats(+ scanner: ReplayScanner,+ queryset: QuerySet[ReplayObservation],+ recent_days: int = _DEFAULT_RECENT_DAYS,+) -> dict[str, Any]:+ # Clamp so a hostile or stale client can't ask for "last 9,999 days" or 0.+ clamped_recent_days = max(1, min(recent_days, _MAX_RECENT_DAYS))status_counts = _status_counts(queryset)payload: dict[str, Any] = {"status_counts": status_counts,- "coverage": _coverage(queryset),+ "coverage": _coverage(queryset, clamped_recent_days),"available_tags": [],"monitor": None,"classifier": None,@@ -65,8 +72,8 @@ def _status_counts(queryset: QuerySet[ReplayObservation]) -> dict[str, Any]:}-def _coverage(queryset: QuerySet[ReplayObservation]) -> dict[str, Any]:- cutoff = timezone.now() - timedelta(days=_RECENT_DAYS)+def _coverage(queryset: QuerySet[ReplayObservation], recent_days: int) -> dict[str, Any]:+ cutoff = timezone.now() - timedelta(days=recent_days)with_sessions = queryset.exclude(session_id="")aggregates = with_sessions.aggregate(total=Count("session_id", distinct=True),@@ -75,7 +82,7 @@ def _coverage(queryset: QuerySet[ReplayObservation]) -> dict[str, Any]:return {"recent_sessions": aggregates["recent"] or 0,"total_sessions": aggregates["total"] or 0,- "recent_days": _RECENT_DAYS,+ "recent_days": recent_days,}diff --git a/products/replay_vision/backend/api/observations.py b/products/replay_vision/backend/api/observations.pyindex ebac37a093df..68f6cc1afca2 100644--- a/products/replay_vision/backend/api/observations.py+++ b/products/replay_vision/backend/api/observations.py@@ -442,7 +442,19 @@ class ReplayObservationViewSet()@extend_schema(- parameters=ReplayObservationFilter.schema_parameters(),+ parameters=[+ *ReplayObservationFilter.schema_parameters(),+ OpenApiParameter(+ "recent_days",+ int,+ OpenApiParameter.QUERY,+ description=(+ "Window size in days for the coverage `recent_sessions` count. Clamped to [1, 365]. "+ "Defaults to 14 when omitted."+ ),+ required=False,+ ),+ ],responses={200: ObservationStatsSerializer},description=("Aggregate counts and per-scanner-type distributions over the filtered observation set. "@@ -453,7 +465,12 @@ class ReplayObservationViewSet(def stats(self, request: Request, **kwargs: Any) -> Response:scanner = self._scanner_for_url()queryset = self.filter_queryset(self.get_queryset())- payload = compute_observation_stats(scanner, queryset)+ recent_days_raw = request.query_params.get("recent_days")+ try:+ recent_days = int(recent_days_raw) if recent_days_raw is not None else 14+ except (TypeError, ValueError):+ recent_days = 14+ payload = compute_observation_stats(scanner, queryset, recent_days=recent_days)return Response(payload)diff --git a/products/replay_vision/frontend/generated/api.schemas.ts b/products/replay_vision/frontend/generated/api.schemas.tsindex 94326d845b5d..ab8f50ab5540 100644--- a/products/replay_vision/frontend/generated/api.schemas.ts+++ b/products/replay_vision/frontend/generated/api.schemas.ts@@ -610,6 +610,10 @@ export type VisionScannersObservationsListParams = {}export type VisionScannersObservationsStatsRetrieveParams = {+ /**+ * Window size in days for the coverage `recent_sessions` count. Clamped to [1, 365]. Defaults to 14 when omitted.+ */+ recent_days?: number/*** Filter to observations of a specific session recording.*/diff --git a/products/replay_vision/frontend/replay_scanners/ReplayScanner.tsx b/products/replay_vision/frontend/replay_scanners/ReplayScanner.tsxindex 570756aa3c01..815f9937b6b4 100644--- a/products/replay_vision/frontend/replay_scanners/ReplayScanner.tsx+++ b/products/replay_vision/frontend/replay_scanners/ReplayScanner.tsx@@ -58,6 +58,20 @@ export function ReplayScannerSceneComponent(): JSX.Element {actions={<><ReplayVisionFeedbackButton />+ <AccessControlAction+ resourceType={AccessControlResourceType.SessionRecording}+ minAccessLevel={AccessControlLevel.Editor}+ >+ <LemonButton+ type="primary"+ size="small"+ to={urls.replayVisionScannerConfigure(scannerId)}+ data-attr="vision-scanner-edit"+ data-ph-capture-attribute-scanner-type={scanner.scanner_type}+ >+ Edit scanner+ </LemonButton>+ </AccessControlAction><Moresize="small"overlay={@@ -91,34 +105,20 @@ export function ReplayScannerSceneComponent(): JSX.Element {<ScannerOverview scannerId={scannerId} />- <LemonCollapse- panels={[- {- key: 'configuration',- header: 'Configuration',- content: <ScannerConfigReadonly scanner={scanner} />,- dataAttr: 'vision-scanner-config-expand',- },- ]}- />- <div className="flex items-center justify-end">- <AccessControlAction- resourceType={AccessControlResourceType.SessionRecording}- minAccessLevel={AccessControlLevel.Editor}- >- <LemonButton- type="primary"- to={urls.replayVisionScannerConfigure(scannerId)}- data-attr="vision-scanner-edit"- data-ph-capture-attribute-scanner-type={scanner.scanner_type}- >- Edit scanner- </LemonButton>- </AccessControlAction>+ <div className="flex flex-col gap-2">+ <LemonCollapse+ panels={[+ {+ key: 'configuration',+ header: 'Configuration',+ content: <ScannerConfigReadonly scanner={scanner} />,+ dataAttr: 'vision-scanner-config-expand',+ },+ ]}+ />+ <SummarizerMaxChat scannerId={scannerId} />+ <ScannerObservationsTable scannerId={scannerId} /></div>-- <SummarizerMaxChat scannerId={scannerId} />- <ScannerObservationsTable scannerId={scannerId} /></SceneContent>)}diff --git a/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.tsx b/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.tsxindex be219ff572a0..3f11018da7be 100644--- a/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.tsx+++ b/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.tsx@@ -14,7 +14,6 @@ import { SceneExport } from 'scenes/sceneTypes'import { urls } from 'scenes/urls'import { SceneContent } from '~/layout/scenes/components/SceneContent'-import { SceneSection } from '~/layout/scenes/components/SceneSection'import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'import { ProductKey } from '~/queries/schema/schema-general'import { AccessControlLevel, AccessControlResourceType } from '~/types'@@ -199,7 +198,25 @@ export function ReplayScannersScene(): JSX.Element {name="Replay vision"description="Set up AI scanners that automatically analyze new session recordings as they come in. Each result emits a queryable event."resourceType={{ type: 'replay_vision' }}- actions={<ReplayVisionFeedbackButton />}+ actions={+ <>+ <ReplayVisionFeedbackButton />+ <AccessControlAction+ resourceType={AccessControlResourceType.SessionRecording}+ minAccessLevel={AccessControlLevel.Editor}+ >+ <LemonButton+ type="primary"+ size="small"+ icon={<IconPlus />}+ to={urls.replayVisionTemplates()}+ data-attr="vision-scanner-create"+ >+ New scanner+ </LemonButton>+ </AccessControlAction>+ </>+ }/><ProductIntroduction@@ -214,35 +231,18 @@ export function ReplayScannersScene(): JSX.Element {{(scannerStats?.total ?? 0) > 0 && <VisionMetrics />}- <SceneSection- title="Scanners"- actions={- <AccessControlAction- resourceType={AccessControlResourceType.SessionRecording}- minAccessLevel={AccessControlLevel.Editor}- >- <LemonButton- type="primary"- icon={<IconPlus />}- to={urls.replayVisionTemplates()}- data-attr="vision-scanner-create"- >- New scanner- </LemonButton>- </AccessControlAction>- }- >- <div className="flex flex-wrap items-center gap-2">- <LemonInput- type="search"- placeholder="Search scanners..."- value={search}- onChange={(v) => setScannersFilters({ search: v })}- prefix={<IconSearch />}- className="max-w-sm"- />- <div className="ml-auto flex flex-wrap items-center gap-2">- <ReplayVisionFeedbackButton label="Feedback?" type="tertiary" />+ <div className="flex flex-col gap-3">+ <div className="flex items-center gap-2">+ <h3 className="font-semibold text-base m-0">Scanners</h3>+ <div className="ml-auto flex items-center gap-2">+ <LemonInput+ type="search"+ placeholder="Search scanners..."+ value={search}+ onChange={(v) => setScannersFilters({ search: v })}+ prefix={<IconSearch />}+ className="max-w-sm"+ /><FilterPill<EnabledFilter>label="Status"options={ENABLED_OPTIONS}@@ -313,7 +313,7 @@ export function ReplayScannersScene(): JSX.Element {)}/>- </SceneSection>+ </div></SceneContent>)}diff --git a/products/replay_vision/frontend/replay_scanners/components/ScannerConfigReadonly.tsx b/products/replay_vision/frontend/replay_scanners/components/ScannerConfigReadonly.tsxindex f61a333375dc..256f1e896763 100644--- a/products/replay_vision/frontend/replay_scanners/components/ScannerConfigReadonly.tsx+++ b/products/replay_vision/frontend/replay_scanners/components/ScannerConfigReadonly.tsx@@ -1,4 +1,4 @@-import { LemonTag } from '@posthog/lemon-ui'+import { LemonCard, LemonTag } from '@posthog/lemon-ui'import { PropertyFilterButton } from 'lib/components/PropertyFilters/components/PropertyFilterButton'@@ -8,46 +8,37 @@ import { ReplayScanner, modelLabel, scannerTypeLabel } from '../types'function Row({ label, children }: { label: string; children: React.ReactNode }): JSX.Element {return (- <div className="flex flex-col gap-1">- <div className="text-xs font-medium text-muted uppercase tracking-wide">{label}</div>+ <div>+ <div className="text-xs text-muted mb-0.5">{label}</div><div className="text-sm">{children}</div></div>)}function Multiline({ value }: { value: string | null | undefined }): JSX.Element {- return <div className="whitespace-pre-wrap">{value || <span className="text-muted">—</span>}</div>+ return <div className="whitespace-pre-wrap text-sm">{value || <span className="text-muted">—</span>}</div>}-export function ScannerConfigReadonly({ scanner }: { scanner: ReplayScanner }): JSX.Element {- const samplingPercent = Math.round((scanner.sampling_rate ?? 0) * 1000) / 10- const filters = (scanner.query?.properties ?? []) as AnyPropertyFilter[]-+function YesNoTag({ value }: { value: boolean }): JSX.Element {return (- <div className="flex flex-col gap-5">- <div className="grid grid-cols-2 gap-5">- <Row label="Type">- <LemonTag type="option">{scannerTypeLabel(scanner.scanner_type)}</LemonTag>- </Row>- <Row label="Sampling">{samplingPercent}%</Row>- </div>-- <Row label="Description">- <Multiline value={scanner.description} />- </Row>+ <LemonTag size="medium" type={value ? 'success' : 'default'} className="self-start">+ {value ? 'Yes' : 'No'}+ </LemonTag>+ )+}+function BehaviorCardContent({ scanner }: { scanner: ReplayScanner }): JSX.Element {+ return (+ <><Row label="Prompt"><Multiline value={scanner.scanner_config.prompt} /></Row>-{scanner.scanner_type === 'summarizer' && <Row label="Summary length">{scanner.scanner_config.length}</Row>}-{scanner.scanner_type === 'monitor' && (<Row label="Allow inconclusive verdicts">- {scanner.scanner_config.allow_inconclusive ? 'Yes' : 'No'}+ <YesNoTag value={!!scanner.scanner_config.allow_inconclusive} /></Row>)}-{scanner.scanner_type === 'classifier' && (<><Row label="Tag vocabulary">@@ -63,36 +54,72 @@ export function ScannerConfigReadonly({ scanner }: { scanner: ReplayScanner }):<span className="text-muted">—</span>)}</Row>- <div className="grid grid-cols-2 gap-5">- <Row label="Multiple tags per session">{scanner.scanner_config.multi_label ? 'Yes' : 'No'}</Row>- <Row label="Freeform tags">{scanner.scanner_config.allow_freeform_tags ? 'Yes' : 'No'}</Row>- </div>+ <Row label="Multiple tags per session">+ <YesNoTag value={!!scanner.scanner_config.multi_label} />+ </Row>+ <Row label="Freeform tags">+ <YesNoTag value={!!scanner.scanner_config.allow_freeform_tags} />+ </Row></>)}-{scanner.scanner_type === 'scorer' && (<Row label="Scale">{scanner.scanner_config.scale.min} – {scanner.scanner_config.scale.max}{scanner.scanner_config.scale.label ? ` (${scanner.scanner_config.scale.label})` : ''}</Row>)}+ </>+ )+}- <Row label="Recording filters">- {filters.length === 0 ? (- <span className="text-muted">All completed recordings</span>- ) : (- <div className="flex flex-wrap gap-1">- {filters.map((filter, i) => (- <PropertyFilterButton key={i} item={filter} />- ))}- </div>- )}- </Row>+export function ScannerConfigReadonly({ scanner }: { scanner: ReplayScanner }): JSX.Element {+ const samplingPercent = Math.round((scanner.sampling_rate ?? 0) * 1000) / 10+ const filters = (scanner.query?.properties ?? []) as AnyPropertyFilter[]++ return (+ <div className="grid grid-cols-1 lg:grid-cols-3 gap-4">+ <LemonCard className="p-4" hoverEffect={false}>+ <div className="text-sm font-medium mb-3">Overview</div>+ <div className="flex flex-col gap-3">+ <Row label="Type">+ <LemonTag type="option" className="self-start">+ {scannerTypeLabel(scanner.scanner_type)}+ </LemonTag>+ </Row>+ <Row label="Description">+ <Multiline value={scanner.description} />+ </Row>+ </div>+ </LemonCard>- <div className="grid grid-cols-2 gap-5">- <Row label="Model">{modelLabel(scanner.model)}</Row>- <Row label="Emit signals">{scanner.emits_signals ? 'Yes' : 'No'}</Row>- </div>+ <LemonCard className="p-4" hoverEffect={false}>+ <div className="text-sm font-medium mb-3">Behavior</div>+ <div className="flex flex-col gap-3">+ <BehaviorCardContent scanner={scanner} />+ </div>+ </LemonCard>++ <LemonCard className="p-4" hoverEffect={false}>+ <div className="text-sm font-medium mb-3">Triggers & runtime</div>+ <div className="flex flex-col gap-3">+ <Row label="Sampling">{samplingPercent}%</Row>+ <Row label="Recording filters">+ {filters.length === 0 ? (+ <span className="text-muted">All completed recordings</span>+ ) : (+ <div className="flex flex-wrap gap-1">+ {filters.map((filter, i) => (+ <PropertyFilterButton key={i} item={filter} />+ ))}+ </div>+ )}+ </Row>+ <Row label="Model">{modelLabel(scanner.model)}</Row>+ <Row label="Emit signals">+ <YesNoTag value={scanner.emits_signals} />+ </Row>+ </div>+ </LemonCard></div>)}diff --git a/products/replay_vision/frontend/replay_scanners/components/ScannerInsightsChart.tsx b/products/replay_vision/frontend/replay_scanners/components/ScannerInsightsChart.tsxindex 9d7e18afbb2c..50bbd2b17d06 100644--- a/products/replay_vision/frontend/replay_scanners/components/ScannerInsightsChart.tsx+++ b/products/replay_vision/frontend/replay_scanners/components/ScannerInsightsChart.tsx@@ -149,7 +149,7 @@ export function ScannerInsightsChart({scannerId: stringscannerType: ScannerType}): JSX.Element {- const { chartDateFrom, chartDateTo } = useValues(replayScannerLogic({ id: scannerId }))+ const { chartDateFrom, chartDateTo, coverageStats } = useValues(replayScannerLogic({ id: scannerId }))const { setChartDateRange } = useActions(replayScannerLogic({ id: scannerId }))// `tags.productKey` is required for ClickHouse query tagging; without it the runner aborts.const source: TrendsQuery = {@@ -159,7 +159,18 @@ export function ScannerInsightsChart({return (<div className="border rounded p-4 bg-surface-primary space-y-3"><div className="flex items-baseline justify-between gap-2">- <span className="text-sm font-medium">{chartTitle(scannerType)}</span>+ <div>+ <div className="text-sm font-medium">{chartTitle(scannerType)}</div>+ {coverageStats.totalSessions > 0 && (+ <div className="text-xs text-muted tabular-nums mt-0.5">+ Scanned <span className="font-semibold text-default">{coverageStats.recentSessions}</span>{' '}+ session+ {coverageStats.recentSessions === 1 ? '' : 's'} in the last {coverageStats.recentDays} day+ {coverageStats.recentDays === 1 ? '' : 's'} ·{' '}+ <span className="font-semibold text-default">{coverageStats.totalSessions}</span> total+ </div>+ )}+ </div><DateFilterdateFrom={chartDateFrom}dateTo={chartDateTo}diff --git a/products/replay_vision/frontend/replay_scanners/components/ScannerObservationsTable.tsx b/products/replay_vision/frontend/replay_scanners/components/ScannerObservationsTable.tsxindex 7b4ca6d8c873..023f07beaf9b 100644--- a/products/replay_vision/frontend/replay_scanners/components/ScannerObservationsTable.tsx+++ b/products/replay_vision/frontend/replay_scanners/components/ScannerObservationsTable.tsx@@ -40,6 +40,23 @@ const VERDICT_OPTIONS: { value: ObservationVerdictValue; label: string }[] = [// Chip color by how many versions behind the live scanner an observation ran: latest → oldest.const VERSION_TAG_TYPES: LemonTagType[] = ['success', 'warning', 'caution', 'danger', 'completion']+function Metric({+ label,+ value,+ valueClass,+}: {+ label: string+ value: number | string+ valueClass?: string+}): JSX.Element {+ return (+ <div className="text-center">+ <div className={`font-semibold text-lg ${valueClass ?? ''}`}>{value}</div>+ <div className="text-muted">{label}</div>+ </div>+ )+}+function versionTag(obsVersion: number | null | undefined,currentVersion: number | null | undefined@@ -173,103 +190,90 @@ export function ScannerObservationsTable({ scannerId }: { scannerId: string }):]return (- <div className="space-y-4">- <div className="flex items-start justify-between gap-4">+ <div className="space-y-2">+ <div className="flex items-center gap-3"><p className="text-muted text-sm m-0">Past observations made by this scanner. Each row is one observation.</p>- <div className="flex items-center gap-4">+ <div className="ml-auto flex items-center gap-3">+ <div className="flex items-center gap-2">+ {(observationStats.total > 0 || hasActiveObservationFilters) && (+ <>+ <FilterPill<ObservationStatusValue>+ label="Status"+ options={STATUS_OPTIONS}+ value={observationStatusFilter}+ onChange={setObservationStatusFilter}+ />+ <FilterPill<ObservationTriggeredByValue>+ label="Triggered by"+ options={TRIGGERED_BY_OPTIONS}+ value={observationTriggeredByFilter}+ onChange={setObservationTriggeredByFilter}+ />+ {scannerType === 'monitor' && (+ <FilterPill<ObservationVerdictValue>+ label="Verdict"+ options={VERDICT_OPTIONS}+ value={observationVerdictFilter}+ onChange={setObservationVerdictFilter}+ />+ )}+ {scannerType === 'classifier' && tagFilterOptions.length > 0 && (+ <FilterPill<string>+ label="Tag"+ options={tagFilterOptions}+ value={observationTagFilter}+ onChange={setObservationTagFilter}+ />+ )}+ {hasActiveObservationFilters && (+ <LemonButton type="tertiary" size="small" onClick={() => clearObservationFilters()}>+ Clear filters+ </LemonButton>+ )}+ </>+ )}+ <Tooltip+ title={+ hasObservationsInFlight+ ? 'Auto-refreshing while observations are in flight'+ : 'Refresh observations'+ }+ >+ <LemonButton+ size="small"+ type="secondary"+ icon={<IconRefresh />}+ onClick={() => loadObservations()}+ loading={observationsLoading}+ data-attr="vision-observations-refresh"+ />+ </Tooltip>+ </div>{observationStats.total > 0 && (<div className="flex gap-4 text-sm">- <div className="text-center">- <div className="font-semibold text-lg">{observationStats.total}</div>- <div className="text-muted">Total</div>- </div>+ <Metric label="Total" value={observationStats.total} />{observationStats.successRate !== null && (- <div className="text-center">- <div className="font-semibold text-lg text-success">- {observationStats.successRate}%- </div>- <div className="text-muted">Success rate</div>- </div>+ <Metric+ label="Success rate"+ value={`${observationStats.successRate}%`}+ valueClass="text-success"+ />)}{observationStats.failed > 0 && (- <div className="text-center">- <div className="font-semibold text-lg text-danger">{observationStats.failed}</div>- <div className="text-muted">Failed</div>- </div>+ <Metric label="Failed" value={observationStats.failed} valueClass="text-danger" />)}{observationStats.ineligible > 0 && (- <div className="text-center">- <div className="font-semibold text-lg">{observationStats.ineligible}</div>- <div className="text-muted">Ineligible</div>- </div>+ <Metric label="Ineligible" value={observationStats.ineligible} />)}{observationStats.inFlight > 0 && (- <div className="text-center">- <div className="font-semibold text-lg">{observationStats.inFlight}</div>- <div className="text-muted">In flight</div>- </div>+ <Metric label="In flight" value={observationStats.inFlight} />)}</div>)}- <Tooltip- title={- hasObservationsInFlight- ? 'Auto-refreshing while observations are in flight'- : 'Refresh observations'- }- >- <LemonButton- size="small"- type="secondary"- icon={<IconRefresh />}- onClick={() => loadObservations()}- loading={observationsLoading}- data-attr="vision-observations-refresh"- >- Refresh- </LemonButton>- </Tooltip></div></div>- {(observationStats.total > 0 || hasActiveObservationFilters) && (- <div className="flex flex-wrap items-center gap-2">- <FilterPill<ObservationStatusValue>- label="Status"- options={STATUS_OPTIONS}- value={observationStatusFilter}- onChange={setObservationStatusFilter}- />- <FilterPill<ObservationTriggeredByValue>- label="Triggered by"- options={TRIGGERED_BY_OPTIONS}- value={observationTriggeredByFilter}- onChange={setObservationTriggeredByFilter}- />- {scannerType === 'monitor' && (- <FilterPill<ObservationVerdictValue>- label="Verdict"- options={VERDICT_OPTIONS}- value={observationVerdictFilter}- onChange={setObservationVerdictFilter}- />- )}- {scannerType === 'classifier' && tagFilterOptions.length > 0 && (- <FilterPill<string>- label="Tag"- options={tagFilterOptions}- value={observationTagFilter}- onChange={setObservationTagFilter}- />- )}- {hasActiveObservationFilters && (- <LemonButton type="tertiary" size="small" onClick={() => clearObservationFilters()}>- Clear filters- </LemonButton>- )}- </div>- )}<LemonTablecolumns={columns}dataSource={observations}diff --git a/products/replay_vision/frontend/replay_scanners/components/ScannerOverview.tsx b/products/replay_vision/frontend/replay_scanners/components/ScannerOverview.tsxindex eac43937d505..d9450709d3d4 100644--- a/products/replay_vision/frontend/replay_scanners/components/ScannerOverview.tsx+++ b/products/replay_vision/frontend/replay_scanners/components/ScannerOverview.tsx@@ -182,7 +182,7 @@ function ScorerOverview({ scannerId }: { scannerId: string }): JSX.Element {}export function ScannerOverview({ scannerId }: { scannerId: string }): JSX.Element | null {- const { scanner, coverageStats } = useValues(replayScannerLogic({ id: scannerId }))+ const { scanner } = useValues(replayScannerLogic({ id: scannerId }))if (!scanner) {return null}@@ -196,23 +196,12 @@ export function ScannerOverview({ scannerId }: { scannerId: string }): JSX.Eleme) : scannerType === 'scorer' ? (<ScorerOverview scannerId={scannerId} />) : null- if (!typeOverview && scannerType !== 'summarizer') {- return null- }const showChart = scannerType !== 'summarizer'- const showCoverage = coverageStats.totalSessions > 0- if (!showCoverage && !showChart && !typeOverview) {+ if (!showChart && !typeOverview) {return null}return (<div className="space-y-4">- {showCoverage && (- <div className="text-xs text-muted tabular-nums">- Scanned <span className="font-semibold text-default">{coverageStats.recentSessions}</span> session- {coverageStats.recentSessions === 1 ? '' : 's'} in the last {coverageStats.recentDays} days ·{' '}- <span className="font-semibold text-default">{coverageStats.totalSessions}</span> total- </div>- )}{showChart && <ScannerInsightsChart scannerId={scannerId} scannerType={scannerType} />}{typeOverview}</div>diff --git a/products/replay_vision/frontend/replay_scanners/components/ScannerQuotaForecast.tsx b/products/replay_vision/frontend/replay_scanners/components/ScannerQuotaForecast.tsxindex 142a2b2cfad4..71244a072d0f 100644--- a/products/replay_vision/frontend/replay_scanners/components/ScannerQuotaForecast.tsx+++ b/products/replay_vision/frontend/replay_scanners/components/ScannerQuotaForecast.tsx@@ -126,28 +126,46 @@ export function ScannerQuotaForecast({ scannerId }: Props): JSX.Element | null {</div>{hasCap && projected !== null && (- <Tooltip title={renderBreakdown()}>- <div- className="flex h-3 rounded overflow-hidden bg-fill-tertiary"- role="meter"- aria-valuemin={0}- aria-valuemax={100}- aria-valuenow={percentLabel}- aria-label={`Projected ${percentLabel}% of monthly observation quota by ${- resetsOn ?? 'period end'- }`}- >- <div className="bg-muted" style={{ width: `${usedPct}%` }} />+ <>+ <Tooltip title={renderBreakdown()}><div- className={styles.bar}- style={{- width: `${additionalUsagePct}%`,- backgroundImage:- 'repeating-linear-gradient(135deg, rgba(255,255,255,0.25) 0, rgba(255,255,255,0.25) 4px, transparent 4px, transparent 8px)',- }}- />+ className="flex h-3 rounded overflow-hidden bg-fill-tertiary"+ role="meter"+ aria-valuemin={0}+ aria-valuemax={100}+ aria-valuenow={percentLabel}+ aria-label={`Projected ${percentLabel}% of monthly observation quota by ${+ resetsOn ?? 'period end'+ }`}+ >+ <div className="bg-muted" style={{ width: `${usedPct}%` }} />+ <div+ className={styles.bar}+ style={{+ width: `${additionalUsagePct}%`,+ backgroundImage:+ 'repeating-linear-gradient(135deg, rgba(255,255,255,0.25) 0, rgba(255,255,255,0.25) 4px, transparent 4px, transparent 8px)',+ }}+ />+ </div>+ </Tooltip>+ <div className="flex items-center gap-3 text-xs text-muted">+ <div className="flex items-center gap-1">+ <span className="inline-block w-2.5 h-2.5 rounded-sm bg-muted" />+ Used+ </div>+ <div className="flex items-center gap-1">+ <span+ className={`inline-block w-2.5 h-2.5 rounded-sm ${styles.bar}`}+ style={{+ backgroundImage:+ 'repeating-linear-gradient(135deg, rgba(255,255,255,0.25) 0, rgba(255,255,255,0.25) 2px, transparent 2px, transparent 4px)',+ }}+ />+ Projected from this scanner+ </div></div>- </Tooltip>+ </>)}{samplingRatio === 0 ? (diff --git a/products/replay_vision/frontend/replay_scanners/components/VisionMetrics.tsx b/products/replay_vision/frontend/replay_scanners/components/VisionMetrics.tsxindex ef4043a16bd0..c009063000b3 100644--- a/products/replay_vision/frontend/replay_scanners/components/VisionMetrics.tsx+++ b/products/replay_vision/frontend/replay_scanners/components/VisionMetrics.tsx@@ -48,17 +48,17 @@ export function VisionMetrics(): JSX.Element {}return (- <div className="flex gap-4 h-96">+ <div className="flex flex-col lg:flex-row gap-4 h-72"><div className="flex-1 bg-bg-light rounded p-4 flex flex-col InsightCard h-full"><div className="flex items-start justify-between gap-2 mb-1">- <h3 className="text-lg font-semibold m-0">Observations over time</h3>+ <h3 className="text-base font-semibold m-0">Observations over time</h3><DateFilterdateFrom={chartDateFrom}dateTo={chartDateTo}onChange={(from, to) => setChartDateRange(from ?? null, to ?? null)}/></div>- <p className="text-muted text-sm mb-4">Total scanner observations across all scanners</p>+ <p className="text-muted text-xs mb-3">Across all scanners</p><div className="flex-1 flex flex-col min-h-0"><Queryquery={{ kind: NodeKind.InsightVizNode, source: chartSource } as InsightVizNode}@@ -139,12 +139,28 @@ export function VisionMetrics(): JSX.Element {/></div></Tooltip>- <div className="text-muted text-sm mt-1">- {quota.exhausted ? (- <span className="text-danger">Quota exhausted</span>- ) : (- `${quota.remaining.toLocaleString()} observations remaining.`- )}+ <div className="flex items-center gap-3 text-xs text-muted mt-1.5">+ <div className="flex items-center gap-1">+ <span className="inline-block w-2 h-2 rounded-sm bg-muted" />+ Used+ </div>+ <div className="flex items-center gap-1">+ <span+ className={`inline-block w-2 h-2 rounded-sm ${projectedBarColor}`}+ style={{+ backgroundImage:+ 'repeating-linear-gradient(135deg, rgba(255,255,255,0.25) 0, rgba(255,255,255,0.25) 2px, transparent 2px, transparent 4px)',+ }}+ />+ Projected+ </div>+ <span className="ml-auto text-muted">+ {quota.exhausted ? (+ <span className="text-danger">Quota exhausted</span>+ ) : (+ `${quota.remaining.toLocaleString()} remaining`+ )}+ </span></div></>) : (diff --git a/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts b/products/replay_vision/frontend/replay_scanners/replayScannerLogic.tsindex f3de56a9212f..f324e52c144e 100644--- a/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts+++ b/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts@@ -3,6 +3,7 @@ import { actions, afterMount, isBreakpoint, kea, key, listeners, path, props, reimport { forms } from 'kea-forms'import { actionToUrl, router, urlToAction } from 'kea-router'+import { dayjs } from 'lib/dayjs'import { lemonToast } from 'lib/lemon-ui/LemonToast'import { objectsEqual } from 'lib/utils'import { teamLogic } from 'scenes/teamLogic'@@ -63,6 +64,57 @@ function omitQuery(scanner: ReplayScanner): Omit<ReplayScanner, 'query'> {return rest}+const UNIT_BY_LETTER: Record<string, dayjs.ManipulateType> = {+ h: 'hour',+ d: 'day',+ w: 'week',+ m: 'month',+ y: 'year',+}++const START_OF_BY_PREFIX: Record<string, dayjs.ManipulateType> = {+ dStart: 'day',+ wStart: 'week',+ mStart: 'month',+ yStart: 'year',+}++function chartRangeToDayjs(expr: string): dayjs.Dayjs | null {+ const relative = expr.match(/^-(\d+)([hdwmy])(Start|End)?$/)+ if (relative) {+ const [, n, letter, suffix] = relative+ const unit = UNIT_BY_LETTER[letter]+ const date = dayjs().subtract(parseInt(n, 10), unit)+ if (suffix === 'Start') {+ return date.startOf(unit)+ }+ if (suffix === 'End') {+ return date.endOf(unit)+ }+ return date+ }+ if (expr in START_OF_BY_PREFIX) {+ return dayjs().startOf(START_OF_BY_PREFIX[expr])+ }+ if (expr === 'all') {+ return dayjs().subtract(1, 'year')+ }+ const parsed = dayjs(expr)+ return parsed.isValid() ? parsed : null+}++function daysFromChartRange(dateFrom: string | null, dateTo: string | null): number {+ if (!dateFrom) {+ return 14+ }+ const from = chartRangeToDayjs(dateFrom)+ if (!from) {+ return 14+ }+ const to = dateTo ? chartRangeToDayjs(dateTo) || dayjs() : dayjs()+ return Math.max(1, to.diff(from, 'day'))+}+interface ObservationListParams {limit?: numberoffset?: number@@ -655,6 +707,10 @@ export const replayScannerLogic = kea<replayScannerLogicType>([setObservationTagFilter: () => reloadObservationsAndStats(),clearObservationFilters: () => reloadObservationsAndStats(),+ setChartDateRange: () => {+ actions.loadObservationStats()+ },+loadObservationStats: async () => {if (props.id === 'new') {actions.loadObservationStatsFailure()@@ -667,7 +723,11 @@ export const replayScannerLogic = kea<replayScannerLogicType>([try {// Stats endpoint accepts the same filters as the list, but `order_by` is meaningless on an aggregate.const { order_by: _ignored, ...params } = buildObservationListParams(values)- const response = await visionScannersObservationsStatsRetrieve(String(teamId), props.id, params)+ const recentDays = daysFromChartRange(values.chartDateFrom, values.chartDateTo)+ const response = await visionScannersObservationsStatsRetrieve(String(teamId), props.id, {+ ...params,+ recent_days: recentDays,+ })actions.loadObservationStatsSuccess(response)} catch {actions.loadObservationStatsFailure()diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex f11843bab992..ab575da0bcb3 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -46384,6 +46384,10 @@ export namespace Schemas {};export type EnvironmentsVisionScannersObservationsStatsRetrieveParams = {+ /**+ * Window size in days for the coverage `recent_sessions` count. Clamped to [1, 365]. Defaults to 14 when omitted.+ */+ recent_days?: number;/*** Filter to observations of a specific session recording.*/@@ -52911,6 +52915,10 @@ export namespace Schemas {};export type VisionScannersObservationsStatsRetrieveParams = {+ /**+ * Window size in days for the coverage `recent_sessions` count. Clamped to [1, 365]. Defaults to 14 when omitted.+ */+ recent_days?: number;/*** Filter to observations of a specific session recording.*/