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): add what to watch in replay as experiments (#113267)

Hayne Ryub761d96acd9f
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index 6162b57df68e..51b2e3161c00 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -527,6 +527,7 @@ export const FEATURE_FLAGS = {
REPLAY_RECOMMENDED_RECORDINGS_FILTER_EXPERIMENT: 'replay-recommended-recordings-filter-experiment', // owner: @arnohillen #team-replay multivariate=control,test
REPLAY_TRIGGERS_V2: 'replay-triggers-v2', // owner: #team-replay
REPLAY_UI_REDESIGN_2026: 'replay-ui-redesign-2026', // owner: #team-replay, New UI layout for replay
+ REPLAY_VISION_WATCH_IN_LIST_EXPERIMENT: 'replay-vision-watch-in-list-experiment', // owner: #team-replay multivariate=control,in-list,watch-tab,both. Compare the variant string, a truthy check turns on for control too
REVAMPED_PY_NOTEBOOKS: 'revamped-py-notebooks', // owner: #team-data-tools
REVENUE_FIELDS_IN_POWER_USERS_TABLE: 'revenue-fields-in-power-users-table', // owner: @arthurdedeus #team-customer-analytics
REVIEW_HOG: 'review-hog', // owner: #team-devex, gates the Code review menu entry, scene, and API access
diff --git a/frontend/src/scenes/session-recordings/SessionRecordings.tsx b/frontend/src/scenes/session-recordings/SessionRecordings.tsx
index b9f8b46ce0e7..92c3d97975d4 100644
--- a/frontend/src/scenes/session-recordings/SessionRecordings.tsx
+++ b/frontend/src/scenes/session-recordings/SessionRecordings.tsx
@@ -32,6 +32,7 @@ import { ProductKey } from '~/queries/schema/schema-general'
import { AccessControlLevel, AccessControlResourceType, ReplayTab, ReplayTabs } from '~/types'
import { sessionReplayEmptyState } from 'products/replay/frontend/emptyState/sessionReplayEmptyState'
+import { WatchPage } from 'products/replay_vision/frontend/replay_scanners/components/WatchPage'
import { SessionRecordingCollections } from './collections/SessionRecordingCollections'
import { SessionRecordingsPlaylistRedesign } from './playlist-redesign/SessionRecordingsPlaylistRedesign'
@@ -41,7 +42,7 @@ import {
SessionRecordingPlaylistLogicProps,
sessionRecordingsPlaylistLogic,
} from './playlist/sessionRecordingsPlaylistLogic'
-import { sessionReplaySceneLogic } from './sessionReplaySceneLogic'
+import { SCENE_PLAYLIST_LOGIC_PROPS, sessionReplaySceneLogic } from './sessionReplaySceneLogic'
function Header(): JSX.Element {
const { tab } = useValues(sessionReplaySceneLogic)
@@ -180,14 +181,9 @@ function AttachScenePlaylistLogic({
}
function MainPanel(): JSX.Element {
- const { tab } = useValues(sessionReplaySceneLogic)
+ const { tab, watchPicksVariant, showWatchTab } = useValues(sessionReplaySceneLogic)
const isRedesignEnabled = useFeatureFlag('REPLAY_UI_REDESIGN_2026', 'test')
- const playlistLogicProps: SessionRecordingPlaylistLogicProps = {
- logicKey: 'scene',
- updateSearchParams: true,
- }
-
return (
<div className={cn('flex flex-col gap-y-4', ReplayTabs.Home === tab && 'grow')}>
<ReplayVisionPromoBanner />
@@ -196,15 +192,24 @@ function MainPanel(): JSX.Element {
<Spinner />
) : tab === ReplayTabs.Home ? (
<div className="SessionRecordingPlaylistHeightWrapper grow">
- <AttachScenePlaylistLogic playlistLogicProps={playlistLogicProps} />
+ <AttachScenePlaylistLogic playlistLogicProps={SCENE_PLAYLIST_LOGIC_PROPS} />
{isRedesignEnabled ? (
- <SessionRecordingsPlaylistRedesign {...playlistLogicProps} />
+ <SessionRecordingsPlaylistRedesign {...SCENE_PLAYLIST_LOGIC_PROPS} />
) : (
- <SessionRecordingsPlaylist {...playlistLogicProps} />
+ <SessionRecordingsPlaylist
+ {...SCENE_PLAYLIST_LOGIC_PROPS}
+ watchPicksVariant={watchPicksVariant}
+ />
)}
</div>
) : tab === ReplayTabs.Playlists ? (
<SessionRecordingCollections />
+ ) : tab === ReplayTabs.WhatToWatch ? (
+ showWatchTab ? (
+ <WatchPage />
+ ) : (
+ <Spinner />
+ )
) : null}
</div>
)
@@ -226,15 +231,23 @@ const ReplayPageTabs: ReplayTab[] = [
},
]
+const WhatToWatchTab: ReplayTab = {
+ label: 'What to watch',
+ key: ReplayTabs.WhatToWatch,
+ tooltip: 'Recordings that Replay vision scanners picked out for you',
+ 'data-attr': 'session-recordings-what-to-watch-tab',
+}
+
export function SessionRecordingsPageTabs(): JSX.Element {
- const { tab } = useValues(sessionReplaySceneLogic)
+ const { tab, showWatchTab } = useValues(sessionReplaySceneLogic)
+ const tabs = showWatchTab ? [WhatToWatchTab, ...ReplayPageTabs] : ReplayPageTabs
return (
<LemonTabs
activeKey={tab}
onChange={(t) => router.actions.push(urls.replay(t as ReplayTabs))}
sceneInset
className="-mt-4"
- tabs={ReplayPageTabs.map((replayTab): LemonTab<string> => {
+ tabs={tabs.map((replayTab): LemonTab<string> => {
return {
label: replayTab.label,
key: replayTab.key,
diff --git a/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylist.tsx b/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylist.tsx
index 507165aa86d9..b8315593d20b 100644
--- a/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylist.tsx
+++ b/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylist.tsx
@@ -15,6 +15,10 @@ import { Playlist } from 'scenes/session-recordings/playlist/Playlist'
import { panelLayoutLogic } from '~/layout/panel-layout/panelLayoutLogic'
+import { WatchPicksListColumn } from 'products/replay_vision/frontend/replay_scanners/components/WatchPicksListColumn'
+import { watchPicksLogic } from 'products/replay_vision/frontend/replay_scanners/watchPicksLogic'
+import { WatchPicksVariant } from 'products/replay_vision/frontend/replay_scanners/watchPicksVariant'
+
import { RecordingsUniversalFiltersEmbed } from '../filters/RecordingsUniversalFiltersEmbed'
import { playerSettingsLogic } from '../player/playerSettingsLogic'
import { SessionRecordingPlayer } from '../player/SessionRecordingPlayer'
@@ -29,9 +33,13 @@ type SessionRecordingsPlaylistProps = SessionRecordingPlaylistLogicProps & {
description?: string
/** Replaces the shared replay troubleshooting panel when the list comes back empty. */
listEmptyState?: JSX.Element
+ watchPicksVariant?: WatchPicksVariant | null
}
-export function SessionRecordingsPlaylist({ ...props }: SessionRecordingsPlaylistProps): JSX.Element {
+export function SessionRecordingsPlaylist({
+ watchPicksVariant,
+ ...props
+}: SessionRecordingsPlaylistProps): JSX.Element {
const logicProps: SessionRecordingPlaylistLogicProps = {
...props,
autoPlay: props.autoPlay ?? true,
@@ -49,16 +57,44 @@ export function SessionRecordingsPlaylist({ ...props }: SessionRecordingsPlaylis
}
const isVerticalLayout = layoutRef.current
+ const picksInList = watchPicksVariant === 'in-list' || watchPicksVariant === 'both'
+ const layout = (
+ <div className={cn('w-full h-full flex', isVerticalLayout ? 'flex-col' : 'flex-row gap-2')}>
+ {isVerticalLayout ? (
+ <VerticalLayout {...props} picksInList={picksInList} />
+ ) : (
+ <HorizontalLayout {...props} picksInList={picksInList} />
+ )}
+ </div>
+ )
+
return (
<BindLogic logic={sessionRecordingsPlaylistLogic} props={logicProps}>
- <div className={cn('w-full h-full flex', isVerticalLayout ? 'flex-col' : 'flex-row gap-2')}>
- {isVerticalLayout ? <VerticalLayout {...props} /> : <HorizontalLayout {...props} />}
- </div>
+ {picksInList ? (
+ <BindLogic
+ logic={watchPicksLogic}
+ props={{ logicKey: logicProps.logicKey ?? 'playlist', playlistLogicProps: logicProps }}
+ >
+ {layout}
+ </BindLogic>
+ ) : (
+ layout
+ )}
</BindLogic>
)
}
-function HorizontalLayout({ ...props }: SessionRecordingsPlaylistProps): JSX.Element {
+type LayoutProps = Omit<SessionRecordingsPlaylistProps, 'watchPicksVariant'> & { picksInList: boolean }
+
+function PlaylistColumn({ picksInList, ...props }: LayoutProps): JSX.Element {
+ const { isPlaylistCollapsed } = useValues(playerSettingsLogic)
+ if (picksInList && !isPlaylistCollapsed) {
+ return <WatchPicksListColumn recordingsList={<Playlist {...props} />} />
+ }
+ return <Playlist {...props} />
+}
+
+function HorizontalLayout({ picksInList, ...props }: LayoutProps): JSX.Element {
const playlistRef = useRef<HTMLDivElement>(null)
const { isPlaylistCollapsed } = useValues(playerSettingsLogic)
@@ -93,7 +129,7 @@ function HorizontalLayout({ ...props }: SessionRecordingsPlaylistProps): JSX.Ele
}
}
>
- <Playlist {...props} />
+ <PlaylistColumn {...props} picksInList={picksInList} />
{!isPlaylistCollapsed && (
<Resizer {...resizerLogicProps} visible={false} offset="0.25rem" handleClassName="rounded my-1" />
)}
@@ -103,7 +139,7 @@ function HorizontalLayout({ ...props }: SessionRecordingsPlaylistProps): JSX.Ele
)
}
-function VerticalLayout({ ...props }: SessionRecordingsPlaylistProps): JSX.Element {
+function VerticalLayout({ picksInList, ...props }: LayoutProps): JSX.Element {
const playerRef = useRef<HTMLDivElement>(null)
const { isPlaylistCollapsed } = useValues(playerSettingsLogic)
@@ -140,7 +176,7 @@ function VerticalLayout({ ...props }: SessionRecordingsPlaylistProps): JSX.Eleme
}
/>
<div className={cn('relative flex flex-col min-h-0', isPlaylistCollapsed ? 'h-5' : 'flex-1')}>
- <Playlist {...props} />
+ <PlaylistColumn {...props} picksInList={picksInList} />
</div>
</>
)
diff --git a/frontend/src/scenes/session-recordings/sessionReplaySceneLogic.test.ts b/frontend/src/scenes/session-recordings/sessionReplaySceneLogic.test.ts
new file mode 100644
index 000000000000..2ef374373b6f
--- /dev/null
+++ b/frontend/src/scenes/session-recordings/sessionReplaySceneLogic.test.ts
@@ -0,0 +1,123 @@
+import { MOCK_DEFAULT_ORGANIZATION } from 'lib/api.mock'
+
+import { router } from 'kea-router'
+import { expectLogic } from 'kea-test-utils'
+
+import { FEATURE_FLAGS } from 'lib/constants'
+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
+
+import { initKeaTests } from '~/test/init'
+
+import { sessionRecordingsPlaylistLogic } from './playlist/sessionRecordingsPlaylistLogic'
+import { SCENE_PLAYLIST_LOGIC_PROPS, sessionReplaySceneLogic } from './sessionReplaySceneLogic'
+
+describe('sessionReplaySceneLogic', () => {
+ let logic: ReturnType<typeof sessionReplaySceneLogic.build>
+ let playlistLogic: ReturnType<typeof sessionRecordingsPlaylistLogic.build>
+
+ beforeEach(() => {
+ localStorage.clear()
+ initKeaTests(true, undefined, undefined, MOCK_DEFAULT_ORGANIZATION)
+ router.actions.push('/replay/home', { sessionRecordingId: 'session-a', t: 42 })
+ logic = sessionReplaySceneLogic()
+ logic.mount()
+ playlistLogic = sessionRecordingsPlaylistLogic(SCENE_PLAYLIST_LOGIC_PROPS)
+ playlistLogic.mount()
+ })
+
+ afterEach(() => {
+ playlistLogic.unmount()
+ logic.unmount()
+ })
+
+ describe('landing on the tab arms', () => {
+ const land = (
+ variant: string,
+ path: string,
+ params: Record<string, any> = {},
+ otherFlags: Record<string, string> = {}
+ ): void => {
+ logic.unmount()
+ featureFlagLogic.actions.setFeatureFlags([], {
+ [FEATURE_FLAGS.REPLAY_VISION_WATCH_IN_LIST_EXPERIMENT]: variant,
+ ...otherFlags,
+ })
+ router.actions.push(path, params)
+ logic = sessionReplaySceneLogic()
+ logic.mount()
+ }
+
+ it.each([
+ ['the tab arm on the bare home route', 'watch-tab', '/replay/home', {}, '/replay/what-to-watch'],
+ ['both arms on the bare home route', 'both', '/replay/home', {}, '/replay/what-to-watch'],
+ ['the in-list arm', 'in-list', '/replay/home', {}, '/replay/home'],
+ ['a deep link to a recording', 'watch-tab', '/replay/home', { sessionRecordingId: 'x' }, '/replay/home'],
+ ['a link with filters', 'watch-tab', '/replay/home', { filters: { date_from: '-30d' } }, '/replay/home'],
+ ['a saved filter link', 'watch-tab', '/replay/home', { savedFilterId: 'sf-1' }, '/replay/home'],
+ ['another tab', 'watch-tab', '/replay/playlists', {}, '/replay/playlists'],
+ ['a direct tab link on the tab arm', 'watch-tab', '/replay/what-to-watch', {}, '/replay/what-to-watch'],
+ ['a direct tab link on control', 'control', '/replay/what-to-watch', {}, '/replay/home'],
+ ['a direct tab link on the in-list arm', 'in-list', '/replay/what-to-watch', {}, '/replay/home'],
+ ])('lands %s where expected', (_, variant, path, params, expected) => {
+ land(variant, path, params)
+ expect(router.values.location.pathname).toMatch(new RegExp(`${expected}$`))
+ })
+
+ it('leaves users on the replay redesign out of the experiment', () => {
+ land('both', '/replay/home', {}, { [FEATURE_FLAGS.REPLAY_UI_REDESIGN_2026]: 'test' })
+ expect(logic.values.watchPicksVariant).toBeNull()
+ expect(router.values.location.pathname).toMatch(/\/replay\/home$/)
+ })
+
+ it('hides every arm when the organization has not approved AI data processing', () => {
+ logic.unmount()
+ playlistLogic.unmount()
+ initKeaTests(true, undefined, undefined, {
+ ...MOCK_DEFAULT_ORGANIZATION,
+ is_ai_data_processing_approved: false,
+ })
+ playlistLogic = sessionRecordingsPlaylistLogic(SCENE_PLAYLIST_LOGIC_PROPS)
+ playlistLogic.mount()
+ land('both', '/replay/home')
+ expect(logic.values.watchPicksVariant).toBeNull()
+ expect(router.values.location.pathname).toMatch(/\/replay\/home$/)
+ })
+
+ it.each([
+ ['Collections', '/replay/playlists', 'playlists'],
+ ['What to watch', '/replay/what-to-watch', 'what-to-watch'],
+ ['Recordings', '/replay/home', 'home'],
+ ])('switches to %s after landing', (_, path, tab) => {
+ land('both', '/replay/home')
+ router.actions.push(path)
+ expect(logic.values.tab).toBe(tab)
+ expect(router.values.location.pathname).toMatch(new RegExp(`${path}$`))
+ })
+
+ it('redirects once per visit, so the Recordings tab stays reachable', () => {
+ land('watch-tab', '/replay/home')
+ router.actions.push('/replay/home')
+ expect(router.values.location.pathname).toMatch(/\/replay\/home$/)
+ })
+
+ it('tells an automatic landing apart from a tab click', () => {
+ land('watch-tab', '/replay/home')
+ expect(logic.values.watchTabEntry).toBe('auto_landed')
+ router.actions.push('/replay/home')
+ router.actions.push('/replay/what-to-watch')
+ expect(logic.values.watchTabEntry).toBe('tab')
+ })
+ })
+
+ it.each([
+ ['a deep link with no pick', null, 'session-b', 42],
+ ['the same pick again', 'session-a', 'session-a', 42],
+ ['another recording after a pick', 'session-a', 'session-b', undefined],
+ ])('keeps the seek param for %s', async (_, pickSessionId, nextId, expectedT) => {
+ logic.actions.setPickSeekSessionId(pickSessionId)
+ await expectLogic(logic, () => {
+ playlistLogic.actions.setSelectedRecordingId(nextId)
+ }).toFinishAllListeners()
+ expect(router.values.searchParams.t).toBe(expectedT)
+ })
+})
diff --git a/frontend/src/scenes/session-recordings/sessionReplaySceneLogic.ts b/frontend/src/scenes/session-recordings/sessionReplaySceneLogic.ts
index 99cbdd62f326..e511e26407bf 100644
--- a/frontend/src/scenes/session-recordings/sessionReplaySceneLogic.ts
+++ b/frontend/src/scenes/session-recordings/sessionReplaySceneLogic.ts
@@ -1,15 +1,66 @@
-import { MakeLogicType, actions, kea, path, reducers, selectors } from 'kea'
+import { MakeLogicType, actions, connect, kea, listeners, path, reducers, selectors } from 'kea'
import { router, urlToAction } from 'kea-router'
+import { FEATURE_FLAGS } from 'lib/constants'
+import { FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { trackedActionToUrl } from 'lib/logic/scenes/trackedActionToUrl'
import { capitalizeFirstLetter } from 'lib/utils/strings'
+import { organizationLogic } from 'scenes/organizationLogic'
import { sceneConfigurations } from 'scenes/scenes'
import { Scene } from 'scenes/sceneTypes'
+import {
+ SessionRecordingPlaylistLogicProps,
+ sessionRecordingsPlaylistLogic,
+} from 'scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic'
+import { aiConsentLogic } from 'scenes/settings/organization/aiConsentLogic'
import { urls } from 'scenes/urls'
import { SIDE_PANEL_CONTEXT_KEY, SidePanelSceneContext } from '~/layout/navigation-3000/sidepanel/types'
import { ActivityScope, Breadcrumb, ReplayTabs } from '~/types'
+import {
+ WatchPicksVariant,
+ watchPicksVariantFromFlag,
+} from 'products/replay_vision/frontend/replay_scanners/watchPicksVariant'
+
+import type { OrganizationType } from '../../types'
+
+export const SCENE_PLAYLIST_LOGIC_PROPS: SessionRecordingPlaylistLogicProps = {
+ logicKey: 'scene',
+ updateSearchParams: true,
+}
+
+export type WatchTabEntry = 'tab' | 'auto_landed'
+
+export function replayUrlPointsSomewhere(searchParams: Record<string, any>, hashParams: Record<string, any>): boolean {
+ return Object.keys(searchParams).length > 0 || Boolean(hashParams.sessionRecordingId)
+}
+
+function landOnWhatToWatch(
+ values: Pick<
+ sessionReplaySceneLogicValues,
+ 'tab' | 'showWatchTab' | 'receivedFeatureFlags' | 'currentOrganization'
+ >,
+ cache: Record<string, any>
+): void {
+ if (!values.receivedFeatureFlags || !values.currentOrganization) {
+ return
+ }
+ const { searchParams, hashParams } = router.values
+ if (values.tab === ReplayTabs.WhatToWatch && !values.showWatchTab) {
+ router.actions.replace(urls.replay(ReplayTabs.Home), searchParams, hashParams)
+ return
+ }
+ if (cache.landed) {
+ return
+ }
+ cache.landed = true
+ if (values.tab === ReplayTabs.Home && values.showWatchTab && !replayUrlPointsSomewhere(searchParams, hashParams)) {
+ cache.autoLanding = true
+ router.actions.replace(urls.replay(ReplayTabs.WhatToWatch), searchParams, hashParams)
+ }
+}
+
export const humanFriendlyTabName = (tab: ReplayTabs): string => {
switch (tab) {
case ReplayTabs.Home:
@@ -18,6 +69,8 @@ export const humanFriendlyTabName = (tab: ReplayTabs): string => {
return 'Collections'
case ReplayTabs.Settings:
return 'Settings'
+ case ReplayTabs.WhatToWatch:
+ return 'What to watch'
default:
return capitalizeFirstLetter(tab)
}
@@ -25,21 +78,51 @@ export const humanFriendlyTabName = (tab: ReplayTabs): string => {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface sessionReplaySceneLogicValues {
+ dataProcessingAccepted: boolean // aiConsentLogic
+ featureFlags: FeatureFlagsSet // featureFlagLogic
+ receivedFeatureFlags: boolean // featureFlagLogic
+ currentOrganization: OrganizationType | null // organizationLogic
breadcrumbs: Breadcrumb[]
+ pickSeekSessionId: string | null
+ showWatchTab: boolean
sidePanelContext: SidePanelSceneContext
tab: ReplayTabs
+ watchPicksVariant: WatchPicksVariant | null
+ watchTabEntry: WatchTabEntry | null
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface sessionReplaySceneLogicActions {
+ setFeatureFlags: (
+ flags: string[],
+ variants: Record<string, boolean | string>
+ ) => {
+ flags: string[]
+ variants: Record<string, boolean | string>
+ } // featureFlagLogic
+ loadCurrentOrganizationSuccess: (
+ currentOrganization: OrganizationType | null,
+ payload?: any
+ ) => {
+ currentOrganization: OrganizationType | null
+ payload?: any
+ } // organizationLogic
+ setPickSeekSessionId: (sessionId: string | null) => {
+ sessionId: string | null
+ }
setTab: (tab?: ReplayTabs) => {
tab: ReplayTabs
}
+ setWatchTabEntry: (entry: WatchTabEntry) => {
+ entry: WatchTabEntry
+ }
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface sessionReplaySceneLogicMeta {
__keaTypeGenInternalSelectorTypes: {
+ watchPicksVariant: (featureFlags: FeatureFlagsSet, dataProcessingAccepted: boolean) => WatchPicksVariant | null
+ showWatchTab: (watchPicksVariant: WatchPicksVariant | null) => boolean
breadcrumbs: (tab: ReplayTabs) => Breadcrumb[]
sidePanelContext: (searchParams: Record<string, any>) => SidePanelSceneContext
}
@@ -54,16 +137,67 @@ export type sessionReplaySceneLogicType = MakeLogicType<
export const sessionReplaySceneLogic = kea<sessionReplaySceneLogicType>([
path(() => ['scenes', 'session-recordings', 'sessionReplaySceneLogic']),
+ connect(() => ({
+ values: [
+ featureFlagLogic,
+ ['featureFlags', 'receivedFeatureFlags'],
+ aiConsentLogic,
+ ['dataProcessingAccepted'],
+ organizationLogic,
+ ['currentOrganization'],
+ ],
+ actions: [featureFlagLogic, ['setFeatureFlags'], organizationLogic, ['loadCurrentOrganizationSuccess']],
+ })),
actions({
setTab: (tab: ReplayTabs = ReplayTabs.Home) => ({ tab }),
+ setPickSeekSessionId: (sessionId: string | null) => ({ sessionId }),
+ setWatchTabEntry: (entry: WatchTabEntry) => ({ entry }),
}),
reducers(() => ({
+ watchTabEntry: [
+ null as WatchTabEntry | null,
+ {
+ setWatchTabEntry: (_, { entry }) => entry,
+ },
+ ],
tab: [
ReplayTabs.Home as ReplayTabs,
{
setTab: (_, { tab }) => tab,
},
],
+ pickSeekSessionId: [
+ null as string | null,
+ {
+ setPickSeekSessionId: (_, { sessionId }) => sessionId,
+ },
+ ],
+ })),
+
+ listeners(({ actions, values, cache }) => ({
+ setFeatureFlags: () => {
+ landOnWhatToWatch(values, cache)
+ },
+ loadCurrentOrganizationSuccess: () => {
+ landOnWhatToWatch(values, cache)
+ },
+ [sessionRecordingsPlaylistLogic(SCENE_PLAYLIST_LOGIC_PROPS).actionTypes.setSelectedRecordingId]: ({
+ id,
+ }: {
+ id: string | null
+ }) => {
+ if (!values.pickSeekSessionId || id === values.pickSeekSessionId) {
+ return
+ }
+ actions.setPickSeekSessionId(null)
+ const { location, searchParams, hashParams } = router.values
+ if (searchParams.t === undefined) {
+ return
+ }
+ const nextParams = { ...searchParams }
+ delete nextParams.t
+ router.actions.replace(location.pathname, nextParams, hashParams)
+ },
})),
trackedActionToUrl(({ values }) => {
@@ -73,6 +207,18 @@ export const sessionReplaySceneLogic = kea<sessionReplaySceneLogicType>([
}),
selectors(() => ({
+ watchPicksVariant: [
+ (s) => [s.featureFlags, s.dataProcessingAccepted],
+ (featureFlags: FeatureFlagsSet, dataProcessingAccepted: boolean): WatchPicksVariant | null =>
+ dataProcessingAccepted && featureFlags[FEATURE_FLAGS.REPLAY_UI_REDESIGN_2026] !== 'test'
+ ? watchPicksVariantFromFlag(featureFlags[FEATURE_FLAGS.REPLAY_VISION_WATCH_IN_LIST_EXPERIMENT])
+ : null,
+ ],
+ showWatchTab: [
+ (s) => [s.watchPicksVariant],
+ (watchPicksVariant: WatchPicksVariant | null): boolean =>
+ watchPicksVariant === 'watch-tab' || watchPicksVariant === 'both',
+ ],
breadcrumbs: [
(s) => [s.tab],
(tab: ReplayTabs): Breadcrumb[] => {
@@ -109,7 +255,7 @@ export const sessionReplaySceneLogic = kea<sessionReplaySceneLogicType>([
],
})),
- urlToAction(({ actions, values }) => {
+ urlToAction(({ actions, values, cache }) => {
return {
'/replay/:tab': ({ tab }) => {
// we saw a page get stuck in a redirect loop between recent and home
@@ -117,8 +263,13 @@ export const sessionReplaySceneLogic = kea<sessionReplaySceneLogicType>([
const candidateTab = tab as ReplayTabs
const validTab = Object.values(ReplayTabs).includes(candidateTab) ? candidateTab : ReplayTabs.Home
if (validTab !== values.tab) {
+ if (validTab === ReplayTabs.WhatToWatch) {
+ actions.setWatchTabEntry(cache.autoLanding ? 'auto_landed' : 'tab')
+ }
actions.setTab(validTab)
}
+ cache.autoLanding = false
+ landOnWhatToWatch({ ...values, tab: validTab }, cache)
},
}
}),
diff --git a/frontend/src/types.ts b/frontend/src/types.ts
index cc5547038b92..c36cdf211589 100644
--- a/frontend/src/types.ts
+++ b/frontend/src/types.ts
@@ -1142,6 +1142,7 @@ export enum ReplayTabs {
Home = 'home',
Playlists = 'playlists',
Settings = 'settings',
+ WhatToWatch = 'what-to-watch',
}
export type ReplayTab = {
diff --git a/products/replay_vision/frontend/replay_scanners/components/WatchPage.tsx b/products/replay_vision/frontend/replay_scanners/components/WatchPage.tsx
new file mode 100644
index 000000000000..67074f4a9190
--- /dev/null
+++ b/products/replay_vision/frontend/replay_scanners/components/WatchPage.tsx
@@ -0,0 +1,91 @@
+import { BindLogic, useActions, useValues } from 'kea'
+
+import { LemonBanner, LemonSkeleton } from '@posthog/lemon-ui'
+
+import type { WatchFeedItemApi } from '../../generated/api.schemas'
+import { TOP_PICKS_COUNT, watchPicksLogic } from '../watchPicksLogic'
+import { WatchPickRankedCard } from './WatchPickRankedCard'
+import { WatchPicksEmptyState } from './WatchPicksEmptyState'
+
+const WATCH_PAGE_LOGIC_KEY = 'what-to-watch'
+const GRID_CLASS_NAME = 'grid grid-cols-2 gap-x-4 gap-y-6 px-2 @3xl:grid-cols-3 @5xl:grid-cols-4 @6xl:grid-cols-5'
+
+function WatchGrid({
+ title,
+ items,
+ ranked,
+ surface,
+}: {
+ title: string
+ items: WatchFeedItemApi[]
+ ranked: boolean
+ surface: 'top_10' | 'more'
+}): JSX.Element | null {
+ if (items.length === 0) {
+ return null
+ }
+ return (
+ <section className="flex flex-col gap-3">
+ <h2 className="m-0 text-base font-semibold">{title}</h2>
+ <div className={GRID_CLASS_NAME}>
+ {items.map((item, index) => (
+ <WatchPickRankedCard
+ key={item.observation.id}
+ item={item}
+ position={ranked ? index : TOP_PICKS_COUNT + index}
+ surface={surface}
+ rank={ranked ? index + 1 : undefined}
+ />
+ ))}
+ </div>
+ </section>
+ )
+}
+
+function WatchPageContent(): JSX.Element {
+ const { picks, picksLoading, picksFailed, topPicks, moreItems } = useValues(watchPicksLogic)
+ const { loadPicks } = useActions(watchPicksLogic)
+
+ let body: JSX.Element
+ if (picksLoading || (picks === null && !picksFailed)) {
+ body = (
+ <div className={GRID_CLASS_NAME} aria-busy>
+ {[0, 1, 2, 3, 4].map((i) => (
+ <LemonSkeleton key={i} className="aspect-video w-full rounded" />
+ ))}
+ </div>
+ )
+ } else if (picksFailed) {
+ body = (
+ <LemonBanner
+ type="error"
+ action={{ children: 'Try again', onClick: loadPicks, 'data-attr': 'vision-watch-page-retry' }}
+ >
+ Couldn't load what to watch.
+ </LemonBanner>
+ )
+ } else if (topPicks.length === 0) {
+ body = <WatchPicksEmptyState size="large" />
+ } else {
+ body = (
+ <>
+ <WatchGrid title="Top 10 this week" items={topPicks} ranked surface="top_10" />
+ <WatchGrid title="More to watch" items={moreItems} ranked={false} surface="more" />
+ </>
+ )
+ }
+
+ return (
+ <div className="@container flex flex-col gap-8 pb-16" data-attr="vision-watch-page">
+ {body}
+ </div>
+ )
+}
+
+export function WatchPage(): JSX.Element {
+ return (
+ <BindLogic logic={watchPicksLogic} props={{ logicKey: WATCH_PAGE_LOGIC_KEY }}>
+ <WatchPageContent />
+ </BindLogic>
+ )
+}
diff --git a/products/replay_vision/frontend/replay_scanners/components/WatchPickPreview.tsx b/products/replay_vision/frontend/replay_scanners/components/WatchPickPreview.tsx
new file mode 100644
index 000000000000..ca56a3b5d999
--- /dev/null
+++ b/products/replay_vision/frontend/replay_scanners/components/WatchPickPreview.tsx
@@ -0,0 +1,28 @@
+import { TZLabel } from 'lib/components/TZLabel'
+import { cn } from 'lib/utils/css-classes'
+
+import { ObservationThumbnail } from '../../components/ObservationThumbnail'
+import { ScannerTypeBadge } from '../../components/ScannerTypeBadge'
+import type { WatchFeedItemApi } from '../../generated/api.schemas'
+import { citedTextToPlainText } from '../../utils/citations'
+import { watchPickSummary } from '../watchPickSummary'
+import { watchReasonCopy } from './WatchFeedCard'
+
+export function WatchPickPreview({ item, className }: { item: WatchFeedItemApi; className?: string }): JSX.Element {
+ const { observation, reason } = item
+ const { title, scannerName, scannerType } = watchPickSummary(observation)
+
+ return (
+ <div className={cn('flex flex-col gap-1.5 py-1', className ?? 'w-64')}>
+ <ObservationThumbnail observation={observation} className="w-full" />
+ <span className="text-sm font-semibold leading-tight">{title}</span>
+ <span className="flex min-w-0 items-center gap-1.5 text-xs">
+ {scannerType && <ScannerTypeBadge scannerType={scannerType} size="small" />}
+ <span className="truncate">{scannerName}</span>
+ <span>·</span>
+ <TZLabel time={observation.created_at} showPopover={false} noStyles className="whitespace-nowrap" />
+ </span>
+ <span className="text-xs leading-snug">{citedTextToPlainText(watchReasonCopy(reason), undefined)}</span>
+ </div>
+ )
+}
diff --git a/products/replay_vision/frontend/replay_scanners/components/WatchPickRankBadge.tsx b/products/replay_vision/frontend/replay_scanners/components/WatchPickRankBadge.tsx
new file mode 100644
index 000000000000..bac4d7a488d7
--- /dev/null
+++ b/products/replay_vision/frontend/replay_scanners/components/WatchPickRankBadge.tsx
@@ -0,0 +1,20 @@
+import { cn } from 'lib/utils/css-classes'
+
+export function WatchPickRankBadge({
+ rank,
+ size = 'medium',
+}: {
+ rank: number
+ size?: 'small' | 'medium'
+}): JSX.Element {
+ return (
+ <span
+ className={cn(
+ 'pointer-events-none absolute left-0 top-0 z-10 rounded-br bg-warning font-bold tabular-nums text-black',
+ size === 'small' ? 'px-1 text-xxs leading-4' : 'px-2 py-0.5 text-xs'
+ )}
+ >
+ #{rank}
+ </span>
+ )
+}
diff --git a/products/replay_vision/frontend/replay_scanners/components/WatchPickRankedCard.tsx b/products/replay_vision/frontend/replay_scanners/components/WatchPickRankedCard.tsx
new file mode 100644
index 000000000000..36a3fef3954c
--- /dev/null
+++ b/products/replay_vision/frontend/replay_scanners/components/WatchPickRankedCard.tsx
@@ -0,0 +1,116 @@
+import { useActions } from 'kea'
+
+import { LemonButton, LemonTag } from '@posthog/lemon-ui'
+
+import { TZLabel } from 'lib/components/TZLabel'
+import { cn } from 'lib/utils/css-classes'
+
+import { ObservationThumbnail } from '../../components/ObservationThumbnail'
+import { scannerTypeIcon } from '../../components/ScannerTypeBadge'
+import { UnviewedObservationTag } from '../../components/UnviewedObservationTag'
+import type { WatchFeedItemApi } from '../../generated/api.schemas'
+import { citedTextToPlainText } from '../../utils/citations'
+import { SCANNER_TYPE_TAG_TYPE } from '../types'
+import { type WatchPickSurface, watchPicksLogic } from '../watchPicksLogic'
+import { watchPickSummary } from '../watchPickSummary'
+import { watchReasonCopy } from './WatchFeedCard'
+import { WatchPickPreview } from './WatchPickPreview'
+import { WatchPickRankBadge } from './WatchPickRankBadge'
+
+interface WatchPickRankedCardProps {
+ item: WatchFeedItemApi
+ position: number
+ surface: WatchPickSurface
+ rank?: number
+}
+
+const SCORE_DOTS = 5
+
+export function WatchPickRankedCard({ item, position, surface, rank }: WatchPickRankedCardProps): JSX.Element {
+ const { watchPick } = useActions(watchPicksLogic)
+ const { observation, reason } = item
+ const { title, scannerName, scannerType } = watchPickSummary(observation)
+ const signalsCount = reason.signals_count ?? 0
+ const notability = typeof reason.notability === 'number' ? reason.notability : null
+
+ return (
+ <div className="group relative" data-attr="vision-watch-ranked-card">
+ <LemonButton
+ noPadding
+ fullWidth
+ onClick={() => watchPick(item, position, surface)}
+ className="items-stretch"
+ data-attr="vision-watch-ranked-poster"
+ >
+ <span className="flex w-full flex-col gap-1.5 text-left">
+ <span className={cn('relative block overflow-hidden rounded', observation.viewed && 'opacity-60')}>
+ <ObservationThumbnail observation={observation} className="w-full rounded-none border-0">
+ <span className="sr-only">
+ {title}. {citedTextToPlainText(watchReasonCopy(reason), undefined)}
+ </span>
+ </ObservationThumbnail>
+ {rank !== undefined && <WatchPickRankBadge rank={rank} />}
+ {!observation.viewed && (
+ <UnviewedObservationTag className="pointer-events-none absolute right-2 top-2 z-10" />
+ )}
+ {signalsCount > 0 && (
+ <span className="pointer-events-none absolute bottom-2 left-2 rounded bg-black/80 px-1.5 text-xxs font-semibold text-white">
+ {signalsCount} {signalsCount === 1 ? 'signal' : 'signals'}
+ </span>
+ )}
+ </span>
+ <span className="flex gap-2">
+ {scannerType && (
+ <LemonTag
+ type={SCANNER_TYPE_TAG_TYPE[scannerType]}
+ className="h-7 w-7 shrink-0 justify-center rounded-full p-0 text-sm"
+ title={scannerName}
+ >
+ {scannerTypeIcon(scannerType)}
+ </LemonTag>
+ )}
+ <span className="flex min-w-0 flex-1 flex-col gap-0.5">
+ <span className="truncate text-sm font-semibold">{title}</span>
+ <span className="truncate text-xs font-normal text-secondary">
+ <span>{scannerName}</span>
+ <span> · </span>
+ <TZLabel
+ time={observation.created_at}
+ showPopover={false}
+ noStyles
+ className="whitespace-nowrap"
+ />
+ </span>
+ {notability !== null && (
+ <span className="flex items-center gap-1" aria-label={`Score ${notability.toFixed(2)}`}>
+ {Array.from({ length: SCORE_DOTS }, (_, dot) => (
+ <span
+ key={dot}
+ className={cn(
+ 'h-1.5 w-1.5 rounded-full',
+ dot < Math.round(notability * SCORE_DOTS) ? 'bg-accent' : 'bg-border'
+ )}
+ />
+ ))}
+ <span className="ml-1 text-xxs font-normal text-secondary">
+ {notability.toFixed(2)}
+ </span>
+ </span>
+ )}
+ </span>
+ </span>
+ </span>
+ </LemonButton>
+ <div
+ aria-hidden
+ className={cn(
+ 'pointer-events-none absolute inset-x-0 top-0 z-20 origin-top scale-95 opacity-0',
+ 'rounded border bg-bg-light p-2 shadow-lg transition motion-reduce:transition-none',
+ 'group-hover:scale-105 group-hover:opacity-100 group-focus-within:scale-105 group-focus-within:opacity-100'
+ )}
+ >
+ <WatchPickPreview item={item} className="w-full" />
+ </div>
+ </div>
+ )
+}
diff --git a/products/replay_vision/frontend/replay_scanners/components/WatchPickRow.tsx b/products/replay_vision/frontend/replay_scanners/components/WatchPickRow.tsx
new file mode 100644
index 000000000000..3bc0aa5fb8dc
--- /dev/null
+++ b/products/replay_vision/frontend/replay_scanners/components/WatchPickRow.tsx
@@ -0,0 +1,71 @@
+import { useActions } from 'kea'
+
+import { LemonButton } from '@posthog/lemon-ui'
+
+import { TZLabel } from 'lib/components/TZLabel'
+import { cn } from 'lib/utils/css-classes'
+
+import { ObservationThumbnail } from '../../components/ObservationThumbnail'
+import type { WatchFeedItemApi } from '../../generated/api.schemas'
+import { citedTextToPlainText } from '../../utils/citations'
+import { type WatchPickSurface, watchPicksLogic } from '../watchPicksLogic'
+import { watchPickSummary } from '../watchPickSummary'
+import { watchReasonCopy } from './WatchFeedCard'
+import { WatchPickPreview } from './WatchPickPreview'
+import { WatchPickRankBadge } from './WatchPickRankBadge'
+
+interface WatchPickRowProps {
+ item: WatchFeedItemApi
+ position: number
+ surface: WatchPickSurface
+ isActive: boolean
+ rank?: number
+}
+
+export function WatchPickRow({ item, position, surface, isActive, rank }: WatchPickRowProps): JSX.Element {
+ const { watchPick } = useActions(watchPicksLogic)
+ const { observation, reason } = item
+ const { title, scannerName } = watchPickSummary(observation)
+
+ return (
+ <LemonButton
+ fullWidth
+ size="small"
+ active={isActive}
+ onClick={() => watchPick(item, position, surface)}
+ tooltip={<WatchPickPreview item={item} />}
+ tooltipPlacement="right"
+ className="min-w-0"
+ data-attr="vision-watch-pick"
+ >
+ <span className={cn('flex w-full min-w-0 items-center gap-3 py-1', observation.viewed && 'opacity-60')}>
+ <span className="relative w-28 shrink-0">
+ <ObservationThumbnail observation={observation} className="w-full" />
+ {rank !== undefined && <WatchPickRankBadge rank={rank} size="small" />}
+ {!observation.viewed && (
+ <span className="absolute inset-y-0 left-0 w-1 rounded-l bg-accent" aria-hidden />
+ )}
+ </span>
+ <span className="flex min-w-0 flex-1 flex-col gap-0.5">
+ <span className="truncate text-sm font-semibold">
+ {!observation.viewed && <span className="sr-only">New: </span>}
+ {title}
+ </span>
+ <span className="truncate text-xs font-normal text-secondary">
+ <span>{scannerName}</span>
+ <span> · </span>
+ <TZLabel
+ time={observation.created_at}
+ showPopover={false}
+ noStyles
+ className="whitespace-nowrap"
+ />
+ </span>
+ <span className="truncate text-xs font-normal text-secondary">
+ {citedTextToPlainText(watchReasonCopy(reason), undefined)}
+ </span>
+ </span>
+ </span>
+ </LemonButton>
+ )
+}
diff --git a/products/replay_vision/frontend/replay_scanners/components/WatchPicksEmptyState.tsx b/products/replay_vision/frontend/replay_scanners/components/WatchPicksEmptyState.tsx
new file mode 100644
index 000000000000..6dfdd607c858
--- /dev/null
+++ b/products/replay_vision/frontend/replay_scanners/components/WatchPicksEmptyState.tsx
@@ -0,0 +1,129 @@
+import { useActions, useValues } from 'kea'
+import { router } from 'kea-router'
+
+import * as townCrierPng from '@posthog/brand/hoggies/png/town-crier'
+import { LemonButton, LemonSkeleton, Link } from '@posthog/lemon-ui'
+
+import { pngHoggie } from 'lib/brand/hoggies'
+import { cn } from 'lib/utils/css-classes'
+import { urls } from 'scenes/urls'
+
+import { visionQuotaLogic } from '../../logics/visionQuotaLogic'
+import { visionScannersListLogic } from '../../logics/visionScannersListLogic'
+import { getReplayVisionEditDisabledReason } from '../../utils/accessControl'
+import { markScannerGoalDraftIntent } from '../scannerHandoffIntent'
+import { resolveWatchFeedEmptyReason } from '../watchFeedEmptyState'
+
+const HedgehogTownCrier = pngHoggie(townCrierPng)
+const DEFAULT_GOAL =
+ 'Watch sessions and give me an overview of what people are doing in the product, so I know which sessions to look at, why, and where the interesting moment is.'
+
+export function WatchPicksEmptyState({ size }: { size: 'small' | 'large' }): JSX.Element {
+ const { scanners, scannersLoading } = useValues(visionScannersListLogic)
+ const { quota, quotaLoading } = useValues(visionQuotaLogic)
+ const { push } = useActions(router)
+ const large = size === 'large'
+
+ if (scannersLoading || quotaLoading) {
+ return <LemonSkeleton className={cn('w-full rounded', large ? 'h-64' : 'h-40')} />
+ }
+
+ const reason = resolveWatchFeedEmptyReason({ scanners, quota, hasFeedFilters: false })
+
+ let title: string
+ let body: string
+ let action: JSX.Element
+ switch (reason) {
+ case 'no-scanners':
+ title = 'Set up your first scanner'
+ body =
+ 'Tell a scanner what to look for and it watches recordings for you. Start with the default goal or write your own.'
+ action = (
+ <div className="flex flex-wrap items-center justify-center gap-2">
+ <LemonButton
+ type="primary"
+ size={large ? 'medium' : 'small'}
+ disabledReason={getReplayVisionEditDisabledReason()}
+ onClick={() => {
+ if (markScannerGoalDraftIntent(DEFAULT_GOAL)) {
+ push(urls.replayVisionTemplates())
+ } else {
+ push(urls.replayVisionTemplates(), { goal: DEFAULT_GOAL })
+ }
+ }}
+ data-attr="vision-watch-picks-draft-scanner"
+ >
+ Draft my scanner
+ </LemonButton>
+ <Link to={urls.replayVisionTemplates()} data-attr="vision-watch-picks-browse-templates">
+ Write my own goal
+ </Link>
+ </div>
+ )
+ break
+ case 'all-disabled':
+ title = 'None of your scanners are running'
+ body = 'Turn one on and its picks appear after the next matching recording.'
+ action = (
+ <LemonButton
+ type="secondary"
+ size="small"
+ onClick={() => push(urls.replayVision(), { tab: 'scanners' })}
+ data-attr="vision-watch-picks-see-scanners"
+ >
+ See scanners
+ </LemonButton>
+ )
+ break
+ case 'all-capped':
+ title = 'Every running scanner has reached its credit limit'
+ body = "They stop scanning until the period resets. Raise a scanner's limit to start it again."
+ action = (
+ <LemonButton
+ type="secondary"
+ size="small"
+ onClick={() => push(urls.replayVision(), { tab: 'usage' })}
+ data-attr="vision-watch-picks-see-usage"
+ >
+ See usage
+ </LemonButton>
+ )
+ break
+ case 'quota-exhausted':
+ title = 'Your Replay vision credits are used up for this period'
+ body = 'Scans are skipped until the period resets. Raise the limit to start them again.'
+ action = (
+ <LemonButton
+ type="secondary"
+ size="small"
+ onClick={() => push(urls.replayVision(), { tab: 'usage' })}
+ data-attr="vision-watch-picks-see-usage"
+ >
+ See usage
+ </LemonButton>
+ )
+ break
+ default:
+ title = 'Nothing to watch yet'
+ body = 'Your scanners are running. Picks appear here as they flag new recordings.'
+ action = (
+ <Link to={urls.replayVision()} data-attr="vision-watch-picks-empty-link">
+ Open Replay vision
+ </Link>
+ )
+ }
+
+ return (
+ <div
+ className={cn(
+ 'flex flex-col items-center gap-2 text-center text-secondary',
+ large ? 'rounded border bg-bg-light p-8 text-sm' : 'p-4 text-xs'
+ )}
+ >
+ <HedgehogTownCrier className={large ? 'h-48 w-48' : 'h-24 w-24'} />
+ <span className={cn('font-semibold text-default', large ? 'text-lg' : 'text-sm')}>{title}</span>
+ <span className="max-w-lg">{body}</span>
+ <div className="mt-1">{action}</div>
+ </div>
+ )
+}
diff --git a/products/replay_vision/frontend/replay_scanners/components/WatchPicksList.tsx b/products/replay_vision/frontend/replay_scanners/components/WatchPicksList.tsx
new file mode 100644
index 000000000000..8b0c63d38580
--- /dev/null
+++ b/products/replay_vision/frontend/replay_scanners/components/WatchPicksList.tsx
@@ -0,0 +1,54 @@
+import { useActions, useValues } from 'kea'
+
+import { LemonBanner, LemonSkeleton } from '@posthog/lemon-ui'
+
+import { watchPicksLogic } from '../watchPicksLogic'
+import { WatchPickRow } from './WatchPickRow'
+import { WatchPicksEmptyState } from './WatchPicksEmptyState'
+
+const LIST_TOP_COUNT = 5
+
+export function WatchPicksList(): JSX.Element {
+ const { picks, picksLoading, picksFailed, activeSessionId } = useValues(watchPicksLogic)
+ const { loadPicks } = useActions(watchPicksLogic)
+
+ return (
+ <div
+ className="flex h-full w-full min-w-60 flex-col overflow-hidden rounded border bg-bg-light contain-inline-size"
+ data-attr="vision-watch-picks-list"
+ >
+ <div className="min-h-0 flex-1 overflow-y-auto">
+ {picksLoading || (picks === null && !picksFailed) ? (
+ <div className="flex flex-col gap-2 p-2" aria-busy>
+ {[0, 1, 2, 3].map((i) => (
+ <LemonSkeleton key={i} className="h-16 rounded" />
+ ))}
+ </div>
+ ) : picksFailed ? (
+ <LemonBanner
+ type="error"
+ className="m-2"
+ action={{ children: 'Try again', onClick: loadPicks, 'data-attr': 'vision-watch-picks-retry' }}
+ >
+ Couldn't load what to watch.
+ </LemonBanner>
+ ) : !picks || picks.length === 0 ? (
+ <WatchPicksEmptyState size="small" />
+ ) : (
+ <div className="flex flex-col gap-0.5 p-1">
+ {picks.map((item, index) => (
+ <WatchPickRow
+ key={item.observation.id}
+ item={item}
+ position={index}
+ surface="list"
+ rank={index < LIST_TOP_COUNT ? index + 1 : undefined}
+ isActive={item.observation.session_id === activeSessionId}
+ />
+ ))}
+ </div>
+ )}
+ </div>
+ </div>
+ )
+}
diff --git a/products/replay_vision/frontend/replay_scanners/components/WatchPicksListColumn.tsx b/products/replay_vision/frontend/replay_scanners/components/WatchPicksListColumn.tsx
new file mode 100644
index 000000000000..980f757e5639
--- /dev/null
+++ b/products/replay_vision/frontend/replay_scanners/components/WatchPicksListColumn.tsx
@@ -0,0 +1,44 @@
+import { useActions, useValues } from 'kea'
+import { ReactNode } from 'react'
+
+import { LemonBadge, LemonSegmentedButton } from '@posthog/lemon-ui'
+
+import { watchPicksLogic } from '../watchPicksLogic'
+import { WatchPicksList } from './WatchPicksList'
+
+interface WatchPicksListColumnProps {
+ recordingsList: ReactNode
+}
+
+export function WatchPicksListColumn({ recordingsList }: WatchPicksListColumnProps): JSX.Element {
+ const { effectiveListMode, unwatchedCount } = useValues(watchPicksLogic)
+ const { setListMode } = useActions(watchPicksLogic)
+
+ return (
+ <>
+ <LemonSegmentedButton
+ size="small"
+ fullWidth
+ className="mb-2"
+ value={effectiveListMode}
+ onChange={setListMode}
+ options={[
+ {
+ value: 'picks',
+ label: (
+ <span className="flex items-center gap-1">
+ <span>What to watch</span>
+ {unwatchedCount > 0 && (
+ <LemonBadge.Number count={unwatchedCount} size="small" status="muted" />
+ )}
+ </span>
+ ),
+ 'data-attr': 'vision-watch-picks-mode-picks',
+ },
+ { value: 'recordings', label: 'All recordings', 'data-attr': 'vision-watch-picks-mode-recordings' },
+ ]}
+ />
+ {effectiveListMode === 'picks' ? <WatchPicksList /> : recordingsList}
+ </>
+ )
+}
diff --git a/products/replay_vision/frontend/replay_scanners/replayScannerLogic.test.ts b/products/replay_vision/frontend/replay_scanners/replayScannerLogic.test.ts
index 1bb9d381ae82..6777629e6f3a 100644
--- a/products/replay_vision/frontend/replay_scanners/replayScannerLogic.test.ts
+++ b/products/replay_vision/frontend/replay_scanners/replayScannerLogic.test.ts
@@ -27,7 +27,11 @@ import {
} from './replayScannerLogic'
import { readScannerDraft, writeScannerDraft } from './scannerDraft'
import { scannerEditorSceneLogic } from './scannerEditorSceneLogic'
-import { consumeScannerHandoffIntent, markScannerHandoffIntent } from './scannerHandoffIntent'
+import {
+ consumeScannerHandoffIntent,
+ markScannerGoalDraftIntent,
+ markScannerHandoffIntent,
+} from './scannerHandoffIntent'
import { observationsDrilldownSearchParams } from './scannerOverviewLogic'
import { defaultScannerTemplates, newScanner } from './scannerTemplates'
import { ClassifierScanner, ReplayScanner, ScorerScanner } from './types'
@@ -394,6 +398,34 @@ describe('replayScannerLogic', () => {
// A ?goal= link (e.g. crafted or shared) must not spend the user's AI allowance on its own;
// it only prefills the box for an explicit click.
+ it('an in-session draft intent starts the draft once, while a ?draft= link never does', async () => {
+ router.actions.push(urls.replayVisionScannerTemplate('new'), { goal: 'crafted', draft: true })
+ await expectLogic(logic, () => logic.actions.loadScanner()).toFinishAllListeners()
+ expect(draftSpy).not.toHaveBeenCalled()
+
+ markScannerGoalDraftIntent('tell me what to watch')
+ router.actions.push(urls.replayVisionScannerTemplate('new'))
+ await expectLogic(logic, () => logic.actions.loadScanner()).toFinishAllListeners()
+ expect(logic.values.goalDraftInput).toEqual('tell me what to watch')
+ expect(draftSpy).toHaveBeenCalledTimes(1)
+
+ await expectLogic(logic, () => logic.actions.loadScanner()).toFinishAllListeners()
+ expect(draftSpy).toHaveBeenCalledTimes(1)
+ })
+
+ it('a draft intent older than a minute is dropped', async () => {
+ const now = Date.now()
+ const nowSpy = jest.spyOn(Date, 'now').mockReturnValue(now)
+ markScannerGoalDraftIntent('tell me what to watch')
+ nowSpy.mockReturnValue(now + 61_000)
+ router.actions.push(urls.replayVisionScannerTemplate('new'))
+ await expectLogic(logic, () => logic.actions.loadScanner()).toFinishAllListeners()
+ nowSpy.mockRestore()
+
+ expect(logic.values.goalDraftInput).toBeFalsy()
+ expect(draftSpy).not.toHaveBeenCalled()
+ })
+
it('a bare ?goal= param prefills the input without auto-starting the draft', async () => {
router.actions.push(urls.replayVisionScannerTemplate('new'), { goal: 'find rage clicks in checkout' })
diff --git a/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts b/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts
index aed5ec48d858..584e40e99c29 100644
--- a/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts
+++ b/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts
@@ -27,6 +27,7 @@ import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { copyToClipboard } from 'lib/utils/copyToClipboard'
import { removeProjectIdIfPresent } from 'lib/utils/kea-router'
import { objectsEqual } from 'lib/utils/objects'
+import { organizationLogic } from 'scenes/organizationLogic'
import { recordingsQueryToUniversalFilters } from 'scenes/session-recordings/filters/recordingsQueryConversions'
import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
@@ -92,7 +93,7 @@ import {
scannerStepUrlWithParams,
UNVALIDATED_SCANNER_STEPS,
} from './scannerEditorSceneLogic'
-import { consumeScannerHandoffIntent } from './scannerHandoffIntent'
+import { consumeScannerGoalDraftIntent, consumeScannerHandoffIntent } from './scannerHandoffIntent'
import type { ObservationStatusStats } from './scannerStats'
import { availableTagsFromStats, daysFromDateRange, deriveObservationStatusStats } from './scannerStats'
import { findScannerTemplate, newScanner } from './scannerTemplates'
@@ -1839,6 +1840,7 @@ export const replayScannerLogic = kea<replayScannerLogicType>([
// not stay armed for the rest of the tab session and prefill a later,
// unrelated wizard visit.
const handoff = consumeScannerHandoffIntent()
+ const armedGoal = consumeScannerGoalDraftIntent()
// Prefill precedence: a cross-product hand-off (a whole scanner, armed by an
// in-tab click moments before navigation), then an experiment deep link, then
// an explicit ?filters= query (both carry fully built state), then a saved
@@ -1956,6 +1958,11 @@ export const replayScannerLogic = kea<replayScannerLogicType>([
if (goalParam && !hasFiltersPrefill) {
actions.setGoalDraftInput(goalParam)
}
+ const consented = !!organizationLogic.values.currentOrganization?.is_ai_data_processing_approved
+ if (armedGoal && !hasFiltersPrefill && consented && !values.goalDraftLoading) {
+ actions.setGoalDraftInput(armedGoal)
+ actions.draftScannerFromGoal(armedGoal, values.goalBudgetInput ?? undefined)
+ }
return
}
const teamId = teamLogic.values.currentTeamId
diff --git a/products/replay_vision/frontend/replay_scanners/scannerHandoffIntent.ts b/products/replay_vision/frontend/replay_scanners/scannerHandoffIntent.ts
index cebd20f8c17a..bb780c0f66d4 100644
--- a/products/replay_vision/frontend/replay_scanners/scannerHandoffIntent.ts
+++ b/products/replay_vision/frontend/replay_scanners/scannerHandoffIntent.ts
@@ -50,3 +50,37 @@ export function consumeScannerHandoffIntent(): ScannerHandoffIntent | null {
return null
}
}
+
+const SCANNER_GOAL_DRAFT_INTENT_KEY = 'replay-vision.scanner-goal-draft-intent'
+const SCANNER_GOAL_DRAFT_INTENT_TTL_MS = 60_000
+
+/** One-shot "draft this goal now" from an in-app click, kept out of the URL so a link cannot
+ * start a draft on its own. Returns false when storage is unavailable. */
+export function markScannerGoalDraftIntent(goal: string): boolean {
+ try {
+ sessionStorage.setItem(SCANNER_GOAL_DRAFT_INTENT_KEY, JSON.stringify({ goal, at: Date.now() }))
+ return true
+ } catch {
+ return false
+ }
+}
+
+export function consumeScannerGoalDraftIntent(): string | null {
+ try {
+ const raw = sessionStorage.getItem(SCANNER_GOAL_DRAFT_INTENT_KEY)
+ sessionStorage.removeItem(SCANNER_GOAL_DRAFT_INTENT_KEY)
+ if (!raw) {
+ return null
+ }
+ const parsed = JSON.parse(raw)
+ if (typeof parsed?.goal !== 'string' || typeof parsed.at !== 'number') {
+ return null
+ }
+ if (Date.now() - parsed.at > SCANNER_GOAL_DRAFT_INTENT_TTL_MS) {
+ return null
+ }
+ return parsed.goal.trim() || null
+ } catch {
+ return null
+ }
+}
diff --git a/products/replay_vision/frontend/replay_scanners/watchPickSummary.ts b/products/replay_vision/frontend/replay_scanners/watchPickSummary.ts
new file mode 100644
index 000000000000..e0ad4ff21261
--- /dev/null
+++ b/products/replay_vision/frontend/replay_scanners/watchPickSummary.ts
@@ -0,0 +1,20 @@
+import type { ReplayObservationApi } from '../generated/api.schemas'
+import { watchCardHeadline } from './components/WatchFeedCard'
+import { ScannerType } from './types'
+
+export interface WatchPickSummary {
+ title: string
+ scannerName: string
+ scannerType: ScannerType | undefined
+ person: string
+}
+
+export function watchPickSummary(observation: ReplayObservationApi): WatchPickSummary {
+ const scannerName = (observation.scanner_snapshot?.name as string | undefined) || '(untitled scanner)'
+ return {
+ title: watchCardHeadline(observation)?.title ?? scannerName,
+ scannerName,
+ scannerType: observation.scanner_snapshot?.scanner_type as ScannerType | undefined,
+ person: observation.recording_subject_email || observation.distinct_id || 'Anonymous',
+ }
+}
diff --git a/products/replay_vision/frontend/replay_scanners/watchPicksLogic.test.ts b/products/replay_vision/frontend/replay_scanners/watchPicksLogic.test.ts
new file mode 100644
index 000000000000..b3fc519dbece
--- /dev/null
+++ b/products/replay_vision/frontend/replay_scanners/watchPicksLogic.test.ts
@@ -0,0 +1,167 @@
+import { router } from 'kea-router'
+import { expectLogic } from 'kea-test-utils'
+import posthog from 'posthog-js'
+
+import { sessionRecordingsPlaylistLogic } from 'scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic'
+
+import { useMocks } from '~/mocks/jest'
+import { initKeaTests } from '~/test/init'
+
+import { watchPicksLogic } from './watchPicksLogic'
+import { watchPicksVariantFromFlag } from './watchPicksVariant'
+
+describe('watchPicksLogic', () => {
+ let feedSpy: jest.Mock
+ let viewedSpy: jest.Mock
+ const playlistLogicProps = { logicKey: 'test-picks' }
+
+ const item = (id: string, sessionId: string, keyMomentMs?: number): Record<string, any> => ({
+ observation: {
+ id,
+ scanner_id: 'scanner-a',
+ session_id: sessionId,
+ status: 'succeeded',
+ viewed: false,
+ scanner_result: keyMomentMs === undefined ? null : { model_output: { key_moment_ms: keyMomentMs } },
+ },
+ reason: { kind: 'signal_emitted' },
+ })
+
+ beforeEach(() => {
+ feedSpy = jest.fn(() => [
+ 200,
+ { results: [item('o1', 'session-a', 45000), item('o2', 'session-a'), item('o3', 'session-b')] },
+ ])
+ viewedSpy = jest.fn(() => [200, {}])
+ useMocks({
+ get: { '/api/projects/:team/vision/scanners/watch_feed/': feedSpy },
+ post: { '/api/projects/:team/vision/observations/:id/viewed/': viewedSpy },
+ })
+ localStorage.clear()
+ initKeaTests()
+ })
+
+ it.each([
+ ['in-list', 'in-list'],
+ ['watch-tab', 'watch-tab'],
+ ['both', 'both'],
+ ['control', null],
+ [undefined, null],
+ ])('maps flag value %p to variant %p', (flagValue, variant) => {
+ expect(watchPicksVariantFromFlag(flagValue)).toBe(variant)
+ })
+
+ describe('inside a recordings list', () => {
+ let logic: ReturnType<typeof watchPicksLogic.build>
+ let playlistLogic: ReturnType<typeof sessionRecordingsPlaylistLogic.build>
+ let captureSpy: jest.SpyInstance
+
+ const mountList = async (): Promise<void> => {
+ captureSpy = jest.spyOn(posthog, 'capture').mockImplementation()
+ captureSpy.mockClear()
+ playlistLogic = sessionRecordingsPlaylistLogic(playlistLogicProps)
+ playlistLogic.mount()
+ logic = watchPicksLogic({ logicKey: 'test-picks', playlistLogicProps })
+ logic.mount()
+ await expectLogic(logic).toDispatchActions(['loadPicks']).toFinishAllListeners()
+ }
+
+ beforeEach(async () => {
+ router.actions.push('/replay/home')
+ await mountList()
+ })
+
+ afterEach(() => {
+ logic.unmount()
+ playlistLogic.unmount()
+ })
+
+ it('loads a bounded window, keeps every moment, and does not select anything', () => {
+ const url = new URL(feedSpy.mock.calls[0][0].request.url)
+ expect(url.searchParams.get('date_from')).toBe('-7d')
+ expect(url.searchParams.get('limit')).toBe('50')
+ expect(logic.values.picks?.map((pick) => pick.observation.id)).toEqual(['o1', 'o2', 'o3'])
+ expect(playlistLogic.values.selectedRecordingId).toBeNull()
+ })
+
+ const shownEvents = (): unknown[] =>
+ captureSpy.mock.calls.filter(([name]) => name === 'replay_vision_watch_picks_shown').map((call) => call[1])
+
+ it('opens on the picks and reports the impression with its count', () => {
+ expect(logic.values.effectiveListMode).toBe('picks')
+ expect(shownEvents()).toEqual([{ view: 'list', count: 3, unwatched_count: 3 }])
+ })
+
+ it.each([
+ ['recordings', {}],
+ ['picks', { sessionRecordingId: 'session-a' }],
+ ])('remembers %s across mounts, even over a deep link', async (mode, params) => {
+ logic.actions.setListMode(mode as 'recordings' | 'picks')
+ logic.unmount()
+ playlistLogic.unmount()
+ router.actions.push('/replay/home', params)
+ await mountList()
+ expect(logic.values.effectiveListMode).toBe(mode)
+ })
+
+ it.each([
+ ['the feed is empty', () => feedSpy.mockImplementation(() => [200, { results: [] }]), {}],
+ ['the feed fails', () => feedSpy.mockImplementation(() => [500, {}]), {}],
+ ['the link carries filters', () => {}, { filters: { date_from: '-30d' } }],
+ ['the link carries a saved filter', () => {}, { savedFilterId: 'sf-1' }],
+ ])('opens on the recordings when %s', async (_, arrange, params) => {
+ logic.unmount()
+ playlistLogic.unmount()
+ arrange()
+ router.actions.push('/replay/home', params)
+ await mountList()
+ expect(logic.values.effectiveListMode).toBe('recordings')
+ expect(shownEvents()).toEqual([])
+ })
+
+ it('selects the pick, seeks ahead of its key moment, and marks it viewed for this person', async () => {
+ expect(logic.values.unwatchedCount).toBe(3)
+ await expectLogic(logic, () => {
+ logic.actions.watchPick(logic.values.picks![0], 0, 'list')
+ })
+ .toDispatchActions([playlistLogic.actionCreators.setSelectedRecordingId('session-a')])
+ .toFinishAllListeners()
+ expect(router.values.searchParams).toMatchObject({ t: 42, sidebarTab: 'observations' })
+ expect(logic.values.activeSessionId).toBe('session-a')
+ expect(logic.values.picks![0].observation.viewed).toBe(true)
+ expect(logic.values.unwatchedCount).toBe(2)
+ expect(viewedSpy).toHaveBeenCalledTimes(1)
+ expect(viewedSpy.mock.calls[0][0].request.url).toContain('/vision/observations/o1/viewed/')
+ })
+ })
+
+ describe('on the What to watch page', () => {
+ let logic: ReturnType<typeof watchPicksLogic.build>
+
+ beforeEach(async () => {
+ logic = watchPicksLogic({ logicKey: 'test-page' })
+ logic.mount()
+ await expectLogic(logic).toDispatchActions(['loadPicksSuccess']).toFinishAllListeners()
+ })
+
+ afterEach(() => {
+ logic.unmount()
+ })
+
+ it.each([
+ ['with a key moment', 0, 'session-a', 42],
+ ['without one', 2, 'session-b', undefined],
+ ])('opens the pick on the Recordings tab %s', async (_, index, sessionId, t) => {
+ await expectLogic(logic, () => {
+ logic.actions.watchPick(logic.values.picks![index], index, 'top_10')
+ }).toFinishAllListeners()
+ expect(router.values.location.pathname).toMatch(/\/replay\/home$/)
+ expect(router.values.searchParams).toMatchObject({
+ sessionRecordingId: sessionId,
+ sidebarTab: 'observations',
+ showInspector: true,
+ })
+ expect(router.values.searchParams.t).toBe(t)
+ })
+ })
+})
diff --git a/products/replay_vision/frontend/replay_scanners/watchPicksLogic.ts b/products/replay_vision/frontend/replay_scanners/watchPicksLogic.ts
new file mode 100644
index 000000000000..c4cd83bd507c
--- /dev/null
+++ b/products/replay_vision/frontend/replay_scanners/watchPicksLogic.ts
@@ -0,0 +1,315 @@
+import {
+ LogicWrapper,
+ MakeLogicType,
+ actions,
+ afterMount,
+ connect,
+ getContext,
+ kea,
+ key,
+ listeners,
+ path,
+ props,
+ reducers,
+ selectors,
+} from 'kea'
+import { loaders } from 'kea-loaders'
+import { router } from 'kea-router'
+
+import posthog from 'lib/posthog-typed'
+import {
+ SessionRecordingPlaylistLogicProps,
+ sessionRecordingsPlaylistLogic,
+} from 'scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic'
+import { replayUrlPointsSomewhere, sessionReplaySceneLogic } from 'scenes/session-recordings/sessionReplaySceneLogic'
+import { teamLogic } from 'scenes/teamLogic'
+import { urls } from 'scenes/urls'
+
+import { ReplayTabs, SessionRecordingSidebarTab } from '~/types'
+
+import { visionObservationsViewedCreate, visionScannersWatchFeedRetrieve } from '../generated/api'
+import type { WatchFeedItemApi } from '../generated/api.schemas'
+import { observationKeyMomentMs, watchStartSeconds } from './components/WatchFeedCard'
+
+export type WatchPicksListMode = 'recordings' | 'picks'
+export type WatchPickSurface = 'list' | 'top_10' | 'more'
+
+export interface WatchPicksLogicProps {
+ logicKey: string
+ playlistLogicProps?: SessionRecordingPlaylistLogicProps
+}
+
+export const TOP_PICKS_COUNT = 10
+const PICKS_LIMIT = 50
+const PICKS_DATE_FROM = '-7d'
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface watchPicksLogicValues {
+ currentTeamId: number | null // teamLogic
+ activeSessionId: string | null
+ effectiveListMode: WatchPicksListMode
+ listMode: WatchPicksListMode | null
+ moreItems: WatchFeedItemApi[]
+ openedOnDeepLink: boolean
+ picks: WatchFeedItemApi[] | null
+ picksFailed: boolean
+ picksLoading: boolean
+ topPicks: WatchFeedItemApi[]
+ unwatchedCount: number
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface watchPicksLogicActions {
+ loadPicks: () => {
+ value: true
+ }
+ loadPicksFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ loadPicksSuccess: (
+ picks: WatchFeedItemApi[],
+ payload?: {
+ value: true
+ }
+ ) => {
+ picks: WatchFeedItemApi[]
+ payload?: {
+ value: true
+ }
+ }
+ markPickViewed: (observationId: string) => {
+ observationId: string
+ }
+ setActiveSessionId: (sessionId: string | null) => {
+ sessionId: string | null
+ }
+ setListMode: (mode: WatchPicksListMode) => {
+ mode: WatchPicksListMode
+ }
+ watchPick: (
+ item: WatchFeedItemApi,
+ position: number,
+ surface: WatchPickSurface
+ ) => {
+ item: WatchFeedItemApi
+ position: number
+ surface: WatchPickSurface
+ }
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface watchPicksLogicMeta {
+ key: string
+ __keaTypeGenInternalSelectorTypes: {
+ effectiveListMode: (
+ listMode: WatchPicksListMode | null,
+ openedOnDeepLink: boolean,
+ picks: WatchFeedItemApi[] | null,
+ picksFailed: boolean
+ ) => WatchPicksListMode
+ topPicks: (picks: WatchFeedItemApi[] | null) => WatchFeedItemApi[]
+ unwatchedCount: (picks: WatchFeedItemApi[] | null) => number
+ moreItems: (picks: WatchFeedItemApi[] | null) => WatchFeedItemApi[]
+ }
+}
+
+export type watchPicksLogicType = MakeLogicType<
+ watchPicksLogicValues,
+ watchPicksLogicActions,
+ WatchPicksLogicProps,
+ watchPicksLogicMeta
+>
+
+export const watchPicksLogic: LogicWrapper<watchPicksLogicType> = kea<watchPicksLogicType>([
+ props({} as WatchPicksLogicProps),
+ key((props) => props.logicKey),
+ path((key) => ['products', 'replay_vision', 'frontend', 'replay_scanners', 'watchPicksLogic', key]),
+
+ connect(() => ({
+ values: [teamLogic, ['currentTeamId']],
+ })),
+
+ actions({
+ loadPicks: true,
+ setListMode: (mode: WatchPicksListMode) => ({ mode }),
+ watchPick: (item: WatchFeedItemApi, position: number, surface: WatchPickSurface) => ({
+ item,
+ position,
+ surface,
+ }),
+ setActiveSessionId: (sessionId: string | null) => ({ sessionId }),
+ markPickViewed: (observationId: string) => ({ observationId }),
+ }),
+
+ loaders(({ values }) => ({
+ picks: [
+ null as WatchFeedItemApi[] | null,
+ {
+ loadPicks: async (_, breakpoint) => {
+ if (!values.currentTeamId) {
+ throw new Error('No current team')
+ }
+ const response = await visionScannersWatchFeedRetrieve(String(values.currentTeamId), {
+ date_from: PICKS_DATE_FROM,
+ limit: PICKS_LIMIT,
+ })
+ breakpoint()
+ return response.results
+ },
+ },
+ ],
+ })),
+
+ reducers(({ props }) => ({
+ picks: {
+ markPickViewed: (state, { observationId }) =>
+ state?.map((pick) =>
+ pick.observation.id === observationId
+ ? { ...pick, observation: { ...pick.observation, viewed: true } }
+ : pick
+ ) ?? null,
+ },
+ listMode: [
+ null as WatchPicksListMode | null,
+ { persist: true, storageKey: 'replay-vision.watch-picks-list-mode' },
+ {
+ setListMode: (_, { mode }) => mode,
+ },
+ ],
+ openedOnDeepLink: [
+ Boolean(
+ props.playlistLogicProps &&
+ replayUrlPointsSomewhere(router.values.searchParams, router.values.hashParams)
+ ),
+ {},
+ ],
+ picksFailed: [
+ false,
+ {
+ loadPicks: () => false,
+ loadPicksFailure: () => true,
+ },
+ ],
+ activeSessionId: [
+ null as string | null,
+ {
+ setActiveSessionId: (_, { sessionId }) => sessionId,
+ },
+ ],
+ })),
+
+ selectors({
+ effectiveListMode: [
+ (s) => [s.listMode, s.openedOnDeepLink, s.picks, s.picksFailed],
+ (
+ listMode: WatchPicksListMode | null,
+ openedOnDeepLink: boolean,
+ picks: WatchFeedItemApi[] | null,
+ picksFailed: boolean
+ ): WatchPicksListMode =>
+ listMode ??
+ (openedOnDeepLink || picksFailed || (picks !== null && picks.length === 0) ? 'recordings' : 'picks'),
+ ],
+ topPicks: [
+ (s) => [s.picks],
+ (picks: WatchFeedItemApi[] | null): WatchFeedItemApi[] => (picks ?? []).slice(0, TOP_PICKS_COUNT),
+ ],
+ unwatchedCount: [
+ (s) => [s.picks],
+ (picks: WatchFeedItemApi[] | null): number =>
+ (picks ?? []).filter((pick) => !pick.observation.viewed).length,
+ ],
+ moreItems: [
+ (s) => [s.picks],
+ (picks: WatchFeedItemApi[] | null): WatchFeedItemApi[] => (picks ?? []).slice(TOP_PICKS_COUNT),
+ ],
+ }),
+
+ listeners(({ actions, props, values, cache }) => {
+ const reportPicksShown = (): void => {
+ if (!values.picks || (props.playlistLogicProps && values.effectiveListMode !== 'picks')) {
+ return
+ }
+ posthog.capture('replay_vision_watch_picks_shown', {
+ view: props.playlistLogicProps ? 'list' : 'page',
+ entry: props.playlistLogicProps
+ ? undefined
+ : sessionReplaySceneLogic.findMounted()?.values.watchTabEntry,
+ count: values.picks.length,
+ unwatched_count: values.unwatchedCount,
+ })
+ }
+ return {
+ loadPicksSuccess: () => {
+ reportPicksShown()
+ },
+ setListMode: ({ mode }) => {
+ posthog.capture('replay_vision_watch_picks_list_mode_changed', { mode })
+ if (mode === 'picks') {
+ reportPicksShown()
+ }
+ },
+ watchPick: async ({ item, position, surface }) => {
+ const { observation, reason } = item
+ const keyMomentMs = observationKeyMomentMs(observation)
+ posthog.capture('replay_vision_watch_clip_clicked', {
+ scanner_id: observation.scanner_id,
+ scanner_type: observation.scanner_snapshot?.scanner_type,
+ observation_id: observation.id,
+ position,
+ reason_kind: reason.kind,
+ has_key_moment: keyMomentMs !== null,
+ target: 'replay_page',
+ view: surface,
+ })
+ const playerParams = {
+ t: keyMomentMs === null ? undefined : watchStartSeconds(keyMomentMs),
+ sidebarTab: SessionRecordingSidebarTab.OBSERVATIONS,
+ showInspector: true,
+ }
+ const markViewed =
+ !observation.viewed && values.currentTeamId
+ ? visionObservationsViewedCreate(String(values.currentTeamId), observation.id)
+ : null
+ sessionReplaySceneLogic.findMounted()?.actions.setPickSeekSessionId(observation.session_id)
+ const { location, searchParams, hashParams } = router.values
+ if (props.playlistLogicProps) {
+ router.actions.replace(location.pathname, { ...searchParams, ...playerParams }, hashParams)
+ sessionRecordingsPlaylistLogic(props.playlistLogicProps).actions.setSelectedRecordingId(
+ observation.session_id
+ )
+ } else {
+ router.actions.push(urls.replay(ReplayTabs.Home), {
+ sessionRecordingId: observation.session_id,
+ ...playerParams,
+ })
+ }
+ if (!markViewed) {
+ return
+ }
+ const mountedIn = getContext()
+ try {
+ await markViewed
+ } catch {
+ return
+ }
+ if (getContext() === mountedIn && !cache.disposables.isDisposed) {
+ actions.markPickViewed(observation.id)
+ }
+ },
+ [props.playlistLogicProps
+ ? sessionRecordingsPlaylistLogic(props.playlistLogicProps).actionTypes.setSelectedRecordingId
+ : 'watchPicksLogic/noPlaylist']: ({ id }: { id: string | null }) => {
+ actions.setActiveSessionId(id)
+ },
+ }
+ }),
+
+ afterMount(({ actions }) => {
+ actions.loadPicks()
+ }),
+])
diff --git a/products/replay_vision/frontend/replay_scanners/watchPicksVariant.ts b/products/replay_vision/frontend/replay_scanners/watchPicksVariant.ts
new file mode 100644
index 000000000000..fcba2014167d
--- /dev/null
+++ b/products/replay_vision/frontend/replay_scanners/watchPicksVariant.ts
@@ -0,0 +1,5 @@
+export type WatchPicksVariant = 'in-list' | 'watch-tab' | 'both'
+
+export function watchPicksVariantFromFlag(value: string | boolean | undefined): WatchPicksVariant | null {
+ return value === 'in-list' || value === 'watch-tab' || value === 'both' ? value : null
+}