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): make watch feed cards media-first (#104635)

Kim Svatos Dugan98e104695b04
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index b24811bc034b..6cbb72c18c10 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -10605,17 +10605,17 @@ snapshots:
scenes-app-project-homepage--project-homepage--light:
hash: v1.k794b7964.45567c13e93e1def5dabfea7b6a4a5a47253482e6dd5c587be257ae5b9374639.IC346vxEHrTKcFor0vVTajrOk8lCGCu3C5pdFW2iTOQ
scenes-app-replay-vision--home-watch-feed--dark:
- hash: v1.k794b7964.ba35d07f2e854eb9babb15b72c37b3ba3866903b3e563bc325a5300f1aab24a0.hkqPKVLRDXp1A3DTGlwRrQaJwLSEwrUrH-VDgR9CL3A
+ hash: v1.k794b7964.ea6584e63096062feb704e29988aaf456173f7964bea67873abf90ffca241df8.1D5HCNI8k0RrgRrCkrSFNEtgf69avW52B465iVgukkk
scenes-app-replay-vision--home-watch-feed--light:
- hash: v1.k794b7964.fc47453fe8d0dfb4ba4061ca3caada95c18c3a2cb58e128dcf3608cfc417a548.eBb1it9dG-OgovPJ1MWnuif2zxjIzBNZqe2Im56ZH-c
+ hash: v1.k794b7964.581f363ba112ff36296f23c1de6f5e1e9b077e38ef7615148ba5013c7d7b6c87.YhvG-EiKemL4xrs4HhWMLAo_HNuV38T7xENWdvByens
scenes-app-replay-vision--home-watch-feed-empty--dark:
hash: v1.k794b7964.c8b63e7c03105a6a22c7dfecc5fa98afb410af14180977eeb9907c2e57f43e29.9d0B-LDyKHrQ75wpveOo913SMTZvi2fe4RTJOrFtDM0
scenes-app-replay-vision--home-watch-feed-empty--light:
hash: v1.k794b7964.33393d260f0654e59dbc209d6052c2b0730dfc6e8f59925406cd3a9349569980.63xRgoQrVu1PM7n1sBaVx6QV7Otc_rKCusdfHhsGuBU
scenes-app-replay-vision--home-watch-feed-only-newest--dark:
- hash: v1.k794b7964.c663fda6f931ec3eb45817b2e6c1a5ce64b76a796aa791fa43809fc8bf76a89d.Stuf9VxRo6CSfm7JlG9zyVo-dgYH-MWGbu-hdjIG3E0
+ hash: v1.k794b7964.535ecf83de06a037ebef4b617eb118149cf1a1a88bc190f878a8ec6ad8580ed3.zfGqUNO52i8cUGb_n92QrVLoGmuF1dFl3yat56TLZYo
scenes-app-replay-vision--home-watch-feed-only-newest--light:
- hash: v1.k794b7964.2970158f57cd96907771a0fd8e05e250013df87cf25ad8c8c9358ca1c11cac30.TncjzQ2-615RVwvIXyzAEyKjHKY2sDJqUke0ERJpdzs
+ hash: v1.k794b7964.6815df3576b3f2c4695eaa1c3ce6e27a5787edde8889b8f83ade58468074e654.4Nh0vul-NwpqwooPzZLWCuK4Q21TmRv2scmOlval-o4
scenes-app-replay-vision--observation-detail--dark:
hash: v1.k794b7964.e9fd7c14ee1899c90ba01049012a8d9947f013869b8ec7d767b7db2220d46166.XZIczm04vBGXxRP7z-rzHaqy34GQDRXXfTrEhICqxi0
scenes-app-replay-vision--observation-detail--light:
diff --git a/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.test.ts b/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.test.ts
index 6b6c0c09e3ca..350c636b811a 100644
--- a/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.test.ts
+++ b/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.test.ts
@@ -1,5 +1,5 @@
import type { ReplayObservationApi, WatchFeedReasonApi } from '../../generated/api.schemas'
-import { observationClipRange, watchReasonCopy } from './WatchFeedCard'
+import { observationClipRange, watchCardHeadline, watchReasonCopy } from './WatchFeedCard'
describe('WatchFeedCard helpers', () => {
describe('watchReasonCopy', () => {
@@ -127,13 +127,13 @@ describe('WatchFeedCard helpers', () => {
})
})
- describe('observationClipRange', () => {
- const observation = (scannerType: string | undefined, output: Record<string, unknown>): ReplayObservationApi =>
- ({
- scanner_snapshot: scannerType ? { scanner_type: scannerType } : undefined,
- scanner_result: { model_output: output },
- }) as unknown as ReplayObservationApi
+ const observation = (scannerType: string | undefined, output: Record<string, unknown>): ReplayObservationApi =>
+ ({
+ scanner_snapshot: scannerType ? { scanner_type: scannerType } : undefined,
+ scanner_result: { model_output: output },
+ }) as unknown as ReplayObservationApi
+ describe('observationClipRange', () => {
it('reads the summary citation when the snapshot type is summarizer, even if the result omits scanner_type', () => {
const range = observationClipRange(
observation('summarizer', {
@@ -149,4 +149,67 @@ describe('WatchFeedCard helpers', () => {
expect(range).toEqual({ startMs: 45_000, endMs: 45_000 })
})
})
+
+ describe('watchCardHeadline', () => {
+ it.each<{
+ name: string
+ scannerType: string
+ output: Record<string, unknown>
+ expected: ReturnType<typeof watchCardHeadline>
+ }>([
+ {
+ name: 'keeps the authored summarizer title and rides the summary along as the body',
+ scannerType: 'summarizer',
+ output: { title: 'Quick bug report', summary: 'Filed feedback (t 30) from the toast.' },
+ expected: {
+ title: 'Quick bug report',
+ body: { text: 'Filed feedback (t 30) from the toast.', segments: undefined },
+ },
+ },
+ {
+ name: 'derives the headline from the summary when the summarizer title is empty',
+ scannerType: 'summarizer',
+ output: { title: '', summary: 'Applied a coupon (t 12). Abandoned the cart.' },
+ expected: { title: 'Applied a coupon (00:12).', body: { text: 'Abandoned the cart.' } },
+ },
+ {
+ name: 'promotes the first reasoning sentence, rest becomes the body',
+ scannerType: 'monitor',
+ output: { reasoning: 'Retried the form twice. The submit then failed.' },
+ expected: { title: 'Retried the form twice.', body: { text: 'The submit then failed.' } },
+ },
+ {
+ name: 'leaves the body empty when the reasoning is a single sentence',
+ scannerType: 'monitor',
+ output: { reasoning: 'Retried the form twice.' },
+ expected: { title: 'Retried the form twice.', body: null },
+ },
+ {
+ name: 'never splits the headline inside a decimal',
+ scannerType: 'scorer',
+ output: { reasoning: 'Scored 9.5 on intent. Opened billing after.' },
+ expected: { title: 'Scored 9.5 on intent.', body: { text: 'Opened billing after.' } },
+ },
+ {
+ name: 'keeps a mid-sentence citation as a plain timestamp',
+ scannerType: 'monitor',
+ output: { reasoning: 'Compares plans at (t 30), then upgrades. Leaves happy.' },
+ expected: { title: 'Compares plans at (00:30), then upgrades.', body: { text: 'Leaves happy.' } },
+ },
+ {
+ name: 'never splits the headline at an abbreviation',
+ scannerType: 'monitor',
+ output: { reasoning: 'Hit errors, e.g. a 500 vs. the usual 200. They retried.' },
+ expected: { title: 'Hit errors, e.g. a 500 vs. the usual 200.', body: { text: 'They retried.' } },
+ },
+ {
+ name: 'keeps the space before a dot-prefixed word',
+ scannerType: 'monitor',
+ output: { reasoning: 'Opened the .env editor. Saved it.' },
+ expected: { title: 'Opened the .env editor.', body: { text: 'Saved it.' } },
+ },
+ ])('$name', ({ scannerType, output, expected }) => {
+ expect(watchCardHeadline(observation(scannerType, output))).toEqual(expected)
+ })
+ })
})
diff --git a/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.tsx b/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.tsx
index ca5e6b13aed7..2a790907dab0 100644
--- a/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.tsx
+++ b/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.tsx
@@ -1,8 +1,8 @@
import { useActions } from 'kea'
import { combineUrl, router } from 'kea-router'
-import { IconPlay, IconPlayFilled } from '@posthog/icons'
-import { LemonButton, LemonDivider, Link, Tooltip } from '@posthog/lemon-ui'
+import { IconFlag, IconPlay, IconPlayFilled } from '@posthog/icons'
+import { LemonButton, Link, Tooltip } from '@posthog/lemon-ui'
import { TZLabel } from 'lib/components/TZLabel'
import posthog from 'lib/posthog-typed'
@@ -15,7 +15,7 @@ import { ObservationThumbnail } from '../../components/ObservationThumbnail'
import { ScannerTypeBadge } from '../../components/ScannerTypeBadge'
import type { ReplayObservationApi, WatchFeedItemApi, WatchFeedReasonApi } from '../../generated/api.schemas'
import { OBSERVATION_ORIGIN_PARAM, WATCH_FEED_ORIGIN } from '../../utils/breadcrumbs'
-import { citedTimestampRange } from '../../utils/citations'
+import { citedTextToPlainText, citedTimestampRange } from '../../utils/citations'
import { ScannerType } from '../types'
const roundScore = (value: number): number => Math.round(value * 100) / 100
@@ -151,6 +151,50 @@ export function observationClipRange(observation: ReplayObservationApi): { start
return typeof text === 'string' ? citedTimestampRange(text, segments) : null
}
+/**
+ * The card's bold headline, plus the prose that follows it. A summarizer authored a title, so its
+ * summary rides along whole (with citation chips). Otherwise the first sentence of the prose the
+ * scan wrote (an untitled summarizer's summary, the other types' reasoning) is promoted to the
+ * headline, with citation chips rendered as plain timestamps so a mid-sentence citation keeps
+ * its place, and the rest becomes the body, already plain.
+ */
+export function watchCardHeadline(
+ observation: ReplayObservationApi
+): { title: string; body: { text: string; segments?: unknown } | null } | null {
+ const result = readResult(observation)
+ if (!result) {
+ return null
+ }
+ const scannerType =
+ (observation.scanner_snapshot?.scanner_type as ScannerType | undefined) ??
+ (result.scanner_type as ScannerType | undefined)
+ if (scannerType === 'summarizer' && typeof result.title === 'string' && result.title) {
+ const summary = typeof result.summary === 'string' ? result.summary : null
+ return {
+ title: result.title,
+ body: summary ? { text: summary, segments: result.summary_segments } : null,
+ }
+ }
+ // The summarizer's title defaults to "", so an untitled summary still earns a derived headline.
+ const [text, segments] =
+ scannerType === 'summarizer'
+ ? [result.summary, result.summary_segments]
+ : [result.reasoning, result.reasoning_segments]
+ if (typeof text !== 'string' || !text) {
+ return null
+ }
+ const plain = citedTextToPlainText(text, segments).replace(/\s+/g, ' ').trim()
+ if (!plain) {
+ return null
+ }
+ // A sentence ends at ./!/? followed by whitespace and a non-lowercase character, so "9.5",
+ // "$0.50", "e.g. this", and "8 vs. 5" never split mid-sentence.
+ const match = plain.match(/^[\s\S]*?[.!?](?=\s+(?![a-z])|$)/)
+ const title = (match?.[0] ?? plain).trim()
+ const rest = plain.slice(match?.[0]?.length ?? plain.length).trim()
+ return { title, body: rest ? { text: rest } : null }
+}
+
interface WatchFeedCardProps {
item: WatchFeedItemApi
/** Zero-based place in the feed, captured so we can see how deep people read. */
@@ -169,15 +213,10 @@ export function WatchFeedCard({ item, position }: WatchFeedCardProps): JSX.Eleme
(result?.scanner_type as ScannerType | undefined)
const scannerName = (observation.scanner_snapshot?.name as string | undefined) || '(untitled scanner)'
const person = observation.recording_subject_email || observation.distinct_id
- // A monitor verdict or a scorer score is a single token, so it rides the header row instead of
- // taking its own line. Classifier tags and summarizer text need the body's full width, so their
- // outcome stays there.
- const outcomeInHeader = scannerType === 'monitor' || scannerType === 'scorer'
- // Summarizers already tell the story through title + summary; the other types show only an
- // outcome chip, so bring their reasoning along for context, clamped to keep the card scannable.
- const reasoning =
- scannerType !== 'summarizer' && typeof result?.reasoning === 'string'
- ? { text: result.reasoning, segments: result.reasoning_segments }
+ const headline = watchCardHeadline(observation)
+ const clipDuration =
+ clip && clip.endMs > clip.startMs
+ ? colonDelimitedDuration(Math.ceil((clip.endMs - clip.startMs) / 1000), null)
: null
// t=0 when nothing is cited, so the observation page still opens with the player expanded. `from`
// marks the feed as the origin, so the observation's back button returns here rather than the scanner.
@@ -214,99 +253,93 @@ export function WatchFeedCard({ item, position }: WatchFeedCardProps): JSX.Eleme
className="@container relative border rounded bg-bg-light p-4 flex gap-4 hover:border-accent"
data-attr="vision-watch-feed-card"
>
- {/* The thumbnail column spans the card's full height; everything else stacks beside it. */}
- <div className="hidden @md:flex w-48 shrink-0 flex-col gap-1">
- {/* The dot and the duration sit outside the poster, which clips its own overflow. */}
- <div className="relative">
+ {/* The thumbnail is the watch affordance, so the whole poster opens the clip modal.
+ The dot and the duration sit outside the poster, which clips its own overflow. */}
+ <div className="relative hidden @md:block w-64 shrink-0 self-start">
+ <button
+ type="button"
+ onClick={watchClipInModal}
+ className="relative z-10 block w-full cursor-pointer"
+ data-attr="vision-watch-clip"
+ aria-label="Watch clip"
+ >
<ObservationThumbnail observation={observation}>
- <IconPlayFilled className="text-2xl text-brand-red drop-shadow" aria-hidden />
+ <span className="flex items-center gap-1.5 rounded-full bg-black/70 px-3 py-1 text-xs font-semibold text-white">
+ <IconPlayFilled aria-hidden />
+ {clipDuration ? `Watch ${clipDuration}` : 'Watch clip'}
+ </span>
</ObservationThumbnail>
- {!observation.viewed && (
- <Tooltip title="You haven't opened this observation yet">
- <span
- className="absolute -top-1 -right-1 w-2.5 h-2.5 rounded-full bg-accent border border-bg-light z-10"
- aria-label="Unviewed"
- />
- </Tooltip>
- )}
{clip && (
<span className="absolute bottom-1 right-1 text-xs tabular-nums bg-bg-light border rounded px-1">
{colonDelimitedDuration(Math.floor(clip.startMs / 1000), null)} to{' '}
{colonDelimitedDuration(Math.floor(clip.endMs / 1000), null)}
</span>
)}
- </div>
- {clip && clip.endMs > clip.startMs && (
- <span className="text-xs text-muted">
- {colonDelimitedDuration(Math.ceil((clip.endMs - clip.startMs) / 1000), null)} of the session
- cited
- </span>
+ </button>
+ {!observation.viewed && (
+ <Tooltip title="You haven't opened this observation yet">
+ <span
+ className="absolute -top-1 -right-1 w-2.5 h-2.5 rounded-full bg-accent border border-bg-light z-10"
+ aria-label="Unviewed"
+ />
+ </Tooltip>
)}
</div>
- <div className="flex-1 min-w-0 flex flex-col gap-2">
- <div className="flex items-start justify-between gap-2">
- <div className="flex flex-wrap items-center gap-2 min-w-0">
- {scannerType && <ScannerTypeBadge scannerType={scannerType} />}
- <span className="text-muted text-sm truncate">{scannerName}</span>
- {/* Above the card's full-area overlay link, like the other interactive
- elements, so the outcome's hover tooltip stays reachable. */}
- {outcomeInHeader && (
- <span className="relative z-10">
- <ObservationResultSummary observation={observation} />
- </span>
- )}
- </div>
- <LemonButton
- type="secondary"
- size="small"
- icon={<IconPlay />}
- onClick={watchClipInModal}
- className="relative z-10 shrink-0"
- data-attr="vision-watch-clip"
- >
- Watch clip
- </LemonButton>
- </div>
+ <div className="flex-1 min-w-0 flex flex-col gap-1.5">
{/* Stretched to cover the card: clicking anywhere opens the observation with the
- player expanded at the first cited moment. Inner links and the button sit
- above it via `relative z-10`, so the anchors never nest. */}
+ player expanded at the first cited moment. Inner links and the thumbnail button
+ sit above it via `relative z-10`, so the anchors never nest. */}
<Link
to={observationUrl}
onClick={() => capture('observation')}
- className="text-sm text-default after:absolute after:inset-0 after:content-['']"
+ className="text-default after:absolute after:inset-0 after:content-['']"
data-attr="vision-watch-feed-card-body"
>
- <div className="flex flex-col gap-1">
- {!outcomeInHeader && <ObservationResultSummary observation={observation} />}
- {reasoning && (
- <p className="text-muted m-0 line-clamp-2">
- <CitedText text={reasoning.text} segments={reasoning.segments} />
- </p>
- )}
- </div>
+ <h3 className="text-sm font-semibold m-0 line-clamp-2">{headline?.title ?? scannerName}</h3>
</Link>
- <LemonDivider className="my-0" />
- <div className="text-xs text-secondary">
- <span className="font-semibold uppercase">Why this clip</span> {watchReasonCopy(reason)}
- </div>
- <div className="flex flex-wrap items-center justify-between gap-2 text-xs text-muted">
- {person ? (
- observation.distinct_id ? (
+ <div className="flex flex-wrap items-center gap-1 text-xs text-muted">
+ {person &&
+ (observation.distinct_id ? (
<Link
to={urls.personByDistinctId(observation.distinct_id)}
- className="relative z-10 truncate min-w-0"
+ className="relative z-10 truncate min-w-0 text-muted"
data-attr="vision-watch-feed-person"
>
{person}
</Link>
) : (
<span className="truncate min-w-0">{person}</span>
- )
- ) : (
- <span />
- )}
+ ))}
+ {person && <span aria-hidden>·</span>}
<TZLabel time={observation.created_at} className="shrink-0" />
</div>
+ {/* Above the overlay link so the outcome's hover tooltip stays reachable. The
+ summarizer's outcome is the title + body above, so it adds no chip here. */}
+ <div className="relative z-10 flex flex-wrap items-center gap-2 min-w-0">
+ {scannerType && <ScannerTypeBadge scannerType={scannerType} />}
+ <span className="text-muted text-xs truncate">{scannerName}</span>
+ {scannerType !== 'summarizer' && <ObservationResultSummary observation={observation} />}
+ </div>
+ {headline?.body && (
+ <p className="text-muted text-xs m-0 line-clamp-2">
+ <CitedText text={headline.body.text} segments={headline.body.segments} />
+ </p>
+ )}
+ <div className="flex items-start gap-1.5 text-xs text-muted">
+ <IconFlag className="mt-0.5 shrink-0 text-accent" aria-hidden />
+ <span>{watchReasonCopy(reason)}</span>
+ </div>
+ {/* Narrow containers hide the thumbnail, so they keep an explicit watch control. */}
+ <LemonButton
+ type="secondary"
+ size="xsmall"
+ icon={<IconPlay />}
+ onClick={watchClipInModal}
+ className="@md:hidden self-start relative z-10"
+ data-attr="vision-watch-clip"
+ >
+ Watch clip
+ </LemonButton>
</div>
</div>
)