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): show highlights from observations on replay (#78189)

Hayne Ryuc1cf4a5535ee
diff --git a/frontend/src/scenes/session-recordings/player/SessionRecordingPlayer.tsx b/frontend/src/scenes/session-recordings/player/SessionRecordingPlayer.tsx
index a9be6463d92e..e1ebcceaef08 100644
--- a/frontend/src/scenes/session-recordings/player/SessionRecordingPlayer.tsx
+++ b/frontend/src/scenes/session-recordings/player/SessionRecordingPlayer.tsx
@@ -60,6 +60,8 @@ export function SessionRecordingPlayer(props: SessionRecordingPlayerProps): JSX.
sessionRecordingData,
autoPlay,
withSidebar,
+ noMeta,
+ noDock,
mode,
playerRef,
pinned,
diff --git a/frontend/src/scenes/session-recordings/player/controller/Seekbar.scss b/frontend/src/scenes/session-recordings/player/controller/Seekbar.scss
index 7bf8ab6780c5..b476f9de04e9 100644
--- a/frontend/src/scenes/session-recordings/player/controller/Seekbar.scss
+++ b/frontend/src/scenes/session-recordings/player/controller/Seekbar.scss
@@ -105,6 +105,23 @@
}
}
+ .PlayerSeekbar__observation {
+ position: absolute;
+ z-index: 4;
+ width: 3px;
+ height: 100%;
+ margin-left: -1.5px;
+ cursor: pointer;
+ background-color: var(--color-accent);
+ border-radius: 2px;
+ opacity: 0.75;
+ transition: opacity 150ms ease;
+
+ &:hover {
+ opacity: 1;
+ }
+ }
+
.PlayerSeekbar__unplayable {
position: absolute;
top: 0;
diff --git a/frontend/src/scenes/session-recordings/player/controller/Seekbar.tsx b/frontend/src/scenes/session-recordings/player/controller/Seekbar.tsx
index 24bd32ecb680..0afd27507597 100644
--- a/frontend/src/scenes/session-recordings/player/controller/Seekbar.tsx
+++ b/frontend/src/scenes/session-recordings/player/controller/Seekbar.tsx
@@ -11,6 +11,8 @@ import { Tooltip } from 'lib/lemon-ui/Tooltip'
import { cn } from 'lib/utils/css-classes'
import { humanFriendlyDuration } from 'lib/utils/durations'
+import { ObservationSeekbarMarks } from 'products/replay_vision/frontend/components/ObservationSeekbarMarks'
+
import { playerInspectorLogic } from '../inspector/playerInspectorLogic'
import { playerMetaLogic } from '../player-meta/playerMetaLogic'
import { playerSettingsLogic } from '../playerSettingsLogic'
@@ -136,6 +138,7 @@ export function Seekbar(): JSX.Element {
endTimeMs={endTimeMs}
onSeekToSegment={seekToTime}
/>
+ <ObservationSeekbarMarks endTimeMs={endTimeMs} onSeek={seekToTime} />
{hasLateFullSnapshot && endTimeMs > 0 ? (
<Tooltip
title={`The first ${humanFriendlyDuration(leadingUnplayableMs / 1000, {
diff --git a/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.ts b/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.ts
index ff8d78406b61..bf2d43bff845 100644
--- a/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.ts
+++ b/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.ts
@@ -150,6 +150,8 @@ export interface SessionRecordingPlayerLogicProps extends SessionRecordingDataCo
onRecordingDeleted?: () => void
autoPlay?: boolean
withSidebar?: boolean
+ noMeta?: boolean
+ noDock?: boolean
mode?: SessionRecordingPlayerMode
playerRef?: RefObject<HTMLDivElement>
pinned?: boolean
diff --git a/products/replay_vision/frontend/components/ObservationSeekbarMarks.tsx b/products/replay_vision/frontend/components/ObservationSeekbarMarks.tsx
new file mode 100644
index 000000000000..441575a4e9b3
--- /dev/null
+++ b/products/replay_vision/frontend/components/ObservationSeekbarMarks.tsx
@@ -0,0 +1,91 @@
+import { useValues } from 'kea'
+import React from 'react'
+
+import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
+import { Tooltip } from 'lib/lemon-ui/Tooltip'
+import { colonDelimitedDuration } from 'lib/utils/durations'
+import {
+ SessionRecordingPlayerMode,
+ sessionRecordingPlayerLogic,
+} from 'scenes/session-recordings/player/sessionRecordingPlayerLogic'
+
+import { observationsDockLogic } from '../logics/observationsDockLogic'
+
+interface ObservationSeekbarMarksProps {
+ endTimeMs: number
+ onSeek: (timestampMs: number) => void
+}
+
+// Same gate as the observations dock: marks only appear where the dock does, so no player fetches observations that didn't already.
+export const ObservationSeekbarMarks = React.memo(function ObservationSeekbarMarks(
+ props: ObservationSeekbarMarksProps
+): JSX.Element | null {
+ const { sessionRecordingId, logicProps } = useValues(sessionRecordingPlayerLogic)
+ const hasReplayVision = useFeatureFlag('REPLAY_VISION')
+ const mode = logicProps.mode ?? SessionRecordingPlayerMode.Standard
+ const dockShown =
+ hasReplayVision && mode === SessionRecordingPlayerMode.Standard && !logicProps.noMeta && !logicProps.noDock
+ if (!dockShown || !sessionRecordingId) {
+ return null
+ }
+ return <ObservationSeekbarMarksContent sessionId={sessionRecordingId} {...props} />
+})
+
+function ObservationSeekbarMarksContent({
+ sessionId,
+ endTimeMs,
+ onSeek,
+}: ObservationSeekbarMarksProps & { sessionId: string }): JSX.Element | null {
+ const { seekbarMarks } = useValues(observationsDockLogic({ sessionId }))
+
+ if (seekbarMarks.length === 0 || endTimeMs <= 0) {
+ return null
+ }
+
+ return (
+ <>
+ {seekbarMarks.map((mark) => {
+ const position = (mark.timestampMs / endTimeMs) * 100
+ if (position < 0 || position > 100) {
+ return null
+ }
+ const timeLabel = colonDelimitedDuration(Math.floor(mark.timestampMs / 1000), null)
+ return (
+ <Tooltip
+ key={mark.timestampMs}
+ title={
+ <div className="flex flex-col gap-1">
+ <span className="font-medium">{timeLabel}</span>
+ {mark.entries.map((entry, i) => (
+ <div key={i} className="flex flex-col">
+ <span>
+ {[entry.scannerName ?? 'Scanner', entry.headline]
+ .filter(Boolean)
+ .join(' · ')}
+ </span>
+ {entry.snippet && <span className="text-xs opacity-75">{entry.snippet}</span>}
+ </div>
+ ))}
+ </div>
+ }
+ placement="top"
+ >
+ <div
+ className="PlayerSeekbar__observation"
+ data-attr="vision-seekbar-observation-mark"
+ // eslint-disable-next-line react/forbid-dom-props
+ style={{ left: `${position}%` }}
+ // The slider scrubs on mousedown. Without this the pointer-position seek overrides the exact one.
+ onMouseDown={(e) => e.stopPropagation()}
+ onTouchStart={(e) => e.stopPropagation()}
+ onClick={(e) => {
+ e.stopPropagation()
+ onSeek(mark.timestampMs)
+ }}
+ />
+ </Tooltip>
+ )
+ })}
+ </>
+ )
+}
diff --git a/products/replay_vision/frontend/logics/observationsDockLogic.ts b/products/replay_vision/frontend/logics/observationsDockLogic.ts
index e73e7a8ea9e6..5dfff4977af9 100644
--- a/products/replay_vision/frontend/logics/observationsDockLogic.ts
+++ b/products/replay_vision/frontend/logics/observationsDockLogic.ts
@@ -6,6 +6,7 @@ import { teamLogic } from 'scenes/teamLogic'
import { visionObservationsList, visionScannersObserveCreate } from '../generated/api'
import type { ReplayScannerApi, ReplayObservationApi } from '../generated/api.schemas'
+import { ObservationSeekbarMark, observationSeekbarMarks } from '../utils/observation'
import { OBSERVE_POLL_GRACE_MS, scheduleObservationPoll, shouldPollObservations } from './observationPolling'
import { requestObservationRetry } from './observationRetry'
import { refreshVisionQuota } from './visionQuotaLogic'
@@ -29,6 +30,7 @@ export interface observationsDockLogicValues {
retryingObservationIds: string[]
scannerPickerOpen: boolean
scannerSearch: string
+ seekbarMarks: ObservationSeekbarMark[]
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
@@ -76,6 +78,7 @@ export interface observationsDockLogicMeta {
key: string
__keaTypeGenInternalSelectorTypes: {
hasObservationsInFlight: (observations: ReplayObservationApi[]) => boolean
+ seekbarMarks: (observations: ReplayObservationApi[]) => ObservationSeekbarMark[]
filteredScanners: (scanners: ReplayScannerApi[], scannerSearch: string) => ReplayScannerApi[]
}
}
@@ -184,6 +187,10 @@ export const observationsDockLogic = kea<observationsDockLogicType>([
(observations: ReplayObservationApi[]): boolean =>
observations.some((o) => o.status === 'pending' || o.status === 'running'),
],
+ seekbarMarks: [
+ (s) => [s.observations],
+ (observations: ReplayObservationApi[]): ObservationSeekbarMark[] => observationSeekbarMarks(observations),
+ ],
filteredScanners: [
(s) => [s.scanners, s.scannerSearch],
(scanners: ReplayScannerApi[], scannerSearch: string): ReplayScannerApi[] => {
diff --git a/products/replay_vision/frontend/utils/observation.test.ts b/products/replay_vision/frontend/utils/observation.test.ts
index 0a28509f05fe..6103c5a73fa2 100644
--- a/products/replay_vision/frontend/utils/observation.test.ts
+++ b/products/replay_vision/frontend/utils/observation.test.ts
@@ -1,44 +1,153 @@
import type { ReplayObservationApi } from '../generated/api.schemas'
-import { observationClipboardText } from './observation'
+import { ObservationSeekbarMark, observationClipboardText, observationSeekbarMarks } from './observation'
+
+const summarizerEntry = { scannerName: 'Session summarizer', headline: null, snippet: 'Rage clicked pay' }
+const longSentence = 'x'.repeat(200)
function makeObservation(
scannerType: string,
modelOutput: Record<string, unknown> | null,
- status: ReplayObservationApi['status'] = 'succeeded'
+ status: ReplayObservationApi['status'] = 'succeeded',
+ scannerName: string = 'Scanner'
): ReplayObservationApi {
return {
id: 'obs-1',
session_id: 'sess-1',
status,
created_at: '2026-07-27T10:00:00Z',
- scanner_snapshot: { scanner_type: scannerType },
+ scanner_snapshot: { scanner_type: scannerType, name: scannerName },
scanner_result: modelOutput ? { model_output: modelOutput } : null,
} as unknown as ReplayObservationApi
}
-describe('observationClipboardText', () => {
- it.each<{ name: string; obs: ReplayObservationApi; expected: string | null }>([
- {
- name: 'summarizer: title headline, summary body with citations as plain timestamps',
- obs: makeObservation('summarizer', { title: 'Checkout rage', summary: 'Rage clicked pay (t 161).' }),
- expected: '[2026-07-27 · sess-1] Checkout rage\nRage clicked pay (02:41).',
- },
- {
- name: 'monitor: verdict headline, reasoning body',
- obs: makeObservation('monitor', { verdict: 'yes', reasoning: 'Error toast shown.' }),
- expected: '[2026-07-27 · sess-1] Verdict: yes\nError toast shown.',
- },
- {
- name: 'failed observations are excluded',
- obs: makeObservation('monitor', { verdict: 'yes' }, 'failed'),
- expected: null,
- },
- {
- name: 'no output yields nothing',
- obs: makeObservation('summarizer', null),
- expected: null,
- },
- ])('$name', ({ obs, expected }) => {
- expect(observationClipboardText(obs)).toBe(expected)
+describe('observation utils', () => {
+ describe('observationClipboardText', () => {
+ it.each<{ name: string; obs: ReplayObservationApi; expected: string | null }>([
+ {
+ name: 'summarizer: title headline, summary body with citations as plain timestamps',
+ obs: makeObservation('summarizer', { title: 'Checkout rage', summary: 'Rage clicked pay (t 161).' }),
+ expected: '[2026-07-27 · sess-1] Checkout rage\nRage clicked pay (02:41).',
+ },
+ {
+ name: 'monitor: verdict headline, reasoning body',
+ obs: makeObservation('monitor', { verdict: 'yes', reasoning: 'Error toast shown.' }),
+ expected: '[2026-07-27 · sess-1] Verdict: yes\nError toast shown.',
+ },
+ {
+ name: 'failed observations are excluded',
+ obs: makeObservation('monitor', { verdict: 'yes' }, 'failed'),
+ expected: null,
+ },
+ {
+ name: 'no output yields nothing',
+ obs: makeObservation('summarizer', null),
+ expected: null,
+ },
+ ])('$name', ({ obs, expected }) => {
+ expect(observationClipboardText(obs)).toBe(expected)
+ })
+ })
+
+ describe('observationSeekbarMarks', () => {
+ it.each<{ name: string; observations: ReplayObservationApi[]; expected: ObservationSeekbarMark[] }>([
+ {
+ name: 'summarizer: persisted citation segments become marks, deduped and ascending',
+ observations: [
+ makeObservation(
+ 'summarizer',
+ {
+ summary: 'Rage clicked pay',
+ summary_segments: [
+ { kind: 'text', value: 'Rage clicked pay' },
+ { kind: 'chip', timestamp_ms: 161_000 },
+ { kind: 'chip', timestamp_ms: 30_000 },
+ { kind: 'chip', timestamp_ms: 161_000 },
+ ],
+ },
+ 'succeeded',
+ 'Session summarizer'
+ ),
+ ],
+ expected: [
+ { timestampMs: 30_000, entries: [summarizerEntry] },
+ { timestampMs: 161_000, entries: [summarizerEntry] },
+ ],
+ },
+ {
+ name: 'monitor: leaked (t N) markers parsed client-side, verdict headline, citing sentence as snippet',
+ observations: [
+ makeObservation(
+ 'monitor',
+ { verdict: 'yes', reasoning: 'User opened checkout. Error toast shown (t 42).' },
+ 'succeeded',
+ 'Error monitor'
+ ),
+ ],
+ expected: [
+ {
+ timestampMs: 42_000,
+ entries: [
+ {
+ scannerName: 'Error monitor',
+ headline: 'Verdict: yes',
+ snippet: 'Error toast shown',
+ },
+ ],
+ },
+ ],
+ },
+ {
+ name: 'two scanners citing the same moment merge into one mark',
+ observations: [
+ makeObservation('monitor', { reasoning: 'Saw it (t 42).' }, 'succeeded', 'Monitor A'),
+ makeObservation('scorer', { score: 3, reasoning: 'Also saw it (t 42).' }, 'succeeded', 'Scorer B'),
+ ],
+ expected: [
+ {
+ timestampMs: 42_000,
+ entries: [
+ { scannerName: 'Monitor A', headline: null, snippet: 'Saw it' },
+ { scannerName: 'Scorer B', headline: 'Score: 3', snippet: 'Also saw it' },
+ ],
+ },
+ ],
+ },
+ {
+ name: 'non-succeeded observations contribute no marks',
+ observations: [makeObservation('monitor', { reasoning: 'Saw it (t 42).' }, 'failed')],
+ expected: [],
+ },
+ {
+ name: 'snippets longer than 160 characters are truncated with an ellipsis',
+ observations: [makeObservation('monitor', { reasoning: `${longSentence} (t 42).` })],
+ expected: [
+ {
+ timestampMs: 42_000,
+ entries: [
+ { scannerName: 'Scanner', headline: null, snippet: `${longSentence.slice(0, 159)}…` },
+ ],
+ },
+ ],
+ },
+ {
+ name: 'output without citations yields no marks',
+ observations: [makeObservation('monitor', { verdict: 'yes', reasoning: 'Error toast shown.' })],
+ expected: [],
+ },
+ {
+ name: 'citation with no preceding text yields a null snippet',
+ observations: [
+ makeObservation('summarizer', {
+ summary: 'Rage clicked pay',
+ summary_segments: [{ kind: 'chip', timestamp_ms: 42_000 }],
+ }),
+ ],
+ expected: [
+ { timestampMs: 42_000, entries: [{ scannerName: 'Scanner', headline: null, snippet: null }] },
+ ],
+ },
+ ])('$name', ({ observations, expected }) => {
+ expect(observationSeekbarMarks(observations)).toEqual(expected)
+ })
})
})
diff --git a/products/replay_vision/frontend/utils/observation.ts b/products/replay_vision/frontend/utils/observation.ts
index 7d8a4805893b..ca1d3b8d5e35 100644
--- a/products/replay_vision/frontend/utils/observation.ts
+++ b/products/replay_vision/frontend/utils/observation.ts
@@ -1,7 +1,7 @@
import { dayjs } from 'lib/dayjs'
import type { ReplayObservationApi } from '../generated/api.schemas'
-import { citedTextToPlainText } from './citations'
+import { citedTextToPlainText, parseCitedSegments } from './citations'
export function readModelOutput(obs: ReplayObservationApi): Record<string, unknown> | null {
const out = obs.scanner_result?.model_output
@@ -51,6 +51,101 @@ export function readTags(obs: ReplayObservationApi): string[] {
return [...readFixedTags(obs), ...readFreeformTags(obs)]
}
+export interface ObservationSeekbarMarkEntry {
+ scannerName: string | null
+ headline: string | null
+ snippet: string | null
+}
+
+export interface ObservationSeekbarMark {
+ timestampMs: number
+ entries: ObservationSeekbarMarkEntry[]
+}
+
+const SNIPPET_MAX_LENGTH = 160
+
+function lastSentence(text: string): string | null {
+ const trimmed = text.trim()
+ if (!trimmed) {
+ return null
+ }
+ // No lookbehind regex, it breaks chunk parsing on older browsers.
+ let start = 0
+ for (const match of trimmed.matchAll(/[.!?]+\s+/g)) {
+ start = match.index + match[0].length
+ }
+ const last = trimmed
+ .slice(start)
+ .replace(/[.!?]+$/, '')
+ .trim()
+ if (!last) {
+ return null
+ }
+ return last.length > SNIPPET_MAX_LENGTH ? `${last.slice(0, SNIPPET_MAX_LENGTH - 1)}…` : last
+}
+
+/** Cited timestamps in a succeeded observation's output, each with the sentence that cites it. */
+function readCitations(obs: ReplayObservationApi): { timestampMs: number; snippet: string | null }[] {
+ const output = readModelOutput(obs)
+ if (!output || obs.status !== 'succeeded') {
+ return []
+ }
+ const [text, segments] =
+ obs.scanner_snapshot?.scanner_type === 'summarizer'
+ ? [output.summary, output.summary_segments]
+ : [output.reasoning, output.reasoning_segments]
+ if (typeof text !== 'string' || !text) {
+ return []
+ }
+ const parsed = parseCitedSegments(text, segments)
+ const snippetByTimestamp = new Map<number, string | null>()
+ parsed.forEach((segment, index) => {
+ if (segment.kind !== 'chip' || snippetByTimestamp.has(segment.timestamp_ms)) {
+ return
+ }
+ let snippet: string | null = null
+ for (let i = index - 1; i >= 0; i--) {
+ const previous = parsed[i]
+ if (previous.kind === 'text') {
+ snippet = lastSentence(previous.value)
+ break
+ }
+ }
+ snippetByTimestamp.set(segment.timestamp_ms, snippet)
+ })
+ return [...snippetByTimestamp.entries()].map(([timestampMs, snippet]) => ({ timestampMs, snippet }))
+}
+
+function observationHeadline(obs: ReplayObservationApi): string | null {
+ const scannerType = obs.scanner_snapshot?.scanner_type
+ if (scannerType === 'monitor') {
+ const verdict = readVerdict(obs)
+ return verdict ? `Verdict: ${verdict}` : null
+ }
+ if (scannerType === 'scorer') {
+ const score = readScore(obs)
+ return score !== null ? `Score: ${score}` : null
+ }
+ return null
+}
+
+/** One mark per cited timestamp; entries merged when scanners cite the same moment. */
+export function observationSeekbarMarks(observations: ReplayObservationApi[]): ObservationSeekbarMark[] {
+ const entriesByTimestamp = new Map<number, Map<string, ObservationSeekbarMarkEntry>>()
+ for (const obs of observations) {
+ const scannerName = obs.scanner_snapshot?.name ?? null
+ const headline = observationHeadline(obs)
+ for (const { timestampMs, snippet } of readCitations(obs)) {
+ const entries = entriesByTimestamp.get(timestampMs) ?? new Map<string, ObservationSeekbarMarkEntry>()
+ entries.set(JSON.stringify([scannerName, headline, snippet]), { scannerName, headline, snippet })
+ entriesByTimestamp.set(timestampMs, entries)
+ }
+ }
+ return [...entriesByTimestamp.entries()]
+ .sort(([a], [b]) => a - b)
+ .map(([timestampMs, entries]) => ({ timestampMs, entries: [...entries.values()] }))
+}
+
/** One succeeded observation as clipboard text: a metadata line, then the result body. */
export function observationClipboardText(obs: ReplayObservationApi): string | null {
const output = readModelOutput(obs)