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.

feat(replay): expand the summary dock for recordings that have one (#87359)

Kim Svatos Dugan84f6dda2e99b
diff --git a/products/replay_vision/frontend/components/ObservationsDock.tsx b/products/replay_vision/frontend/components/ObservationsDock.tsx
index 8eb5514798a0..5e419c3240f7 100644
--- a/products/replay_vision/frontend/components/ObservationsDock.tsx
+++ b/products/replay_vision/frontend/components/ObservationsDock.tsx
@@ -13,6 +13,7 @@ import { AIConsentPopoverWrapper } from 'scenes/settings/organization/AIConsentP
import { observationsDockLogic } from '../logics/observationsDockLogic'
import { visionQuotaLogic } from '../logics/visionQuotaLogic'
import { getReplayVisionEditDisabledReason } from '../utils/accessControl'
+import { isSummaryObservation } from '../utils/observation'
import { quotaUx } from '../utils/quotaProjection'
import { VisionDocsLink } from './DocsLink'
import { ObservationDockCard } from './ObservationCard'
@@ -102,7 +103,7 @@ function ObservationsDockContent({ sessionId }: { sessionId: string }): JSX.Elem
const { desiredSize, isResizeInProgress } = useValues(resizerLogic(resizerProps))
// Scanner observations live in the sidebar's Observations tab; the dock only surfaces summaries
- const summaries = observations.filter((o) => o.scanner_snapshot?.scanner_type === 'summarizer')
+ const summaries = observations.filter(isSummaryObservation)
const hasContent = summaries.length > 0 || observationsLoading
const expandedHeight = Math.max(
MIN_EXPANDED_HEIGHT,
diff --git a/products/replay_vision/frontend/logics/observationsDockLogic.test.ts b/products/replay_vision/frontend/logics/observationsDockLogic.test.ts
index 71c6fa888d77..9bb32fbf1535 100644
--- a/products/replay_vision/frontend/logics/observationsDockLogic.test.ts
+++ b/products/replay_vision/frontend/logics/observationsDockLogic.test.ts
@@ -7,14 +7,26 @@ import { initKeaTests } from '~/test/init'
import type { ReplayObservationApi } from '../generated/api.schemas'
import { observationsDockLogic } from './observationsDockLogic'
+import { visionDockPreferenceLogic } from './visionDockPreferenceLogic'
import { visionScannersListLogic } from './visionScannersListLogic'
jest.mock('lib/lemon-ui/LemonToast', () => ({
lemonToast: { success: jest.fn(), info: jest.fn(), warning: jest.fn(), error: jest.fn() },
}))
+function summaryObservation(): ReplayObservationApi {
+ return {
+ id: 'obs-summary',
+ scanner_id: 'scanner-x',
+ session_id: 'sess-1',
+ status: 'succeeded',
+ scanner_snapshot: { scanner_type: 'summarizer' },
+ } as ReplayObservationApi
+}
+
describe('observationsDockLogic', () => {
let logic: ReturnType<typeof observationsDockLogic.build>
+ let preferences: ReturnType<typeof visionDockPreferenceLogic.build>
let observeCalls: number
let inlineScanCalls: number
let releaseObserve: () => void
@@ -65,6 +77,10 @@ describe('observationsDockLogic', () => {
},
})
initKeaTests()
+ // Persisted, so a collapse in one test would otherwise decide the next test's starting state.
+ preferences = visionDockPreferenceLogic()
+ preferences.mount()
+ preferences.actions.setSummaryDockAutoExpand(true)
logic = observationsDockLogic({ sessionId: 'sess-1' })
logic.mount()
})
@@ -74,6 +90,7 @@ describe('observationsDockLogic', () => {
releaseInlineScan?.()
releaseScanners?.()
logic?.unmount()
+ preferences?.unmount()
})
// Regression guard: the picker used `scanners.length === 0` alone to decide when to show the
@@ -149,4 +166,29 @@ describe('observationsDockLogic', () => {
expect(lemonToast.info).toHaveBeenCalled()
expect(lemonToast.warning).not.toHaveBeenCalled()
})
+
+ it('opens the dock for a recording that already has a summary', async () => {
+ observationResults = [summaryObservation()]
+
+ logic.actions.loadObservations()
+
+ await expectLogic(logic).toDispatchActions(['loadObservationsSuccess'])
+ await expectLogic(logic).toMatchValues({ dockOpen: true })
+ })
+
+ it('leaves the dock closed on the next recording once the user collapses it', async () => {
+ // The preference has to outlive the dock logic, which is keyed by session. Held per key, a
+ // collapse would be forgotten the moment the user clicks the next recording in the playlist.
+ observationResults = [summaryObservation()]
+ logic.actions.loadObservations()
+ await expectLogic(logic).toDispatchActions(['loadObservationsSuccess'])
+
+ logic.actions.setDockOpen(false)
+
+ const nextRecording = observationsDockLogic({ sessionId: 'sess-2' })
+ nextRecording.mount()
+ await expectLogic(nextRecording).toDispatchActions(['loadObservationsSuccess'])
+ await expectLogic(nextRecording).toMatchValues({ dockOpen: false })
+ nextRecording.unmount()
+ })
})
diff --git a/products/replay_vision/frontend/logics/observationsDockLogic.ts b/products/replay_vision/frontend/logics/observationsDockLogic.ts
index ec874522bd92..d7a1f6bd1f98 100644
--- a/products/replay_vision/frontend/logics/observationsDockLogic.ts
+++ b/products/replay_vision/frontend/logics/observationsDockLogic.ts
@@ -7,10 +7,11 @@ import { teamLogic } from 'scenes/teamLogic'
import { visionObservationsList, visionScannersInlineScanCreate, visionScannersObserveCreate } from '../generated/api'
import type { ReplayScannerApi, ReplayObservationApi } from '../generated/api.schemas'
-import { ObservationSeekbarMark, observationSeekbarMarks } from '../utils/observation'
+import { ObservationSeekbarMark, isSummaryObservation, observationSeekbarMarks } from '../utils/observation'
import { OBSERVE_POLL_GRACE_MS, scheduleObservationPoll, shouldPollObservations } from './observationPolling'
import { requestObservationRetry } from './observationRetry'
import { SUMMARIZE_RECORDING_CONFIG, summarizeOutcomeMessage } from './summarizeRecording'
+import { visionDockPreferenceLogic } from './visionDockPreferenceLogic'
import { refreshVisionQuota } from './visionQuotaLogic'
import { visionScannersListLogic } from './visionScannersListLogic'
@@ -20,6 +21,7 @@ export interface ObservationsDockLogicProps {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface observationsDockLogicValues {
+ summaryDockAutoExpand: boolean // visionDockPreferenceLogic
scanners: ReplayScannerApi[] // visionScannersListLogic
scannersLoading: boolean // visionScannersListLogic
dockOpen: boolean
@@ -38,6 +40,9 @@ export interface observationsDockLogicValues {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface observationsDockLogicActions {
+ setSummaryDockAutoExpand: (autoExpand: boolean) => {
+ autoExpand: boolean
+ } // visionDockPreferenceLogic
loadObservations: () => {
value: true
}
@@ -109,7 +114,13 @@ 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', 'scannersLoading']],
+ values: [
+ visionScannersListLogic,
+ ['scanners', 'scannersLoading'],
+ visionDockPreferenceLogic,
+ ['summaryDockAutoExpand'],
+ ],
+ actions: [visionDockPreferenceLogic, ['setSummaryDockAutoExpand']],
})),
actions({
@@ -232,9 +243,19 @@ export const observationsDockLogic = kea<observationsDockLogicType>([
actions.loadObservations
)
}
+ // A summary is only readable once the dock is open, so a recording that already has one opens it
+ // rather than hiding it behind the caret. Collapsing the dock turns this off until it is expanded
+ // again, otherwise the next recording in the playlist would re-open what the user just closed.
+ const openDockForExistingSummary = (): void => {
+ if (values.dockOpen || !values.summaryDockAutoExpand) {
+ return
+ }
+ if (values.observations.some((o) => isSummaryObservation(o) && o.status === 'succeeded')) {
+ actions.setDockOpen(true)
+ }
+ }
// Show the row that is coming, and re-read the quota the scan spent. Only call this when a scan
- // actually started, or the poll window opens for work that will never land. The dock is opened
- // by the summarize path alone; it only surfaces summaries.
+ // actually started, or the poll window opens for work that will never land.
const afterScanStarted = (): void => {
actions.loadObservations()
refreshVisionQuota()
@@ -265,9 +286,15 @@ export const observationsDockLogic = kea<observationsDockLogicType>([
},
// Poll while in flight and through the observe grace window; rescheduled on failure so one hiccup can't kill it.
- loadObservationsSuccess: reschedulePoll,
+ loadObservationsSuccess: () => {
+ openDockForExistingSummary()
+ reschedulePoll()
+ },
loadObservationsFailure: reschedulePoll,
+ // Every open and close runs through here, so the preference tracks the last one the user made.
+ setDockOpen: ({ open }) => actions.setSummaryDockAutoExpand(open),
+
observe: async ({ scannerId }) => {
// A cache flag, not `values.observing`: the reducer has already flipped that to true by the
// time this listener runs, so it would reject every call.
diff --git a/products/replay_vision/frontend/logics/visionDockPreferenceLogic.ts b/products/replay_vision/frontend/logics/visionDockPreferenceLogic.ts
new file mode 100644
index 000000000000..1f54ab0a2a56
--- /dev/null
+++ b/products/replay_vision/frontend/logics/visionDockPreferenceLogic.ts
@@ -0,0 +1,42 @@
+import { MakeLogicType, actions, kea, path, reducers } from 'kea'
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface visionDockPreferenceLogicValues {
+ summaryDockAutoExpand: boolean
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface visionDockPreferenceLogicActions {
+ setSummaryDockAutoExpand: (autoExpand: boolean) => {
+ autoExpand: boolean
+ }
+}
+
+export type visionDockPreferenceLogicType = MakeLogicType<
+ visionDockPreferenceLogicValues,
+ visionDockPreferenceLogicActions
+>
+
+/**
+ * Whether the summary dock opens on its own for a recording that already has a summary.
+ *
+ * Propless and persisted on purpose. `observationsDockLogic` is keyed by session, so a preference
+ * kept there would reset on every recording the user opens and re-expand a dock they just collapsed.
+ */
+export const visionDockPreferenceLogic = kea<visionDockPreferenceLogicType>([
+ path(['products', 'replay_vision', 'frontend', 'logics', 'visionDockPreferenceLogic']),
+
+ actions({
+ setSummaryDockAutoExpand: (autoExpand: boolean) => ({ autoExpand }),
+ }),
+
+ reducers({
+ summaryDockAutoExpand: [
+ true,
+ { persist: true },
+ {
+ setSummaryDockAutoExpand: (_: boolean, { autoExpand }: { autoExpand: boolean }) => autoExpand,
+ },
+ ],
+ }),
+])
diff --git a/products/replay_vision/frontend/utils/observation.ts b/products/replay_vision/frontend/utils/observation.ts
index 7d1dfae43fef..0b96f4b0b582 100644
--- a/products/replay_vision/frontend/utils/observation.ts
+++ b/products/replay_vision/frontend/utils/observation.ts
@@ -30,6 +30,11 @@ export function readReasoning(obs: ReplayObservationApi): string | null {
return typeof raw === 'string' && raw ? raw : null
}
+/** The dock shows summaries only; observations from the team's own scanners live in the sidebar tab. */
+export function isSummaryObservation(obs: ReplayObservationApi): boolean {
+ return obs.scanner_snapshot?.scanner_type === 'summarizer'
+}
+
/** Summarizer output: the one-line headline. */
export function readTitle(obs: ReplayObservationApi): string | null {
const raw = readModelOutput(obs)?.title