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): one feed row layout for both arms, with why (#114076)

Kim Svatos Dugan41a5b82be1ee
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index bc30454510ed..43606e2e4d4b 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -13107,25 +13107,21 @@ snapshots:
scenes-app-replay-vision--experiment-variants-waiting-for-observations--light:
hash: v1.k794b7964.a1555dab4c0006028e8c240451c56c6aed5e31c8a8e68c893e3d6a07b562bba6.VYeYPsjZ_p0Rt4cbZzF7lbxjxurMjLXff9kJRsy49gU
scenes-app-replay-vision--home-watch-feed--dark:
- hash: v1.k794b7964.4e49c04cab295c8244570e27b42dd6d08712914dfb46c071e8d58cf97e05ca22.j0LdxNaQxcSLZggc0YaC6ZMGaRSWCAHeIz8Pu4EN9e0
+ hash: v1.k794b7964.2f49725f7fc8058939b56b25742619a3b02a8e0e485258b09b3038fd647e1581.2ziFn3a3_CJk7A_YbZJqqn-jOlTJangjfnLcyHp0BBw
scenes-app-replay-vision--home-watch-feed--light:
- hash: v1.k794b7964.288fedc5c386d3f56e1a966bde1c7e23925aff3dfd14b9bd59f4850819561df3.QKxn0utvK9ZKjjQkKna85QywDjMVBeQXLvUPBvzJq54
+ hash: v1.k794b7964.7119fa5e588c2763bbeee5e5bdb76b621f8d8609291dba0d9c065e8860a3ee6d.TDf10qFfSYUJohljt-AGKzhlPBv6e8q-fXq30frva5c
scenes-app-replay-vision--home-watch-feed-empty--dark:
hash: v1.k794b7964.926bab41fb78cabf70493f52b629520842bcdb6fd7e0a838babb178ad948c67f.6Q9grGAgt0DLOh0YWKUgIOuHlFvn0gDCeHHOrqdav7g
scenes-app-replay-vision--home-watch-feed-empty--light:
hash: v1.k794b7964.71ae84e0d38203d5860ee8feb2a633a339e79de59b03b514807c7493517486fb.3NLgnN7g1YbjscaN_XzQhxSoqltm99utfh3_1E_29J8
- scenes-app-replay-vision--home-watch-feed-grid--dark:
- hash: v1.k794b7964.b6c0021cb654a1959c5f31038f0d0bfc677d02e14feee183cd6c4e116db5242b.z8lywqGVYD1SrmfpwUCvjNguFhzC69zsQh8dHfKnhGM
- scenes-app-replay-vision--home-watch-feed-grid--light:
- hash: v1.k794b7964.eef70399f888f57b020a2ec2df31807c2ab0fab72d763576aa997d792a869677.Q2y0D347yvVcCTX-e9lPPuFzqH1fcfpoXQqwc087OWk
scenes-app-replay-vision--home-watch-feed-jev-arm--dark:
- hash: v1.k794b7964.68e5ee597c3499f4df7de4dfe3db661e339fa8d2e30ef1c569959d86bd430305.v0bBkJTYcpwECQvdW_vQaJWpcwoVQpVn2Kqav6mrVuY
+ hash: v1.k794b7964.f1ddd21726c2a6464c6734a43d55d6f1cb3938607c120e59405c84aee9750203.VH9Ne1pCl3SvraNkfcQizTMUOFzY5J2WrIRNLA6itqE
scenes-app-replay-vision--home-watch-feed-jev-arm--light:
- hash: v1.k794b7964.7ac581d7622f7ca2428054e97936ff0e336496cff0ba686d77db329f1a9041ff.qahPVGOLQ8poz4tAePFts3hdloy-GUEIw7z7JVnMQ7Y
+ hash: v1.k794b7964.10c14bad4b7111fb176e5bc4f8fa56c7edc9bc7d97756ba772d86180fb53a2e2.4F19ofQPZuJqqHdqZiBgHYfLMVhFZNcqoDCbQ0tfLtE
scenes-app-replay-vision--home-watch-feed-only-newest--dark:
- hash: v1.k794b7964.4bdb8bb02fdf4e1402f3187ef680ef0bf1081f23689307facdbbe83906c6077f.LfMy-ghDtnRl-yhFxu1Xc7L8o2ZVkHtnzxtov82AuZY
+ hash: v1.k794b7964.a08092f004c07051bbdc5e85710f2c146e717dcd5c62ac1de2f74957b2f665fc.73h8-FXjGYrbmE7uoiIIty2DSmeJ5JNCmD6_jaIUEWc
scenes-app-replay-vision--home-watch-feed-only-newest--light:
- hash: v1.k794b7964.7a3c6205566a677d0d78d3c0e4c04c19aaaaad98857323c0ee4138d572a9b29c.hpcmZrUqq_ViM2kzyyACs4gqqfrIuEckqWWEH5fTWGU
+ hash: v1.k794b7964.68e1efa2832251afd6354e66319e5bee18ecc25c3c636c6e4a52465a80113a85.mh7o0KC4GUS0HPNTp1eiNh8eptNnA80TPgDhE5n4VFI
scenes-app-replay-vision--monitor-observations--dark:
hash: v1.k794b7964.9ec7ef6c17074e9547647fe71aa2613100208fa0c7ba87a3d97897b4f183a5c8.-UKB-w06mWDRH2yNgzIBhn3Qhn2MYlFTNXjhMce1hh4
scenes-app-replay-vision--monitor-observations--light:
diff --git a/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx b/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx
index f800826a3246..7d3d7e505bd9 100644
--- a/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx
+++ b/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx
@@ -1111,23 +1111,9 @@ export const UsageTab: StoryObj = {
// The home page lands on the What to watch feed.
export const HomeWatchFeed: StoryObj = {}
-const WATCH_FEED_VIEW_STORAGE_KEY = 'products.replay_vision.frontend.replay_scanners.watchFeedLogic.view'
-
-// The same feed as thumbnail cards, each closing with why the recording was picked.
-export const HomeWatchFeedGrid: StoryObj = {
- // Seed the saved view before render instead of clicking the toggle: the snapshot build is production
- // React, which has no act(), so testing-library helpers fail there. Remove it afterwards, or every
- // later feed story renders as a grid too.
- beforeEach: () => {
- localStorage.setItem(WATCH_FEED_VIEW_STORAGE_KEY, JSON.stringify('grid'))
- return () => localStorage.removeItem(WATCH_FEED_VIEW_STORAGE_KEY)
- },
-}
-
-// The jev ranker arm serves the simplified card: the scan's own sentence plus a scanner chip and
-// person line, with the question and verdict behind the chip's tooltip. The first card leads with
-// the scan's notability sentence, the second falls back to the derived headline, and the filler
-// row reads muted with no finding claim.
+// The jev ranker arm: the same rows as the default arm, plus the reason Jev picked each finding. The
+// first row leads with the scan's notability sentence, the second falls back to the derived headline,
+// and the filler row reads muted with no finding claim or reason.
export const HomeWatchFeedJevArm: StoryObj = {
decorators: [
mswDecorator({
@@ -1166,6 +1152,7 @@ export const HomeWatchFeedJevArm: StoryObj = {
jev_probability: 0.91,
notability_reason:
'The card form rejected a valid card three times before the user abandoned the checkout.',
+ watch_reason: 'visible_error',
},
},
{
@@ -1193,7 +1180,7 @@ export const HomeWatchFeedJevArm: StoryObj = {
},
viewed: true,
}),
- reason: { kind: 'jev_watchable', jev_probability: 0.48 },
+ reason: { kind: 'jev_watchable', jev_probability: 0.48, watch_reason: 'success' },
},
{
observation: observation({ id: '00000000-0000-0000-0000-0000000000e3' }),
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 52233802f33d..da626799a3c3 100644
--- a/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.test.ts
+++ b/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.test.ts
@@ -1,9 +1,10 @@
import type { ReplayObservationApi, WatchFeedReasonApi } from '../../generated/api.schemas'
import {
- jevCardSentence,
- jevRowTitle,
+ watchFeedRowSentence,
+ watchFeedRowTitle,
observationKeyMomentMs,
watchCardHeadline,
+ watchFeedRowWhy,
watchReasonCopy,
watchStartSeconds,
} from './WatchFeedCard'
@@ -134,6 +135,37 @@ describe('WatchFeedCard helpers', () => {
})
})
+ describe('watchFeedRowWhy', () => {
+ it.each<{ name: string; reason: WatchFeedReasonApi; expected: string }>([
+ {
+ name: "leads with Jev's pick when it gave one",
+ reason: {
+ kind: 'jev_watchable',
+ jev_probability: 0.9,
+ watch_reason: 'churn_signal',
+ } as WatchFeedReasonApi,
+ expected: 'The user showed signs of churn or downgrading in this session.',
+ },
+ {
+ name: "explains a weighted-score row from its reason kind, never repeating the title's sentence",
+ reason: {
+ kind: 'outlier_score',
+ score: 9.5,
+ window_mean: 5,
+ notability_reason: 'The card form rejected a valid card three times.',
+ } as WatchFeedReasonApi,
+ expected: "Scored 9.5, far from this scanner's recent average of 5.",
+ },
+ {
+ name: 'falls back to the kind copy for a reason this build does not know',
+ reason: { kind: 'jev_watchable', watch_reason: 'some_future_reason' } as unknown as WatchFeedReasonApi,
+ expected: 'The decision model judged this session worth watching.',
+ },
+ ])('$name', ({ reason, expected }) => {
+ expect(watchFeedRowWhy(reason)).toBe(expected)
+ })
+ })
+
const observation = (scannerType: string | undefined, output: Record<string, unknown>): ReplayObservationApi =>
({
scanner_snapshot: scannerType ? { scanner_type: scannerType } : undefined,
@@ -162,9 +194,9 @@ describe('WatchFeedCard helpers', () => {
})
})
- describe('jevCardSentence', () => {
+ describe('watchFeedRowSentence', () => {
it("prefers the scan's notability sentence over the derived headline", () => {
- const sentence = jevCardSentence(
+ const sentence = watchFeedRowSentence(
observation('monitor', { reasoning: 'Retried the form twice. The submit then failed.' }),
{
kind: 'jev_watchable',
@@ -176,7 +208,7 @@ describe('WatchFeedCard helpers', () => {
})
it('derives the headline when the reason carries no notability sentence', () => {
- const sentence = jevCardSentence(
+ const sentence = watchFeedRowSentence(
observation('monitor', { reasoning: 'Retried the form twice. The submit then failed.' }),
{ kind: 'jev_watchable', jev_probability: 0.9 } as WatchFeedReasonApi
)
@@ -188,11 +220,13 @@ describe('WatchFeedCard helpers', () => {
scanner_snapshot: { name: 'Confused checkout', scanner_type: 'monitor' },
scanner_result: { model_output: {} },
} as unknown as ReplayObservationApi
- expect(jevCardSentence(bare, { kind: 'unviewed_recent' } as WatchFeedReasonApi)).toBe('Confused checkout')
+ expect(watchFeedRowSentence(bare, { kind: 'unviewed_recent' } as WatchFeedReasonApi)).toBe(
+ 'Confused checkout'
+ )
})
})
- describe('jevRowTitle', () => {
+ describe('watchFeedRowTitle', () => {
const notable = {
kind: 'jev_watchable',
jev_probability: 0.9,
@@ -218,7 +252,7 @@ describe('WatchFeedCard helpers', () => {
expected: 'The card form rejected a valid card three times.',
},
])('$name', ({ scannerType, output, expected }) => {
- expect(jevRowTitle(observation(scannerType, output), notable)).toBe(expected)
+ expect(watchFeedRowTitle(observation(scannerType, output), notable)).toBe(expected)
})
})
diff --git a/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.tsx b/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.tsx
index eb5ce8a0d13f..a5604d57388f 100644
--- a/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.tsx
+++ b/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.tsx
@@ -1,24 +1,32 @@
import { useActions } from 'kea'
-import { combineUrl, router } from 'kea-router'
+import { combineUrl } from 'kea-router'
-import { IconFlag, IconPlay, IconPlayFilled } from '@posthog/icons'
-import { LemonButton, LemonCard, LemonTag, Link, Tooltip } from '@posthog/lemon-ui'
+import { IconFlag } from '@posthog/icons'
+import { LemonDivider, LemonTag, Link, Tooltip } from '@posthog/lemon-ui'
import { TZLabel } from 'lib/components/TZLabel'
import posthog from 'lib/posthog-typed'
import { colonDelimitedDuration } from 'lib/utils/durations'
-import { sessionPlayerModalLogic } from 'scenes/session-recordings/player/modal/sessionPlayerModalLogic'
import { urls } from 'scenes/urls'
-import { CitedText, ObservationResultSummary, readResult } from '../../components/ObservationCard'
+import { readResult } from '../../components/ObservationCard'
import { ObservationThumbnail } from '../../components/ObservationThumbnail'
-import { ScannerTypeBadge, scannerTypeIcon } from '../../components/ScannerTypeBadge'
+import { scannerTypeIcon } from '../../components/ScannerTypeBadge'
import { UnviewedObservationTag } from '../../components/UnviewedObservationTag'
-import type { ReplayObservationApi, WatchFeedItemApi, WatchFeedReasonApi } from '../../generated/api.schemas'
+import type {
+ JevWatchReasonEnumApi,
+ ReplayObservationApi,
+ WatchFeedItemApi,
+ WatchFeedReasonApi,
+} from '../../generated/api.schemas'
import { OBSERVATION_ORIGIN_PARAM, WATCH_FEED_ORIGIN } from '../../utils/breadcrumbs'
import { citedTextToPlainText } from '../../utils/citations'
import { SCANNER_TYPE_TAG_TYPE, ScannerType } from '../types'
-import { type WatchFeedView, watchFeedLogic } from '../watchFeedLogic'
+import { watchFeedLogic } from '../watchFeedLogic'
+
+/** Reason kinds that say nothing about the session. The backend returns these only to pad a near-empty
+ * feed, so a feed made up entirely of them means the window turned up no findings at all. */
+export const FILLER_REASON_KINDS = new Set(['unviewed_recent', 'recent'])
const roundScore = (value: number): number => Math.round(value * 100) / 100
@@ -38,16 +46,9 @@ const MAX_SHOWN_HEADLINES = 3
const joinWithAnd = (parts: string[]): string =>
parts.length > 1 ? `${parts.slice(0, -1).join(', ')}, and ${parts[parts.length - 1]}` : parts[0]
-/** Reason kinds that say nothing about the session. The backend returns these only to pad a near-empty
- * feed, so a feed made up entirely of them means the window turned up no findings at all. */
-export const FILLER_REASON_KINDS = new Set(['unviewed_recent', 'recent'])
-
+/** What the reason kind says about the session. Never the scan's notability sentence: the row's title
+ * already leads with it. */
export function watchReasonCopy(reason: WatchFeedReasonApi): string {
- // The scan wrote this sentence while watching the session, so it beats anything derived from the
- // reason kind. Absent on observations scanned before notability shipped, which fall through below.
- if (reason.notability_reason) {
- return reason.notability_reason
- }
switch (reason.kind) {
case 'signal_emitted': {
const total = reason.signals_count ?? 0
@@ -197,121 +198,12 @@ export function watchCardHeadline(
return { title, body: rest ? { text: rest } : null }
}
-interface WatchFeedCardProps {
+interface WatchFeedRowProps {
item: WatchFeedItemApi
/** Zero-based place in the feed, captured so we can see how deep people read. */
position: number
}
-interface WatchFeedCardData {
- keyMomentMs: number | null
- scannerType: ScannerType | undefined
- scannerName: string
- person: string | null | undefined
- headline: ReturnType<typeof watchCardHeadline>
- observationUrl: string
- captureObservationOpened: () => void
- watchClipInModal: () => void
-}
-
-/** What both card layouts show and do, so the grid and the list open and report clips the same way. */
-function useWatchFeedCardData(
- { observation, reason }: WatchFeedItemApi,
- position: number,
- view: WatchFeedView
-): WatchFeedCardData {
- const { openSessionPlayer } = useActions(sessionPlayerModalLogic)
- const result = readResult(observation)
- // Fall back to the result's own scanner_type when the snapshot is absent, like watchCardHeadline,
- // so a scan with no snapshot still places its outcome in the right spot.
- const scannerType =
- (observation.scanner_snapshot?.scanner_type as ScannerType | undefined) ??
- (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
- const headline = watchCardHeadline(observation)
- const keyMomentMs = observationKeyMomentMs(observation)
- const startSeconds = watchStartSeconds(keyMomentMs)
- // t is always set, so the observation page opens with the player expanded. `from` marks the feed as the
- // origin, so the observation's back button returns here rather than the scanner.
- const observationUrl = combineUrl(urls.replayVisionObservation(observation.id), {
- t: startSeconds,
- [OBSERVATION_ORIGIN_PARAM]: WATCH_FEED_ORIGIN,
- }).url
- const capture = (target: 'clip_modal' | 'observation'): void => {
- posthog.capture('replay_vision_watch_clip_clicked', {
- scanner_id: observation.scanner_id,
- scanner_type: scannerType,
- observation_id: observation.id,
- position,
- reason_kind: reason.kind,
- has_key_moment: keyMomentMs !== null,
- target,
- view,
- })
- }
- const watchClipInModal = (): void => {
- capture('clip_modal')
- // The modal's own `initialTimestamp` is an absolute unix-ms time, but the key moment is an offset
- // into the recording. The player reads `?t=<seconds>` as an offset on first load and the modal
- // preserves existing search params, so set `t` before opening. Without a key moment, clear any stale
- // `t` so the clip starts from the beginning.
- const { location, searchParams, hashParams } = router.values
- router.actions.replace(
- location.pathname,
- { ...searchParams, t: keyMomentMs === null ? undefined : startSeconds },
- hashParams
- )
- openSessionPlayer({ id: observation.session_id })
- }
- return {
- keyMomentMs,
- scannerType,
- scannerName,
- person,
- headline,
- observationUrl,
- captureObservationOpened: () => capture('observation'),
- watchClipInModal,
- }
-}
-
-function WatchClipPoster({
- observation,
- keyMomentMs,
- onWatch,
- className,
-}: {
- observation: ReplayObservationApi
- keyMomentMs: number | null
- onWatch: () => void
- className?: string
-}): JSX.Element {
- return (
- <button
- type="button"
- onClick={onWatch}
- className="relative z-10 block w-full cursor-pointer"
- data-attr="vision-watch-clip"
- aria-label="Watch clip"
- >
- <ObservationThumbnail observation={observation} className={className}>
- <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 />
- Watch clip
- </span>
- </ObservationThumbnail>
- {keyMomentMs !== null && (
- <Tooltip title="Key moment: where the scan's answer rests most. The clip starts just before it.">
- <span className="absolute bottom-1 right-1 text-xs tabular-nums bg-bg-light border rounded px-1">
- {colonDelimitedDuration(Math.floor(keyMomentMs / 1000), null)}
- </span>
- </Tooltip>
- )}
- </button>
- )
-}
-
function WatchCardPerson({
observation,
person,
@@ -339,118 +231,12 @@ function WatchCardPerson({
)
}
-function WatchCardScanner({
- observation,
- scannerType,
- scannerName,
-}: {
- observation: ReplayObservationApi
- scannerType: ScannerType | undefined
- scannerName: string
-}): JSX.Element {
- return (
- // Above the overlay link so the outcome's hover tooltip stays reachable. The summarizer's
- // outcome is the title + body, so it adds no chip here.
- <div className="relative z-10 flex flex-wrap items-center gap-x-2 gap-y-1 min-w-0">
- {/* One text flow, so on a narrow card the question starts beside the badge and wraps under it
- instead of the whole question dropping to its own line. */}
- <p className="m-0 min-w-0 text-xs leading-5">
- {scannerType && (
- <span className="inline-flex align-middle mr-1.5">
- <ScannerTypeBadge scannerType={scannerType} />
- </span>
- )}
- {/* The question says what the result answers; the scanner's name is a hover away. */}
- {observation.prompt_question ? (
- <Tooltip title={scannerName}>
- <span>{observation.prompt_question}</span>
- </Tooltip>
- ) : (
- <span className="text-muted">{scannerName}</span>
- )}
- </p>
- {scannerType !== 'summarizer' && <ObservationResultSummary observation={observation} />}
- </div>
- )
-}
-
-export function WatchFeedCard({ item, position }: WatchFeedCardProps): JSX.Element {
- const { observation, reason } = item
- const {
- keyMomentMs,
- scannerType,
- scannerName,
- person,
- headline,
- observationUrl,
- captureObservationOpened,
- watchClipInModal,
- } = useWatchFeedCardData(item, position, 'list')
-
- return (
- <div
- className="@container relative border rounded bg-bg-light p-4 flex gap-4 hover:border-accent"
- data-attr="vision-watch-feed-card"
- >
- {!observation.viewed && <span className="absolute inset-y-0 left-0 w-1 rounded-l bg-accent" aria-hidden />}
- {/* The thumbnail is the watch affordance, so the whole poster opens the clip modal.
- The New tag and the key moment sit outside the poster, which clips its own overflow. */}
- <div className="relative hidden @md:block w-64 shrink-0 self-start">
- <WatchClipPoster observation={observation} keyMomentMs={keyMomentMs} onWatch={watchClipInModal} />
- {/* Sits above the button, so it lets clicks through to open the clip. */}
- {!observation.viewed && (
- <UnviewedObservationTag className="absolute top-1 left-1 z-10 pointer-events-none" />
- )}
- </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. Inner links and the thumbnail button sit above it via
- `relative z-10`, so the anchors never nest. */}
- <Link
- to={observationUrl}
- onClick={captureObservationOpened}
- className="text-default after:absolute after:inset-0 after:content-['']"
- data-attr="vision-watch-feed-card-body"
- >
- <h3 className="text-sm font-semibold m-0 line-clamp-2">
- {/* The tag hides with the thumbnail on narrow cards, so screen readers get it here. */}
- {!observation.viewed && <span className="sr-only">New: </span>}
- {headline?.title ?? scannerName}
- </h3>
- </Link>
- <WatchCardPerson observation={observation} person={person} />
- <WatchCardScanner observation={observation} scannerType={scannerType} scannerName={scannerName} />
- {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 font-medium border-t pt-2">
- <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>
- )
-}
-
/**
- * The one sentence a jev-arm card leads with. The scan's notability sentence names the finding, so
- * it outranks prose derived from the result; the derived headline covers scans from before
- * notability shipped, and the scanner's name covers scans with no prose at all.
+ * The one sentence a row leads with when the scan wrote no short title. The scan's notability
+ * sentence names the finding, so it outranks prose derived from the result; the derived headline
+ * covers scans from before notability shipped, and the scanner's name covers scans with no prose at all.
*/
-export function jevCardSentence(observation: ReplayObservationApi, reason: WatchFeedReasonApi): string {
+export function watchFeedRowSentence(observation: ReplayObservationApi, reason: WatchFeedReasonApi): string {
if (reason.notability_reason) {
return reason.notability_reason
}
@@ -459,10 +245,10 @@ export function jevCardSentence(observation: ReplayObservationApi, reason: Watch
}
/**
- * The scanner behind a jev row: a circle in its type's color, then its name. Clicking it narrows the
+ * The scanner behind a row: a circle in its type's color, then its name. Clicking it narrows the
* feed to that scanner. The tooltip carries the scanner's question and verdict.
*/
-function JevScannerLink({
+function WatchFeedScannerLink({
observation,
scannerName,
scannerType,
@@ -508,11 +294,33 @@ function JevScannerLink({
)
}
+/** The sentence that says why a row was picked, for each reason Jev can pick from its fixed list. */
+const JEV_WATCH_REASON_COPY: Record<JevWatchReasonEnumApi, string> = {
+ visible_error: 'The user saw an error message or a failed action in this session.',
+ silent_failure: "Something the user did didn't take effect, and nothing told them.",
+ unresponsive: "The user clicked on something that didn't respond.",
+ slow_or_stuck: 'The page was slow to load or got stuck while the user waited.',
+ blocked: "The user hit a dead end they couldn't get past.",
+ cant_find: "The user searched for something and couldn't find it.",
+ confused: 'The user seemed unsure how something worked and went back and forth.',
+ workaround: 'The user gave up on the usual path and found another way to finish.',
+ abandoned: 'The user started a task and left without finishing it.',
+ churn_signal: 'The user showed signs of churn or downgrading in this session.',
+ success: 'The user reached their goal smoothly, a good example of the product working.',
+}
+
+/** Why a row was picked: Jev's pick when it gave one, otherwise what the reason kind says, so both
+ * ranker arms explain each row. */
+export function watchFeedRowWhy(reason: WatchFeedReasonApi): string {
+ // A value this build does not know (the backend list grew first) falls back to the kind's copy.
+ return (reason.watch_reason && JEV_WATCH_REASON_COPY[reason.watch_reason]) || watchReasonCopy(reason)
+}
+
/**
- * The title of a jev row. A summarizer's authored title is already short, so it leads. Other scans
- * lead with jevCardSentence.
+ * The title of a row. A summarizer's authored title is already short, so it leads. Other scans
+ * lead with watchFeedRowSentence.
*/
-export function jevRowTitle(observation: ReplayObservationApi, reason: WatchFeedReasonApi): string {
+export function watchFeedRowTitle(observation: ReplayObservationApi, reason: WatchFeedReasonApi): string {
const result = readResult(observation)
const scannerType =
(observation.scanner_snapshot?.scanner_type as ScannerType | undefined) ??
@@ -520,19 +328,44 @@ export function jevRowTitle(observation: ReplayObservationApi, reason: WatchFeed
if (scannerType === 'summarizer' && typeof result?.title === 'string' && result.title) {
return result.title
}
- return jevCardSentence(observation, reason)
+ return watchFeedRowSentence(observation, reason)
}
/**
- * The jev arm's row, laid out like a video search result: a large key-moment poster, then a title,
- * the scanner, and the person and time. The whole row opens the observation page, which starts the
- * player at the key moment.
+ * One feed row, laid out like a video search result: a large key-moment poster, then a title, the
+ * reason Jev picked the session when it gave one, the scanner, and the person and time. Both ranker
+ * arms render it, so the experiment compares rankings, not layouts. The whole row opens the
+ * observation page, which starts the player at the key moment.
*/
-export function JevWatchFeedRow({ item, position }: WatchFeedCardProps): JSX.Element {
+export function WatchFeedRow({ item, position }: WatchFeedRowProps): JSX.Element {
const { observation, reason } = item
- const data = useWatchFeedCardData(item, position, 'list')
- const title = jevRowTitle(observation, reason)
+ const result = readResult(observation)
+ // Fall back to the result's own scanner_type when the snapshot is absent, like watchCardHeadline.
+ const scannerType =
+ (observation.scanner_snapshot?.scanner_type as ScannerType | undefined) ??
+ (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
+ const keyMomentMs = observationKeyMomentMs(observation)
+ // `t` is always set, so the observation page opens with the player expanded. `from` marks the feed as
+ // the origin, so the observation's back button returns here rather than the scanner.
+ const observationUrl = combineUrl(urls.replayVisionObservation(observation.id), {
+ t: watchStartSeconds(keyMomentMs),
+ [OBSERVATION_ORIGIN_PARAM]: WATCH_FEED_ORIGIN,
+ }).url
+ const title = watchFeedRowTitle(observation, reason)
const filler = FILLER_REASON_KINDS.has(reason.kind)
+ const captureOpened = (): void => {
+ posthog.capture('replay_vision_watch_clip_clicked', {
+ scanner_id: observation.scanner_id,
+ scanner_type: scannerType,
+ observation_id: observation.id,
+ position,
+ reason_kind: reason.kind,
+ has_key_moment: keyMomentMs !== null,
+ target: 'observation',
+ })
+ }
return (
<article className="group relative flex min-w-0 gap-4" data-attr="vision-watch-feed-row">
<div className="relative w-36 shrink-0 self-start overflow-hidden rounded-lg border group-hover:border-accent group-focus-within:border-accent @xl:w-80">
@@ -541,16 +374,16 @@ export function JevWatchFeedRow({ item, position }: WatchFeedCardProps): JSX.Ele
{!observation.viewed && (
<UnviewedObservationTag className="absolute top-2 left-2 z-10 pointer-events-none" />
)}
- {data.keyMomentMs !== null && (
+ {keyMomentMs !== null && (
<span className="absolute bottom-2 right-2 z-10 rounded bg-black/70 px-1.5 text-xs tabular-nums text-white">
- {colonDelimitedDuration(Math.floor(data.keyMomentMs / 1000), null)}
+ {colonDelimitedDuration(Math.floor(keyMomentMs / 1000), null)}
</span>
)}
</div>
<div className="flex min-w-0 flex-1 flex-col gap-2 pt-0.5">
<Link
- to={data.observationUrl}
- onClick={data.captureObservationOpened}
+ to={observationUrl}
+ onClick={captureOpened}
className="text-default after:absolute after:inset-0 after:content-['']"
data-attr="vision-watch-feed-row-open"
>
@@ -562,78 +395,25 @@ export function JevWatchFeedRow({ item, position }: WatchFeedCardProps): JSX.Ele
{title}
</h3>
</Link>
- <JevScannerLink
- observation={observation}
- scannerName={data.scannerName}
- scannerType={data.scannerType}
- />
- <WatchCardPerson observation={observation} person={data.person} />
- </div>
- </article>
- )
-}
-
-/** The thumbnail-first layout for the grid view, with the feed's reason as its own closing section. */
-export function WatchFeedGridCard({ item, position }: WatchFeedCardProps): JSX.Element {
- const { observation, reason } = item
- const {
- keyMomentMs,
- scannerType,
- scannerName,
- person,
- headline,
- observationUrl,
- captureObservationOpened,
- watchClipInModal,
- } = useWatchFeedCardData(item, position, 'grid')
-
- return (
- <LemonCard
- className="relative flex flex-col rounded-lg p-0 overflow-hidden hover:border-accent"
- data-attr="vision-watch-feed-grid-card"
- >
- {!observation.viewed && <span className="absolute inset-x-0 top-0 h-1 z-20 bg-accent" aria-hidden />}
- {/* The card clips its own corners and draws its own edge, so the poster goes edge to edge. */}
- <div className="relative">
- <WatchClipPoster
- observation={observation}
- keyMomentMs={keyMomentMs}
- onWatch={watchClipInModal}
- className="rounded-none border-0"
- />
- {!observation.viewed && (
- <UnviewedObservationTag className="absolute top-2 left-2 z-10 pointer-events-none" />
- )}
- </div>
- <div className="flex flex-col gap-1.5 p-3 min-w-0 flex-1">
- {/* Stretched over the card like the list card, so a click outside the poster and inner
- links opens the observation. */}
- <Link
- to={observationUrl}
- onClick={captureObservationOpened}
- className="text-default after:absolute after:inset-0 after:content-['']"
- data-attr="vision-watch-feed-card-body"
- >
- <h3 className="text-sm font-semibold m-0 line-clamp-2">
- {!observation.viewed && <span className="sr-only">New: </span>}
- {headline?.title ?? scannerName}
- </h3>
- </Link>
+ <WatchFeedScannerLink observation={observation} scannerName={scannerName} scannerType={scannerType} />
<WatchCardPerson observation={observation} person={person} />
- <WatchCardScanner observation={observation} scannerType={scannerType} scannerName={scannerName} />
- {headline?.body && (
- <p className="text-muted text-xs m-0 line-clamp-2">
- <CitedText text={headline.body.text} segments={headline.body.segments} />
+ {/* A short rule rather than a full-width line: rows carry no card, so a full line reads as
+ the border between two rows. */}
+ <div className="mt-1 flex flex-col gap-2" data-attr="vision-watch-feed-why">
+ <LemonDivider className="m-0 w-36" />
+ <p className="m-0 flex items-start gap-1.5 text-sm text-secondary">
+ <Tooltip title="Why this recording">
+ <span className="mt-0.5 flex shrink-0">
+ <IconFlag className="text-accent" aria-hidden />
+ </span>
+ </Tooltip>
+ <span className="line-clamp-2">
+ <span className="sr-only">Why this recording: </span>
+ {watchFeedRowWhy(reason)}
+ </span>
</p>
- )}
- <div className="mt-auto flex flex-col gap-1 border-t pt-2" data-attr="vision-watch-feed-why">
- <span className="flex items-center gap-1.5 text-xs font-semibold text-muted">
- <IconFlag className="shrink-0 text-accent" aria-hidden />
- Why this recording
- </span>
- <span className="text-xs">{watchReasonCopy(reason)}</span>
</div>
</div>
- </LemonCard>
+ </article>
)
}
diff --git a/products/replay_vision/frontend/replay_scanners/components/WatchFeedTab.tsx b/products/replay_vision/frontend/replay_scanners/components/WatchFeedTab.tsx
index 60a067ebc9af..4c9a8bbc35d2 100644
--- a/products/replay_vision/frontend/replay_scanners/components/WatchFeedTab.tsx
+++ b/products/replay_vision/frontend/replay_scanners/components/WatchFeedTab.tsx
@@ -1,7 +1,7 @@
import { useActions, useValues } from 'kea'
-import { IconGridMasonry, IconList, IconSearch } from '@posthog/icons'
-import { LemonButton, LemonInput, LemonSegmentedButton, LemonSkeleton } from '@posthog/lemon-ui'
+import { IconSearch } from '@posthog/icons'
+import { LemonButton, LemonInput, LemonSkeleton } from '@posthog/lemon-ui'
import { DateFilter } from 'lib/components/DateFilter/DateFilter'
import { dateMapping } from 'lib/utils/dateFilters'
@@ -10,8 +10,8 @@ import { pluralize } from 'lib/utils/strings'
import { FilterPill } from '../../components/FilterPill'
import { visionScannersListLogic } from '../../logics/visionScannersListLogic'
import { SCANNER_TYPE_OPTIONS, ScannerType } from '../types'
-import { type WatchFeedView, watchFeedLogic } from '../watchFeedLogic'
-import { FILLER_REASON_KINDS, JevWatchFeedRow, WatchFeedCard, WatchFeedGridCard } from './WatchFeedCard'
+import { watchFeedLogic } from '../watchFeedLogic'
+import { FILLER_REASON_KINDS, WatchFeedRow } from './WatchFeedCard'
import { WatchFeedEmptyState } from './WatchFeedEmptyState'
const TYPE_OPTIONS: { value: ScannerType; label: string }[] = SCANNER_TYPE_OPTIONS.map(({ value, label }) => ({
@@ -31,23 +31,8 @@ const FEED_DATE_OPTION_KEYS = new Set([
])
const FEED_DATE_OPTIONS = dateMapping.filter((option) => FEED_DATE_OPTION_KEYS.has(option.key))
-const GRID_CLASS_NAME = 'grid gap-3 grid-cols-1 @xl:grid-cols-2 @3xl:grid-cols-3'
-
-function FeedSkeleton({ view }: { view: WatchFeedView }): JSX.Element {
- return view === 'grid' ? (
- <div className={GRID_CLASS_NAME} aria-busy>
- {[0, 1, 2].map((i) => (
- <div key={i} className="flex flex-col border rounded-lg overflow-hidden">
- <LemonSkeleton className="aspect-video w-full rounded-none" />
- <div className="flex flex-col gap-1.5 p-3">
- <LemonSkeleton className="h-4 w-2/3" />
- <LemonSkeleton className="h-3 w-full" />
- <LemonSkeleton className="h-3 w-1/2" />
- </div>
- </div>
- ))}
- </div>
- ) : (
+function FeedSkeleton(): JSX.Element {
+ return (
<div className="flex flex-col gap-3" aria-busy>
{[0, 1, 2].map((i) => (
<LemonSkeleton key={i} className="h-32 rounded" />
@@ -70,9 +55,6 @@ export function WatchFeedTab(): JSX.Element {
search,
hasFeedFilters,
emptyReason,
- view,
- displayView,
- feedRanker,
} = useValues(watchFeedLogic)
const {
setDateRange,
@@ -82,7 +64,6 @@ export function WatchFeedTab(): JSX.Element {
setSearch,
clearFeedFilters,
loadFeed,
- setView,
} = useActions(watchFeedLogic)
const { scanners: allScanners } = useValues(visionScannersListLogic)
const scannerOptions = allScanners.map((scanner) => ({
@@ -97,33 +78,27 @@ export function WatchFeedTab(): JSX.Element {
// Every card carrying a no-evidence reason means the window produced no findings. A feed that mixes a
// finding with padding needs no explaining, so this stays off unless the whole feed is padding.
const onlyFiller = items.length > 0 && items.every((item) => FILLER_REASON_KINDS.has(item.reason.kind))
- // The jev arm gets its own row, so the experiment compares rankings and layouts as one arm.
- const ListCard = feedRanker === 'jev' ? JevWatchFeedRow : WatchFeedCard
return (
<div className="@container flex flex-col gap-4">
<div className="flex flex-wrap items-end justify-between gap-2">
<div className="flex flex-col gap-1">
<h2 className="text-xl font-semibold m-0">
- {items.length === 0
- ? 'What to watch'
- : feedRanker === 'jev'
- ? `Top ${pluralize(items.length, 'session')}`
- : pluralize(items.length, 'clip')}
+ {items.length === 0 ? 'What to watch' : `Top ${pluralize(items.length, 'session')}`}
</h2>
<p className="text-muted text-sm m-0">
{narrowedToScanners > 0
? `Following ${pluralize(narrowedToScanners, 'scanner')} of ${allScanners.length}. `
: ''}
{items.length > 0
- ? `Picked from ${pluralize(scannerCount, 'scanner')} in this window. Each clip is the moment an observation cites.`
+ ? `Picked from ${pluralize(scannerCount, 'scanner')} in this window. Each session opens at the moment its scan cites.`
: 'The observations most worth a look, picked across your scanners.'}
</p>
</div>
<div className="flex flex-wrap items-center gap-2">
<LemonInput
type="search"
- placeholder="Search clips..."
+ placeholder="Search sessions..."
value={search}
onChange={setSearch}
prefix={<IconSearch />}
@@ -166,32 +141,11 @@ export function WatchFeedTab(): JSX.Element {
Clear filters
</LemonButton>
)}
- {feedRanker !== 'jev' && (
- <LemonSegmentedButton<WatchFeedView>
- size="xsmall"
- value={view}
- onChange={setView}
- options={[
- {
- value: 'grid',
- icon: <IconGridMasonry />,
- tooltip: 'Thumbnails',
- 'data-attr': 'vision-watch-feed-view-grid',
- },
- {
- value: 'list',
- icon: <IconList />,
- tooltip: 'List',
- 'data-attr': 'vision-watch-feed-view-list',
- },
- ]}
- />
- )}
</div>
</div>
{feedItemsLoading && feedItems === null ? (
- <FeedSkeleton view={displayView} />
+ <FeedSkeleton />
) : (
<div className="flex flex-col gap-3">
{/* kea-loaders keeps the last value on failure, so a later filter or date change can fail
@@ -212,22 +166,14 @@ export function WatchFeedTab(): JSX.Element {
rather than leaving the reader to infer it from three identical reason lines. */}
{onlyFiller && (
<p className="text-sm text-secondary m-0">
- Nothing stood out in this window. These are the newest clips. Try a longer date range to see
- more.
+ Nothing stood out in this window. These are the newest sessions. Try a longer date range to
+ see more.
</p>
)}
{items.length > 0 ? (
- displayView === 'grid' ? (
- <div className={GRID_CLASS_NAME}>
- {items.map((item, index) => (
- <WatchFeedGridCard key={item.observation.id} item={item} position={index} />
- ))}
- </div>
- ) : (
- items.map((item, index) => (
- <ListCard key={item.observation.id} item={item} position={index} />
- ))
- )
+ items.map((item, index) => (
+ <WatchFeedRow key={item.observation.id} item={item} position={index} />
+ ))
) : feedFailed ? null : emptyReason ? (
<WatchFeedEmptyState reason={emptyReason} />
) : (
diff --git a/products/replay_vision/frontend/replay_scanners/watchFeedLogic.test.ts b/products/replay_vision/frontend/replay_scanners/watchFeedLogic.test.ts
index 78724cc32063..265478ae3f82 100644
--- a/products/replay_vision/frontend/replay_scanners/watchFeedLogic.test.ts
+++ b/products/replay_vision/frontend/replay_scanners/watchFeedLogic.test.ts
@@ -52,7 +52,7 @@ describe('watchFeedLogic', () => {
.toFinishAllListeners()
const lastUrl = new URL(feedSpy.mock.calls.at(-1)[0].request.url)
expect(lastUrl.searchParams.get('scanner_type')).toBe('monitor')
- // The response names the ranker, which picks the card layout.
+ // The response names the ranker that ordered the feed.
expect(logic.values.feedRanker).toBe('jev')
await expectLogic(logic, () => {
@@ -132,20 +132,6 @@ describe('watchFeedLogic', () => {
.toFinishAllListeners()
})
- it('defaults to the list view and keeps the chosen view when filters clear', async () => {
- logic.mount()
- expect(logic.values.view).toBe('list')
- logic.actions.setView('grid')
- await expectLogic(logic, () => {
- logic.actions.clearFeedFilters()
- })
- .toMatchValues({ view: 'grid', displayView: 'grid' })
- .toFinishAllListeners()
- // The jev arm's rows only come as a list, so it ignores the saved grid choice.
- logic.actions.setFeedRanker('jev')
- expect(logic.values.displayView).toBe('list')
- })
-
it('names the empty reason only once the fleet and budget have answered', async () => {
feedSpy.mockImplementation(() => [200, { results: [] }])
useMocks({
diff --git a/products/replay_vision/frontend/replay_scanners/watchFeedLogic.ts b/products/replay_vision/frontend/replay_scanners/watchFeedLogic.ts
index 9a98ca8a6135..a54ca59d5236 100644
--- a/products/replay_vision/frontend/replay_scanners/watchFeedLogic.ts
+++ b/products/replay_vision/frontend/replay_scanners/watchFeedLogic.ts
@@ -6,7 +6,6 @@ import { trackedActionToUrl } from 'lib/logic/scenes/trackedActionToUrl'
import posthog from 'lib/posthog-typed'
import { getCurrentTeamIdOrNone } from 'lib/utils/getAppContext'
import { objectsEqual } from 'lib/utils/objects'
-import { sessionPlayerModalLogic } from 'scenes/session-recordings/player/modal/sessionPlayerModalLogic'
import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
@@ -32,7 +31,6 @@ export interface watchFeedLogicValues {
scannersLoading: boolean // visionScannersListLogic
dateFrom: string
dateTo: string | null
- displayView: WatchFeedView
emptyReason: WatchFeedEmptyReason | null
feedFailed: boolean
feedItems: WatchFeedItemApi[] | null
@@ -47,7 +45,6 @@ export interface watchFeedLogicValues {
value: string
}[]
tagsFilter: string[]
- view: WatchFeedView
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
@@ -110,15 +107,11 @@ export interface watchFeedLogicActions {
setTagsFilter: (tags: string[]) => {
tags: string[]
}
- setView: (view: WatchFeedView) => {
- view: WatchFeedView
- }
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface watchFeedLogicMeta {
__keaTypeGenInternalSelectorTypes: {
- displayView: (view: WatchFeedView, feedRanker: RankerEnumApi) => WatchFeedView
emptyReason: (
scanners: ReplayScannerApi[],
scannersLoading: boolean,
@@ -151,8 +144,6 @@ export type watchFeedLogicType = MakeLogicType<
export const DEFAULT_FEED_DATE_FROM: string = '-7d'
-export type WatchFeedView = 'grid' | 'list'
-
/** Which ranker ordered the loaded feed. Server-decided per team (the flag evaluates against the
* team, not the viewer), so the client reads it from the response instead of checking the flag. */
export type WatchFeedRanker = WatchFeedResponseApi['ranker']
@@ -197,7 +188,6 @@ export const watchFeedLogic = kea<watchFeedLogicType>([
restoreFeedFilters: (search: string, scannerIds: string[], tags: string[]) => ({ search, scannerIds, tags }),
clearFeedFilters: true,
loadFeed: true,
- setView: (view: WatchFeedView) => ({ view }),
setFeedRanker: (ranker: WatchFeedRanker) => ({ ranker }),
}),
@@ -289,14 +279,6 @@ export const watchFeedLogic = kea<watchFeedLogicType>([
clearFeedFilters: () => [],
},
],
- // A display choice, not a filter, so clearing filters leaves it alone.
- view: [
- 'list' as WatchFeedView,
- { persist: true },
- {
- setView: (_, { view }) => view,
- },
- ],
feedFailed: [
false,
{
@@ -344,9 +326,6 @@ export const watchFeedLogic = kea<watchFeedLogicType>([
reportFiltered(values)
actions.loadFeed()
},
- setView: ({ view }) => {
- posthog.capture('replay_vision_watch_feed_view_changed', { view })
- },
loadFeedSuccess: ({ feedItems }) => {
const items = feedItems ?? []
// The click event reports the reason a reader picked; without this one nothing reports the mix
@@ -360,32 +339,15 @@ export const watchFeedLogic = kea<watchFeedLogicType>([
scanner_count: new Set(items.map((item) => item.observation.scanner_id)).size,
reason_kind_counts: countByReasonKind,
ranker: values.feedRanker,
- view: values.displayView,
signal_share: items.length > 0 ? (countByReasonKind.signal_emitted ?? 0) / items.length : 0,
// Which dead end the reader hit, so the empty screens can be counted and ranked
// against each other instead of only showing up as a clip count of zero.
...(items.length === 0 ? { empty_reason: values.emptyReason ?? 'unresolved' } : {}),
})
},
- // A card writes `?t=<seconds>` so the player opens at the key moment; clear it on close so a
- // link copied afterwards doesn't seek a recording the user is no longer looking at.
- [sessionPlayerModalLogic.actionTypes.closeSessionPlayer]: () => {
- const { location, searchParams, hashParams } = router.values
- if (searchParams.t === undefined) {
- return
- }
- const nextParams = { ...searchParams }
- delete nextParams.t
- router.actions.replace(location.pathname, nextParams, hashParams)
- },
})),
selectors({
- // The jev arm's rows only come as a list, so its view toggle is hidden and the saved choice is ignored.
- displayView: [
- (s) => [s.view, s.feedRanker],
- (view: WatchFeedView, feedRanker: WatchFeedRanker): WatchFeedView => (feedRanker === 'jev' ? 'list' : view),
- ],
/** Null until both probes answer, so an empty screen is never drawn from unresolved data. */
emptyReason: [
(s) => [s.scanners, s.scannersLoading, s.quota, s.quotaLoading, s.hasFeedFilters],