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): lay the observations section out for the wide player (#127410)

Hayne Ryu1c547c52aadd
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 9b6464a35917..38fcc86289d6 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -15223,9 +15223,9 @@ snapshots:
scenes-app-replay-vision-highlightfeedemptystate--replay-off--light:
hash: v1.k794b7964.efdafaa9746c142c7fa9a0bd0bbada2e935fa2e3a7304d9d27323b452885d0a4.u-la7nBxCH2WXQqMM9b7V8lu95C2TDlKlyfa8MDgung
scenes-app-replay-vision-observations-tab-in-the-player--scans-without-a-summary--dark:
- hash: v1.k794b7964.541ee5233b1f6805324b95d5d01de4cfec0b0012e0cceb100339735c9dcbd338.a66QPGNk0yvyiiaTOmkd2k1leqmyN9g85cLMJ8EWdXE
+ hash: v1.k794b7964.3ca23c5d25ff42d01cc193744433cc8e4c85be7eb5f0ce9e619bfd869575b70c.Kzu13dVcfsnUO1d1QYK3P23-fuOczBIHn-lmhR5HNuE
scenes-app-replay-vision-observations-tab-in-the-player--scans-without-a-summary--light:
- hash: v1.k794b7964.db23e0a097d8b126311d34389654c7e3e2a2f1eb070090d484b4977736db0b64.z7YTE4X2ZpMgVow1sWEijAXxKOH8UM-28wwDIiB7d8g
+ hash: v1.k794b7964.274fb5f0b4b6eb216c368482363bb26772c48fd04b456c74ba74c7b7b9299dee.D-nhgRaEokKEt_2pn_COIjHqvfpDbjQ-daMltASxp9M
scenes-app-replay-vision-observations-tab-in-the-player--timeline-with-scans--dark:
hash: v1.k794b7964.5d3dbd7b44baa14a4d441dab5a95f5160b9cdfc0d796f02be45a0774e6779c6c.xTMCRyvVbIEmXln90wTFTe3jZdBkIIZbi-V5TsQxVV4
scenes-app-replay-vision-observations-tab-in-the-player--timeline-with-scans--light:
diff --git a/frontend/src/scenes/session-recordings/player/watch/RecordingObservationsSection.tsx b/frontend/src/scenes/session-recordings/player/watch/RecordingObservationsSection.tsx
index f11238a754d8..ef1da58c3516 100644
--- a/frontend/src/scenes/session-recordings/player/watch/RecordingObservationsSection.tsx
+++ b/frontend/src/scenes/session-recordings/player/watch/RecordingObservationsSection.tsx
@@ -22,7 +22,11 @@ export function RecordingObservationsSection({ sessionId }: { sessionId: string
const content = !hasLoadedObservations ? (
<LemonSkeleton className="h-24 m-2" />
) : observations.length === 0 ? (
- <RecordingObservationsEmptyState sessionId={sessionId} scanBlock={recordingScanBlock(sessionPlayerMetaData)} />
+ <RecordingObservationsEmptyState
+ sessionId={sessionId}
+ scanBlock={recordingScanBlock(sessionPlayerMetaData)}
+ surface="watch"
+ />
) : (
<div className="flex flex-col max-h-[60vh]">
<RecordingMoments key={sessionId} sessionId={sessionId} playerLogicProps={logicProps} />
diff --git a/products/replay_vision/frontend/components/ChapterFilmstrip.tsx b/products/replay_vision/frontend/components/ChapterFilmstrip.tsx
new file mode 100644
index 000000000000..a64a3c0fa773
--- /dev/null
+++ b/products/replay_vision/frontend/components/ChapterFilmstrip.tsx
@@ -0,0 +1,159 @@
+import { useCallback, useEffect, useRef, useState } from 'react'
+
+import { IconChevronLeft, IconChevronRight } from '@posthog/icons'
+import { LemonButton, Tooltip } from '@posthog/lemon-ui'
+
+import { useResizeObserver } from 'lib/hooks/useResizeObserver'
+import { cn } from 'lib/utils/css-classes'
+import { colonDelimitedDuration, humanFriendlyDuration } from 'lib/utils/durations'
+
+import type { ReplayObservationApi } from '../generated/api.schemas'
+import { MIN_INACTIVE_ROW_MS, currentRowIndex } from '../utils/recordingTimeline'
+import { ObservationThumbnail } from './ObservationThumbnail'
+import { RecordingTimelineProps, SummaryNotice } from './RecordingTimeline'
+
+const formatSpan = (ms: number): string => humanFriendlyDuration(ms / 1000, { maxUnits: 1 })
+
+export function ChapterFilmstrip(props: RecordingTimelineProps): JSX.Element {
+ const { timeline, rows, currentTimeMs, onSeek } = props
+ const [edges, setEdges] = useState({ atStart: true, atEnd: true })
+ const stripRef = useRef<HTMLDivElement | null>(null)
+ const { width, ref: observeStrip } = useResizeObserver<HTMLDivElement>()
+ const currentIndex = currentRowIndex(rows, currentTimeMs)
+ const hasHours = rows.some((row) => row.kind === 'chapter' && row.chapter.startMs >= 3_600_000)
+ const formatTime = (ms: number): string => colonDelimitedDuration(Math.floor(ms / 1000), hasHours ? 3 : 2)
+
+ const updateEdges = useCallback((): void => {
+ const strip = stripRef.current
+ if (!strip) {
+ return
+ }
+ setEdges({
+ atStart: strip.scrollLeft <= 1,
+ atEnd: strip.scrollLeft + strip.clientWidth >= strip.scrollWidth - 1,
+ })
+ }, [])
+
+ useEffect(updateEdges, [updateEdges, width, rows.length])
+
+ const setStrip = useCallback(
+ (element: HTMLDivElement | null): void => {
+ stripRef.current = element
+ observeStrip(element)
+ },
+ [observeStrip]
+ )
+
+ const page = (direction: -1 | 1): void => {
+ const strip = stripRef.current
+ strip?.scrollBy({ left: direction * strip.clientWidth * 0.8, behavior: 'smooth' })
+ }
+
+ return (
+ <div className="flex flex-col" data-attr="vision-chapter-filmstrip">
+ {rows.length > 0 && (
+ <div className="flex items-center gap-1 px-1.5 py-2">
+ <LemonButton
+ size="xsmall"
+ icon={<IconChevronLeft />}
+ tooltip="Earlier chapters"
+ disabledReason={edges.atStart ? 'At the start of the recording' : undefined}
+ onClick={() => page(-1)}
+ data-attr="vision-filmstrip-earlier"
+ />
+ <div
+ ref={setStrip}
+ onScroll={updateEdges}
+ className="flex flex-1 min-w-0 gap-2 overflow-x-auto snap-x snap-proximity [scrollbar-width:thin]"
+ >
+ {rows.map((row, index) => {
+ if (row.kind === 'boundary') {
+ return null
+ }
+ if (row.kind === 'inactive') {
+ return (
+ <span
+ key={`inactive-${row.startMs}`}
+ className="flex w-11 shrink-0 flex-col items-center justify-center border-x border-dashed text-center text-xxs text-tertiary"
+ data-attr="vision-filmstrip-inactive"
+ >
+ <span>{formatSpan(row.endMs - row.startMs)}</span>
+ <span>idle</span>
+ </span>
+ )
+ }
+ const { chapter } = row
+ const isCurrent = index === currentIndex
+ const summary = timeline.summary as ReplayObservationApi
+ return (
+ <button
+ key={`chapter-${chapter.startMs}`}
+ type="button"
+ onClick={() => onSeek(chapter.startMs)}
+ data-current-moment={isCurrent ? true : undefined}
+ className={cn(
+ 'flex min-w-0 shrink-0 grow basis-[9.5rem] max-w-[14rem] snap-start flex-col gap-1 rounded p-1 text-left cursor-pointer hover:bg-surface-secondary',
+ isCurrent && 'bg-fill-highlight-50'
+ )}
+ data-attr="vision-filmstrip-chapter"
+ >
+ <Tooltip
+ title={
+ chapter.hasFrame ? (
+ <ObservationThumbnail
+ observation={summary}
+ chapter={chapter.position}
+ className="w-128 border-0"
+ />
+ ) : undefined
+ }
+ placement="top"
+ delayMs={300}
+ containerClassName="max-w-none p-1"
+ >
+ <span className="flex w-full">
+ <ObservationThumbnail
+ observation={summary}
+ chapter={chapter.position}
+ className={cn('w-full', isCurrent && 'ring-2 ring-accent')}
+ size="small"
+ >
+ <span
+ className={cn(
+ 'absolute bottom-1 left-1 rounded bg-black/70 px-1 font-mono text-xxs text-white',
+ isCurrent && 'bg-accent'
+ )}
+ >
+ {formatTime(chapter.startMs)}
+ </span>
+ </ObservationThumbnail>
+ </span>
+ </Tooltip>
+ <span className="text-sm font-medium line-clamp-2">{chapter.title}</span>
+ <span className="text-xs text-secondary">
+ {formatSpan(chapter.endMs - chapter.startMs - chapter.inactiveMs)}
+ {chapter.inactiveMs >= MIN_INACTIVE_ROW_MS && (
+ <span className="text-tertiary">
+ {' '}
+ · {formatSpan(chapter.inactiveMs)} inactive
+ </span>
+ )}
+ </span>
+ </button>
+ )
+ })}
+ </div>
+ <LemonButton
+ size="xsmall"
+ icon={<IconChevronRight />}
+ tooltip="Later chapters"
+ disabledReason={edges.atEnd ? 'At the end of the recording' : undefined}
+ onClick={() => page(1)}
+ data-attr="vision-filmstrip-later"
+ />
+ </div>
+ )}
+ <SummaryNotice {...props} />
+ </div>
+ )
+}
diff --git a/products/replay_vision/frontend/components/RecordingMoments.tsx b/products/replay_vision/frontend/components/RecordingMoments.tsx
index ecd2bb4ea620..c08130717951 100644
--- a/products/replay_vision/frontend/components/RecordingMoments.tsx
+++ b/products/replay_vision/frontend/components/RecordingMoments.tsx
@@ -1,9 +1,8 @@
import { useActions, useValues } from 'kea'
-import { router } from 'kea-router'
import { useEffect, useMemo, useRef } from 'react'
import { IconChevronRight } from '@posthog/icons'
-import { LemonButton, LemonSwitch, LemonTag, Link, Spinner, Tooltip } from '@posthog/lemon-ui'
+import { LemonButton, LemonSwitch, Spinner } from '@posthog/lemon-ui'
import { useResizeObserver } from 'lib/hooks/useResizeObserver'
import { cn } from 'lib/utils/css-classes'
@@ -14,102 +13,24 @@ import {
} from 'scenes/session-recordings/player/sessionRecordingPlayerLogic'
import { playerUsesWatchLayout } from 'scenes/session-recordings/playlist/replayLayout'
-import type { ReplayObservationApi } from '../generated/api.schemas'
import { observationsDockLogic } from '../logics/observationsDockLogic'
import { visionQuotaLogic } from '../logics/visionQuotaLogic'
-import { SCANNER_TYPE_TAG_TYPE, scannerTypeLabel } from '../replay_scanners/types'
-import { RECORDING_ORIGIN, currentReturnPath, observationFromOriginUrl } from '../utils/breadcrumbs'
-import { isSummaryObservation, readModelOutput, readReasoning, scannerLabel } from '../utils/observation'
import { quotaUx } from '../utils/quotaProjection'
-import { currentRowIndex, nextTimelineStopMs, timelineRows as buildTimelineRows } from '../utils/recordingTimeline'
-import { recordingScanBlock } from '../utils/scanEligibility'
-import { CitedMarkdown } from './CitedMarkdown'
import {
- FailureDetail,
- IneligibleDetail,
- ObservationPrimaryOutput,
- ObservationResultSummary,
- ObservationStatusTag,
-} from './ObservationCard'
-import { ObservationProgressBar } from './ObservationProgressBar'
-import { ObservationRetryButton } from './ObservationRetryButton'
+ currentRowIndex,
+ nextTimelineStopMs,
+ timelineEndMs,
+ timelineRows as buildTimelineRows,
+} from '../utils/recordingTimeline'
+import { recordingScanBlock } from '../utils/scanEligibility'
+import { ChapterFilmstrip } from './ChapterFilmstrip'
+import { RecordingObservationsEmptyState } from './RecordingObservationsEmptyState'
import { RecordingTimeline } from './RecordingTimeline'
+import { ScanList } from './ScanList'
import { ScannerPicker } from './ScannerPicker'
-import { scannerTypeIcon } from './ScannerTypeBadge'
const CURRENT_MOMENT_SELECTOR = '[data-current-moment]'
-
-const isInFlight = (o: ReplayObservationApi): boolean => o.status === 'pending' || o.status === 'running'
-
-function defaultFocus(observations: ReplayObservationApi[]): ReplayObservationApi | null {
- return (
- observations.find(isInFlight) ?? observations.find((o) => o.status === 'succeeded') ?? observations[0] ?? null
- )
-}
-
-function ObservationRuns({
- sessionId,
- observations,
- onSeek,
-}: {
- sessionId: string
- observations: ReplayObservationApi[]
- onSeek: (timestampMs: number) => void
-}): JSX.Element | null {
- const logic = observationsDockLogic({ sessionId })
- const { focusedObservationId, retryingObservationIds } = useValues(logic)
- const { focusObservation, retryObservation } = useActions(logic)
- if (observations.length === 0) {
- return null
- }
- const focused = observations.find((o) => o.id === focusedObservationId) ?? defaultFocus(observations)
- return (
- <>
- <SectionHeader label="Observations" />
- <div>
- {observations.map((observation) => {
- const scannerType = observation.scanner_snapshot?.scanner_type
- return (
- <div key={observation.id} className="border-b border-primary">
- <LemonButton
- fullWidth
- size="small"
- className="rounded-none"
- active={observation.id === focused?.id}
- icon={
- scannerType ? (
- <Tooltip title={scannerTypeLabel(scannerType)}>
- <LemonTag type={SCANNER_TYPE_TAG_TYPE[scannerType]} size="small">
- {scannerTypeIcon(scannerType)}
- </LemonTag>
- </Tooltip>
- ) : undefined
- }
- onClick={() => focusObservation(observation.id)}
- data-attr="vision-run-row"
- >
- <span className="flex items-center gap-2 min-w-0 w-full font-normal">
- <span className="text-sm truncate flex-1">{scannerLabel(observation)}</span>
- <span className="flex items-center gap-2 min-w-0 max-w-[60%]">
- <RunResult observation={observation} />
- </span>
- </span>
- </LemonButton>
- {observation.id === focused?.id && (
- <FocusPane
- observation={observation}
- onSeek={onSeek}
- onRetry={() => retryObservation(observation.id)}
- retrying={retryingObservationIds.includes(observation.id)}
- />
- )}
- </div>
- )
- })}
- </div>
- </>
- )
-}
+const FILMSTRIP_MIN_WIDTH_PX = 840
function SectionHeader({ label, className }: { label: string; className?: string }): JSX.Element {
return (
@@ -124,103 +45,24 @@ function SectionHeader({ label, className }: { label: string; className?: string
)
}
-function RunResult({ observation }: { observation: ReplayObservationApi }): JSX.Element | null {
- if (observation.status !== 'succeeded') {
- return <ObservationStatusTag status={observation.status} errorReason={observation.error_reason} />
- }
- if (isSummaryObservation(observation)) {
- return null
- }
- return <ObservationResultSummary observation={observation} />
-}
-
-function FocusPane({
- observation,
- onSeek,
- onRetry,
- retrying,
-}: {
- observation: ReplayObservationApi
- onSeek: (timestampMs: number) => void
- onRetry: () => void
- retrying: boolean
-}): JSX.Element {
- const { height: contentHeight, ref: contentRef } = useResizeObserver<HTMLDivElement>({ box: 'border-box' })
- const { location } = useValues(router)
- const isSummary = isSummaryObservation(observation)
- const reasoning = observation.status === 'succeeded' && !isSummary ? readReasoning(observation) : null
- const hasText = observation.status === 'succeeded' && (isSummary || reasoning !== null)
- return (
- <div
- className="overflow-hidden transition-[height] duration-200 ease-in-out border-t bg-surface-primary"
- // eslint-disable-next-line react/forbid-dom-props
- style={{ height: contentHeight }}
- data-attr="vision-focus-run"
- >
- <div ref={contentRef}>
- {(observation.error_reason || isInFlight(observation)) && (
- <div className="flex flex-col gap-2 px-2 pb-2">
- {observation.status === 'failed' && observation.error_reason && (
- <FailureDetail errorReason={observation.error_reason} />
- )}
- {observation.status === 'ineligible' && observation.error_reason && (
- <IneligibleDetail errorReason={observation.error_reason} />
- )}
- {observation.error_reason && (
- <div>
- <ObservationRetryButton
- status={observation.status}
- errorReason={observation.error_reason}
- onRetry={onRetry}
- loading={retrying}
- size="xsmall"
- dataAttr="vision-tab-retry-observation"
- />
- </div>
- )}
- {isInFlight(observation) && (
- <ObservationProgressBar observationId={observation.id} sessionId={observation.session_id} />
- )}
- </div>
- )}
- <div className="flex flex-col gap-2 px-2 py-2">
- {hasText && (
- <div className="text-sm">
- {isSummary ? (
- <ObservationPrimaryOutput
- observation={observation}
- showPrompt={false}
- expandSummary
- copyable
- onSeek={onSeek}
- />
- ) : (
- <CitedMarkdown
- text={reasoning ?? ''}
- segments={readModelOutput(observation)?.reasoning_segments}
- onSeek={onSeek}
- />
- )}
- </div>
- )}
- <Link
- data-attr="vision-observation-open-from-sidebar"
- to={observationFromOriginUrl(observation.id, RECORDING_ORIGIN, currentReturnPath(location))}
- className="text-xs self-end"
- >
- View details
- </Link>
- </div>
- </div>
- </div>
- )
-}
-
export interface RecordingMomentsProps {
sessionId: string
playerLogicProps: SessionRecordingPlayerLogicProps
}
+// Aligned to the card's start, a snap point; a smaller scroll gets snapped back and the card stays clipped.
+function scrollIntoStrip(card: HTMLElement): void {
+ const strip = card.parentElement
+ if (!strip) {
+ return
+ }
+ const cardRect = card.getBoundingClientRect()
+ const stripRect = strip.getBoundingClientRect()
+ if (cardRect.left < stripRect.left || cardRect.right > stripRect.right) {
+ strip.scrollBy({ left: cardRect.left - stripRect.left })
+ }
+}
+
export function RecordingMoments({ sessionId, playerLogicProps }: RecordingMomentsProps): JSX.Element {
const logic = observationsDockLogic({ sessionId })
const { observations, observationsLoading, timeline, followMoments, summarizePending } = useValues(logic)
@@ -232,6 +74,7 @@ export function RecordingMoments({ sessionId, playerLogicProps }: RecordingMomen
const lastJumpMs = useRef<number | null>(null)
const timelineRef = useRef<HTMLDivElement>(null)
const followedIndex = useRef<number | null>(null)
+ const { width, ref: rootRef } = useResizeObserver<HTMLDivElement>()
const { logicProps, sessionPlayerMetaData, currentPlayerTime, sessionPlayerData } = useValues(
sessionRecordingPlayerLogic(playerLogicProps)
)
@@ -241,6 +84,7 @@ export function RecordingMoments({ sessionId, playerLogicProps }: RecordingMomen
sessionRecordingPlayerLogic.findMounted(logicProps)?.actions.seekToTime(ms)
}
const scanBlock = recordingScanBlock(sessionPlayerMetaData)
+ const filmstrip = inWatchLayout && width !== undefined && width >= FILMSTRIP_MIN_WIDTH_PX
// A seek can land short of its target. Step from the last jump while still on it.
const nextFrom =
lastJumpMs.current !== null && Math.abs(currentPlayerTime - lastJumpMs.current) < 1000
@@ -256,6 +100,10 @@ export function RecordingMoments({ sessionId, playerLogicProps }: RecordingMomen
}
const currentIndex = currentRowIndex(timelineRows, currentPlayerTime)
+ useEffect(() => {
+ followedIndex.current = null
+ }, [filmstrip])
+
useEffect(() => {
if (!followMoments) {
followedIndex.current = null
@@ -264,39 +112,44 @@ export function RecordingMoments({ sessionId, playerLogicProps }: RecordingMomen
if (currentIndex < 0 || followedIndex.current === currentIndex) {
return
}
+ const current = timelineRef.current?.querySelector<HTMLElement>(CURRENT_MOMENT_SELECTOR)
+ if (!current) {
+ return
+ }
followedIndex.current = currentIndex
- timelineRef.current?.querySelector<HTMLElement>(CURRENT_MOMENT_SELECTOR)?.scrollIntoView({ block: 'nearest' })
- }, [currentIndex, followMoments])
+ if (filmstrip) {
+ scrollIntoStrip(current)
+ } else {
+ current.scrollIntoView({ block: 'nearest' })
+ }
+ }, [currentIndex, followMoments, filmstrip, width])
+
+ const timelineProps = {
+ timeline,
+ rows: timelineRows,
+ currentTimeMs: currentPlayerTime,
+ onSeek: seekToTime,
+ onSummarize: () => summarize(inWatchLayout),
+ summarizing: summarizePending,
+ summarizeDisabledReason: scanBlock?.reason ?? quotaDisabledReason,
+ }
return (
// A container, so long observation text wraps at the sidebar's width instead of widening the sidebar.
- <div className="@container flex flex-col flex-1 min-h-0" data-attr="vision-observations-tab">
+ <div ref={rootRef} className="@container flex flex-col flex-1 min-h-0" data-attr="vision-observations-tab">
{observationsLoading && observations.length === 0 ? (
<div className="flex items-center gap-2 text-muted p-4">
<Spinner /> Loading observations…
</div>
) : observations.length === 0 ? (
- <div className="flex flex-col flex-1 items-center justify-center gap-2 p-4 text-center">
- {scanBlock ? (
- // No scanner can clear the gate, so the picker would only lead to an ineligible result.
- <>
- <p className="text-muted text-sm mb-0" data-attr="vision-observations-tab-skipped">
- Replay vision skipped this recording, so it has no summary.
- </p>
- <p className="text-muted text-xs mb-0">{scanBlock.reason}</p>
- </>
- ) : (
- <>
- <p className="text-muted text-sm mb-0">
- No observations yet. Pick a scanner to run on this recording.
- </p>
- <ScannerPicker sessionId={sessionId} scanBlock={scanBlock} />
- </>
- )}
- </div>
+ <RecordingObservationsEmptyState
+ sessionId={sessionId}
+ scanBlock={scanBlock}
+ surface={inWatchLayout ? 'watch' : 'tab'}
+ />
) : (
<>
- <div className="@container flex items-center gap-2 p-2 border-b bg-surface-secondary">
+ <div className="flex items-center gap-2 p-2 border-b bg-surface-secondary">
<ScannerPicker sessionId={sessionId} scanBlock={scanBlock} type="secondary" />
{timelineRows.length > 0 && (
<div className="ml-auto flex items-center gap-2">
@@ -324,33 +177,24 @@ export function RecordingMoments({ sessionId, playerLogicProps }: RecordingMomen
</div>
)}
</div>
- <div
- className={cn(
- 'flex-1 min-h-0 overflow-y-auto grid grid-cols-1 content-start',
- inWatchLayout &&
- '@[840px]:content-stretch @[840px]:grid-cols-2 @[840px]:grid-rows-[minmax(0,1fr)] @[840px]:overflow-hidden'
+ <div className="flex-1 min-h-0 overflow-y-auto" ref={timelineRef}>
+ {/* Nothing before the width is known, so posters are fetched once. */}
+ {width === undefined ? null : filmstrip ? (
+ <ChapterFilmstrip {...timelineProps} />
+ ) : (
+ <>
+ <SectionHeader label="Timeline" />
+ <RecordingTimeline {...timelineProps} />
+ </>
)}
- ref={timelineRef}
- >
- <div className={cn(inWatchLayout && '@[840px]:min-h-0 @[840px]:overflow-y-auto')}>
- <SectionHeader label="Timeline" />
- <RecordingTimeline
- timeline={timeline}
- rows={timelineRows}
- currentTimeMs={currentPlayerTime}
- onSeek={seekToTime}
- onSummarize={() => summarize(inWatchLayout)}
- summarizing={summarizePending}
- summarizeDisabledReason={scanBlock?.reason ?? quotaDisabledReason}
- />
- </div>
- <div
- className={cn(
- inWatchLayout && '@[840px]:min-h-0 @[840px]:overflow-y-auto @[840px]:border-l'
- )}
- >
- <ObservationRuns sessionId={sessionId} observations={observations} onSeek={seekToTime} />
- </div>
+ <SectionHeader label="Scans" />
+ <ScanList
+ sessionId={sessionId}
+ observations={observations}
+ endMs={timelineEndMs(timeline, durationMs)}
+ currentTimeMs={currentPlayerTime}
+ onSeek={seekToTime}
+ />
</div>
</>
)}
diff --git a/products/replay_vision/frontend/components/RecordingObservationsEmptyState.tsx b/products/replay_vision/frontend/components/RecordingObservationsEmptyState.tsx
index e593dd49bdc4..b0fff2b6db11 100644
--- a/products/replay_vision/frontend/components/RecordingObservationsEmptyState.tsx
+++ b/products/replay_vision/frontend/components/RecordingObservationsEmptyState.tsx
@@ -2,16 +2,18 @@ import { useValues } from 'kea'
import * as asleepPng from '@posthog/brand/hoggies/png/asleep'
import * as magnifyingGlassPng from '@posthog/brand/hoggies/png/magnifying-glass'
-import { LemonButton } from '@posthog/lemon-ui'
+import { LemonButton, LemonTag, Link } from '@posthog/lemon-ui'
import { pngHoggie } from 'lib/brand/hoggies'
+import { cn } from 'lib/utils/css-classes'
import { urls } from 'scenes/urls'
import { observationsDockLogic } from '../logics/observationsDockLogic'
-import { HighlightPicksStateFrame } from '../replay_scanners/components/HighlightPicksStateFrame'
+import { SCANNER_TYPE_TAG_TYPE, ScannerType } from '../replay_scanners/types'
import { ScanBlock } from '../utils/scanEligibility'
import { VisionDocsLink } from './DocsLink'
import { ScannerPicker } from './ScannerPicker'
+import { scannerTypeIcon } from './ScannerTypeBadge'
const HedgehogMagnifyingGlass = pngHoggie(magnifyingGlassPng)
const HedgehogAsleep = pngHoggie(asleepPng)
@@ -22,83 +24,152 @@ const SKIPPED_TITLE: Partial<Record<ScanBlock['kind'], string>> = {
too_long: 'Too long to scan',
}
-const TITLE = 'No observations yet'
-const BODY =
- 'Summarize this recording above for chapters and a short write-up, or run a scanner to check it for something specific.'
+interface ExampleScan {
+ scannerType: ScannerType
+ name: string
+ result: JSX.Element
+ line: string
+}
+
+// Invented, not sampled.
+const EXAMPLE_SCANS: ExampleScan[] = [
+ {
+ scannerType: 'monitor',
+ name: 'Checkout friction',
+ result: (
+ <LemonTag size="medium" type="highlight">
+ Yes
+ </LemonTag>
+ ),
+ line: 'Nine clicks on a disabled payment button, no request sent',
+ },
+ {
+ scannerType: 'scorer',
+ name: 'Frustration',
+ result: <span className="font-semibold">8</span>,
+ line: 'A rejected card and a retry, then an abandoned purchase',
+ },
+ {
+ scannerType: 'classifier',
+ name: 'Support intent',
+ result: (
+ <LemonTag size="medium" type="option">
+ Billing
+ </LemonTag>
+ ),
+ line: 'Help search for a payment error, then a plan change',
+ },
+]
+
+function ExampleScanRows({ className }: { className?: string }): JSX.Element {
+ return (
+ <div className={cn('relative flex min-w-0 flex-col', className)} data-attr="vision-observations-empty-examples">
+ <span className="pb-1 text-xs text-secondary">Examples, not your data</span>
+ <div className="rounded border border-primary opacity-60">
+ {EXAMPLE_SCANS.map((scan) => (
+ <div
+ key={scan.name}
+ className="flex items-center gap-2 border-b border-primary px-2 py-1.5 last:border-b-0"
+ >
+ <LemonTag type={SCANNER_TYPE_TAG_TYPE[scan.scannerType]} size="small">
+ {scannerTypeIcon(scan.scannerType)}
+ </LemonTag>
+ <span className="shrink-0 text-sm">{scan.name}</span>
+ <span className="shrink-0">{scan.result}</span>
+ <span className="min-w-0 flex-1 truncate text-xs text-secondary">{scan.line}</span>
+ </div>
+ ))}
+ </div>
+ <div
+ aria-hidden
+ className="pointer-events-none absolute inset-0 bg-gradient-to-b from-transparent from-45% to-surface-primary"
+ />
+ </div>
+ )
+}
+
+export type ObservationsSurface = 'watch' | 'tab'
+
+const SKIPPED_ATTR: Record<ObservationsSurface, string> = {
+ watch: 'vision-observations-skipped',
+ tab: 'vision-observations-tab-skipped',
+}
+const EMPTY_ATTR: Record<ObservationsSurface, string> = {
+ watch: 'vision-observations-empty',
+ tab: 'vision-observations-tab-empty',
+}
export function RecordingObservationsEmptyState({
sessionId,
scanBlock,
+ surface,
}: {
sessionId: string
scanBlock: ScanBlock | null
+ surface: ObservationsSurface
}): JSX.Element {
const { scanners, scannersLoading } = useValues(observationsDockLogic({ sessionId }))
if (scanBlock) {
return (
- <HighlightPicksStateFrame
- size="small"
- image={HedgehogAsleep}
- title={SKIPPED_TITLE[scanBlock.kind] ?? 'Replay vision skipped this recording'}
- body={scanBlock.reason}
- dataAttr="vision-observations-skipped"
- footer={
- <VisionDocsLink
- page="running-scanners"
- anchor="ineligible-sessions"
- dataAttr="vision-observations-skipped-docs"
- >
- Which recordings can be scanned
- </VisionDocsLink>
- }
- />
+ <div className="flex flex-wrap items-center gap-4 px-4 py-3" data-attr={SKIPPED_ATTR[surface]}>
+ <HedgehogAsleep className="h-14 w-14 shrink-0" />
+ <div className="flex min-w-0 flex-1 basis-64 flex-col gap-0.5">
+ <span className="text-sm font-semibold">
+ {SKIPPED_TITLE[scanBlock.kind] ?? 'Replay vision skipped this recording'}
+ </span>
+ <span className="text-xs text-secondary">{scanBlock.reason}</span>
+ </div>
+ <VisionDocsLink
+ page="running-scanners"
+ anchor="ineligible-sessions"
+ dataAttr="vision-observations-skipped-docs"
+ >
+ Which recordings can be scanned
+ </VisionDocsLink>
+ </div>
)
}
const noScanners = !scannersLoading && scanners.length === 0
- const actions = noScanners ? (
- <LemonButton
- type="primary"
- size="small"
- fullWidth
- center
- to={urls.replayVisionNewScanner()}
- data-attr="vision-observations-empty-create-scanner"
- >
- Create a scanner
- </LemonButton>
- ) : (
- <ScannerPicker sessionId={sessionId} scanBlock={scanBlock} fullWidth />
- )
- const footer = (
- <div className="mt-1 flex flex-wrap items-baseline justify-center gap-x-3 gap-y-1">
- {!noScanners && (
- <LemonButton
- type="tertiary"
- size="xsmall"
- to={urls.replayVisionNewScanner()}
- data-attr="vision-observations-empty-new-scanner"
- >
- Create a scanner
- </LemonButton>
- )}
- <VisionDocsLink page="observations" dataAttr="vision-observations-empty-docs">
- How observations work
- </VisionDocsLink>
- </div>
- )
return (
- <HighlightPicksStateFrame
- size="small"
- image={HedgehogMagnifyingGlass}
- title={TITLE}
- body={BODY}
- dataAttr="vision-observations-empty"
- footer={footer}
- >
- {actions}
- </HighlightPicksStateFrame>
+ <div className="@container" data-attr={EMPTY_ATTR[surface]}>
+ <div className="grid grid-cols-[auto_minmax(0,1fr)] items-center gap-x-4 gap-y-3 px-4 py-4 @[760px]:grid-cols-[6rem_minmax(0,1fr)_minmax(14rem,36%)] @[760px]:gap-x-5 @[760px]:px-5">
+ <HedgehogMagnifyingGlass className="h-16 w-16 @[760px]:h-24 @[760px]:w-24" />
+ <div className="flex min-w-0 flex-col gap-2">
+ <span className="text-sm font-semibold">No observations yet</span>
+ <p className="m-0 max-w-[52ch] text-xs text-secondary">
+ Summarize this recording above for chapters and a short write-up, or run a scanner to check it
+ for something specific.
+ </p>
+ <div className="mt-1 flex flex-wrap gap-2">
+ {noScanners ? (
+ <LemonButton
+ type="secondary"
+ size="small"
+ to={urls.replayVisionNewScanner()}
+ data-attr="vision-observations-empty-create-scanner"
+ >
+ Create a scanner
+ </LemonButton>
+ ) : (
+ <ScannerPicker sessionId={sessionId} scanBlock={null} type="secondary" />
+ )}
+ </div>
+ <div className="flex flex-wrap gap-x-3 gap-y-1 text-xs">
+ {!noScanners && (
+ <Link to={urls.replayVisionNewScanner()} data-attr="vision-observations-empty-new-scanner">
+ Create a scanner
+ </Link>
+ )}
+ <VisionDocsLink page="observations" dataAttr="vision-observations-empty-docs">
+ How observations work
+ </VisionDocsLink>
+ </div>
+ </div>
+ <ExampleScanRows className="col-span-2 @[760px]:col-span-1" />
+ </div>
+ </div>
)
}
diff --git a/products/replay_vision/frontend/components/RecordingTimeline.tsx b/products/replay_vision/frontend/components/RecordingTimeline.tsx
index 3e11f02f1a48..0235b820e402 100644
--- a/products/replay_vision/frontend/components/RecordingTimeline.tsx
+++ b/products/replay_vision/frontend/components/RecordingTimeline.tsx
@@ -28,7 +28,7 @@ const HOUR_MS = 3_600_000
const formatSpan = (ms: number): string => humanFriendlyDuration(ms / 1000, { maxUnits: 1 })
-function SummaryNotice({
+export function SummaryNotice({
timeline,
onSummarize,
summarizing,
diff --git a/products/replay_vision/frontend/components/ScanList.tsx b/products/replay_vision/frontend/components/ScanList.tsx
new file mode 100644
index 000000000000..9e6b874762ad
--- /dev/null
+++ b/products/replay_vision/frontend/components/ScanList.tsx
@@ -0,0 +1,254 @@
+import { useActions, useValues } from 'kea'
+import { router } from 'kea-router'
+import { useMemo } from 'react'
+
+import { IconChevronRight } from '@posthog/icons'
+import { LemonButton, LemonTag, Link, Tooltip } from '@posthog/lemon-ui'
+
+import { useResizeObserver } from 'lib/hooks/useResizeObserver'
+import { cn } from 'lib/utils/css-classes'
+import { colonDelimitedDuration } from 'lib/utils/durations'
+
+import type { ReplayObservationApi } from '../generated/api.schemas'
+import { observationsDockLogic } from '../logics/observationsDockLogic'
+import { SCANNER_TYPE_TAG_TYPE, scannerTypeLabel } from '../replay_scanners/types'
+import { RECORDING_ORIGIN, currentReturnPath, observationFromOriginUrl } from '../utils/breadcrumbs'
+import { isSummaryObservation, readModelOutput, readReasoning, scannerLabel } from '../utils/observation'
+import { citedMoments } from '../utils/recordingTimeline'
+import { CitedMarkdown } from './CitedMarkdown'
+import {
+ FailureDetail,
+ IneligibleDetail,
+ ObservationPrimaryOutput,
+ ObservationResultSummary,
+ ObservationStatusTag,
+} from './ObservationCard'
+import { ObservationProgressBar } from './ObservationProgressBar'
+import { ObservationRetryButton } from './ObservationRetryButton'
+import { scannerTypeIcon } from './ScannerTypeBadge'
+
+const NEAR_PLAYHEAD_MS = 60_000
+
+const isInFlight = (o: ReplayObservationApi): boolean => o.status === 'pending' || o.status === 'running'
+
+function defaultFocus(observations: ReplayObservationApi[]): ReplayObservationApi | null {
+ return (
+ observations.find(isInFlight) ?? observations.find((o) => o.status === 'succeeded') ?? observations[0] ?? null
+ )
+}
+
+function RunResult({ observation }: { observation: ReplayObservationApi }): JSX.Element | null {
+ if (observation.status !== 'succeeded') {
+ return <ObservationStatusTag status={observation.status} errorReason={observation.error_reason} />
+ }
+ if (isSummaryObservation(observation)) {
+ return null
+ }
+ return <ObservationResultSummary observation={observation} />
+}
+
+function MomentTicks({
+ moments,
+ endMs,
+ currentTimeMs,
+ onSeek,
+}: {
+ moments: number[]
+ endMs: number
+ currentTimeMs: number
+ onSeek: (timestampMs: number) => void
+}): JSX.Element {
+ return (
+ <span
+ className="pointer-events-none absolute right-8 top-1/2 hidden h-2 w-28 -translate-y-1/2 rounded-sm bg-surface-tertiary @[560px]:block"
+ data-attr="vision-scan-moment-ticks"
+ >
+ {moments.map((ms) => {
+ const label = colonDelimitedDuration(Math.floor(ms / 1000), null)
+ return (
+ <Tooltip key={ms} title={`Jump to ${label}`}>
+ <button
+ type="button"
+ aria-label={`Jump to ${label}`}
+ onClick={() => onSeek(ms)}
+ className={cn(
+ 'pointer-events-auto absolute -top-0.5 h-3 w-1 -translate-x-1/2 cursor-pointer rounded-sm',
+ Math.abs(ms - currentTimeMs) < NEAR_PLAYHEAD_MS ? 'bg-accent' : 'bg-border-bold'
+ )}
+ // eslint-disable-next-line react/forbid-dom-props
+ style={{ left: `${Math.min(100, (ms / endMs) * 100)}%` }}
+ data-attr="vision-scan-moment-tick"
+ />
+ </Tooltip>
+ )
+ })}
+ </span>
+ )
+}
+
+function FocusPane({
+ observation,
+ onSeek,
+ onRetry,
+ retrying,
+}: {
+ observation: ReplayObservationApi
+ onSeek: (timestampMs: number) => void
+ onRetry: () => void
+ retrying: boolean
+}): JSX.Element {
+ const { height: contentHeight, ref: contentRef } = useResizeObserver<HTMLDivElement>({ box: 'border-box' })
+ const { location } = useValues(router)
+ const isSummary = isSummaryObservation(observation)
+ const reasoning = observation.status === 'succeeded' && !isSummary ? readReasoning(observation) : null
+ const hasText = observation.status === 'succeeded' && (isSummary || reasoning !== null)
+ return (
+ <div
+ className="overflow-hidden transition-[height] duration-200 ease-in-out border-t bg-surface-primary"
+ // eslint-disable-next-line react/forbid-dom-props
+ style={{ height: contentHeight }}
+ data-attr="vision-focus-run"
+ >
+ <div ref={contentRef}>
+ {(observation.error_reason || isInFlight(observation)) && (
+ <div className="flex flex-col gap-2 px-3 pb-2">
+ {observation.status === 'failed' && observation.error_reason && (
+ <FailureDetail errorReason={observation.error_reason} />
+ )}
+ {observation.status === 'ineligible' && observation.error_reason && (
+ <IneligibleDetail errorReason={observation.error_reason} />
+ )}
+ {observation.error_reason && (
+ <div>
+ <ObservationRetryButton
+ status={observation.status}
+ errorReason={observation.error_reason}
+ onRetry={onRetry}
+ loading={retrying}
+ size="xsmall"
+ dataAttr="vision-tab-retry-observation"
+ />
+ </div>
+ )}
+ {isInFlight(observation) && (
+ <ObservationProgressBar observationId={observation.id} sessionId={observation.session_id} />
+ )}
+ </div>
+ )}
+ <div className="flex flex-col gap-2 px-3 py-2">
+ {hasText && (
+ <div className="text-sm max-w-[120ch]">
+ {isSummary ? (
+ <ObservationPrimaryOutput
+ observation={observation}
+ showPrompt={false}
+ expandSummary
+ copyable
+ onSeek={onSeek}
+ />
+ ) : (
+ <CitedMarkdown
+ text={reasoning ?? ''}
+ segments={readModelOutput(observation)?.reasoning_segments}
+ onSeek={onSeek}
+ />
+ )}
+ </div>
+ )}
+ <Link
+ data-attr="vision-observation-open-from-sidebar"
+ to={observationFromOriginUrl(observation.id, RECORDING_ORIGIN, currentReturnPath(location))}
+ className="text-xs self-start"
+ >
+ View details
+ </Link>
+ </div>
+ </div>
+ </div>
+ )
+}
+
+export interface ScanListProps {
+ sessionId: string
+ observations: ReplayObservationApi[]
+ endMs: number | null
+ currentTimeMs: number
+ onSeek: (timestampMs: number) => void
+}
+
+export function ScanList({ sessionId, observations, endMs, currentTimeMs, onSeek }: ScanListProps): JSX.Element {
+ const logic = observationsDockLogic({ sessionId })
+ const { focusedObservationId, retryingObservationIds } = useValues(logic)
+ const { focusObservation, retryObservation } = useActions(logic)
+ const focused = observations.find((o) => o.id === focusedObservationId) ?? defaultFocus(observations)
+ const moments = useMemo(() => new Map(observations.map((o) => [o.id, citedMoments(o)])), [observations])
+ return (
+ <div>
+ {observations.map((observation) => {
+ const scannerType = observation.scanner_snapshot?.scanner_type
+ const isFocused = observation.id === focused?.id
+ const ticks = moments.get(observation.id) ?? []
+ const ticksEndMs = endMs !== null && ticks.length > 0 ? endMs : null
+ return (
+ <div key={observation.id} className="border-b border-primary">
+ <div className={cn('relative flex items-center', isFocused && 'bg-fill-highlight-50')}>
+ <LemonButton
+ fullWidth
+ size="small"
+ className="rounded-none min-w-0 flex-1"
+ icon={
+ scannerType ? (
+ <Tooltip title={scannerTypeLabel(scannerType)}>
+ <LemonTag type={SCANNER_TYPE_TAG_TYPE[scannerType]} size="small">
+ {scannerTypeIcon(scannerType)}
+ </LemonTag>
+ </Tooltip>
+ ) : undefined
+ }
+ sideIcon={<IconChevronRight className={cn(isFocused && 'invisible')} />}
+ onClick={() => focusObservation(observation.id)}
+ aria-expanded={isFocused}
+ data-attr="vision-run-row"
+ >
+ <span
+ className={cn(
+ 'flex items-center gap-2 min-w-0 w-full font-normal',
+ ticksEndMs !== null && '@[560px]:pr-32'
+ )}
+ >
+ <span className="min-w-0 truncate text-sm @[760px]:shrink-0 @[760px]:max-w-[40%]">
+ {scannerLabel(observation)}
+ </span>
+ <span className="flex items-center gap-2 min-w-0 shrink-0 max-w-[40%]">
+ <RunResult observation={observation} />
+ </span>
+ {!isFocused && observation.summary_line && (
+ <span className="hidden min-w-0 flex-1 truncate text-xs text-secondary @[760px]:block">
+ {observation.summary_line}
+ </span>
+ )}
+ </span>
+ </LemonButton>
+ {ticksEndMs !== null && (
+ <MomentTicks
+ moments={ticks}
+ endMs={ticksEndMs}
+ currentTimeMs={currentTimeMs}
+ onSeek={onSeek}
+ />
+ )}
+ </div>
+ {isFocused && (
+ <FocusPane
+ observation={observation}
+ onSeek={onSeek}
+ onRetry={() => retryObservation(observation.id)}
+ retrying={retryingObservationIds.includes(observation.id)}
+ />
+ )}
+ </div>
+ )
+ })}
+ </div>
+ )
+}
diff --git a/products/replay_vision/frontend/utils/recordingTimeline.test.ts b/products/replay_vision/frontend/utils/recordingTimeline.test.ts
index c81f3cb6f747..ca9c4366a142 100644
--- a/products/replay_vision/frontend/utils/recordingTimeline.test.ts
+++ b/products/replay_vision/frontend/utils/recordingTimeline.test.ts
@@ -1,5 +1,5 @@
import type { ReplayObservationApi } from '../generated/api.schemas'
-import { momentCount, recordingTimeline, timelineRows } from './recordingTimeline'
+import { citedMoments, momentCount, recordingTimeline, timelineRows } from './recordingTimeline'
function summary(
output: Record<string, unknown> | null,
@@ -35,6 +35,14 @@ const chapter = (start: number, end: number, title: string, kind = 'activity'):
title,
})
+function withReasoning(observation: ReplayObservationApi, reasoning: string): ReplayObservationApi {
+ const result = observation.scanner_result as { model_output: Record<string, unknown> }
+ return {
+ ...observation,
+ scanner_result: { ...result, model_output: { ...result.model_output, reasoning } },
+ } as ReplayObservationApi
+}
+
describe('recordingTimeline', () => {
it.each<{
name: string
@@ -189,4 +197,20 @@ describe('recordingTimeline', () => {
])('counts the moments of $name', ({ observations, count }) => {
expect(momentCount(recordingTimeline(observations))).toBe(count)
})
+
+ it.each([
+ ['a failed run', { ...monitor('m', 5_000), status: 'failed' } as ReplayObservationApi, []],
+ [
+ 'a key moment with cited and repeated timestamps',
+ withReasoning(monitor('m', 9_000), '(t 3) then (t 3) and (t 12)'),
+ [3_000, 9_000, 12_000],
+ ],
+ [
+ 'a summary, as its chapter starts',
+ summary({ chapters: [chapter(0, 60_000, 'Intro'), chapter(60_000, 90_000, 'Checkout')] }),
+ [0, 60_000],
+ ],
+ ])('lists the moments of %s in order without repeats', (_name, observation, expected) => {
+ expect(citedMoments(observation)).toEqual(expected)
+ })
})
diff --git a/products/replay_vision/frontend/utils/recordingTimeline.ts b/products/replay_vision/frontend/utils/recordingTimeline.ts
index 92ad5954f05e..a1b60798e61c 100644
--- a/products/replay_vision/frontend/utils/recordingTimeline.ts
+++ b/products/replay_vision/frontend/utils/recordingTimeline.ts
@@ -1,9 +1,11 @@
import type { ReplayObservationApi } from '../generated/api.schemas'
+import { parseCitedSegments } from './citations'
import {
VERDICT_LABEL,
isFlaggedObservation,
isSummaryObservation,
readModelOutput,
+ readReasoning,
readScore,
readTags,
readVerdict,
@@ -196,6 +198,13 @@ export function recordingTimeline(observations: ReplayObservationApi[]): Recordi
return { summary, summaryState, chapters, inactive, markers }
}
+export function timelineEndMs(timeline: RecordingTimeline, durationMs: number | null): number | null {
+ if (durationMs === null || durationMs <= 0) {
+ return null
+ }
+ return Math.max(durationMs, ...timeline.chapters.map((c) => c.endMs))
+}
+
/** The rows the sidebar lists, in time order: the session's ends, chapters and idle gaps. Empty without chapters. */
export function timelineRows(timeline: RecordingTimeline, durationMs: number | null = null): TimelineRow[] {
if (timeline.chapters.length === 0) {
@@ -209,9 +218,8 @@ export function timelineRows(timeline: RecordingTimeline, durationMs: number | n
for (const gap of timeline.inactive) {
rows.push({ atMs: gap.startMs, order: 1, row: { kind: 'inactive', startMs: gap.startMs, endMs: gap.endMs } })
}
- if (durationMs !== null && durationMs > 0) {
- // The player's length can come up short of what the scan saw, and the end must still close the rail.
- const endMs = Math.max(durationMs, ...timeline.chapters.map((c) => c.endMs))
+ const endMs = timelineEndMs(timeline, durationMs)
+ if (endMs !== null) {
rows.push({ atMs: endMs, order: 3, row: { kind: 'boundary', edge: 'end', atMs: endMs } })
}
return rows.sort((a, b) => a.atMs - b.atMs || a.order - b.order).map(({ row }) => row)
@@ -249,3 +257,15 @@ export function nextTimelineStopMs(timeline: RecordingTimeline, playerTimeMs: nu
const later = timeline.chapters.map((c) => c.startMs).filter((ms) => ms > playerTimeMs)
return later.length > 0 ? Math.min(...later) : null
}
+
+export function citedMoments(observation: ReplayObservationApi): number[] {
+ if (observation.status !== 'succeeded') {
+ return []
+ }
+ const moments = isSummaryObservation(observation)
+ ? readChapters(observation).map((chapter) => chapter.startMs)
+ : parseCitedSegments(readReasoning(observation) ?? '', readModelOutput(observation)?.reasoning_segments)
+ .flatMap((segment) => (segment.kind === 'chip' ? [segment.timestamp_ms] : []))
+ .concat(readNumber(readModelOutput(observation)?.key_moment_ms) ?? [])
+ return [...new Set(moments.map((ms) => Math.max(0, Math.round(ms))))].sort((a, b) => a - b)
+}