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): poll fallback so observation detail page lands the result (#61786)

Kim Svatos Duganab710f0cb4c3
diff --git a/products/replay_vision/frontend/observations/replayObservationLogic.ts b/products/replay_vision/frontend/observations/replayObservationLogic.ts
index 16d1ad33df66..7284390b9cf4 100644
--- a/products/replay_vision/frontend/observations/replayObservationLogic.ts
+++ b/products/replay_vision/frontend/observations/replayObservationLogic.ts
@@ -5,6 +5,7 @@ import { teamLogic } from 'scenes/teamLogic'
import { visionObservationsRetrieve } from '../generated/api'
import type { ReplayObservationApi } from '../generated/api.schemas'
+import { scheduleObservationPoll } from '../logics/observationPolling'
import { observationProgressLogic } from './observationProgressLogic'
import type { replayObservationLogicType } from './replayObservationLogicType'
import { replayObservationSceneLogic } from './replayObservationSceneLogic'
@@ -47,7 +48,7 @@ export const replayObservationLogic = kea<replayObservationLogicType>([
],
}),
- listeners(({ actions, props }) => ({
+ listeners(({ actions, props, cache }) => ({
loadObservation: async () => {
const teamId = teamLogic.values.currentTeamId
if (!teamId) {
@@ -67,6 +68,14 @@ export const replayObservationLogic = kea<replayObservationLogicType>([
}
},
+ loadObservationSuccess: ({ observation }) => {
+ // SSE flips us to the result instantly when our listener catches `streamCompleted`, but the
+ // stream is a shared keyed logic — if the dock started and finished it before this page opened,
+ // the past event isn't replayed here. Poll while in flight as a fallback so we still land the result.
+ const inFlight = observation.status === 'pending' || observation.status === 'running'
+ scheduleObservationPoll(cache.disposables, inFlight, actions.loadObservation)
+ },
+
// When the stream reports the observation has settled, reload once to render the final result.
streamCompleted: () => {
actions.loadObservation()