: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
fix(replay-vision): defer ranked card previews (#115538)
Paul D'Ambra58cf409db87e
diff --git a/products/replay_vision/frontend/replay_scanners/components/WatchPickRankedCard.test.tsx b/products/replay_vision/frontend/replay_scanners/components/WatchPickRankedCard.test.tsxnew file mode 100644index 000000000000..a13584442ae1--- /dev/null+++ b/products/replay_vision/frontend/replay_scanners/components/WatchPickRankedCard.test.tsx@@ -0,0 +1,58 @@+import { cleanup, fireEvent, render, screen } from '@testing-library/react'+import { BindLogic } from 'kea'++import { useMocks } from '~/mocks/jest'+import { initKeaTests } from '~/test/init'++import type { WatchFeedItemApi } from '../../generated/api.schemas'+import { watchPicksLogic } from '../watchPicksLogic'+import { WatchPickRankedCard } from './WatchPickRankedCard'++jest.mock('../../components/ObservationThumbnail', () => ({+ ObservationThumbnail: () => <div data-attr="thumbnail" />,+}))++jest.mock('./WatchPickPreview', () => ({+ WatchPickPreview: () => <div data-attr="preview" />,+}))++const item = {+ observation: {+ id: 'observation-1',+ created_at: '2026-10-12T12:00:00Z',+ viewed: false,+ scanner_snapshot: null,+ scanner_result: null,+ },+ reason: { kind: 'recent' },+} as WatchFeedItemApi++describe('WatchPickRankedCard', () => {+ beforeEach(() => {+ initKeaTests()+ useMocks({ get: { '/api/projects/:team/vision/scanners/watch_feed/': [200, { results: [] }] } })+ })+ afterEach(() => cleanup())++ it.each(['mouseEnter', 'focus'] as const)('mounts its preview after %s and keeps it for later use', (event) => {+ const { container } = render(+ <BindLogic logic={watchPicksLogic} props={{ logicKey: 'test' }}>+ <WatchPickRankedCard item={item} position={0} surface="top_10" />+ </BindLogic>+ )++ const card = container.querySelector('[data-attr="vision-watch-ranked-card"]')!+ expect(screen.queryByTestId('preview')).toBeNull()+ expect(screen.getAllByTestId('thumbnail')).toHaveLength(1)++ if (event === 'focus') {+ fireEvent.focus(card.querySelector('button')!)+ } else {+ fireEvent.mouseEnter(card)+ }++ expect(screen.getByTestId('preview')).toBeTruthy()+ fireEvent.mouseLeave(card)+ expect(screen.getByTestId('preview')).toBeTruthy()+ })+})diff --git a/products/replay_vision/frontend/replay_scanners/components/WatchPickRankedCard.tsx b/products/replay_vision/frontend/replay_scanners/components/WatchPickRankedCard.tsxindex 8d99bd756c9f..b66dd8602780 100644--- a/products/replay_vision/frontend/replay_scanners/components/WatchPickRankedCard.tsx+++ b/products/replay_vision/frontend/replay_scanners/components/WatchPickRankedCard.tsx@@ -1,4 +1,5 @@import { useActions } from 'kea'+import { useState } from 'react'import { LemonButton, LemonTag } from '@posthog/lemon-ui'@@ -27,6 +28,7 @@ interface WatchPickRankedCardProps {const SCORE_DOTS = 5export function WatchPickRankedCard({ item, position, surface, rank }: WatchPickRankedCardProps): JSX.Element {+ const [hasOpenedPreview, setHasOpenedPreview] = useState(false)const { watchPick } = useActions(watchPicksLogic)const { observation, reason } = itemconst { title, scannerName, scannerType } = watchPickSummary(observation)@@ -34,7 +36,12 @@ export function WatchPickRankedCard({ item, position, surface, rank }: WatchPickconst notability = typeof reason.notability === 'number' ? reason.notability : nullreturn (- <div className="group relative" data-attr="vision-watch-ranked-card">+ <div+ className="group relative"+ data-attr="vision-watch-ranked-card"+ onMouseEnter={() => setHasOpenedPreview(true)}+ onFocusCapture={() => setHasOpenedPreview(true)}+ ><LemonButtonnoPaddingfullWidth@@ -109,7 +116,7 @@ export function WatchPickRankedCard({ item, position, surface, rank }: WatchPick'group-hover:scale-105 group-hover:opacity-100 group-focus-within:scale-105 group-focus-within:opacity-100')}>- <WatchPickPreview item={item} className="w-full" />+ {hasOpenedPreview && <WatchPickPreview item={item} className="w-full" />}</div></div>)