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.

feat(replay-vision): add observation detail pages per sacnner type (#60217)

Hayne Ryu9ef5d72f2627
diff --git a/frontend/src/products.tsx b/frontend/src/products.tsx
index 72718e2c7fa8..886abf8fe0a4 100644
--- a/frontend/src/products.tsx
+++ b/frontend/src/products.tsx
@@ -125,6 +125,7 @@ export const productScenes: Record<string, () => Promise<any>> = {
Metrics: () => import('../../products/metrics/frontend/MetricsScene'),
ReplayVision: () => import('../../products/replay_vision/frontend/replay_scanners/ReplayScannersScene'),
ReplayVisionScanner: () => import('../../products/replay_vision/frontend/replay_scanners/ReplayScanner'),
+ ReplayVisionObservation: () => import('../../products/replay_vision/frontend/observations/ReplayObservation'),
RevenueAnalytics: () => import('../../products/revenue_analytics/frontend/RevenueAnalyticsScene'),
SessionGroupSummariesTable: () => import('../../products/session_summaries/frontend/SessionGroupSummariesTable'),
SessionGroupSummary: () => import('../../products/session_summaries/frontend/SessionGroupSummaryScene'),
@@ -246,6 +247,7 @@ export const productRoutes: Record<string, [string, string]> = {
'/mcp-analytics/intent-clustering': ['MCPAnalytics', 'mcpAnalyticsIntentClustering'],
'/metrics': ['Metrics', 'metrics'],
'/replay-vision': ['ReplayVision', 'replayVision'],
+ '/replay-vision/observations/:observationId': ['ReplayVisionObservation', 'replayVisionObservation'],
'/replay-vision/:id': ['ReplayVisionScanner', 'replayVision'],
'/revenue_analytics': ['RevenueAnalytics', 'revenueAnalytics'],
'/session-summaries': ['SessionGroupSummariesTable', 'sessionGroupSummariesTable'],
@@ -695,6 +697,12 @@ export const productConfiguration: Record<string, any> = {
iconType: 'replay_vision',
layout: 'app-container',
},
+ ReplayVisionObservation: {
+ name: 'Replay vision observation',
+ projectBased: true,
+ iconType: 'replay_vision',
+ layout: 'app-container',
+ },
RevenueAnalytics: {
name: 'Revenue Analytics',
projectBased: true,
@@ -1138,6 +1146,7 @@ export const productUrls = {
replayKiosk: (): string => '/replay/kiosk',
replaySettings: (sectionId?: string): string => `/replay/settings${sectionId ? `?sectionId=${sectionId}` : ''}`,
replayVision: (id?: string): string => (id ? `/replay-vision/${id}` : '/replay-vision'),
+ replayVisionObservation: (observationId: string): string => `/replay-vision/observations/${observationId}`,
revenueAnalytics: (): string => '/revenue_analytics',
sessionSummaries: (): string => '/session-summaries',
sessionSummary: (sessionGroupId: string): string => `/session-summaries/${sessionGroupId}`,
diff --git a/products/replay_vision/frontend/components/ObservationCard.tsx b/products/replay_vision/frontend/components/ObservationCard.tsx
index e1109a0b18ad..342bc77f54bf 100644
--- a/products/replay_vision/frontend/components/ObservationCard.tsx
+++ b/products/replay_vision/frontend/components/ObservationCard.tsx
@@ -1,18 +1,15 @@
-import { IconWarning } from '@posthog/icons'
-import { LemonTag, Spinner, Tooltip } from '@posthog/lemon-ui'
+import { IconRewindPlay, IconSparkles, IconWarning } from '@posthog/icons'
+import { LemonTag, Link, Spinner, Tooltip } from '@posthog/lemon-ui'
-import { TZLabel } from 'lib/components/TZLabel'
+import { urls } from 'scenes/urls'
-import type { ScannerTypeEnumApi, ReplayObservationApi } from '../generated/api.schemas'
-import { failureKindDescription, parseFailureReason, parseIneligibleReason } from '../replay_scanners/types'
-
-const SCANNER_TYPE_LABEL: Record<ScannerTypeEnumApi, string> = {
- monitor: 'Monitor',
- classifier: 'Classifier',
- scorer: 'Scorer',
- summarizer: 'Summarizer',
- indexer: 'Indexer',
-}
+import type { ReplayObservationApi, ScannerSnapshotApi } from '../generated/api.schemas'
+import {
+ failureKindDescription,
+ parseFailureReason,
+ parseIneligibleReason,
+ scannerTypeLabel,
+} from '../replay_scanners/types'
export function ObservationStatusTag({ status }: { status: ReplayObservationApi['status'] }): JSX.Element {
if (status === 'succeeded') {
@@ -35,64 +32,97 @@ export function ObservationStatusTag({ status }: { status: ReplayObservationApi[
return <LemonTag type="default">Pending</LemonTag>
}
-function readResult(observation: ReplayObservationApi): Record<string, unknown> | null {
+export function readResult(observation: ReplayObservationApi): Record<string, unknown> | null {
const output = observation.scanner_result?.model_output
return output && typeof output === 'object' ? (output as Record<string, unknown>) : null
}
-/** Compact, single-cell preview of an observation result for the Vision scene's observations table. */
-export function ObservationResultSummary({ observation }: { observation: ReplayObservationApi }): JSX.Element {
- if (observation.status === 'ineligible') {
- const parsed = parseIneligibleReason(observation.error_reason)
- const label = parsed?.label ?? 'Ineligible'
- const detail = parsed?.message ?? observation.error_reason
- return (
- <Tooltip title={detail || label}>
- <span className="text-muted text-sm">{label}</span>
- </Tooltip>
- )
+// Mirrors backend's `_EVENT_ID_CITATION_RE`; keep in sync.
+const EVENT_ID_PATTERN = /\(event_id ([0-9a-f]{16})\)/gi
+
+function formatSessionOffset(ms: number): string {
+ const totalSeconds = Math.max(0, Math.floor(ms / 1000))
+ const h = Math.floor(totalSeconds / 3600)
+ const m = Math.floor((totalSeconds % 3600) / 60)
+ const s = totalSeconds % 60
+ if (h > 0) {
+ return `${h}:${m.toString().padStart(2, '0')}:${s.toString().padStart(2, '0')}`
}
- if (observation.status === 'failed') {
- const parsed = parseFailureReason(observation.error_reason)
- const label = parsed?.label ?? 'Failed'
- const description = parsed ? failureKindDescription(parsed.kind) : null
- const detail = parsed?.message ?? observation.error_reason
- const tooltip = [description, detail].filter(Boolean).join('\n\n') || 'Unknown error'
- return (
- <Tooltip title={tooltip}>
- <span className="inline-flex items-center gap-1 text-danger text-sm">
- <IconWarning /> {label}
- </span>
- </Tooltip>
+ return `${m}:${s.toString().padStart(2, '0')}`
+}
+
+export function CitedText({ observation, text }: { observation: ReplayObservationApi; text: string }): JSX.Element {
+ const mapping = (observation.scanner_result?.event_id_mapping ?? {}) as Record<string, unknown>
+ if (!text || Object.keys(mapping).length === 0) {
+ return <>{text}</>
+ }
+ const sessionId = observation.session_id
+ const parts: React.ReactNode[] = []
+ let lastIndex = 0
+ let chipIndex = 0
+ EVENT_ID_PATTERN.lastIndex = 0
+ let match: RegExpExecArray | null
+ while ((match = EVENT_ID_PATTERN.exec(text)) !== null) {
+ const [full, hash] = match
+ const citation = mapping[hash.toLowerCase()] as { uuid?: string; timestamp_ms?: number } | undefined
+ if (!citation || typeof citation.timestamp_ms !== 'number') {
+ continue
+ }
+ if (match.index > lastIndex) {
+ parts.push(text.slice(lastIndex, match.index))
+ }
+ parts.push(
+ <Link
+ key={`evt-${chipIndex++}`}
+ to={urls.replaySingle(sessionId, {
+ secondsOffsetFromStart: Math.max(0, Math.floor(citation.timestamp_ms / 1000)),
+ })}
+ >
+ <IconRewindPlay className="inline-block align-text-bottom mr-0.5" />
+ <span className="font-mono">{formatSessionOffset(citation.timestamp_ms)}</span>
+ </Link>
)
+ lastIndex = match.index + full.length
}
- const scannerType = observation.scanner_snapshot?.scanner_type
- const result = readResult(observation)
- if (!scannerType || !result) {
- return <span className="text-muted text-sm">—</span>
+ if (lastIndex < text.length) {
+ parts.push(text.slice(lastIndex))
}
- return <ObservationResult scannerType={scannerType} result={result} compact />
+ return <>{parts}</>
}
-function ObservationResult({
- scannerType,
- result,
+export function readConfig(snapshot: ScannerSnapshotApi | null): Record<string, unknown> {
+ const config = snapshot?.scanner_config
+ return config && typeof config === 'object' ? (config as Record<string, unknown>) : {}
+}
+
+export function ObservationPrimaryOutput({
+ observation,
compact = false,
+ showPrompt = true,
}: {
- scannerType: ScannerTypeEnumApi
- result: Record<string, unknown>
+ observation: ReplayObservationApi
compact?: boolean
-}): JSX.Element {
- const reasoning = typeof result.reasoning === 'string' ? result.reasoning : null
- const reasoningClass = compact ? 'text-muted text-xs truncate' : 'text-muted text-sm'
+ showPrompt?: boolean
+}): JSX.Element | null {
+ const snapshot = observation.scanner_snapshot
+ const result = readResult(observation)
+ if (!snapshot || !result) {
+ return null
+ }
+ const scannerType = snapshot.scanner_type
+ const config = readConfig(snapshot)
+ const prompt = showPrompt && typeof config.prompt === 'string' ? config.prompt : null
const bodyClass = compact ? 'text-sm truncate' : 'text-sm'
+ const promptClass = 'text-xs text-muted'
if (scannerType === 'monitor') {
const verdict = Boolean(result.verdict)
return (
<div className="flex flex-col gap-1">
- <LemonTag type={verdict ? 'success' : 'default'}>{verdict ? 'Yes' : 'No'}</LemonTag>
- {reasoning && <span className={reasoningClass}>{reasoning}</span>}
+ <LemonTag size="medium" type={verdict ? 'success' : 'default'} className="self-start">
+ {verdict ? 'Yes' : 'No'}
+ </LemonTag>
+ {prompt && <span className={promptClass}>{prompt}</span>}
</div>
)
}
@@ -103,27 +133,51 @@ function ObservationResult({
return (
<div className="flex flex-col gap-1">
{title && <span className="font-semibold text-sm">{title}</span>}
- {summary && <span className={bodyClass}>{summary}</span>}
+ {summary && (
+ <span className={bodyClass}>
+ {compact ? summary : <CitedText observation={observation} text={summary} />}
+ </span>
+ )}
</div>
)
}
if (scannerType === 'classifier') {
- const tags = Array.isArray(result.tags) ? (result.tags as string[]) : []
+ const fixedTags = Array.isArray(result.tags) ? (result.tags as string[]) : []
+ const freeformTags = Array.isArray(result.tags_freeform) ? (result.tags_freeform as string[]) : []
+ const empty = fixedTags.length === 0 && freeformTags.length === 0
return (
<div className="flex flex-col gap-1">
<div className="flex flex-wrap gap-1">
- {tags.length === 0 ? (
+ {empty ? (
<span className="text-muted text-sm">No tags</span>
) : (
- tags.map((tag) => (
- <LemonTag key={tag} type="option">
- {tag}
- </LemonTag>
- ))
+ <>
+ {fixedTags.map((tag) => (
+ <LemonTag
+ key={`fixed-${tag}`}
+ size="medium"
+ type="option"
+ title="From the configured tag list"
+ >
+ {tag}
+ </LemonTag>
+ ))}
+ {freeformTags.map((tag) => (
+ <LemonTag
+ key={`freeform-${tag}`}
+ size="medium"
+ type="default"
+ icon={<IconSparkles />}
+ title="Free-form tag from the model"
+ >
+ {tag}
+ </LemonTag>
+ ))}
+ </>
)}
</div>
- {reasoning && <span className={reasoningClass}>{reasoning}</span>}
+ {prompt && <span className={promptClass}>{prompt}</span>}
</div>
)
}
@@ -131,17 +185,24 @@ function ObservationResult({
if (scannerType === 'scorer') {
const score = typeof result.score === 'number' ? result.score : null
const label = typeof result.label === 'string' ? result.label : null
+ const scale =
+ config.scale && typeof config.scale === 'object' ? (config.scale as Record<string, unknown>) : null
+ const scaleMax = scale && typeof scale.max === 'number' ? scale.max : null
+ const scaleLabel = scale && typeof scale.label === 'string' ? scale.label : null
return (
<div className="flex flex-col gap-1">
<span className="text-sm">
- <span className="font-semibold">{score ?? '—'}</span>
- {label && <span className="text-muted"> {label}</span>}
+ <span className="font-semibold text-base">{score ?? '—'}</span>
+ {scaleMax !== null && <span className="text-muted"> / {scaleMax}</span>}
+ {scaleLabel && <span className="text-muted text-xs"> {scaleLabel}</span>}
+ {label && <span className="text-muted"> — {label}</span>}
</span>
- {reasoning && <span className={reasoningClass}>{reasoning}</span>}
+ {prompt && <span className={promptClass}>{prompt}</span>}
</div>
)
}
+ // Indexer / unknown fallback.
const summary = typeof result.summary === 'string' ? result.summary : null
const userType = typeof result.user_type === 'string' ? result.user_type : null
const outcome = typeof result.outcome === 'string' ? result.outcome : null
@@ -150,13 +211,13 @@ function ObservationResult({
<div className="flex flex-col gap-1">
{summary && <span className={bodyClass}>{summary}</span>}
{userType && (
- <span className={reasoningClass}>
+ <span className="text-muted text-xs">
<span className="font-medium">User: </span>
{userType}
</span>
)}
{outcome && (
- <span className={reasoningClass}>
+ <span className="text-muted text-xs">
<span className="font-medium">Outcome: </span>
{outcome}
</span>
@@ -174,7 +235,60 @@ function ObservationResult({
)
}
-function FailureDetail({ errorReason }: { errorReason: string }): JSX.Element {
+export function ObservationConfidence({ result }: { result: Record<string, unknown> }): JSX.Element | null {
+ if (typeof result.confidence !== 'number') {
+ return null
+ }
+ const value = result.confidence
+ const pct = Math.round(value * 100)
+ const { type, label } =
+ value >= 0.8
+ ? ({ type: 'success', label: 'High' } as const)
+ : value >= 0.5
+ ? ({ type: 'warning', label: 'Medium' } as const)
+ : ({ type: 'danger', label: 'Low' } as const)
+ return (
+ <div className="flex items-center gap-2">
+ <LemonTag type={type}>{label}</LemonTag>
+ <span className="text-sm tabular-nums text-muted">{pct}%</span>
+ </div>
+ )
+}
+
+export function ObservationResultSummary({ observation }: { observation: ReplayObservationApi }): JSX.Element {
+ if (observation.status === 'ineligible') {
+ const parsed = parseIneligibleReason(observation.error_reason)
+ const label = parsed?.label ?? 'Ineligible'
+ const detail = parsed?.message ?? observation.error_reason
+ return (
+ <Tooltip title={detail || label}>
+ <span className="text-muted text-sm">{label}</span>
+ </Tooltip>
+ )
+ }
+ if (observation.status === 'failed') {
+ const parsed = parseFailureReason(observation.error_reason)
+ const label = parsed?.label ?? 'Failed'
+ const description = parsed ? failureKindDescription(parsed.kind) : null
+ const detail = parsed?.message ?? observation.error_reason
+ const tooltip = [description, detail].filter(Boolean).join('\n\n') || 'Unknown error'
+ return (
+ <Tooltip title={tooltip}>
+ <span className="inline-flex items-center gap-1 text-danger text-sm">
+ <IconWarning /> {label}
+ </span>
+ </Tooltip>
+ )
+ }
+ const snapshot = observation.scanner_snapshot
+ const result = readResult(observation)
+ if (!snapshot || !result) {
+ return <span className="text-muted text-sm">—</span>
+ }
+ return <ObservationPrimaryOutput observation={observation} compact showPrompt={false} />
+}
+
+export function FailureDetail({ errorReason }: { errorReason: string }): JSX.Element {
const parsed = parseFailureReason(errorReason)
if (!parsed) {
return <div className="text-danger text-sm">{errorReason}</div>
@@ -188,7 +302,7 @@ function FailureDetail({ errorReason }: { errorReason: string }): JSX.Element {
)
}
-function IneligibleDetail({ errorReason }: { errorReason: string }): JSX.Element {
+export function IneligibleDetail({ errorReason }: { errorReason: string }): JSX.Element {
const parsed = parseIneligibleReason(errorReason)
if (!parsed) {
return <div className="text-muted text-sm">{errorReason}</div>
@@ -201,7 +315,6 @@ function IneligibleDetail({ errorReason }: { errorReason: string }): JSX.Element
)
}
-/** In-progress state for a pending/running observation. */
function ObservationProgress({ observation }: { observation: ReplayObservationApi }): JSX.Element {
return (
<div className="flex items-center gap-2 text-muted text-sm">
@@ -211,12 +324,10 @@ function ObservationProgress({ observation }: { observation: ReplayObservationAp
)
}
-/** Full observation presentation for the replay-page dock and the Vision scene's expanded rows. */
-export function ObservationCard({ observation }: { observation: ReplayObservationApi }): JSX.Element {
+export function ObservationDockCard({ observation }: { observation: ReplayObservationApi }): JSX.Element {
const snapshot = observation.scanner_snapshot
const scannerType = snapshot?.scanner_type
const result = readResult(observation)
- const signalsCount = observation.scanner_result?.signals_count ?? 0
return (
<div className="border rounded p-3 bg-surface-primary space-y-2">
@@ -224,9 +335,11 @@ export function ObservationCard({ observation }: { observation: ReplayObservatio
<div className="flex items-center gap-2 min-w-0">
<ObservationStatusTag status={observation.status} />
<span className="font-semibold text-sm truncate">{snapshot?.name || 'Scanner'}</span>
- {scannerType && <span className="text-muted text-xs">{SCANNER_TYPE_LABEL[scannerType]}</span>}
+ {scannerType && <span className="text-muted text-xs">{scannerTypeLabel(scannerType)}</span>}
</div>
- <TZLabel time={observation.created_at} className="text-muted text-xs whitespace-nowrap" />
+ <Link to={urls.replayVisionObservation(observation.id)} className="text-xs whitespace-nowrap">
+ View details
+ </Link>
</div>
{observation.status === 'failed' && observation.error_reason && (
@@ -237,22 +350,13 @@ export function ObservationCard({ observation }: { observation: ReplayObservatio
<IneligibleDetail errorReason={observation.error_reason} />
)}
- {observation.status === 'succeeded' && scannerType && result && (
- <ObservationResult scannerType={scannerType} result={result} />
+ {observation.status === 'succeeded' && snapshot && result && (
+ <ObservationPrimaryOutput observation={observation} compact />
)}
{(observation.status === 'pending' || observation.status === 'running') && (
<ObservationProgress observation={observation} />
)}
-
- <div className="flex items-center gap-3 text-muted text-xs">
- {snapshot?.model && <span className="font-mono">{snapshot.model}</span>}
- {signalsCount > 0 && (
- <span>
- {signalsCount} signal{signalsCount === 1 ? '' : 's'}
- </span>
- )}
- </div>
</div>
)
}
diff --git a/products/replay_vision/frontend/components/ObservationsDock.tsx b/products/replay_vision/frontend/components/ObservationsDock.tsx
index ba9e1abb7ad8..732b1f9456b2 100644
--- a/products/replay_vision/frontend/components/ObservationsDock.tsx
+++ b/products/replay_vision/frontend/components/ObservationsDock.tsx
@@ -12,7 +12,7 @@ import { urls } from 'scenes/urls'
import type { ReplayScannerApi } from '../generated/api.schemas'
import { observationsDockLogic } from '../logics/observationsDockLogic'
-import { ObservationCard } from './ObservationCard'
+import { ObservationDockCard } from './ObservationCard'
const COLLAPSED_HEIGHT = 44
const DEFAULT_EXPANDED_HEIGHT = 480
@@ -86,7 +86,7 @@ function ScannerPicker({ sessionId }: { sessionId: string }): JSX.Element {
loading={observing}
data-attr="vision-observe-recording"
>
- Observe this recording
+ Scan this recording
</LemonButton>
</LemonDropdown>
)
@@ -151,7 +151,7 @@ function ObservationsDockContent({ sessionId }: { sessionId: string }): JSX.Elem
</div>
) : (
observations.map((observation) => (
- <ObservationCard key={observation.id} observation={observation} />
+ <ObservationDockCard key={observation.id} observation={observation} />
))
)}
</div>
diff --git a/products/replay_vision/frontend/observations/ReplayObservation.tsx b/products/replay_vision/frontend/observations/ReplayObservation.tsx
new file mode 100644
index 000000000000..99f58b0d66b2
--- /dev/null
+++ b/products/replay_vision/frontend/observations/ReplayObservation.tsx
@@ -0,0 +1,238 @@
+import { useValues } from 'kea'
+
+import { LemonTag, Link } from '@posthog/lemon-ui'
+
+import { TZLabel } from 'lib/components/TZLabel'
+import { dayjs } from 'lib/dayjs'
+import { ProfilePicture } from 'lib/lemon-ui/ProfilePicture'
+import { useAttachedLogic } from 'lib/logic/scenes/useAttachedLogic'
+import { SceneExport } from 'scenes/sceneTypes'
+import { SessionRecordingPlayer } from 'scenes/session-recordings/player/SessionRecordingPlayer'
+import { SessionRecordingPlayerMode } from 'scenes/session-recordings/player/sessionRecordingPlayerLogic'
+import { urls } from 'scenes/urls'
+
+import { SceneContent } from '~/layout/scenes/components/SceneContent'
+import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
+import { ProductKey } from '~/queries/schema/schema-general'
+
+import {
+ CitedText,
+ FailureDetail,
+ IneligibleDetail,
+ ObservationConfidence,
+ ObservationPrimaryOutput,
+ ObservationStatusTag,
+ readConfig,
+ readResult,
+} from '../components/ObservationCard'
+import { modelLabel, scannerTypeLabel } from '../replay_scanners/types'
+import { replayObservationLogic } from './replayObservationLogic'
+import { ReplayObservationSceneLogicProps, replayObservationSceneLogic } from './replayObservationSceneLogic'
+
+export const scene: SceneExport<ReplayObservationSceneLogicProps> = {
+ component: ReplayObservationSceneComponent,
+ logic: replayObservationSceneLogic,
+ productKey: ProductKey.REPLAY_VISION,
+}
+
+export function ReplayObservationSceneComponent({ tabId }: { tabId: string }): JSX.Element {
+ const { observationId } = useValues(replayObservationSceneLogic)
+
+ const observationLogic = replayObservationLogic({ id: observationId, tabId })
+ useAttachedLogic(observationLogic, replayObservationSceneLogic)
+
+ const { observation, observationLoading } = useValues(observationLogic)
+
+ if (observationLoading) {
+ return (
+ <SceneContent>
+ <SceneTitleSection name="Loading…" resourceType={{ type: 'replay_vision' }} />
+ </SceneContent>
+ )
+ }
+
+ if (!observation) {
+ return (
+ <SceneContent>
+ <SceneTitleSection name="Observation not found" resourceType={{ type: 'replay_vision' }} />
+ <p className="text-muted">
+ This observation either doesn't exist or you don't have access to it.{' '}
+ <Link to={urls.replayVision()}>Back to scanners</Link>.
+ </p>
+ </SceneContent>
+ )
+ }
+
+ const snapshot = observation.scanner_snapshot
+ const result = readResult(observation)
+ const reasoning = result && typeof result.reasoning === 'string' ? result.reasoning : null
+ const scannerType = snapshot?.scanner_type
+ const scannerName = snapshot?.name || 'Scanner'
+ const triggerLabel = observation.triggered_by === 'on_demand' ? 'On demand' : 'Schedule'
+ const snapshotConfig = readConfig(snapshot ?? null)
+ const prompt = typeof snapshotConfig.prompt === 'string' ? snapshotConfig.prompt : null
+ const configuredTags =
+ scannerType === 'classifier' && Array.isArray(snapshotConfig.tags)
+ ? (snapshotConfig.tags as unknown[]).filter((t): t is string => typeof t === 'string')
+ : []
+ const multiLabel = scannerType === 'classifier' ? snapshotConfig.multi_label === true : false
+ const summarizerLength =
+ scannerType === 'summarizer' && typeof snapshotConfig.length === 'string' ? snapshotConfig.length : null
+ const durationMs =
+ observation.started_at && observation.completed_at
+ ? dayjs(observation.completed_at).diff(observation.started_at)
+ : null
+ const durationLabel =
+ durationMs !== null && Number.isFinite(durationMs) && durationMs >= 0
+ ? durationMs < 1000
+ ? `${durationMs} ms`
+ : durationMs < 60_000
+ ? `${(durationMs / 1000).toFixed(1)} s`
+ : `${Math.floor(durationMs / 60_000)}m ${Math.floor((durationMs % 60_000) / 1000)}s`
+ : null
+
+ return (
+ <SceneContent>
+ <SceneTitleSection
+ name={scannerName}
+ description={`Observation on session ${observation.session_id}`}
+ resourceType={{ type: 'replay_vision' }}
+ />
+
+ <div className="grid grid-cols-1 lg:grid-cols-2 gap-4">
+ <section className="border rounded p-4 bg-surface-primary space-y-3">
+ <div className="flex items-center justify-between gap-2">
+ <div className="flex items-center gap-2">
+ <span className="text-sm font-medium uppercase tracking-wide text-muted">Result</span>
+ {scannerType && <LemonTag type="option">{scannerTypeLabel(scannerType)}</LemonTag>}
+ </div>
+ <ObservationStatusTag status={observation.status} />
+ </div>
+
+ {observation.status === 'failed' && observation.error_reason && (
+ <FailureDetail errorReason={observation.error_reason} />
+ )}
+
+ {observation.status === 'ineligible' && observation.error_reason && (
+ <IneligibleDetail errorReason={observation.error_reason} />
+ )}
+
+ {observation.status === 'succeeded' && snapshot && result && (
+ <div className="flex flex-col gap-2">
+ {prompt && scannerType !== 'summarizer' && (
+ <p className="text-sm text-default m-0 leading-snug">{prompt}</p>
+ )}
+ <ObservationPrimaryOutput observation={observation} showPrompt={false} />
+ {configuredTags.length > 0 && (
+ <div className="flex flex-wrap items-center gap-1 text-xs text-muted">
+ <span>Allowed tags{multiLabel ? ' (multi-label)' : ''}:</span>
+ {configuredTags.map((tag) => (
+ <LemonTag key={tag} type="option" size="small">
+ {tag}
+ </LemonTag>
+ ))}
+ </div>
+ )}
+ </div>
+ )}
+
+ {(observation.status === 'pending' || observation.status === 'running') && (
+ <div className="text-muted text-sm">
+ {observation.status === 'pending' ? 'Queued…' : 'Analyzing recording…'}
+ </div>
+ )}
+ </section>
+
+ <section className="border rounded p-4 bg-surface-primary space-y-2">
+ <div className="text-sm font-medium">Reasoning</div>
+ {reasoning ? (
+ <p className="text-sm whitespace-pre-wrap m-0">
+ <CitedText observation={observation} text={reasoning} />
+ </p>
+ ) : (
+ <p className="text-muted text-sm m-0">No reasoning provided.</p>
+ )}
+ </section>
+ </div>
+
+ <section className="border rounded p-4 bg-surface-primary">
+ <div className="text-sm font-medium mb-3">Run details</div>
+ <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-x-6 gap-y-3 text-sm">
+ <div>
+ <div className="text-xs text-muted mb-0.5">Triggered by</div>
+ {observation.triggered_by === 'on_demand' && observation.triggered_by_user ? (
+ <ProfilePicture
+ user={{
+ first_name: observation.triggered_by_user.first_name,
+ last_name: observation.triggered_by_user.last_name,
+ email: observation.triggered_by_user.email,
+ }}
+ size="sm"
+ showName
+ />
+ ) : (
+ <span>{triggerLabel}</span>
+ )}
+ </div>
+ <div>
+ <div className="text-xs text-muted mb-0.5">Run at</div>
+ <TZLabel time={observation.created_at} />
+ </div>
+ {durationLabel && (
+ <div>
+ <div className="text-xs text-muted mb-0.5">Duration</div>
+ <span>{durationLabel}</span>
+ </div>
+ )}
+ {result && typeof result.confidence === 'number' && (
+ <div>
+ <div className="text-xs text-muted mb-0.5">Confidence</div>
+ <ObservationConfidence result={result} />
+ </div>
+ )}
+ {snapshot?.model && (
+ <div>
+ <div className="text-xs text-muted mb-0.5">Model</div>
+ <span>{modelLabel(snapshot.model)}</span>
+ </div>
+ )}
+ {typeof snapshot?.scanner_version === 'number' && (
+ <div>
+ <div className="text-xs text-muted mb-0.5">Scanner version</div>
+ <span>v{snapshot.scanner_version}</span>
+ </div>
+ )}
+ {summarizerLength && (
+ <div>
+ <div className="text-xs text-muted mb-0.5">Summary length</div>
+ <span className="capitalize">{summarizerLength}</span>
+ </div>
+ )}
+ {snapshot?.emits_signals && (
+ <div>
+ <div className="text-xs text-muted mb-0.5">Signals</div>
+ <span>Emitted ({observation.scanner_result?.signals_count ?? 0})</span>
+ </div>
+ )}
+ </div>
+ </section>
+
+ <section className="border rounded bg-surface-primary overflow-hidden">
+ <div className="p-4 pb-2 text-sm font-medium">Recording</div>
+ <div className="aspect-video max-h-[80vh] min-h-[480px]">
+ <SessionRecordingPlayer
+ sessionRecordingId={observation.session_id}
+ playerKey={`vision-observation-${observation.id}`}
+ mode={SessionRecordingPlayerMode.Standard}
+ autoPlay={false}
+ noMeta
+ noBorder
+ withSidebar={false}
+ />
+ </div>
+ </section>
+ </SceneContent>
+ )
+}
+
+export default ReplayObservationSceneComponent
diff --git a/products/replay_vision/frontend/observations/replayObservationLogic.ts b/products/replay_vision/frontend/observations/replayObservationLogic.ts
new file mode 100644
index 000000000000..f61b1754e1f3
--- /dev/null
+++ b/products/replay_vision/frontend/observations/replayObservationLogic.ts
@@ -0,0 +1,62 @@
+import { actions, afterMount, kea, key, listeners, path, props, reducers } from 'kea'
+
+import { lemonToast } from 'lib/lemon-ui/LemonToast'
+import { teamLogic } from 'scenes/teamLogic'
+
+import { visionObservationsRetrieve } from '../generated/api'
+import type { ReplayObservationApi } from '../generated/api.schemas'
+import type { replayObservationLogicType } from './replayObservationLogicType'
+
+export interface ReplayObservationLogicProps {
+ id: string
+ tabId: string
+}
+
+export const replayObservationLogic = kea<replayObservationLogicType>([
+ path(['products', 'replay_vision', 'frontend', 'observations', 'replayObservationLogic']),
+ props({} as ReplayObservationLogicProps),
+ key((props) => `${props.tabId}:${props.id}`),
+
+ actions({
+ loadObservation: true,
+ loadObservationSuccess: (observation: ReplayObservationApi) => ({ observation }),
+ loadObservationFailure: true,
+ }),
+
+ reducers({
+ observation: [
+ null as ReplayObservationApi | null,
+ {
+ loadObservationSuccess: (_, { observation }) => observation,
+ },
+ ],
+ observationLoading: [
+ true,
+ {
+ loadObservation: () => true,
+ loadObservationSuccess: () => false,
+ loadObservationFailure: () => false,
+ },
+ ],
+ }),
+
+ listeners(({ actions, props }) => ({
+ loadObservation: async () => {
+ const teamId = teamLogic.values.currentTeamId
+ if (!teamId) {
+ return
+ }
+ try {
+ const response = await visionObservationsRetrieve(String(teamId), props.id)
+ actions.loadObservationSuccess(response)
+ } catch (error) {
+ lemonToast.error(`Failed to load observation: ${String(error)}`)
+ actions.loadObservationFailure()
+ }
+ },
+ })),
+
+ afterMount(({ actions }) => {
+ actions.loadObservation()
+ }),
+])
diff --git a/products/replay_vision/frontend/observations/replayObservationSceneLogic.ts b/products/replay_vision/frontend/observations/replayObservationSceneLogic.ts
new file mode 100644
index 000000000000..038e10956bbd
--- /dev/null
+++ b/products/replay_vision/frontend/observations/replayObservationSceneLogic.ts
@@ -0,0 +1,60 @@
+import { actions, kea, path, props, reducers, selectors } from 'kea'
+
+import { tabAwareScene } from 'lib/logic/scenes/tabAwareScene'
+import { tabAwareUrlToAction } from 'lib/logic/scenes/tabAwareUrlToAction'
+import { urls } from 'scenes/urls'
+
+import { Breadcrumb } from '~/types'
+
+import type { replayObservationSceneLogicType } from './replayObservationSceneLogicType'
+
+export interface ReplayObservationSceneLogicProps {
+ tabId: string
+}
+
+export const replayObservationSceneLogic = kea<replayObservationSceneLogicType>([
+ path(['products', 'replay_vision', 'frontend', 'observations', 'replayObservationSceneLogic']),
+ props({} as ReplayObservationSceneLogicProps),
+ tabAwareScene(),
+
+ actions({
+ setObservationId: (observationId: string) => ({ observationId }),
+ }),
+
+ reducers({
+ observationId: [
+ '' as string,
+ {
+ setObservationId: (_, { observationId }) => observationId,
+ },
+ ],
+ }),
+
+ selectors({
+ breadcrumbs: [
+ (s) => [s.observationId],
+ (observationId: string): Breadcrumb[] => [
+ {
+ key: 'replay-vision',
+ name: 'Replay vision',
+ path: urls.replayVision(),
+ iconType: 'replay_vision',
+ },
+ {
+ key: observationId ? `observation-${observationId}` : 'observation',
+ name: 'Observation',
+ path: urls.replayVisionObservation(observationId),
+ },
+ ],
+ ],
+ }),
+
+ tabAwareUrlToAction(({ actions, values }) => ({
+ [urls.replayVisionObservation(':observationId')]: ({ observationId }) => {
+ const next = observationId || ''
+ if (next !== values.observationId) {
+ actions.setObservationId(next)
+ }
+ },
+ })),
+])
diff --git a/products/replay_vision/frontend/replay_scanners/ReplayScanner.tsx b/products/replay_vision/frontend/replay_scanners/ReplayScanner.tsx
index a5728cf93e7b..4f06dc48da21 100644
--- a/products/replay_vision/frontend/replay_scanners/ReplayScanner.tsx
+++ b/products/replay_vision/frontend/replay_scanners/ReplayScanner.tsx
@@ -57,6 +57,16 @@ export function ReplayScannerSceneComponent({ tabId }: { tabId: string }): JSX.E
}
const tabs: (LemonTab<EditorTab> | false)[] = [
+ !isNew && {
+ key: 'observations' as EditorTab,
+ label: 'Observations',
+ content: <ScannerObservationsTable scannerId={scannerId} tabId={tabId} />,
+ },
+ {
+ key: 'triggers',
+ label: 'Triggers',
+ content: <ScannerTriggers scannerId={scannerId} tabId={tabId} />,
+ },
{
key: 'configuration',
label: 'Configuration',
@@ -110,10 +120,7 @@ export function ReplayScannerSceneComponent({ tabId }: { tabId: string }): JSX.E
<LemonSwitch checked={!!value} onChange={onChange} />
<div>
<div className="text-sm font-medium">Emit PostHog Signals</div>
- <div className="text-xs text-muted">
- When on, the model also identifies actionable issues that feed into PostHog
- Signals.
- </div>
+ <div className="text-xs text-muted">Also flags actionable issues as Signals.</div>
</div>
</div>
)}
@@ -121,16 +128,6 @@ export function ReplayScannerSceneComponent({ tabId }: { tabId: string }): JSX.E
</div>
),
},
- {
- key: 'triggers',
- label: 'Triggers',
- content: <ScannerTriggers scannerId={scannerId} tabId={tabId} />,
- },
- !isNew && {
- key: 'observations' as EditorTab,
- label: 'Observations',
- content: <ScannerObservationsTable scannerId={scannerId} tabId={tabId} />,
- },
]
return (
diff --git a/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.tsx b/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.tsx
index f817030e3938..6ce8a4432fab 100644
--- a/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.tsx
+++ b/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.tsx
@@ -131,12 +131,11 @@ export function ReplayScannersScene(): JSX.Element {
sorter: (a, b) => a.scanner_type.localeCompare(b.scanner_type),
},
{
- title: 'Config',
- key: 'config',
- width: '40%',
+ title: 'Description',
+ key: 'description',
render: (_, scanner) => (
- <div className="text-sm font-mono bg-bg-light border rounded px-2 py-1 truncate">
- {scanner.scanner_config.prompt || '(empty)'}
+ <div className="text-sm text-muted truncate max-w-md">
+ {scanner.description || <span className="italic">No description</span>}
</div>
),
},
diff --git a/products/replay_vision/frontend/replay_scanners/components/ScannerObservationsTable.tsx b/products/replay_vision/frontend/replay_scanners/components/ScannerObservationsTable.tsx
index 500fa2b3b689..28a664563b1f 100644
--- a/products/replay_vision/frontend/replay_scanners/components/ScannerObservationsTable.tsx
+++ b/products/replay_vision/frontend/replay_scanners/components/ScannerObservationsTable.tsx
@@ -1,13 +1,13 @@
import { useActions, useValues } from 'kea'
-import { IconRefresh } from '@posthog/icons'
+import { IconRefresh, IconRewindPlay } from '@posthog/icons'
import { LemonButton, LemonTable, LemonTag, Link, Tooltip } from '@posthog/lemon-ui'
import { TZLabel } from 'lib/components/TZLabel'
import { LemonTableColumns } from 'lib/lemon-ui/LemonTable'
import { urls } from 'scenes/urls'
-import { ObservationCard, ObservationResultSummary, ObservationStatusTag } from '../../components/ObservationCard'
+import { ObservationResultSummary, ObservationStatusTag } from '../../components/ObservationCard'
import type { ReplayObservationApi } from '../../generated/api.schemas'
import { replayScannerLogic } from '../replayScannerLogic'
@@ -42,7 +42,10 @@ export function ScannerObservationsTable({ scannerId, tabId }: { scannerId: stri
key: 'session',
width: 300,
render: (_, obs) => (
- <Link to={urls.replaySingle(obs.session_id)} className="font-mono text-xs text-primary truncate block">
+ <Link
+ to={urls.replayVisionObservation(obs.id)}
+ className="font-mono text-xs text-primary truncate block"
+ >
{obs.session_id}
</Link>
),
@@ -55,7 +58,11 @@ export function ScannerObservationsTable({ scannerId, tabId }: { scannerId: stri
{
title: 'Result',
key: 'result',
- render: (_, obs) => <ObservationResultSummary observation={obs} />,
+ render: (_, obs) => (
+ <div className="min-w-[18rem] max-w-xl">
+ <ObservationResultSummary observation={obs} />
+ </div>
+ ),
},
{
title: 'Triggered by',
@@ -66,23 +73,32 @@ export function ScannerObservationsTable({ scannerId, tabId }: { scannerId: stri
</LemonTag>
),
},
- {
- title: 'Model',
- key: 'model',
- render: (_, obs) => (
- <span className="font-mono text-xs text-muted">{obs.scanner_snapshot?.model || '—'}</span>
- ),
- },
{
title: 'Created',
key: 'created_at',
render: (_, obs) => <TZLabel time={obs.created_at} />,
sorter: (a, b) => a.created_at.localeCompare(b.created_at),
},
+ {
+ title: '',
+ key: 'actions',
+ width: 1,
+ render: (_, obs) => (
+ <LemonButton
+ size="small"
+ type="secondary"
+ icon={<IconRewindPlay />}
+ to={urls.replaySingle(obs.session_id)}
+ className="whitespace-nowrap"
+ >
+ View recording
+ </LemonButton>
+ ),
+ },
]
return (
- <div className="space-y-4 max-w-6xl">
+ <div className="space-y-4">
<div className="flex items-start justify-between gap-4">
<p className="text-muted text-sm m-0">
Past applications of this scanner to session recordings. Each row is one observation.
@@ -146,15 +162,6 @@ export function ScannerObservationsTable({ scannerId, tabId }: { scannerId: stri
rowKey="id"
pagination={{ pageSize: 50 }}
nouns={['observation', 'observations']}
- expandable={{
- rowExpandable: (obs) =>
- obs.status === 'succeeded' || obs.status === 'failed' || obs.status === 'ineligible',
- expandedRowRender: (obs) => (
- <div className="p-2">
- <ObservationCard observation={obs} />
- </div>
- ),
- }}
emptyState={
<div className="p-6 text-center text-muted">
No observations yet. Observations appear here once the scanner runs on a schedule, or when you
diff --git a/products/replay_vision/frontend/replay_scanners/components/ScannerTriggers.tsx b/products/replay_vision/frontend/replay_scanners/components/ScannerTriggers.tsx
index f5f066de82c2..4a6ed471a5f2 100644
--- a/products/replay_vision/frontend/replay_scanners/components/ScannerTriggers.tsx
+++ b/products/replay_vision/frontend/replay_scanners/components/ScannerTriggers.tsx
@@ -30,8 +30,7 @@ export function ScannerTriggers({ scannerId, tabId }: { scannerId: string; tabId
return (
<div className="space-y-6 max-w-3xl">
<div className="text-sm text-muted">
- This scanner runs against completed session recordings that match the filters below. Sampling controls
- what fraction of matching sessions are observed.
+ Sampling and filters control which completed recordings this scanner runs against.
</div>
<Field name="sampling_rate" label="Sampling">
@@ -64,8 +63,7 @@ export function ScannerTriggers({ scannerId, tabId }: { scannerId: string; tabId
</div>
</div>
<div className="text-xs text-muted">
- Each observation counts against your monthly Vision quota. A scanner that matches 1,000
- sessions per day at 10% sampling produces ~100 observations per day.
+ Each observation counts against your monthly Vision quota.
</div>
</div>
)
@@ -86,8 +84,8 @@ export function ScannerTriggers({ scannerId, tabId }: { scannerId: string; tabId
return (
<div className="space-y-2">
<div className="text-sm text-muted">
- Filter by person, session, cohort, or event properties to target specific recordings.
- Leave empty to apply this scanner to all completed recordings.
+ Filter by person, session, cohort, or event properties. Leave empty to scan all
+ completed recordings.
</div>
<PropertyFilters
propertyFilters={properties}
diff --git a/products/replay_vision/frontend/replay_scanners/components/ScannerTypeConfigEditor.tsx b/products/replay_vision/frontend/replay_scanners/components/ScannerTypeConfigEditor.tsx
index 019ce04ec094..7dba111d198e 100644
--- a/products/replay_vision/frontend/replay_scanners/components/ScannerTypeConfigEditor.tsx
+++ b/products/replay_vision/frontend/replay_scanners/components/ScannerTypeConfigEditor.tsx
@@ -73,7 +73,20 @@ export function ScannerTypeConfigEditor({ scannerId, tabId }: { scannerId: strin
<div>
<div className="text-sm font-medium">Allow multiple tags per session</div>
<div className="text-xs text-muted">
- When off, the model picks exactly one tag. When on, it can pick zero or more.
+ Otherwise the model picks exactly one tag from your vocabulary.
+ </div>
+ </div>
+ </div>
+ )}
+ </Field>
+ <Field name="scanner_config.allow_freeform_tags">
+ {({ value, onChange }) => (
+ <div className="flex items-center gap-2">
+ <LemonSwitch checked={!!value} onChange={onChange} />
+ <div>
+ <div className="text-sm font-medium">Allow freeform tags</div>
+ <div className="text-xs text-muted">
+ Lets the model emit tags outside your tag vocabulary.
</div>
</div>
</div>
diff --git a/products/replay_vision/frontend/replay_scanners/types.ts b/products/replay_vision/frontend/replay_scanners/types.ts
index ddcb70857c01..7ae1f6254980 100644
--- a/products/replay_vision/frontend/replay_scanners/types.ts
+++ b/products/replay_vision/frontend/replay_scanners/types.ts
@@ -1,5 +1,6 @@
import { RecordingsQuery } from '~/queries/schema/schema-general'
+import { ScannerModelEnumApi } from '../generated/api.schemas'
import type { PatchedReplayScannerApi, ReplayScannerApi } from '../generated/api.schemas'
export type ScannerType = 'monitor' | 'classifier' | 'scorer' | 'summarizer' | 'indexer'
@@ -83,18 +84,32 @@ export function failureKindDescription(kind: FailureKind): string {
}
export const DEFAULT_PROVIDER = 'google'
-export const DEFAULT_MODEL = 'gemini-3-flash-preview'
+export const DEFAULT_MODEL: ScannerModelEnumApi = ScannerModelEnumApi.Gemini3FlashPreview
export const ENABLED_OPTIONS: { value: EnabledFilter; label: string }[] = [
{ value: 'enabled', label: 'Enabled' },
{ value: 'disabled', label: 'Disabled' },
]
-export const MODEL_OPTIONS: { value: string; label: string }[] = [
- { value: 'gemini-3-flash-preview', label: 'Gemini 3 Flash' },
- { value: 'gemini-3.1-flash-lite-preview', label: 'Gemini 3 Flash Lite' },
+export const MODEL_OPTIONS: { value: ScannerModelEnumApi; label: string }[] = [
+ { value: ScannerModelEnumApi.Gemini3FlashPreview, label: 'Gemini 3 Flash' },
+ { value: ScannerModelEnumApi.Gemini31FlashLitePreview, label: 'Gemini 3 Flash Lite' },
]
+export function modelLabel(model: string | null | undefined): string {
+ if (!model) {
+ return '—'
+ }
+ return MODEL_OPTIONS.find((opt) => opt.value === model)?.label ?? model
+}
+
+export function scannerTypeLabel(scannerType: ScannerType | null | undefined): string {
+ if (!scannerType) {
+ return '—'
+ }
+ return SCANNER_TYPE_OPTIONS.find((opt) => opt.value === scannerType)?.label ?? scannerType
+}
+
export const SCANNER_TYPE_OPTIONS: { value: ScannerType; label: string; description: string }[] = [
{
value: 'monitor',
@@ -123,9 +138,9 @@ export const SCANNER_TYPE_OPTIONS: { value: ScannerType; label: string; descript
},
]
-export type EditorTab = 'configuration' | 'triggers' | 'observations'
+export type EditorTab = 'observations' | 'triggers' | 'configuration'
-export const ALL_EDITOR_TABS: EditorTab[] = ['configuration', 'triggers', 'observations']
+export const ALL_EDITOR_TABS: EditorTab[] = ['observations', 'triggers', 'configuration']
export interface MonitorScannerConfig {
prompt: string
@@ -140,6 +155,7 @@ export interface ClassifierScannerConfig {
prompt: string
tags: string[]
multi_label: boolean
+ allow_freeform_tags?: boolean
}
export interface ScorerScannerConfig {
diff --git a/products/replay_vision/manifest.tsx b/products/replay_vision/manifest.tsx
index a1b8388649ec..1c9cf64cf6b7 100644
--- a/products/replay_vision/manifest.tsx
+++ b/products/replay_vision/manifest.tsx
@@ -24,9 +24,17 @@ export const manifest: ProductManifest = {
iconType: 'replay_vision',
layout: 'app-container',
},
+ ReplayVisionObservation: {
+ name: 'Replay vision observation',
+ import: () => import('./frontend/observations/ReplayObservation'),
+ projectBased: true,
+ iconType: 'replay_vision',
+ layout: 'app-container',
+ },
},
routes: {
'/replay-vision': ['ReplayVision', 'replayVision'],
+ '/replay-vision/observations/:observationId': ['ReplayVisionObservation', 'replayVisionObservation'],
'/replay-vision/:id': ['ReplayVisionScanner', 'replayVision'],
},
redirects: {},
@@ -34,6 +42,7 @@ export const manifest: ProductManifest = {
replayVision:
/** @param id A UUID or 'new'. Omit for the scanner list page. */
(id?: string): string => (id ? `/replay-vision/${id}` : '/replay-vision'),
+ replayVisionObservation: (observationId: string): string => `/replay-vision/observations/${observationId}`,
},
fileSystemTypes: {},
treeItemsNew: [],