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): stop summary dock force-opening over the user's choice (#63118)

Arno Hillen7cbfdd5a2692
diff --git a/frontend/src/scenes/session-recordings/player/PlayerSummaryDock.tsx b/frontend/src/scenes/session-recordings/player/PlayerSummaryDock.tsx
index 5682a142c206..d37b98c9199f 100644
--- a/frontend/src/scenes/session-recordings/player/PlayerSummaryDock.tsx
+++ b/frontend/src/scenes/session-recordings/player/PlayerSummaryDock.tsx
@@ -103,10 +103,10 @@ export function PlayerSummaryDock(): JSX.Element | null {
const summaryId = summaryIdBySessionId[sessionRecordingId] ?? null
const hasRenderedSummary = hasSummary && !sessionSummaryError
const setIsOpen = (open: boolean): void => setSummaryOpen(sessionRecordingId, open)
- const expandedHeight = Math.max(
- MIN_EXPANDED_HEIGHT,
- Math.min(MAX_EXPANDED_HEIGHT, desiredSize ?? DEFAULT_EXPANDED_HEIGHT)
- )
+ // Cap the default height to the viewport so the dock can't crush the player.
+ const expandedMaxHeight = desiredSize
+ ? `${Math.max(MIN_EXPANDED_HEIGHT, Math.min(MAX_EXPANDED_HEIGHT, desiredSize))}px`
+ : `min(${DEFAULT_EXPANDED_HEIGHT}px, 45vh)`
// `isOpen` flips multiple times per summary, so dedupe to one capture per render.
const capturedKeyRef = useRef<string | null>(null)
@@ -136,7 +136,7 @@ export function PlayerSummaryDock(): JSX.Element | null {
'relative border-t bg-surface-primary overflow-hidden flex flex-col',
!isResizeInProgress && 'transition-[max-height] duration-300 ease-out'
)}
- style={{ maxHeight: isOpen ? expandedHeight : COLLAPSED_HEIGHT }}
+ style={{ maxHeight: isOpen ? expandedMaxHeight : COLLAPSED_HEIGHT }}
data-attr="player-summary-dock"
>
{isOpen && <Resizer {...resizerProps} />}
diff --git a/frontend/src/scenes/session-recordings/player/player-meta/sessionSummaryProgressLogic.test.ts b/frontend/src/scenes/session-recordings/player/player-meta/sessionSummaryProgressLogic.test.ts
index 61c89463cd83..f7f24f2d73f4 100644
--- a/frontend/src/scenes/session-recordings/player/player-meta/sessionSummaryProgressLogic.test.ts
+++ b/frontend/src/scenes/session-recordings/player/player-meta/sessionSummaryProgressLogic.test.ts
@@ -26,6 +26,7 @@ describe('sessionSummaryProgressLogic', () => {
let logic: ReturnType<typeof sessionSummaryProgressLogic.build>
beforeEach(() => {
+ localStorage.clear() // the persisted autoExpandSummary reducer must not leak between tests
initKeaTests()
logic = sessionSummaryProgressLogic()
logic.mount()
@@ -68,22 +69,38 @@ describe('sessionSummaryProgressLogic', () => {
})
})
- it('re-opens via setSummary after user closed, only if summary is non-null', async () => {
+ it('does not re-open via setSummary after the user closed', async () => {
logic.actions.startSummarization(SESSION_ID)
logic.actions.setSummaryOpen(SESSION_ID, false)
- // Null summary should not reopen
await expectLogic(logic, () => {
- logic.actions.setSummary(SESSION_ID, null)
+ logic.actions.setSummary(SESSION_ID, { segments: [] } as any)
}).toMatchValues({
openBySessionId: expect.objectContaining({ [SESSION_ID]: false }),
})
+ })
+
+ it('does not auto-open when the user collapsed the dock for another session', async () => {
+ logic.actions.setSummaryOpen('session-a', false)
- // Non-null summary should reopen
await expectLogic(logic, () => {
- logic.actions.setSummary(SESSION_ID, { segments: [] } as any)
+ logic.actions.startSummarization('session-b')
+ logic.actions.setSummary('session-c', { segments: [] } as any)
}).toMatchValues({
- openBySessionId: expect.objectContaining({ [SESSION_ID]: true }),
+ autoExpandSummary: false,
+ openBySessionId: { 'session-a': false },
+ })
+ })
+
+ it('expanding the dock re-enables auto-open for future sessions', async () => {
+ logic.actions.setSummaryOpen('session-a', false)
+ logic.actions.setSummaryOpen('session-a', true)
+
+ await expectLogic(logic, () => {
+ logic.actions.startSummarization('session-b')
+ }).toMatchValues({
+ autoExpandSummary: true,
+ openBySessionId: expect.objectContaining({ 'session-b': true }),
})
})
diff --git a/frontend/src/scenes/session-recordings/player/player-meta/sessionSummaryProgressLogic.ts b/frontend/src/scenes/session-recordings/player/player-meta/sessionSummaryProgressLogic.ts
index 8c9a67c935d8..a369cdf31f59 100644
--- a/frontend/src/scenes/session-recordings/player/player-meta/sessionSummaryProgressLogic.ts
+++ b/frontend/src/scenes/session-recordings/player/player-meta/sessionSummaryProgressLogic.ts
@@ -131,13 +131,28 @@ export const sessionSummaryProgressLogic = kea<sessionSummaryProgressLogicType>(
{} as Record<string, boolean>,
{
setSummaryOpen: (state, { sessionId, open }) => ({ ...state, [sessionId]: open }),
- startSummarization: (state, { sessionId }) => ({ ...state, [sessionId]: true }),
- setSummary: (state, { sessionId, summary }) => (summary ? { ...state, [sessionId]: true } : state),
+ },
+ ],
+ // The user's last expand/collapse choice, used as the default for future recordings.
+ autoExpandSummary: [
+ true,
+ { persist: true },
+ {
+ setSummaryOpen: (_, { open }) => open,
},
],
}),
- listeners(({ actions }) => ({
+ listeners(({ actions, values }) => ({
+ // Auto-expand unless the user collapsed the dock, in this session or a previous one.
+ setSummary: ({ sessionId, summary }) => {
+ if (summary && values.openBySessionId[sessionId] === undefined && values.autoExpandSummary) {
+ actions.setSummaryOpen(sessionId, true)
+ }
+ },
startSummarization: async ({ sessionId }) => {
+ if (values.openBySessionId[sessionId] === undefined && values.autoExpandSummary) {
+ actions.setSummaryOpen(sessionId, true)
+ }
if (inFlightSessionIds.has(sessionId)) {
return
}