: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(replay-vision): tidy what to watch empty states and scope tabs (#123221)
Tue Haulundc6d227243e3b
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex a44c83985ac0..d5928dfcfda1 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -14597,21 +14597,21 @@ snapshots:scenes-app-replay-vision--home-watch-feed--light:hash: v1.k794b7964.4d1c2d852d5380f72997ca12282df9c5194effa9f908e62b6086dd675e797e6f.9B9NfkA62DYoeVZKKFjbn8Dv9mg1zn7GXPZjGqnhr9Yscenes-app-replay-vision--home-watch-feed-embedding-arm--dark:- hash: v1.k794b7964.1a1cbdd6acabea08dd2d68e14fe040eaf902ef8465927578ace8a9f5bbde6ce5.GTgpW1FTkzZrHK7RUxilJPC2AxgeWgp4C8Ga_scR5fo+ hash: v1.k794b7964.ccaaf7d4f0753f587f0f9a925f24da96088e28acdd9e03439486bbac356478f8.yWzVWUCUSLPvu5-cOEucqXHc0xzNZUUL-FM7GmgCglQscenes-app-replay-vision--home-watch-feed-embedding-arm--light:- hash: v1.k794b7964.7590868e3a7d088106dc18e3e0d2a8d838be86b0acef135e97a45ecc53b67f36.cel6SQmC7MujdHW5o9lkpJ2h42bm3FAyefLD8im6eKM+ hash: v1.k794b7964.ef9bc52e0e31035e1ced8b94ed67348d4d31cff269e9a4c6bc8af2357b2117bd.cmduyszYcyvgTo8cLSgqyzbUI-Swod1Hqh72SJfaRBkscenes-app-replay-vision--home-watch-feed-empty--dark:- hash: v1.k794b7964.614c2f25e846b4b62d453da1f3e8eeea44c57e1139cbd6a9aa93553a457aac17.l7w_nfYdsx17uChOCZUrB1cjbXW6Iif4KBTpTsL08Xk+ hash: v1.k794b7964.e8bf2a561963c96df9eb9dc6d005e192bdc64301c92c9654b7de4593ea8518c5.X43IWxVfHE9iboy6cY-VKIyo3R0N8Fej_PiO1JIyYZYscenes-app-replay-vision--home-watch-feed-empty--light:- hash: v1.k794b7964.9d99877526d83ea7f03feab63d2d0e94fb66e68d585889e6b37e9bae480f68c9.x1Aal2QclDzow3a5Hx6BpkJcnv_l-PhLDjkIqexUTNA+ hash: v1.k794b7964.347da36a401fa205ffb5d2c388197fdf5a102eff3148438c2da416aeba65c2a7.TBRMQTWYMU9iHr1naonnIVacv_NqjtZOCWe3Yc6__UUscenes-app-replay-vision--home-watch-feed-jev-arm--dark:- hash: v1.k794b7964.a275b0ea478208f97f7198bc67644bedddc12083ebaae9cafe287ebdcbd02faa.cRV7FtQxED_hIn3kObdcUdMPsj8WeUpHmOulEahgTTo+ hash: v1.k794b7964.dded93992064551ce579a8a07c96b7414e3d83d33104497a391a88ffa0bf15bd.J9WyZjcnl0CsP0t2Ml9Ic9wv6IWl6XlpIjV9m0OOFvkscenes-app-replay-vision--home-watch-feed-jev-arm--light:- hash: v1.k794b7964.e7e598f0ce15c0c82d52af9a0e2030d955e55ab40abfe9cc2052a2acd7c1f6d0.wrabqzKi1LjI6N4dPGG9kCC6UCdDrcq0Hm-l4VLemHs+ hash: v1.k794b7964.029b6b85f20f538d24a908cd7fdb8322aef5087f69103a81b10fd3d3bfbea887.lmw6vqb-wXrFbsAMle9av0BP2tkB9CyhK1IL9xMmDa8scenes-app-replay-vision--home-watch-feed-only-newest--dark:- hash: v1.k794b7964.db86a44f2ccb474abc3fbfc0c16d690ec06099ebec1a13d0006717cc24a8bae9.46YbWyXBGKdeS6wjijnt0Zy3_fPL-zY1DbF3Wkvbvac+ hash: v1.k794b7964.42e9a57b761186ae53e6d6a9aad97b59bc0a71a572ee9c6977b733818930ced7.Ab1APElWbvJ9mvPg5s-ezcdcRb1VTakv0FDgE3i-VfAscenes-app-replay-vision--home-watch-feed-only-newest--light:- hash: v1.k794b7964.b9ef681e0d7f7cf3dcdfe6b5ea74e6aa6308e301aadeada4819df13fcbaa12f8.ZUNDzzhrBQbzMegH2AdNIwvFOXtfdVyJCwV_P3cv_LY+ hash: v1.k794b7964.b76b262f44c32205b44d80ca4d41dc262e4d52446cd9d627acfb053fdfefb67e.eKCkLSAbysz40mpn9JdPpdRfUsIXH7GdFyNqi4pjE8oscenes-app-replay-vision--monitor-observations--dark:hash: v1.k794b7964.9ec7ef6c17074e9547647fe71aa2613100208fa0c7ba87a3d97897b4f183a5c8.-UKB-w06mWDRH2yNgzIBhn3Qhn2MYlFTNXjhMce1hh4scenes-app-replay-vision--monitor-observations--light:@@ -14920,30 +14920,34 @@ snapshots:hash: v1.k794b7964.0dac77dbf97e99deb916b18c338f397b1c7c58d305dcb722c2c397f1efe2167f.CH2uxVc4xyfRne0meiJNYXeK1aiNC9KaBpAX_EVhWiQscenes-app-replay-vision-test-account-filter-settings-dialog--default--light:hash: v1.k794b7964.4a45317cf1541935394cc4f27a9b29c17f0c8aeaebb6a832fd947dca51c1dacd.-SOqokEQ4yQf2ZbX4EM6nY2csQRt0E46XT4F1g_pTlE+ scenes-app-replay-vision-watchfeedblockedbanner--quota-exhausted--dark:+ hash: v1.k794b7964.e535872d607f48c58be28228332bf871f8d5f748662f3e0d086f7e2be529a2b7.ErHiOeF3vI_gUmyOuaU_wqe8g7F8R8ufcGnV1t8vChQ+ scenes-app-replay-vision-watchfeedblockedbanner--quota-exhausted--light:+ hash: v1.k794b7964.e4c3b121ad7a311eabb7753806ff56a78261ffe5333b681774bc97a41038799a.uAGUW2ndVlXKZN_0E1SDPUKGT-fw0Iyb7k91r7mofqwscenes-app-replay-vision-watchfeedemptystate--all-capped--dark:- hash: v1.k794b7964.2044f64f59724a250003d8be462529ad61a07e05f5a7104879a7b00980c17b1e.2ec-AsxkwzKRLGbe4NJhCFYTVZhBBS-G4PowHISQAK0+ hash: v1.k794b7964.827b25db6e216bda95ef8b687689225b9d47c06bd64dc14fd335bce5e3aac0ba.KxHvg-8tw1ZADRo--7J6WfR_g2KH2T_iWxrgHsdWXv4scenes-app-replay-vision-watchfeedemptystate--all-capped--light:- hash: v1.k794b7964.827951eedc4b27a19c51943be56de5e66332fe2af13d258a5020c5f9e02d90ef.fnVEjjQoWjIJ-A4NO1HbAOmf1QkPjatVvl56ecWn5-o+ hash: v1.k794b7964.bc518219001629e905129ef03223474b721177ca32b7f8fcb2f1a802115aa39a.SDgQVN9PhcKY_x3slsioMgbWc-_Q5BEVxGeq-XPH_wMscenes-app-replay-vision-watchfeedemptystate--all-disabled--dark:- hash: v1.k794b7964.95f5488d9be93532b070280e334d24ebc7ea4216b3fd91e317c60ba3a4c6bb37.wX3TVVh7pA_u9ZeTvQFT7quClJdoO-mzd_EKzQqTXJw+ hash: v1.k794b7964.8a46fd3ccf6f1981a60ac60d43153d2805ae156d72f63101a64e92d80d578f46.RJVLCBqwjMpnxhrzJtjRzDCLW3lO-TL3olfNaiSl3E8scenes-app-replay-vision-watchfeedemptystate--all-disabled--light:- hash: v1.k794b7964.87641562db015731f2de39e04591e3efd4e136db74a726b4e7a8835f6b608be6._VX6C8s2D6xBgXcwhyxW47DDLTNUg90321xZZc0enxE+ hash: v1.k794b7964.854972182cbc01b9ef8eb658b0bdc1e92ac08c753789d15da28118c3cf171a95.FF5FucA4taWLV3Qh5SS1SwobEt-YETag9DPhni3rfZwscenes-app-replay-vision-watchfeedemptystate--filtered--dark:- hash: v1.k794b7964.9c28b22694bf445428e287ffba15a43ba9f8e6096f2975525a0f101c168f9acc.AMzob-d5Se4UV-_lnmynB4K58gbjmwCo6zDyVJmpEUc+ hash: v1.k794b7964.0474769b535df6aa12a7b084d282670d43cdee3e4d25bea774343b31a3507222.Km4N8RA3EPJr8WkNaiJY9gIjm6eHvx0KvYnQGCy2ZiQscenes-app-replay-vision-watchfeedemptystate--filtered--light:- hash: v1.k794b7964.8d5946497bd09e2b026c061d1455a817ba966af095a88728ea6d29fbb9f52bb9.pE1i1IRnnpYJTGvEFuMWHNYnVKUoGparwVoG0Sx_VHg+ hash: v1.k794b7964.a46eecfe214809eb57f9cee104966134dc9ee7e7c87c76ece00804cc4b7e01ed.YQtNRdaka2JN1Uf-MG38xWtTxCVx0zFvXsCkq_BVS9cscenes-app-replay-vision-watchfeedemptystate--no-scanners--dark:- hash: v1.k794b7964.f2bd16f47816e1a9d2fd314270daa72223c37a8946af17765b3f3c43df966cfe.3wSlppAgHktz_NPXbdFqdb0d4SxmdQ4_lBtKTji20e0+ hash: v1.k794b7964.1a2bc2d84fde117a62c1e247a770c177eec921730810ba1ddc5fd561bd5b56a6.-WrqvOi2Y6Wt2K2HgpXJb1f3X0Q5t-bee_q8rpu01LYscenes-app-replay-vision-watchfeedemptystate--no-scanners--light:- hash: v1.k794b7964.5de8b483a01bf5f9ed595e900d6b6f26180f901bcfb9c8bb2729fbf46f847264.nqlSLSEafSpbB7kI11PSDxLlU-YmYfwC5oDLC1QLVbw+ hash: v1.k794b7964.f0fbceb29ededf3b34b97b3c6b86bd0797b25a9135aec3fd583a6aed09f45c9c.sjcRTwrc9JZz7_05WxzsN4bl_Ybjlo6am8hHKWvrqGkscenes-app-replay-vision-watchfeedemptystate--quiet-window--dark:- hash: v1.k794b7964.50cd583401f3e45ec47f476cc0d9fb3208294202af2aa1cb0856fb7c1fd3fb83.EKR4ZZU6vyZ6xxUv4dX_f5telnfevtft2rV7R8wv_mY+ hash: v1.k794b7964.c4ed5fbd745303fc8ebcd4ac215fc9022b99c4188f963d99b15d721bb15935d8.wZ2qbLFdR0hBmesjaQ0prKaHK4-j0dUW0DdP0danhEEscenes-app-replay-vision-watchfeedemptystate--quiet-window--light:- hash: v1.k794b7964.e0ed64d8967f7b29fdc9503d95da3f8ce8936a49c15a861c276355f27282e2a9.8J-XaVdJjUsBXNVxy_GjYq-5lQn3RpH3QAEce7x34lU+ hash: v1.k794b7964.1f589f91ce12f7c154679d17d97a21c8e203aa87397164cccc78157535b977d3.MfHogT00qi5y8x4FSB5fNPlsH5snNQP9JVY6dWPbAFEscenes-app-replay-vision-watchfeedemptystate--quota-exhausted--dark:- hash: v1.k794b7964.156b681d8c3026279523eae78298898334fecd340a168a93c2b1f27e8b87c477.2RIkQGbqyk33Exg6GczARiEZpZowlwCUPXbukhOSki0+ hash: v1.k794b7964.b1f47cd49f93204542abf607f565859a592273ca11d2c068f04b04bd32049409.UtIhUrTC1d46S9kkqMXQEljNax3AtJYIxgAiUxeNWL8scenes-app-replay-vision-watchfeedemptystate--quota-exhausted--light:- hash: v1.k794b7964.955908541d73f6f32bd758cdd758724f10e201e3fea481b91294b284a489fe96.3buIiPKIIBer22g58o_OW3nkOAcV0uHmNfUFXn8ldnI+ hash: v1.k794b7964.206cb4c6e3d6ae106a0e07edb31a30c597af6fa2917a5e19330d1b3dfdb3622a.84P18hlPeqHHEv8WDiFn8zetROCxHJqdgZGHZYrvDgMscenes-app-saved-insights--empty-state--dark:hash: v1.k794b7964.8186a1849accab762928456f98db977a9b097cf28199d7e1eb6c1e841500852c.SXNRf2LgiH3DkvhwUukZcGqDXngv1kGiEhGYUAhlKC8scenes-app-saved-insights--empty-state--light:diff --git a/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx b/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsxindex 32b4a5192048..a5a0687b2894 100644--- a/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx+++ b/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx@@ -1,3 +1,5 @@+import { MOCK_DEFAULT_BASIC_USER, MOCK_DEFAULT_USER } from 'lib/api.mock'+import type { Meta, StoryObj } from '@storybook/react'import { waitFor, within } from '@testing-library/dom'import userEvent from '@testing-library/user-event'@@ -1128,8 +1130,23 @@ export const UsageTab: StoryObj = {parameters: { pageUrl: `${urls.replayVision()}?tab=usage` },}-// The home page lands on the What to watch feed.-export const HomeWatchFeed: StoryObj = {}+// The home page lands on the What to watch feed. The viewer created one scanner, so the feed offers the scope tabs.+export const HomeWatchFeed: StoryObj = {+ decorators: [+ mswDecorator({+ get: {+ '/api/projects/:team_id/vision/scanners/': {+ ...scanners,+ results: scanners.results.map((item, index) =>+ index === 0+ ? { ...item, created_by: { ...MOCK_DEFAULT_BASIC_USER, id: MOCK_DEFAULT_USER.id } }+ : item+ ),+ },+ },+ }),+ ],+}// 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,diff --git a/products/replay_vision/frontend/replay_scanners/components/WatchFeedBlockedBanner.stories.tsx b/products/replay_vision/frontend/replay_scanners/components/WatchFeedBlockedBanner.stories.tsxnew file mode 100644index 000000000000..5cf9391243e3--- /dev/null+++ b/products/replay_vision/frontend/replay_scanners/components/WatchFeedBlockedBanner.stories.tsx@@ -0,0 +1,19 @@+import type { Meta, StoryObj } from '@storybook/react'++import { WatchFeedBlockedBanner } from './WatchFeedBlockedBanner'++const meta: Meta<typeof WatchFeedBlockedBanner> = {+ title: 'Scenes-App/Replay Vision/WatchFeedBlockedBanner',+ component: WatchFeedBlockedBanner,+ decorators: [+ // LemonBanner is a CSS container, so the parent sets its width.+ (Story) => (+ <div className="w-200">+ <Story />+ </div>+ ),+ ],+}+export default meta++export const QuotaExhausted: StoryObj<typeof WatchFeedBlockedBanner> = { args: { reason: 'quota-exhausted' } }diff --git a/products/replay_vision/frontend/replay_scanners/components/WatchFeedBlockedBanner.tsx b/products/replay_vision/frontend/replay_scanners/components/WatchFeedBlockedBanner.tsxnew file mode 100644index 000000000000..2acf0b55fd93--- /dev/null+++ b/products/replay_vision/frontend/replay_scanners/components/WatchFeedBlockedBanner.tsx@@ -0,0 +1,29 @@+import { useActions } from 'kea'+import { router } from 'kea-router'++import { LemonBanner } from '@posthog/lemon-ui'++import { urls } from 'scenes/urls'++import { WATCH_FEED_BLOCKS, type WatchFeedBlockReason } from '../watchFeedEmptyState'++/** Sits above cards that are still in the window, to say the feed will not get new ones and why. */+export function WatchFeedBlockedBanner({ reason }: { reason: WatchFeedBlockReason }): JSX.Element {+ const { push } = useActions(router)+ const block = WATCH_FEED_BLOCKS[reason]+ return (+ <LemonBanner+ type="warning"+ action={{+ children: block.actionLabel,+ onClick: () => push(urls.replayVision(), { tab: block.tab }),+ 'data-attr': block.bannerDataAttr,+ }}+ >+ <p className="font-semibold m-0">New sessions aren't being scanned</p>+ <p className="m-0">+ {block.cause} {block.fix}+ </p>+ </LemonBanner>+ )+}diff --git a/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.tsx b/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.tsxindex f6834fb14d8b..055c5df5a46a 100644--- a/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.tsx+++ b/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.tsx@@ -23,6 +23,7 @@ import type {} from '../../generated/api.schemas'import { OBSERVATION_ORIGIN_PARAM, WATCH_FEED_ORIGIN } from '../../utils/breadcrumbs'import { citedTextToPlainText } from '../../utils/citations'+import { hasScannerPage, scannerLabel } from '../../utils/observation'import { SCANNER_TYPE_TAG_TYPE, ScannerType } from '../types'import { watchFeedLogic } from '../watchFeedLogic'import { CARD_SEEN_DWELL_MS, cardProperties } from '../watchFeedTelemetry'@@ -261,7 +262,7 @@ export function watchFeedRowSentence(observation: ReplayObservationApi, reason:return reason.notability_reason}const headline = watchCardHeadline(observation)- return headline?.title ?? ((observation.scanner_snapshot?.name as string | undefined) || '(untitled scanner)')+ return headline?.title ?? scannerLabel(observation)}/**@@ -278,6 +279,20 @@ function WatchFeedScannerLink({scannerType: ScannerType | undefined}): JSX.Element {const verdict = readResult(observation)?.verdict+ const linked = hasScannerPage(observation)+ const chip = (+ <>+ {scannerType && (+ <LemonTag+ type={SCANNER_TYPE_TAG_TYPE[scannerType]}+ className="size-6 shrink-0 justify-center !rounded-full !p-0"+ >+ {scannerTypeIcon(scannerType)}+ </LemonTag>+ )}+ <span className="truncate font-medium">{scannerName}</span>+ </>+ )return (<Tooltiptitle={@@ -289,26 +304,25 @@ function WatchFeedScannerLink({{typeof verdict === 'string' && verdict ? ` Answered ${verdict}.` : ''}</span>)}- <span className="italic">Click to open this scanner</span>+ {linked && <span className="italic">Click to open this scanner</span>}</div>}>- <Link- to={urls.replayVision(observation.scanner_id)}- subtle- className="relative z-10 flex max-w-full min-w-0 items-center gap-2 self-start text-sm text-secondary hover:text-default"- data-attr="vision-watch-feed-scanner-chip"- >- {scannerType && (- <LemonTag- type={SCANNER_TYPE_TAG_TYPE[scannerType]}- className="size-6 shrink-0 justify-center !rounded-full !p-0"- >- {scannerTypeIcon(scannerType)}- </LemonTag>- )}- <span className="truncate font-medium">{scannerName}</span>- </Link>+ {/* A one-off scan has no scanner page, so its chip names the scan without linking anywhere. */}+ {linked ? (+ <Link+ to={urls.replayVision(observation.scanner_id)}+ subtle+ className="relative z-10 flex max-w-full min-w-0 items-center gap-2 self-start text-sm text-secondary hover:text-default"+ data-attr="vision-watch-feed-scanner-chip"+ >+ {chip}+ </Link>+ ) : (+ <span className="relative z-10 flex max-w-full min-w-0 items-center gap-2 self-start text-sm text-secondary">+ {chip}+ </span>+ )}</Tooltip>)}@@ -366,7 +380,7 @@ export function WatchFeedRow({ item, position }: WatchFeedRowProps): JSX.Elementconst 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 scannerName = scannerLabel(observation)const person = observation.recording_subject_email || observation.distinct_idconst keyMomentMs = observationKeyMomentMs(observation)// `t` is always set, so the observation page opens with the player expanded. `from` marks the feed asdiff --git a/products/replay_vision/frontend/replay_scanners/components/WatchFeedEmptyState.tsx b/products/replay_vision/frontend/replay_scanners/components/WatchFeedEmptyState.tsxindex 8e28086233a1..ae48737ed81b 100644--- a/products/replay_vision/frontend/replay_scanners/components/WatchFeedEmptyState.tsx+++ b/products/replay_vision/frontend/replay_scanners/components/WatchFeedEmptyState.tsx@@ -1,13 +1,12 @@import { useActions, useValues } from 'kea'import { router } from 'kea-router'-import { LemonBanner, LemonButton } from '@posthog/lemon-ui'+import { LemonButton } from '@posthog/lemon-ui'import { urls } from 'scenes/urls'-import { visionScannersListLogic } from '../../logics/visionScannersListLogic'-import type { WatchFeedEmptyReason } from '../watchFeedEmptyState'-import { watchFeedLogic } from '../watchFeedLogic'+import { WATCH_FEED_BLOCKS, type WatchFeedEmptyReason, isWatchFeedBlock } from '../watchFeedEmptyState'+import { feedWindowPhrase, longerFeedWindow, watchFeedLogic } from '../watchFeedLogic'import { WatchFeedIntro } from './WatchFeedIntro'function DashedNote({ children }: { children: React.ReactNode }): JSX.Element {@@ -23,85 +22,63 @@ function DashedNote({ children }: { children: React.ReactNode }): JSX.Element {* that would actually fill the feed, so a reader is never told to wait on scanners that cannot run.*/export function WatchFeedEmptyState({ reason }: { reason: WatchFeedEmptyReason }): JSX.Element {- const { setOnlyMyScanners } = useActions(watchFeedLogic)- const { scanners } = useValues(visionScannersListLogic)+ const { setOnlyMyScanners, setDateFrom } = useActions(watchFeedLogic)+ const { dateFrom } = useValues(watchFeedLogic)const { push } = useActions(router)if (reason === 'no-scanners') {return <WatchFeedIntro />}- if (reason === 'all-disabled') {+ if (isWatchFeedBlock(reason)) {+ const block = WATCH_FEED_BLOCKS[reason]return (- <LemonBanner- type="warning"- action={{- children: 'See all scanners',- onClick: () => push(urls.replayVision(), { tab: 'scanners' }),- 'data-attr': 'vision-watch-feed-see-scanners',- }}- >- <p className="font-semibold m-0">None of your scanners are running</p>- <p className="m-0">- {/* Only worth counting once there are several. The list loads on its own, so a count- taken before it answers would read as "All 0 of your scanners". */}- {scanners.length > 1- ? `All ${scanners.length} of your scanners are off, so nothing new can reach this feed.`- : 'Every scanner on this project is off, so nothing new can reach this feed.'}{' '}- Turn one on and its clips appear after the next matching recording.- </p>- </LemonBanner>+ <DashedNote>+ <span>No sessions to show. {block.cause}</span>+ <LemonButton+ type="secondary"+ size="small"+ onClick={() => push(urls.replayVision(), { tab: block.tab })}+ data-attr={block.dataAttr}+ >+ {block.actionLabel}+ </LemonButton>+ </DashedNote>)}- if (reason === 'quota-exhausted') {- return (- <LemonBanner- type="warning"- action={{- children: 'See usage',- onClick: () => push(urls.replayVision(), { tab: 'usage' }),- 'data-attr': 'vision-watch-feed-see-usage',- }}- >- <p className="font-semibold m-0">Your Replay Vision credits are used up for this period</p>- <p className="m-0">- Scans are skipped until the period resets, so no new clips reach this feed. Raise the limit to start- them again.- </p>- </LemonBanner>- )- }-- if (reason === 'all-capped') {- return (- <LemonBanner- type="warning"- action={{- children: 'See usage',- onClick: () => push(urls.replayVision(), { tab: 'usage' }),- 'data-attr': 'vision-watch-feed-see-usage',- }}- >- <p className="font-semibold m-0">Every running scanner has reached its own credit limit</p>- <p className="m-0">- They stop scanning until the period resets. Raise a scanner's limit to start it again. The sessions- they skipped are not scanned later.- </p>- </LemonBanner>- )- }+ const inWindow = feedWindowPhrase(dateFrom)if (reason === 'filtered') {return (<DashedNote>- <span>Your scanners picked nothing in this window.</span>- <LemonButton type="secondary" size="small" onClick={() => setOnlyMyScanners(false)}>+ <span>No sessions from your scanners stood out {inWindow}.</span>+ <LemonButton+ type="secondary"+ size="small"+ onClick={() => setOnlyMyScanners(false)}+ data-attr="vision-watch-feed-show-all-scanners"+ >Show all scanners</LemonButton></DashedNote>)}- return <DashedNote>Nothing stood out in this window. Try a longer date range to see more.</DashedNote>+ const longerWindow = longerFeedWindow(dateFrom)+ return (+ <DashedNote>+ <span>No sessions stood out {inWindow}.</span>+ {longerWindow && (+ <LemonButton+ type="secondary"+ size="small"+ onClick={() => setDateFrom(longerWindow.value)}+ data-attr="vision-watch-feed-longer-window"+ >+ Show {longerWindow.label.toLowerCase()}+ </LemonButton>+ )}+ </DashedNote>+ )}diff --git a/products/replay_vision/frontend/replay_scanners/components/WatchFeedIntro.tsx b/products/replay_vision/frontend/replay_scanners/components/WatchFeedIntro.tsxindex 0e3b1bb85d75..956dbed76c7a 100644--- a/products/replay_vision/frontend/replay_scanners/components/WatchFeedIntro.tsx+++ b/products/replay_vision/frontend/replay_scanners/components/WatchFeedIntro.tsx@@ -10,10 +10,10 @@ export function WatchFeedIntro(): JSX.Element {return (<div className="flex flex-col gap-4"><div className="flex flex-col items-center gap-2 text-center">- <h3 className="text-xl font-semibold m-0">See your most notable observations here</h3>+ <h3 className="text-xl font-semibold m-0">Sessions worth watching show up here</h3><p className="text-secondary m-0 max-w-lg">- Scanners watch each new session recording and cite the moment they found. We surface the most- notable ones here.+ Create a scanner to analyze new session recordings. Sessions that stand out in its results show up+ here.</p><div className="flex flex-wrap items-center justify-center gap-2 mt-1"><CreateScannerButtondiff --git a/products/replay_vision/frontend/replay_scanners/components/WatchFeedTab.tsx b/products/replay_vision/frontend/replay_scanners/components/WatchFeedTab.tsxindex b2e582ed974f..de6fd4d007fa 100644--- a/products/replay_vision/frontend/replay_scanners/components/WatchFeedTab.tsx+++ b/products/replay_vision/frontend/replay_scanners/components/WatchFeedTab.tsx@@ -5,17 +5,12 @@ import { useInView } from 'react-intersection-observer'import { IconChevronDown } from '@posthog/icons'import { LemonButton, LemonMenu, LemonSkeleton, LemonTabs } from '@posthog/lemon-ui'-import { watchFeedLogic } from '../watchFeedLogic'+import { isWatchFeedBlock } from '../watchFeedEmptyState'+import { FEED_DATE_OPTIONS, feedWindowOption, feedWindowPhrase, watchFeedLogic } from '../watchFeedLogic'+import { WatchFeedBlockedBanner } from './WatchFeedBlockedBanner'import { FILLER_REASON_KINDS, WatchFeedRow } from './WatchFeedCard'import { WatchFeedEmptyState } from './WatchFeedEmptyState'-const FEED_DATE_OPTIONS = [- { value: '-24h', label: 'Last 24 hours' },- { value: '-7d', label: 'Last 7 days' },- { value: '-30d', label: 'Last 30 days' },- { value: '-90d', label: 'Last 90 days' },-]-function FeedSkeleton(): JSX.Element {return (<div className="mx-auto flex w-full max-w-xl flex-col gap-4" aria-busy>@@ -64,7 +59,7 @@ function FeedEnd({ itemCount }: { itemCount: number }): JSX.Element | null {}export function WatchFeedTab(): JSX.Element {- const { feedItems, feedItemsLoading, feedLoad, feedFailed, dateFrom, onlyMyScanners, emptyReason } =+ const { feedItems, feedItemsLoading, feedLoad, feedFailed, dateFrom, scopedToMine, hasOwnScanners, emptyReason } =useValues(watchFeedLogic)const { setDateFrom, setOnlyMyScanners, loadFeed } = useActions(watchFeedLogic)@@ -73,43 +68,53 @@ export function WatchFeedTab(): JSX.Element {// 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))+ const rangeMenu = (+ <LemonMenu+ items={FEED_DATE_OPTIONS.map((option) => ({+ label: option.label,+ active: option.value === dateFrom,+ onClick: () => setDateFrom(option.value),+ }))}+ >+ <LemonButton+ size="small"+ type="tertiary"+ sideIcon={<IconChevronDown />}+ data-attr="vision-watch-feed-range"+ >+ {feedWindowOption(dateFrom)?.label ?? dateFrom}+ </LemonButton>+ </LemonMenu>+ )+return (<div className="@container flex flex-col gap-4">- <p className="mx-auto w-full max-w-xl text-sm text-secondary m-0 -mb-2">- Sessions that stand out in your scanner results.- </p>- <LemonTabs- size="small"- // The small size packs tabs two units apart below md, too tight for two labels this long.- className="mx-auto w-full max-w-xl -mb-2 [&_ul>div]:gap-x-6"- activeKey={onlyMyScanners ? 'mine' : 'all'}- onChange={(key) => setOnlyMyScanners(key === 'mine')}- data-attr="vision-watch-feed-scope"- tabs={[- { key: 'all', label: 'All scanners', 'data-attr': 'vision-watch-feed-scope-all' },- { key: 'mine', label: 'My scanners', 'data-attr': 'vision-watch-feed-scope-mine' },- ]}- rightSlotClassName="bg-transparent pr-0"- rightSlot={- <LemonMenu- items={FEED_DATE_OPTIONS.map((option) => ({- label: option.label,- active: option.value === dateFrom,- onClick: () => setDateFrom(option.value),- }))}- >- <LemonButton- size="small"- type="tertiary"- sideIcon={<IconChevronDown />}- data-attr="vision-watch-feed-range"- >- {FEED_DATE_OPTIONS.find((option) => option.value === dateFrom)?.label ?? dateFrom}- </LemonButton>- </LemonMenu>- }- />- {feedItemsLoading && feedItems === null ? (+ {/* The intro explains the feed on its own, and a project without scanners has no window to pick. */}+ {!(emptyReason === 'no-scanners' && items.length === 0) && (+ <div className="mx-auto flex w-full max-w-xl items-center justify-between gap-2 -mb-2">+ <p className="text-sm text-secondary m-0">Sessions that stand out in your scanner results.</p>+ {!hasOwnScanners && rangeMenu}+ </div>+ )}+ {hasOwnScanners && (+ <LemonTabs+ size="small"+ // The small size packs tabs two units apart below md, too tight for two labels this long.+ className="mx-auto w-full max-w-xl -mb-2 [&_ul>div]:gap-x-6"+ activeKey={scopedToMine ? 'mine' : 'all'}+ onChange={(key) => setOnlyMyScanners(key === 'mine')}+ data-attr="vision-watch-feed-scope"+ tabs={[+ { key: 'all', label: 'All scanners', 'data-attr': 'vision-watch-feed-scope-all' },+ { key: 'mine', label: 'My scanners', 'data-attr': 'vision-watch-feed-scope-mine' },+ ]}+ rightSlotClassName="bg-transparent pr-0"+ rightSlot={rangeMenu}+ />+ )}+ {/* The first render comes before the mount starts the load, and a filter change keeps the last+ result until the new one lands, so an empty screen is only drawn from a finished load. */}+ {(feedItems === null && !feedFailed) || (feedItemsLoading && items.length === 0) ? (<FeedSkeleton />) : (<div className="mx-auto flex w-full max-w-xl flex-col gap-4">@@ -127,12 +132,14 @@ export function WatchFeedTab(): JSX.Element {</LemonButton></div>)}+ {items.length > 0 && isWatchFeedBlock(emptyReason) && (+ <WatchFeedBlockedBanner reason={emptyReason} />+ )}{/* Three newest clips and nothing else is the answer, not a half-loaded feed, so say sorather 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 sessions. Try a longer date range to- see more.+ No sessions stood out {feedWindowPhrase(dateFrom)}. These are the newest ones.</p>)}{items.length > 0 ? (diff --git a/products/replay_vision/frontend/replay_scanners/watchFeedEmptyState.ts b/products/replay_vision/frontend/replay_scanners/watchFeedEmptyState.tsindex 88c7a47bac4c..304c9f487f6f 100644--- a/products/replay_vision/frontend/replay_scanners/watchFeedEmptyState.ts+++ b/products/replay_vision/frontend/replay_scanners/watchFeedEmptyState.ts@@ -13,6 +13,51 @@ export type WatchFeedEmptyReason =| 'filtered'| 'quiet-window'+/** The reasons no new sessions can reach the feed, whether or not it still has older ones to show. */+export type WatchFeedBlockReason = 'quota-exhausted' | 'all-disabled' | 'all-capped'++/** What blocks the feed, and where the reader lifts the block. Both the banner and the empty note use it. */+export const WATCH_FEED_BLOCKS: Record<+ WatchFeedBlockReason,+ {+ cause: string+ fix: string+ actionLabel: string+ tab: 'scanners' | 'usage'+ dataAttr: string+ bannerDataAttr: string+ }+> = {+ 'all-disabled': {+ cause: 'All scanners on this project are off.',+ fix: 'Turn one on to scan new recordings again.',+ actionLabel: 'See scanners',+ tab: 'scanners',+ dataAttr: 'vision-watch-feed-see-scanners',+ bannerDataAttr: 'vision-watch-feed-banner-see-scanners',+ },+ 'quota-exhausted': {+ cause: 'Your Replay Vision credits are used up for this period.',+ fix: 'Raise the limit to scan new recordings again.',+ actionLabel: 'See usage',+ tab: 'usage',+ dataAttr: 'vision-watch-feed-see-usage',+ bannerDataAttr: 'vision-watch-feed-banner-see-usage',+ },+ 'all-capped': {+ cause: 'Every running scanner has reached its credit limit for this period.',+ fix: "Raise a scanner's limit to scan new recordings again.",+ actionLabel: 'See usage',+ tab: 'usage',+ dataAttr: 'vision-watch-feed-see-usage',+ bannerDataAttr: 'vision-watch-feed-banner-see-usage',+ },+}++export function isWatchFeedBlock(reason: WatchFeedEmptyReason | null): reason is WatchFeedBlockReason {+ return reason !== null && reason in WATCH_FEED_BLOCKS+}+export interface WatchFeedEmptyInput {scanners: ReplayScannerApi[]/** Null when the snapshot has not answered, which reads here as "no block seen". */diff --git a/products/replay_vision/frontend/replay_scanners/watchFeedLogic.test.ts b/products/replay_vision/frontend/replay_scanners/watchFeedLogic.test.tsindex d60b2bffef04..8d818b736d23 100644--- a/products/replay_vision/frontend/replay_scanners/watchFeedLogic.test.ts+++ b/products/replay_vision/frontend/replay_scanners/watchFeedLogic.test.ts@@ -8,6 +8,8 @@ import { userLogic } from 'scenes/userLogic'import { useMocks } from '~/mocks/jest'import { initKeaTests } from '~/test/init'+import type { ReplayScannerApi } from '../generated/api.schemas'+import { visionScannersListLogic } from '../logics/visionScannersListLogic'import { watchFeedLogic } from './watchFeedLogic'jest.mock('lib/lemon-ui/LemonToast', () => ({ lemonToast: { success: jest.fn(), error: jest.fn() } }))@@ -28,10 +30,13 @@ describe('watchFeedLogic', () => {})beforeEach(() => {+ // The scope choice persists, so one test's choice must not leak into the next.+ localStorage.clear()feedSpy = jest.fn(() => [200, { results: [item('o1', 'signal_emitted'), item('o2', 'recent')] }])useMocks({get: {'/api/projects/:team/vision/scanners/watch_feed/': feedSpy,+ '/api/projects/:team/vision/scanners/': { results: [], next: null },},})initKeaTests()@@ -58,13 +63,39 @@ describe('watchFeedLogic', () => {200,{ results: [item('o1', 'jev_watchable')], ranker: 'jev', ranker_variant: 'jev' },])+ const owned = [{ id: 'scanner-a', created_by: userLogic.values.user } as unknown as ReplayScannerApi]+ const lastCreatedBy = (): string | null =>+ new URL(feedSpy.mock.calls.at(-1)[0].request.url).searchParams.get('created_by')+ // The scope tabs are hidden for a viewer with no scanners, so a stored "mine" choice must not narrow the feed.+ const requestsBefore = feedSpy.mock.calls.length+ logic.actions.setOnlyMyScanners(true)+ await expectLogic(logic).toFinishAllListeners()+ expect(feedSpy.mock.calls).toHaveLength(requestsBefore)+ // Owning a scanner applies the stored choice.+ await expectLogic(logic, () => {+ visionScannersListLogic.actions.loadScannersSuccess(owned)+ })+ .toDispatchActions(['loadFeed', 'loadFeedSuccess'])+ .toFinishAllListeners()+ expect(lastCreatedBy()).toBe(String(userLogic.values.user?.id))+ // Losing the last owned scanner drops the scope, and the narrowed feed must reload without it.+ await expectLogic(logic, () => {+ visionScannersListLogic.actions.loadScannersSuccess([])+ })+ .toDispatchActions(['loadFeed', 'loadFeedSuccess'])+ .toFinishAllListeners()+ expect(lastCreatedBy()).toBeNull()+ // A tab switch sends one request, not one per reload path.+ visionScannersListLogic.actions.loadScannersSuccess(owned)+ await expectLogic(logic).toDispatchActions(['loadFeed', 'loadFeedSuccess']).toFinishAllListeners()+ const requestsBeforeSwitch = feedSpy.mock.calls.lengthawait expectLogic(logic, () => {- logic.actions.setOnlyMyScanners(true)+ logic.actions.setOnlyMyScanners(false)}).toDispatchActions(['loadFeed', 'loadFeedSuccess']).toFinishAllListeners()- const lastUrl = new URL(feedSpy.mock.calls.at(-1)[0].request.url)- expect(lastUrl.searchParams.get('created_by')).toBe(String(userLogic.values.user?.id))+ expect(feedSpy.mock.calls).toHaveLength(requestsBeforeSwitch + 1)+ expect(lastCreatedBy()).toBeNull()// The response names the ranker that ordered the feed, and the feed-viewed event reports the// project's variant, which is the exposure the experiment counts.expect(logic.values.feedRanker).toBe('jev')diff --git a/products/replay_vision/frontend/replay_scanners/watchFeedLogic.ts b/products/replay_vision/frontend/replay_scanners/watchFeedLogic.tsindex 61b5bc1a651c..83cb121dd229 100644--- a/products/replay_vision/frontend/replay_scanners/watchFeedLogic.ts+++ b/products/replay_vision/frontend/replay_scanners/watchFeedLogic.ts@@ -1,5 +1,6 @@import { MakeLogicType, actions, afterMount, connect, kea, listeners, path, reducers, selectors } from 'kea'import { loaders } from 'kea-loaders'+import { subscriptions } from 'kea-subscriptions'import { FEATURE_FLAGS } from 'lib/constants'import posthog from 'lib/posthog-typed'@@ -46,7 +47,9 @@ export interface watchFeedLogicValues {feedRanker: WatchFeedRankerfeedRankerVariant: string | nullfeedServed: number+ hasOwnScanners: boolean | nullonlyMyScanners: boolean+ scopedToMine: boolean}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.@@ -143,12 +146,18 @@ export interface watchFeedLogicActions {// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface watchFeedLogicMeta {__keaTypeGenInternalSelectorTypes: {+ hasOwnScanners: (+ scanners: ReplayScannerApi[],+ scannersLoading: boolean,+ user: UserType | null+ ) => boolean | null+ scopedToMine: (onlyMyScanners: boolean, hasOwnScanners: boolean | null) => booleanemptyReason: (scanners: ReplayScannerApi[],scannersLoading: boolean,quota: VisionQuotaApi | null,quotaLoading: boolean,- onlyMyScanners: boolean+ scopedToMine: boolean) => WatchFeedEmptyReason | null}}@@ -161,6 +170,29 @@ export type watchFeedLogicType = MakeLogicType<>export const DEFAULT_FEED_DATE_FROM: string = '-7d'+/** The windows the feed offers, shortest first. */+export const FEED_DATE_OPTIONS: { value: string; label: string }[] = [+ { value: '-24h', label: 'Last 24 hours' },+ { value: '-7d', label: 'Last 7 days' },+ { value: '-30d', label: 'Last 30 days' },+ { value: '-90d', label: 'Last 90 days' },+]+export function feedWindowOption(dateFrom: string): { value: string; label: string } | undefined {+ return FEED_DATE_OPTIONS.find((option) => option.value === dateFrom)+}++/** The next longer window the feed offers, or undefined at the longest. */+export function longerFeedWindow(dateFrom: string): { value: string; label: string } | undefined {+ const index = FEED_DATE_OPTIONS.findIndex((option) => option.value === dateFrom)+ return index >= 0 ? FEED_DATE_OPTIONS[index + 1] : undefined+}++/** "in the last 7 days" for an offered window, for copy that names the window the reader picked. */+export function feedWindowPhrase(dateFrom: string): string {+ const option = feedWindowOption(dateFrom)+ return option ? `in the ${option.label.toLowerCase()}` : 'in this window'+}+export const FEED_PAGE_SIZE = 20/** Which ranker ordered the loaded feed. Server-decided per team (the flag evaluates against the@@ -169,7 +201,7 @@ export type WatchFeedRanker = WatchFeedResponseApi['ranker']function feedParams(values: watchFeedLogicValues): VisionScannersWatchFeedRetrieveParams {const params: VisionScannersWatchFeedRetrieveParams = { date_from: values.dateFrom, limit: FEED_PAGE_SIZE }- if (values.onlyMyScanners && values.user) {+ if (values.scopedToMine && values.user) {params.created_by = String(values.user.id)}return params@@ -178,7 +210,7 @@ function feedParams(values: watchFeedLogicValues): VisionScannersWatchFeedRetriefunction reportFiltered(values: watchFeedLogicValues): void {posthog.capture('replay_vision_watch_feed_filtered', {date_from: values.dateFrom,- only_my_scanners: values.onlyMyScanners,+ only_my_scanners: values.scopedToMine,})}@@ -391,9 +423,9 @@ export const watchFeedLogic = kea<watchFeedLogicType>([reportFiltered(values)actions.loadFeed()},+ // The `scopedToMine` subscription reloads, so a tab switch sends one request.setOnlyMyScanners: () => {reportFiltered(values)- actions.loadFeed()},loadFeedSuccess: ({ feedItems }) => {const items = feedItems ?? []@@ -422,15 +454,30 @@ export const watchFeedLogic = kea<watchFeedLogicType>([})),selectors({+ /** Null until the scanner list answers, so the scope tabs never flash in and out. */+ hasOwnScanners: [+ (s) => [s.scanners, s.scannersLoading, s.user],+ (scanners: ReplayScannerApi[], scannersLoading: boolean, user: UserType | null): boolean | null =>+ // A reload keeps the last answer, so only the first load reads as unknown.+ scannersLoading && scanners.length === 0+ ? null+ : !!user && scanners.some((scanner) => scanner.created_by?.id === user.id),+ ],+ // A choice persisted while the viewer still had scanners must not narrow a feed whose tabs are hidden.+ scopedToMine: [+ (s) => [s.onlyMyScanners, s.hasOwnScanners],+ (onlyMyScanners: boolean, hasOwnScanners: boolean | null): boolean =>+ onlyMyScanners && hasOwnScanners !== false,+ ],/** 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.onlyMyScanners],+ (s) => [s.scanners, s.scannersLoading, s.quota, s.quotaLoading, s.scopedToMine],(scanners: ReplayScannerApi[],scannersLoading: boolean,quota: VisionQuotaApi | null,quotaLoading: boolean,- onlyMyScanners: boolean+ scopedToMine: boolean): WatchFeedEmptyReason | null =>scannersLoading || quotaLoading? null@@ -439,11 +486,20 @@ export const watchFeedLogic = kea<watchFeedLogicType>([scanners,quota,sessionRecordingOptIn: null,- hasFeedFilters: onlyMyScanners,+ hasFeedFilters: scopedToMine,}),],}),+ subscriptions(({ actions }) => ({+ // Reloads on a tab switch, and when the scanner list answers after a load and the stored scope stops applying.+ scopedToMine: (scopedToMine: boolean, previous: boolean | undefined) => {+ if (previous !== undefined && scopedToMine !== previous) {+ actions.loadFeed()+ }+ },+ })),+// The tab content mounts only while the tab is active, so mount is the fetch signal.afterMount(({ actions, cache }) => {cache.impressions = new WatchFeedImpressions('feed_tab', (load, ids) =>diff --git a/products/replay_vision/frontend/replay_scanners/watchPickSummary.ts b/products/replay_vision/frontend/replay_scanners/watchPickSummary.tsindex e0ad4ff21261..3806469a78e1 100644--- a/products/replay_vision/frontend/replay_scanners/watchPickSummary.ts+++ b/products/replay_vision/frontend/replay_scanners/watchPickSummary.ts@@ -1,4 +1,5 @@import type { ReplayObservationApi } from '../generated/api.schemas'+import { scannerLabel } from '../utils/observation'import { watchCardHeadline } from './components/WatchFeedCard'import { ScannerType } from './types'@@ -10,7 +11,7 @@ export interface WatchPickSummary {}export function watchPickSummary(observation: ReplayObservationApi): WatchPickSummary {- const scannerName = (observation.scanner_snapshot?.name as string | undefined) || '(untitled scanner)'+ const scannerName = scannerLabel(observation)return {title: watchCardHeadline(observation)?.title ?? scannerName,scannerName,