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.

fix(replay-vision): stop the dock ejecting users to the vision page (#81210)

Tue Haulund02a6587506bf
diff --git a/products/replay_vision/frontend/components/ObservationCard.test.tsx b/products/replay_vision/frontend/components/ObservationCard.test.tsx
new file mode 100644
index 000000000000..3937fd96ed88
--- /dev/null
+++ b/products/replay_vision/frontend/components/ObservationCard.test.tsx
@@ -0,0 +1,52 @@
+import { render, screen, waitFor } from '@testing-library/react'
+import { router } from 'kea-router'
+
+import { useMocks } from '~/mocks/jest'
+import { initKeaTests } from '~/test/init'
+
+import type { ReplayObservationApi } from '../generated/api.schemas'
+import { ObservationDockCard } from './ObservationCard'
+
+// A summary's observation belongs to an inline scanner, which the scanner viewset excludes. Fetching
+// one 404s, and replayScannerLogic answers a load failure by replacing the route with /replay-vision,
+// so a card that loads its scanner throws the user off the recording they are watching.
+describe('ObservationDockCard', () => {
+ let scannerRetrieveCalls: number
+
+ const observation = {
+ id: 'obs-1',
+ scanner_id: 'inline-scanner-1',
+ session_id: 'sess-1',
+ status: 'succeeded',
+ scanner_snapshot: { name: '', scanner_type: 'summarizer' },
+ scanner_result: { model_output: { scanner_type: 'summarizer', title: 'Checkout', summary: 'Bought a hat.' } },
+ } as unknown as ReplayObservationApi
+
+ beforeEach(() => {
+ scannerRetrieveCalls = 0
+ useMocks({
+ get: {
+ '/api/projects/:team/vision/scanners/:id/': () => {
+ scannerRetrieveCalls += 1
+ return [404, { detail: 'Not found.' }]
+ },
+ },
+ })
+ initKeaTests()
+ router.actions.push('/replay/sess-1')
+ })
+
+ it('renders a summary without navigating away from the recording', async () => {
+ const startPath = router.values.location.pathname
+
+ render(<ObservationDockCard observation={observation} />)
+
+ // findByText rejects if the summary never renders, so this is the assertion.
+ await screen.findByText('Bought a hat.')
+
+ // The redirect is what the user sees, so assert the route rather than only the request count.
+ // Both need a flush: the fetch and the resulting replace are async.
+ await waitFor(() => expect(scannerRetrieveCalls).toBe(0))
+ expect(router.values.location.pathname).toBe(startPath)
+ })
+})
diff --git a/products/replay_vision/frontend/components/ObservationCard.tsx b/products/replay_vision/frontend/components/ObservationCard.tsx
index 667b12d93ec3..c21240df686c 100644
--- a/products/replay_vision/frontend/components/ObservationCard.tsx
+++ b/products/replay_vision/frontend/components/ObservationCard.tsx
@@ -1,5 +1,3 @@
-import { useValues } from 'kea'
-
import { IconCopy, IconRewindPlay, IconSparkles } from '@posthog/icons'
import { LemonButton, LemonTag, Link, Spinner, Tooltip } from '@posthog/lemon-ui'
@@ -8,7 +6,6 @@ import { colonDelimitedDuration } from 'lib/utils/durations'
import { urls } from 'scenes/urls'
import type { ReplayObservationApi } from '../generated/api.schemas'
-import { replayScannerLogic } from '../replay_scanners/replayScannerLogic'
import {
type ClassifierScannerConfig,
type ScorerScannerConfig,
@@ -413,7 +410,6 @@ export function ObservationDockCard({
const snapshot = observation.scanner_snapshot
const scannerType = snapshot?.scanner_type
const result = readResult(observation)
- const { scanner } = useValues(replayScannerLogic({ id: observation.scanner_id }))
return (
<div className="border rounded p-3 bg-surface-primary space-y-2">
@@ -437,7 +433,6 @@ export function ObservationDockCard({
errorReason={observation.error_reason}
onRetry={onRetry}
loading={retrying}
- userAccessLevel={scanner?.user_access_level}
dataAttr="vision-dock-retry-observation"
/>
)}
@@ -453,7 +448,6 @@ export function ObservationDockCard({
errorReason={observation.error_reason}
onRetry={onRetry}
loading={retrying}
- userAccessLevel={scanner?.user_access_level}
dataAttr="vision-dock-retry-observation"
/>
)}
diff --git a/products/replay_vision/frontend/observations/ReplayObservation.tsx b/products/replay_vision/frontend/observations/ReplayObservation.tsx
index b34491e5941e..bc527394e3db 100644
--- a/products/replay_vision/frontend/observations/ReplayObservation.tsx
+++ b/products/replay_vision/frontend/observations/ReplayObservation.tsx
@@ -49,7 +49,6 @@ import { ObservationProgressBar } from '../components/ObservationProgressBar'
import { ObservationRetryButton } from '../components/ObservationRetryButton'
import { ReplayVisionFeedbackButton } from '../components/ReplayVisionFeedbackButton'
import { ScannerTypeBadge } from '../components/ScannerTypeBadge'
-import { replayScannerLogic } from '../replay_scanners/replayScannerLogic'
import {
type ClassifierScannerConfig,
type MonitorScannerConfig,
@@ -127,10 +126,6 @@ export function ReplayObservationSceneComponent(): JSX.Element {
const { observation, observationLoading, retrying } = useValues(observationLogic)
const { retryObservation } = useActions(observationLogic)
- // Hooks can't follow the early returns below, and the scanner id isn't known until `observation`
- // loads — 'new' is the sentinel replayScannerLogic already uses to skip its fetch, so this is a
- // harmless placeholder until the real id is available and the logic remounts keyed on it.
- const { scanner } = useValues(replayScannerLogic({ id: observation?.scanner_id ?? 'new' }))
if (observationLoading && !observation) {
return (
@@ -348,7 +343,6 @@ export function ReplayObservationSceneComponent(): JSX.Element {
errorReason={observation.error_reason}
onRetry={() => retryObservation()}
loading={retrying}
- userAccessLevel={scanner?.user_access_level}
emphasis="primary"
size="small"
dataAttr="vision-observation-detail-retry"
@@ -382,7 +376,6 @@ export function ReplayObservationSceneComponent(): JSX.Element {
errorReason={observation.error_reason}
onRetry={() => retryObservation()}
loading={retrying}
- userAccessLevel={scanner?.user_access_level}
size="small"
dataAttr="vision-observation-detail-retry"
/>