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): return to watch feed from an observation opened there (#102575)

Kim Svatos Duganbf080e4115a5
diff --git a/products/replay_vision/frontend/observations/ReplayObservation.tsx b/products/replay_vision/frontend/observations/ReplayObservation.tsx
index 465584c0cb56..01b865cebb11 100644
--- a/products/replay_vision/frontend/observations/ReplayObservation.tsx
+++ b/products/replay_vision/frontend/observations/ReplayObservation.tsx
@@ -74,6 +74,7 @@ import { ObservationSignalReports } from './ObservationSignalReports'
import {
neighborFilterParams,
observationDetailUrl,
+ observationOriginParams,
replayObservationLogic,
scannerReturnParams,
} from './replayObservationLogic'
@@ -239,9 +240,14 @@ export function ReplayObservationSceneComponent(): JSX.Element {
// navigation (and the server-computed neighbor ids) stay within the filtered list.
const neighborParams = neighborFilterParams(searchParams)
const neighborsFiltered = Object.keys(neighborParams).some((key) => key !== 'order_by')
- // Prev/next keeps the return params too, so back still lands on the list view the reader came from.
+ // Prev/next keeps the return params too, so back still lands on the list view (or the watch feed)
+ // the reader came from.
const observationUrl = (id: string): string =>
- observationDetailUrl(id, { ...neighborParams, ...scannerReturnParams(searchParams) })
+ observationDetailUrl(id, {
+ ...neighborParams,
+ ...scannerReturnParams(searchParams),
+ ...observationOriginParams(searchParams),
+ })
const seekEmbeddedPlayer = (ms: number): void => {
if (!recordingExpanded) {
diff --git a/products/replay_vision/frontend/observations/replayObservationLogic.test.ts b/products/replay_vision/frontend/observations/replayObservationLogic.test.ts
index e9646e5951d9..19a57f9610b3 100644
--- a/products/replay_vision/frontend/observations/replayObservationLogic.test.ts
+++ b/products/replay_vision/frontend/observations/replayObservationLogic.test.ts
@@ -207,6 +207,21 @@ describe('replayObservationLogic', () => {
}
})
+ // The watch feed lives on the home scene, not the scanner that owns the row, so an observation
+ // opened from it (carrying `from=watch`) must send back to the feed rather than the scanner.
+ it('back returns to the watch feed when the observation was opened from it', async () => {
+ router.actions.push('/replay-vision/observations/obs-1', { from: 'watch', t: 12 })
+ const logic = replayObservationLogic({ id: 'obs-1' })
+ logic.mount()
+ try {
+ await expectLogic(logic).toDispatchActions(['loadObservationSuccess'])
+ const { breadcrumbs } = sceneLogic.values
+ expect(breadcrumbs[breadcrumbs.length - 2].path).toBe('/replay-vision?tab=watch')
+ } finally {
+ logic.unmount()
+ }
+ })
+
// Retry deletes the row and mints a pending replacement with no verdict, so the redirect must
// drop the reader's filters and page — a filtered list would hide the row it promises "shortly".
it('retry lands on the unfiltered scanner page, not the reader saved list view', async () => {
diff --git a/products/replay_vision/frontend/observations/replayObservationLogic.ts b/products/replay_vision/frontend/observations/replayObservationLogic.ts
index 1c7b2818229d..6e1a2ec37b12 100644
--- a/products/replay_vision/frontend/observations/replayObservationLogic.ts
+++ b/products/replay_vision/frontend/observations/replayObservationLogic.ts
@@ -12,7 +12,12 @@ import type { ReplayObservationApi, VisionObservationsRetrieveParams } from '../
import { scheduleObservationPoll } from '../logics/observationPolling'
import { requestObservationRetry } from '../logics/observationRetry'
import { OBSERVATION_LIST_FILTER_KEYS, OBSERVATION_LIST_URL_PARAM_KEYS } from '../replay_scanners/types'
-import { scannerBreadcrumb } from '../utils/breadcrumbs'
+import {
+ OBSERVATION_ORIGIN_PARAM,
+ WATCH_FEED_ORIGIN,
+ scannerBreadcrumb,
+ watchFeedBreadcrumb,
+} from '../utils/breadcrumbs'
import { hasScannerPage, scannerLabel } from '../utils/observation'
import { parseNumericParam } from '../utils/urlParams'
import { observationProgressLogic } from './observationProgressLogic'
@@ -77,6 +82,16 @@ export function scannerReturnParams(searchParams: Record<string, unknown>): Reco
return params
}
+/**
+ * Carries the home-view origin (`from`) across prev/next, so back keeps returning to the feed the
+ * reader came from even after they page through neighbors within the scene.
+ */
+export function observationOriginParams(searchParams: Record<string, unknown>): Record<string, string> {
+ return searchParams[OBSERVATION_ORIGIN_PARAM] === WATCH_FEED_ORIGIN
+ ? { [OBSERVATION_ORIGIN_PARAM]: WATCH_FEED_ORIGIN }
+ : {}
+}
+
/** The crumb the observation page's back button returns to. */
export function observationParentBreadcrumb(
observation: ReplayObservationApi,
@@ -301,10 +316,15 @@ export const replayObservationLogic = kea<replayObservationLogicType>([
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.
+ // Point the breadcrumb at whatever owns this observation, so "back" returns there instead of the
+ // vision home. The watch feed is the exception: it opens rows from the home scene, so back returns
+ // to the feed rather than the scanner that owns the row.
const setParentBreadcrumb = (observation: ReplayObservationApi): void => {
+ const { searchParams } = router.values
replayObservationSceneLogic().actions.setParentBreadcrumb(
- observationParentBreadcrumb(observation, scannerReturnParams(router.values.searchParams))
+ searchParams[OBSERVATION_ORIGIN_PARAM] === WATCH_FEED_ORIGIN
+ ? watchFeedBreadcrumb()
+ : observationParentBreadcrumb(observation, scannerReturnParams(searchParams))
)
}
return {
diff --git a/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.tsx b/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.tsx
index 70ceec3e52fa..06d4768fe416 100644
--- a/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.tsx
+++ b/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.tsx
@@ -1,5 +1,5 @@
import { useActions } from 'kea'
-import { router } from 'kea-router'
+import { combineUrl, router } from 'kea-router'
import { IconPlay } from '@posthog/icons'
import { LemonButton, LemonDivider, Link, Tooltip } from '@posthog/lemon-ui'
@@ -13,6 +13,7 @@ import { urls } from 'scenes/urls'
import { CitedText, ObservationResultSummary, readResult } from '../../components/ObservationCard'
import { ScannerTypeBadge } from '../../components/ScannerTypeBadge'
import type { ReplayObservationApi, WatchFeedItemApi, WatchFeedReasonApi } from '../../generated/api.schemas'
+import { OBSERVATION_ORIGIN_PARAM, WATCH_FEED_ORIGIN } from '../../utils/breadcrumbs'
import { citedTimestampRange } from '../../utils/citations'
import { ScannerType } from '../types'
@@ -103,8 +104,12 @@ export function WatchFeedCard({ item, position }: WatchFeedCardProps): JSX.Eleme
scannerType !== 'summarizer' && typeof result?.reasoning === 'string'
? { text: result.reasoning, segments: result.reasoning_segments }
: null
- // t=0 when nothing is cited, so the observation page still opens with the player expanded.
- const observationUrl = `${urls.replayVisionObservation(observation.id)}?t=${clip ? Math.floor(clip.startMs / 1000) : 0}`
+ // t=0 when nothing is cited, so the observation page still opens with the player expanded. `from`
+ // marks the feed as the origin, so the observation's back button returns here rather than the scanner.
+ const observationUrl = combineUrl(urls.replayVisionObservation(observation.id), {
+ t: clip ? Math.floor(clip.startMs / 1000) : 0,
+ [OBSERVATION_ORIGIN_PARAM]: WATCH_FEED_ORIGIN,
+ }).url
const capture = (target: 'clip_modal' | 'observation'): void => {
posthog.capture('replay_vision_watch_clip_clicked', {
scanner_id: observation.scanner_id,
diff --git a/products/replay_vision/frontend/utils/breadcrumbs.ts b/products/replay_vision/frontend/utils/breadcrumbs.ts
index 8cd4cc5c3e09..d6b4e50dc948 100644
--- a/products/replay_vision/frontend/utils/breadcrumbs.ts
+++ b/products/replay_vision/frontend/utils/breadcrumbs.ts
@@ -12,6 +12,23 @@ export const VISION_ROOT_BREADCRUMB: Breadcrumb = {
iconType: 'replay_vision',
}
+/**
+ * The home view an observation was opened from, carried in its URL's `from` param. The watch feed
+ * lives on the home scene, not the scanner that owns a row, so back needs this to return to the feed
+ * rather than the scanner. Absent for observations opened from a scanner's own list.
+ */
+export const OBSERVATION_ORIGIN_PARAM = 'from'
+export const WATCH_FEED_ORIGIN = 'watch'
+
+/** The crumb the back button returns to for an observation opened from the "What to watch" feed. */
+export function watchFeedBreadcrumb(): Breadcrumb {
+ return {
+ key: 'replay-vision-watch',
+ name: 'What to watch',
+ path: combineUrl(urls.replayVision(), { tab: WATCH_FEED_ORIGIN }).url,
+ }
+}
+
/** A crumb pointing at a saved scanner's page, optionally deep-linked to one of its tabs and its state. */
export function scannerBreadcrumb(
scannerId: string,