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 scan picker dead-ending on the recording page (#77230)

posthog[bot]05a5c3f015b2
diff --git a/products/replay_vision/frontend/components/ObservationsDock.tsx b/products/replay_vision/frontend/components/ObservationsDock.tsx
index 71ff53bd5615..ade81962b059 100644
--- a/products/replay_vision/frontend/components/ObservationsDock.tsx
+++ b/products/replay_vision/frontend/components/ObservationsDock.tsx
@@ -33,7 +33,8 @@ export function ObservationsDock(): JSX.Element | null {
/** Searchable scanner picker for "Observe this recording"; a flat menu doesn't scale to teams with many scanners. */
function ScannerPicker({ sessionId }: { sessionId: string }): JSX.Element {
const logic = observationsDockLogic({ sessionId })
- const { scanners, filteredScanners, scannerSearch, scannerPickerOpen, observing } = useValues(logic)
+ const { scanners, scannersLoading, filteredScanners, scannerSearch, scannerPickerOpen, observing } =
+ useValues(logic)
const { observe, setScannerSearch, setScannerPickerOpen } = useActions(logic)
const { quota } = useValues(visionQuotaLogic)
const { disabledReason: quotaDisabledReason, tooltip: quotaTooltip } = quotaUx(quota)
@@ -57,8 +58,14 @@ function ScannerPicker({ sessionId }: { sessionId: string }): JSX.Element {
/>
</div>
<div className="max-h-80 overflow-y-auto p-1">
- {scanners.length === 0 ? (
- <Link to={urls.replayVision()} className="block px-2 py-3 text-sm">
+ {scanners.length === 0 && scannersLoading ? (
+ <div className="flex items-center gap-2 px-2 py-3 text-sm text-muted">
+ <Spinner /> Loading scanners…
+ </div>
+ ) : scanners.length === 0 ? (
+ // Opens in a new tab so the recording stays put behind it — this dropdown is
+ // reached mid-recording and a same-tab navigation would abandon that context.
+ <Link to={urls.replayVision()} target="_blank" className="block px-2 py-3 text-sm">
No scanners yet — create one
</Link>
) : filteredScanners.length === 0 ? (
diff --git a/products/replay_vision/frontend/logics/observationsDockLogic.test.ts b/products/replay_vision/frontend/logics/observationsDockLogic.test.ts
index dc9d6171d5ad..f67db510e271 100644
--- a/products/replay_vision/frontend/logics/observationsDockLogic.test.ts
+++ b/products/replay_vision/frontend/logics/observationsDockLogic.test.ts
@@ -4,17 +4,24 @@ import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
import { observationsDockLogic } from './observationsDockLogic'
+import { visionScannersListLogic } from './visionScannersListLogic'
describe('observationsDockLogic', () => {
let logic: ReturnType<typeof observationsDockLogic.build>
let observeCalls: number
let releaseObserve: () => void
+ let releaseScanners: () => void
beforeEach(() => {
observeCalls = 0
useMocks({
get: {
- '/api/projects/:team/vision/scanners/': () => [200, { results: [] }],
+ '/api/projects/:team/vision/scanners/': async () => {
+ await new Promise<void>((resolve) => {
+ releaseScanners = resolve
+ })
+ return [200, { results: [] }]
+ },
'/api/projects/:team/vision/observations/': () => [200, { results: [] }],
},
post: {
@@ -35,9 +42,21 @@ describe('observationsDockLogic', () => {
afterEach(() => {
releaseObserve?.()
+ releaseScanners?.()
logic?.unmount()
})
+ // Regression guard: the picker used `scanners.length === 0` alone to decide when to show the
+ // "No scanners yet" dead-end link, so it rendered that link during the initial fetch too — the
+ // exact window `scannersLoading` exists to distinguish from a team that truly has none.
+ it('reports scanners as loading until the fetch resolves', async () => {
+ await expectLogic(logic).toMatchValues({ scanners: [], scannersLoading: true })
+
+ releaseScanners()
+ await expectLogic(visionScannersListLogic).toDispatchActions(['loadScannersSuccess'])
+ await expectLogic(logic).toMatchValues({ scannersLoading: false })
+ })
+
it('starts one observation when the same scanner row is clicked twice', async () => {
// The picker rows disable while observing, but both click events can land before React re-renders,
// and the duplicate-scanner guard can't see a run that has no observation row yet. Two POSTs mean a
diff --git a/products/replay_vision/frontend/logics/observationsDockLogic.ts b/products/replay_vision/frontend/logics/observationsDockLogic.ts
index 323b4e6bbfb0..e73e7a8ea9e6 100644
--- a/products/replay_vision/frontend/logics/observationsDockLogic.ts
+++ b/products/replay_vision/frontend/logics/observationsDockLogic.ts
@@ -18,6 +18,7 @@ export interface ObservationsDockLogicProps {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface observationsDockLogicValues {
scanners: ReplayScannerApi[] // visionScannersListLogic
+ scannersLoading: boolean // visionScannersListLogic
dockOpen: boolean
filteredScanners: ReplayScannerApi[]
hasObservationsInFlight: boolean
@@ -93,7 +94,7 @@ export const observationsDockLogic = kea<observationsDockLogicType>([
connect(() => ({
// The scanner list is team-wide — shared so per-recording dock instances don't each refetch it.
- values: [visionScannersListLogic, ['scanners']],
+ values: [visionScannersListLogic, ['scanners', 'scannersLoading']],
})),
actions({