: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): speed up the observation page (#99719)
Hayne Ryu5e1f4f96f3fb
diff --git a/products/replay_vision/backend/scanner_access.py b/products/replay_vision/backend/scanner_access.pyindex 0e382386da2d..b2bbf40dbf39 100644--- a/products/replay_vision/backend/scanner_access.py+++ b/products/replay_vision/backend/scanner_access.py@@ -80,18 +80,12 @@ def accessible_observations(experiment targeting (every observation predating this feature) is unrestricted here and stayssubject to the scanner and session-recording gates the caller already passed.- One experiment query for the whole page, not one per row.+ The accessible set comes from the team's experiments, which are few and indexed. The snapshot+ path has no index, so reading the ids off the observations instead scans the whole scanner or team."""- snapshot_experiment_ids = {- eid- for eid in observations.values_list(- "scanner_snapshot__experiment_targeting__experiment_id", flat=True- ).distinct()- if eid is not None- }- accessible = _accessible_experiment_ids(access, team_id, snapshot_experiment_ids)- if accessible == snapshot_experiment_ids:- return observations+ accessible = set(+ access.filter_queryset_by_access_level(Experiment.objects.filter(team_id=team_id)).values_list("id", flat=True)+ )# Keep rows whose snapshot names no experiment (untargeted, unrestricted) OR an accessible one.# Phrased positively rather than `.exclude(path__in=inaccessible)`: on a nullable JSON path, exclude# negates to `NOT (path IN (...))`, which is NULL — and therefore false — for untargeted rows, so itdiff --git a/products/replay_vision/backend/tests/test_access_control.py b/products/replay_vision/backend/tests/test_access_control.pyindex 37edf9f2293c..5715be5b2252 100644--- a/products/replay_vision/backend/tests/test_access_control.py+++ b/products/replay_vision/backend/tests/test_access_control.py@@ -427,3 +427,33 @@ class TestReplayScannerAccessControl(_AccessControlTestCase):self.assertTrue(observation_reads, "expected the dock read to query the observation table")for sql in observation_reads:self.assertIn("session_id", sql, sql)++ def test_detail_read_never_scans_the_observation_table(self) -> None:+ # The snapshot path has no index, so any observation read not bound to the row or to a keyset+ # scans the team's whole observation history.+ self._set_resource_default("replay_scanner", "editor")+ self._set_resource_default("session_recording", "editor")+ scanner = self._create_scanner(name="detail")+ observation = ReplayObservation.objects.create(+ scanner=scanner, session_id="sess-1", scanner_snapshot=snapshot_for(scanner)+ )+ ReplayObservation.objects.create(scanner=scanner, session_id="sess-2", scanner_snapshot=snapshot_for(scanner))+ urls = {+ "flat": f"/api/environments/{self.team.id}/vision/observations/{observation.id}/",+ "nested": f"{self.observations_url(str(scanner.id))}{observation.id}/",+ }++ self.client.force_login(self.other_user)+ for label, url in urls.items():+ with self.subTest(label):+ self.client.get(url) # warm request-scoped caches so the capture is the read itself.+ with CaptureQueriesContext(connection) as queries:+ self.assertEqual(self.client.get(url).status_code, 200)++ observation_reads = [+ q["sql"] for q in queries.captured_queries if 'FROM "replay_vision_replayobservation"' in q["sql"]+ ]+ self.assertTrue(observation_reads, "expected the detail read to query the observation table")+ for sql in observation_reads:+ self.assertNotIn("SELECT DISTINCT", sql, sql)+ self.assertTrue(observation.id.hex in sql or sql.endswith("LIMIT 1"), sql)diff --git a/products/replay_vision/frontend/observations/ReplayObservation.tsx b/products/replay_vision/frontend/observations/ReplayObservation.tsxindex 9f3deda679be..e58a285f6b6b 100644--- a/products/replay_vision/frontend/observations/ReplayObservation.tsx+++ b/products/replay_vision/frontend/observations/ReplayObservation.tsx@@ -196,7 +196,8 @@ export function ReplayObservationSceneComponent(): JSX.Element {const observationLogic = replayObservationLogic({ id: observationId })useAttachedLogic(observationLogic, replayObservationSceneLogic)- const { observation, observationLoading, retrying } = useValues(observationLogic)+ const { observation, observationLoading, retrying, previousObservationId, nextObservationId, neighborsPending } =+ useValues(observationLogic)const { retryObservation } = useActions(observationLogic)if (observationLoading && !observation) {@@ -297,13 +298,10 @@ export function ReplayObservationSceneComponent(): JSX.Element {icon={<IconArrowLeft />}type="secondary"size="small"- to={- observation.previous_observation_id- ? observationUrl(observation.previous_observation_id)- : undefined- }+ loading={neighborsPending}+ to={previousObservationId ? observationUrl(previousObservationId) : undefined}disabledReason={- observation.previous_observation_id+ previousObservationId || neighborsPending? undefined: neighborsFiltered? 'No previous observation matching your filters'@@ -322,13 +320,10 @@ export function ReplayObservationSceneComponent(): JSX.Element {sideIcon={<IconArrowRight />}type="secondary"size="small"- to={- observation.next_observation_id- ? observationUrl(observation.next_observation_id)- : undefined- }+ loading={neighborsPending}+ to={nextObservationId ? observationUrl(nextObservationId) : undefined}disabledReason={- observation.next_observation_id+ nextObservationId || neighborsPending? undefined: neighborsFiltered? 'No next observation matching your filters'diff --git a/products/replay_vision/frontend/observations/replayObservationLogic.test.ts b/products/replay_vision/frontend/observations/replayObservationLogic.test.tsindex 97980ebf8ef4..4f8be011e21f 100644--- a/products/replay_vision/frontend/observations/replayObservationLogic.test.ts+++ b/products/replay_vision/frontend/observations/replayObservationLogic.test.ts@@ -2,15 +2,25 @@ import { waitFor } from '@testing-library/react'import { router } from 'kea-router'import { expectLogic } from 'kea-test-utils'+import { lemonToast } from 'lib/lemon-ui/LemonToast'+import { useMocks } from '~/mocks/jest'import { initKeaTests } from '~/test/init'-import { replayObservationLogic } from './replayObservationLogic'+import type { ReplayObservationApi, VisionObservationsRetrieveParams } from '../generated/api.schemas'+import { neighborsFromPage, replayObservationLogic } from './replayObservationLogic'+import { type ObservationsPage, lastObservationsPage } from './replayObservationSceneLogic'import { replayObservationSceneLogic } from './replayObservationSceneLogic'+jest.mock('lib/lemon-ui/LemonToast', () => ({+ lemonToast: { success: jest.fn(), info: jest.fn(), warning: jest.fn(), error: jest.fn() },+}))+describe('replayObservationLogic', () => {let retrySpy: jest.Mocklet viewedSpy: jest.Mock+ let retrieveUrls: string[]+ let retrieveStatus: numberlet scannerOrigin: 'configured' | 'inline'let observationStatus: 'failed' | 'running'let sceneLogic: ReturnType<typeof replayObservationSceneLogic.build>@@ -20,33 +30,42 @@ describe('replayObservationLogic', () => {observationStatus = 'failed'retrySpy = jest.fn(() => [202, { workflow_id: 'wf-retry' }])viewedSpy = jest.fn(() => [204])+ retrieveUrls = []+ retrieveStatus = 200+ lastObservationsPage.current = null+ jest.clearAllMocks()useMocks({get: {- '/api/projects/:team/vision/observations/:id/': () => [- 200,- {- id: 'obs-1',- scanner_id: 'scanner-9',- scanner_origin: scannerOrigin,- session_id: 'sess-1',- status: observationStatus,- error_reason: 'internal_error:boom',- scanner_snapshot: {- // An inline scanner carries no name.- name: scannerOrigin === 'configured' ? 'My scanner' : '',- scanner_type: 'monitor',- scanner_version: 1,- model: 'm',- provider: 'p',- emits_signals: false,- scanner_config: { prompt: 'q' },+ '/api/projects/:team/vision/observations/:id/': ({ request }) => {+ retrieveUrls.push(request.url)+ return [+ retrieveStatus,+ {+ id: 'obs-1',+ scanner_id: 'scanner-9',+ scanner_origin: scannerOrigin,+ session_id: 'sess-1',+ status: observationStatus,+ error_reason: 'internal_error:boom',+ scanner_snapshot: {+ // An inline scanner carries no name.+ name: scannerOrigin === 'configured' ? 'My scanner' : '',+ scanner_type: 'monitor',+ scanner_version: 1,+ model: 'm',+ provider: 'p',+ emits_signals: false,+ scanner_config: { prompt: 'q' },+ },+ scanner_result: null,+ triggered_by: 'schedule',+ viewed: false,+ previous_observation_id: 'prev-from-retrieve',+ next_observation_id: 'next-from-retrieve',+ created_at: '2026-07-01T00:00:00Z',},- scanner_result: null,- triggered_by: 'schedule',- viewed: false,- created_at: '2026-07-01T00:00:00Z',- },- ],+ ]+ },},post: {'/api/projects/:team/vision/observations/:id/retry/': retrySpy,@@ -170,4 +189,120 @@ describe('replayObservationLogic', () => {logic.unmount()}})++ const row = (id: string): ReplayObservationApi =>+ ({+ id,+ scanner_id: 'scanner-9',+ scanner_origin: 'configured',+ session_id: `sess-${id}`,+ }) as ReplayObservationApi+ const page = (ids: string[], overrides: Partial<ObservationsPage> = {}): ObservationsPage => ({+ rows: ids.map(row),+ number: 1,+ pageSize: 3,+ total: ids.length,+ filterParams: {},+ ...overrides,+ })++ it.each([+ ['a row with both neighbors on the page', page(['a', 'b', 'c']), 1, {}, { previous: 'a', next: 'c' }],+ ['the first row of the first page', page(['a', 'b', 'c']), 0, {}, { previous: null, next: 'b' }],+ [+ 'the last row of the last page',+ page(['a', 'b', 'c'], { number: 2, total: 6 }),+ 2,+ {},+ { previous: 'b', next: null },+ ],+ ['the first row of a later page', page(['a', 'b', 'c'], { number: 2, total: 6 }), 0, {}, null],+ ['the last row of an earlier page', page(['a', 'b', 'c'], { total: 6 }), 2, {}, null],+ ['a page loaded under other filters', page(['a', 'b', 'c']), 1, { verdict: 'yes' }, null],+ ])('resolves prev/next for %s', (_case, handoff, index, params, expected) => {+ expect(neighborsFromPage(handoff, index, params as VisionObservationsRetrieveParams)).toEqual(expected)+ })++ it('paints the row from the table page and skips the filtered read when the page answers prev/next', async () => {+ lastObservationsPage.current = page(['a', 'obs-1', 'c'], {+ filterParams: { verdict: 'yes' } as VisionObservationsRetrieveParams,+ })+ router.actions.push('/replay-vision/observation/obs-1', { verdict: 'yes' })+ const logic = replayObservationLogic({ id: 'obs-1' })+ logic.mount()+ try {+ expect(logic.values.observation?.session_id).toBe('sess-obs-1')+ expect(logic.values.previousObservationId).toBe('a')+ expect(logic.values.nextObservationId).toBe('c')+ await expectLogic(logic).toDispatchActions(['loadObservationSuccess'])+ expect(logic.values.observation?.session_id).toBe('sess-1')+ expect(logic.values.nextObservationId).toBe('c')+ expect(retrieveUrls).toEqual([expect.not.stringContaining('?')])+ } finally {+ logic.unmount()+ }+ })++ it('falls back to the filtered read when the page cannot answer prev/next', async () => {+ router.actions.push('/replay-vision/observation/obs-1', { verdict: 'yes' })+ const logic = replayObservationLogic({ id: 'obs-1' })+ logic.mount()+ try {+ await expectLogic(logic).toDispatchActions(['loadObservationSuccess'])+ expect(logic.values.nextObservationId).toBe('next-from-retrieve')+ expect(retrieveUrls).toEqual([expect.stringContaining('verdict=yes')])+ } finally {+ logic.unmount()+ }+ })++ // A pending or running observation reloads every few seconds. The reload re-enters the loading+ // state, so prev/next must not fall back to a spinner that rejects clicks on every tick.+ it('keeps prev/next clickable while a background reload runs', async () => {+ router.actions.push('/replay-vision/observation/obs-1', { verdict: 'yes' })+ const logic = replayObservationLogic({ id: 'obs-1' })+ logic.mount()+ try {+ await expectLogic(logic).toDispatchActions(['loadObservationSuccess'])+ logic.actions.loadObservation()+ expect(logic.values.observationLoading).toBe(true)+ expect(logic.values.neighborsPending).toBe(false)+ expect(logic.values.previousObservationId).toBe('prev-from-retrieve')+ expect(logic.values.nextObservationId).toBe('next-from-retrieve')+ await waitFor(() => expect(logic.values.observationLoading).toBe(false))+ } finally {+ logic.unmount()+ }+ })++ it('drops the row from the table page and reports the error when its first read fails', async () => {+ retrieveStatus = 500+ lastObservationsPage.current = page(['a', 'obs-1', 'c'])+ router.actions.push('/replay-vision/observation/obs-1')+ const logic = replayObservationLogic({ id: 'obs-1' })+ logic.mount()+ try {+ expect(logic.values.observation?.session_id).toBe('sess-obs-1')+ await expectLogic(logic).toDispatchActions(['loadObservationFailure'])+ expect(logic.values.observation).toBeNull()+ expect(lemonToast.error).toHaveBeenCalledTimes(1)+ } finally {+ logic.unmount()+ }+ })++ it('does not seed from a page once the scene has been left', async () => {+ lastObservationsPage.current = page(['a', 'obs-1', 'c'])+ sceneLogic.unmount()+ sceneLogic.mount()+ router.actions.push('/replay-vision/observation/obs-1')+ const logic = replayObservationLogic({ id: 'obs-1' })+ logic.mount()+ try {+ expect(logic.values.observation).toBeNull()+ await expectLogic(logic).toDispatchActions(['loadObservationSuccess'])+ } finally {+ logic.unmount()+ }+ })})diff --git a/products/replay_vision/frontend/observations/replayObservationLogic.ts b/products/replay_vision/frontend/observations/replayObservationLogic.tsindex a3c187eb997c..7d6d35e8be41 100644--- a/products/replay_vision/frontend/observations/replayObservationLogic.ts+++ b/products/replay_vision/frontend/observations/replayObservationLogic.ts@@ -1,4 +1,4 @@-import { MakeLogicType, actions, afterMount, connect, kea, key, listeners, path, props, reducers } from 'kea'+import { MakeLogicType, actions, afterMount, connect, kea, key, listeners, path, props, reducers, selectors } from 'kea'import { combineUrl, router } from 'kea-router'import { lemonToast } from 'lib/lemon-ui/LemonToast'@@ -16,7 +16,7 @@ import { scannerBreadcrumb } from '../utils/breadcrumbs'import { hasScannerPage, scannerLabel } from '../utils/observation'import { parseNumericParam } from '../utils/urlParams'import { observationProgressLogic } from './observationProgressLogic'-import { replayObservationSceneLogic } from './replayObservationSceneLogic'+import { type ObservationsPage, lastObservationsPage, replayObservationSceneLogic } from './replayObservationSceneLogic'export interface ReplayObservationLogicProps {id: string@@ -98,11 +98,38 @@ export function observationDetailUrl(id: string, filterParams: Record<string, streturn combineUrl(urls.replayVisionObservation(id), filterParams).url}+export interface ObservationNeighbors {+ previous: string | null+ next: string | null+}++/** Null when a neighbor lies outside the page, or the page was loaded under other filters. */+export function neighborsFromPage(+ page: ObservationsPage,+ index: number,+ neighborParams: VisionObservationsRetrieveParams+): ObservationNeighbors | null {+ if (JSON.stringify(page.filterParams) !== JSON.stringify(neighborParams)) {+ return null+ }+ const offset = (page.number - 1) * page.pageSize + index+ const previous = index > 0 ? page.rows[index - 1].id : offset === 0 ? null : undefined+ const next = index < page.rows.length - 1 ? page.rows[index + 1].id : offset === page.total - 1 ? null : undefined+ return previous === undefined || next === undefined ? null : { previous, next }+}+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface replayObservationLogicValues {+ loadedObservation: ReplayObservationApi | null+ neighborParams: VisionObservationsRetrieveParams+ neighborsPending: boolean+ nextObservationId: string | nullobservation: ReplayObservationApi | nullobservationLoading: boolean+ pageNeighbors: ObservationNeighbors | null+ previousObservationId: string | nullretrying: boolean+ seededObservation: ReplayObservationApi | null}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.@@ -131,11 +158,38 @@ export interface replayObservationLogicActions {retryObservationSuccess: () => {value: true}+ seedObservation: (+ observation: ReplayObservationApi,+ neighbors: ObservationNeighbors | null+ ) => {+ neighbors: ObservationNeighbors | null+ observation: ReplayObservationApi+ }}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface replayObservationLogicMeta {key: string+ __keaTypeGenInternalSelectorTypes: {+ neighborParams: (searchParams: Record<string, any>) => VisionObservationsRetrieveParams+ observation: (+ loadedObservation: ReplayObservationApi | null,+ seededObservation: ReplayObservationApi | null+ ) => ReplayObservationApi | null+ neighborsPending: (+ pageNeighbors: ObservationNeighbors | null,+ loadedObservation: ReplayObservationApi | null,+ observationLoading: boolean+ ) => boolean+ previousObservationId: (+ pageNeighbors: ObservationNeighbors | null,+ observation: ReplayObservationApi | null+ ) => string | null+ nextObservationId: (+ pageNeighbors: ObservationNeighbors | null,+ observation: ReplayObservationApi | null+ ) => string | null+ }}export type replayObservationLogicType = MakeLogicType<@@ -159,6 +213,10 @@ export const replayObservationLogic = kea<replayObservationLogicType>([loadObservation: true,loadObservationSuccess: (observation: ReplayObservationApi) => ({ observation }),loadObservationFailure: true,+ seedObservation: (observation: ReplayObservationApi, neighbors: ObservationNeighbors | null) => ({+ observation,+ neighbors,+ }),markViewed: true,retryObservation: true,retryObservationSuccess: true,@@ -166,12 +224,27 @@ export const replayObservationLogic = kea<replayObservationLogicType>([}),reducers({- observation: [+ // Two rows, not one: a failed read clears the seed but must keep a row the server already sent.+ seededObservation: [+ null as ReplayObservationApi | null,+ {+ seedObservation: (_, { observation }) => observation,+ loadObservationSuccess: () => null,+ loadObservationFailure: () => null,+ },+ ],+ loadedObservation: [null as ReplayObservationApi | null,{loadObservationSuccess: (_, { observation }) => observation,},],+ pageNeighbors: [+ null as ObservationNeighbors | null,+ {+ seedObservation: (_, { neighbors }) => neighbors,+ },+ ],observationLoading: [true,{@@ -190,12 +263,50 @@ export const replayObservationLogic = kea<replayObservationLogicType>([],}),+ selectors({+ neighborParams: [+ () => [router.selectors.searchParams],+ (searchParams: Record<string, any>): VisionObservationsRetrieveParams => neighborFilterParams(searchParams),+ ],+ observation: [+ (s) => [s.loadedObservation, s.seededObservation],+ (+ loadedObservation: ReplayObservationApi | null,+ seededObservation: ReplayObservationApi | null+ ): ReplayObservationApi | null => loadedObservation ?? seededObservation,+ ],+ neighborsPending: [+ (s) => [s.pageNeighbors, s.loadedObservation, s.observationLoading],+ (+ pageNeighbors: ObservationNeighbors | null,+ loadedObservation: ReplayObservationApi | null,+ observationLoading: boolean+ ): boolean => !pageNeighbors && !loadedObservation && observationLoading,+ ],+ previousObservationId: [+ (s) => [s.pageNeighbors, s.observation],+ (pageNeighbors: ObservationNeighbors | null, observation: ReplayObservationApi | null): string | null =>+ pageNeighbors ? pageNeighbors.previous : (observation?.previous_observation_id ?? null),+ ],+ nextObservationId: [+ (s) => [s.pageNeighbors, s.observation],+ (pageNeighbors: ObservationNeighbors | null, observation: ReplayObservationApi | null): string | null =>+ pageNeighbors ? pageNeighbors.next : (observation?.next_observation_id ?? null),+ ],+ }),+listeners(({ actions, props, values, cache }) => {// Poll while in flight as the SSE fallback, on failure too; reducers run first, so `observation` is current.const reschedulePoll = (): void => {const inFlight = values.observation?.status === 'pending' || values.observation?.status === 'running'scheduleObservationPoll(cache.disposables, inFlight, actions.loadObservation)}+ // Point the breadcrumb at whatever owns this observation, so "back" returns there instead of the vision home.+ const setParentBreadcrumb = (observation: ReplayObservationApi): void => {+ replayObservationSceneLogic().actions.setParentBreadcrumb(+ observationParentBreadcrumb(observation, scannerReturnParams(router.values.searchParams))+ )+ }return {loadObservation: async () => {const teamId = teamLogic.values.currentTeamId@@ -204,20 +315,17 @@ export const replayObservationLogic = kea<replayObservationLogicType>([return}try {+ // Filters only scope the server-side prev/next, which the page may already answer.const response = await visionObservationsRetrieve(String(teamId),props.id,- neighborFilterParams(router.values.searchParams)+ values.pageNeighbors ? undefined : values.neighborParams)actions.loadObservationSuccess(response)- // Point the breadcrumb at whatever owns this observation, so "back" returns there- // instead of the vision home.- replayObservationSceneLogic().actions.setParentBreadcrumb(- observationParentBreadcrumb(response, scannerReturnParams(router.values.searchParams))- )+ setParentBreadcrumb(response)} catch (error: any) {// Only toast the initial load — background poll retries would otherwise spam one toast per tick.- if (!values.observation) {+ if (!values.loadedObservation) {lemonToast.error(`Failed to load observation${error.detail ? `: ${error.detail}` : ''}`)}actions.loadObservationFailure()@@ -233,6 +341,8 @@ export const replayObservationLogic = kea<replayObservationLogicType>([},loadObservationFailure: reschedulePoll,+ seedObservation: ({ observation }) => setParentBreadcrumb(observation),+markViewed: async () => {const teamId = teamLogic.values.currentTeamIdif (!teamId) {@@ -275,7 +385,12 @@ export const replayObservationLogic = kea<replayObservationLogicType>([}}),- afterMount(({ actions }) => {+ afterMount(({ actions, props, values }) => {+ const page = lastObservationsPage.current+ const index = page ? page.rows.findIndex((row) => row.id === props.id) : -1+ if (page && index !== -1) {+ actions.seedObservation(page.rows[index], neighborsFromPage(page, index, values.neighborParams))+ }actions.loadObservation()}),])diff --git a/products/replay_vision/frontend/observations/replayObservationSceneLogic.ts b/products/replay_vision/frontend/observations/replayObservationSceneLogic.tsindex ee4ea99ddebe..9d516dda0706 100644--- a/products/replay_vision/frontend/observations/replayObservationSceneLogic.ts+++ b/products/replay_vision/frontend/observations/replayObservationSceneLogic.ts@@ -1,12 +1,24 @@-import { MakeLogicType, actions, kea, path, reducers, selectors } from 'kea'+import { MakeLogicType, actions, beforeUnmount, kea, path, reducers, selectors } from 'kea'import { urlToAction } from 'kea-router'import { urls } from 'scenes/urls'import { Breadcrumb } from '~/types'+import type { ReplayObservationApi, VisionObservationsRetrieveParams } from '../generated/api.schemas'import { VISION_ROOT_BREADCRUMB } from '../utils/breadcrumbs'+export interface ObservationsPage {+ rows: ReplayObservationApi[]+ number: number+ pageSize: number+ total: number+ filterParams: VisionObservationsRetrieveParams+}++/** The page the scanner table last loaded, so a row opened from it paints before its own read lands. */+export const lastObservationsPage: { current: ObservationsPage | null } = { current: null }+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface replayObservationSceneLogicValues {breadcrumbs: Breadcrumb[]@@ -88,4 +100,9 @@ export const replayObservationSceneLogic = kea<replayObservationSceneLogicType>(}},})),++ // Siblings opened within the scene still read the page; a later deep link must not seed a stale row.+ beforeUnmount(() => {+ lastObservationsPage.current = null+ }),])diff --git a/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts b/products/replay_vision/frontend/replay_scanners/replayScannerLogic.tsindex 89c390b29408..c12b3ebeac38 100644--- a/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts+++ b/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts@@ -56,6 +56,8 @@ import type { ScannerCreationMethodEnumApi, ScannerTypeEnumApi } from '../generaimport { OBSERVE_POLL_GRACE_MS, scheduleObservationPoll, shouldPollObservations } from '../logics/observationPolling'import { requestObservationRetry } from '../logics/observationRetry'import { refreshVisionQuota } from '../logics/visionQuotaLogic'+import { neighborFilterParams } from '../observations/replayObservationLogic'+import { lastObservationsPage } from '../observations/replayObservationSceneLogic'import { observationClipboardText } from '../utils/observation'import {type UrlSorting,@@ -1593,6 +1595,15 @@ export const replayScannerLogic = kea<replayScannerLogicType>([actions.setScannerDraftSavedAt(savedAt)}return {+ loadObservationsSuccess: ({ observations, total }) => {+ lastObservationsPage.current = {+ rows: observations,+ number: values.observationsPage,+ pageSize: OBSERVATIONS_PAGE_SIZE,+ total,+ filterParams: neighborFilterParams(values.observationDetailLinkParams),+ }+ },// kea-forms' exact rejection for failed client-side validation. API failures toast in submit's catch.submitScannerFailure: async ({ error }) => {if (error?.message !== 'Validation Failed') {