: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(replay): add a self serve debug this replay button for posthog ai (#110130)
Christian Raffertyeea16643938c
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsxindex 44979e3c3f5a..ffbc2db468f2 100644--- a/frontend/src/lib/constants.tsx+++ b/frontend/src/lib/constants.tsx@@ -497,6 +497,7 @@ export const FEATURE_FLAGS = {RECORDINGS_PLAYER_EVENT_PROPERTY_EXPANSION: 'recordings-player-event-property-expansion', // owner: @pauldambra #team-replayREMOTE_CONFIG: 'remote-config', // owner: #team-platform-featuresREPLAY_COLLAPSE_INSPECTOR_ITEMS: 'replay-collapse-inspector-items', // owner: @fasyy612 #team-replay+ REPLAY_DEBUG_WITH_AI: 'replay-debug-with-ai', // owner: @clr182 #team-replay, player button that sends the recording JSON to PostHog AIREPLAY_EVENT_MATCH_SCOPE: 'replay-event-match-scope', // owner: @pauldambra #team-replay, shows the "Match the whole session / only during recording" filter selectREPLAY_FILTERS_REDESIGN: 'replay-filters-redesign', // owner: @ksvat #team-replayREPLAY_NEGATIVE_EVENT_FILTERS: 'replay-negative-event-filters', // owner: @arnohillen #team-replaydiff --git a/frontend/src/scenes/session-recordings/player/SessionRecordingPlayer.tsx b/frontend/src/scenes/session-recordings/player/SessionRecordingPlayer.tsxindex 6994e7a1e125..75780ada1faa 100644--- a/frontend/src/scenes/session-recordings/player/SessionRecordingPlayer.tsx+++ b/frontend/src/scenes/session-recordings/player/SessionRecordingPlayer.tsx@@ -4,12 +4,15 @@ import clsx from 'clsx'import { BindLogic, useValues } from 'kea'import { useRef } from 'react'+import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { MatchingEventsMatchType } from 'scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic'import { AnalysisNudge } from 'products/replay_vision/frontend/components/AnalysisNudge'import { ObservationsDock } from 'products/replay_vision/frontend/components/ObservationsDock'import { visionSurfaceShown } from 'products/replay_vision/frontend/utils/visionSurface'+import { DebugReplayButton } from './player-meta/DebugReplayButton'import { playerSettingsLogic } from './playerSettingsLogic'import { PlayerSidebar } from './PlayerSidebar'import { PurePlayer } from './PurePlayer'@@ -98,6 +101,7 @@ function SessionRecordingPlayerInternal({}): JSX.Element {const { isVerticallyStacked, sidebarOpen } = useValues(playerSettingsLogic)const { logicProps } = useValues(sessionRecordingPlayerLogic)+ const { featureFlags } = useValues(featureFlagLogic)return (<div@@ -110,7 +114,14 @@ function SessionRecordingPlayerInternal({<PurePlayer noMeta={noMeta} noBorder={noBorder} />{visionSurfaceShown(logicProps) && (<>- <ObservationsDock />+ <ObservationsDock+ // The player modal covers the side panel, so the conversation would open out of sight.+ extraActions={+ featureFlags[FEATURE_FLAGS.REPLAY_DEBUG_WITH_AI] && logicProps.playerKey !== 'modal' ? (+ <DebugReplayButton />+ ) : null+ }+ /><AnalysisNudge /></>)}diff --git a/frontend/src/scenes/session-recordings/player/player-meta/DebugReplayButton.tsx b/frontend/src/scenes/session-recordings/player/player-meta/DebugReplayButton.tsxnew file mode 100644index 000000000000..37338ba13e93--- /dev/null+++ b/frontend/src/scenes/session-recordings/player/player-meta/DebugReplayButton.tsx@@ -0,0 +1,88 @@+import { useActions, useValues } from 'kea'+import { useMemo } from 'react'++import { IconChevronDown, IconSparkles } from '@posthog/icons'+import { LemonButton } from '@posthog/lemon-ui'++import { LemonMenuOverlay } from 'lib/lemon-ui/LemonMenu/LemonMenu'+import { sessionRecordingPlayerLogic } from 'scenes/session-recordings/player/sessionRecordingPlayerLogic'++import { useAttachedContext } from 'products/posthog_ai/frontend/api/logics'++import { debugReplayChatLogic } from './debugReplayChatLogic'+import { buildDebugReplayContextItems } from './debugReplayPrompt'++export function DebugReplayButton(): JSX.Element {+ const { sessionRecordingId, debugRecordingPreparing } = useValues(sessionRecordingPlayerLogic)+ const { debugRecordingWithAI } = useActions(sessionRecordingPlayerLogic)+ const { taskIdBySessionRecordingId, openingSessionRecordingId } = useValues(debugReplayChatLogic)+ const { openDebugChat } = useActions(debugReplayChatLogic)++ const contextItems = useMemo(() => buildDebugReplayContextItems(sessionRecordingId), [sessionRecordingId])+ useAttachedContext(contextItems)++ const hasDebugChat = !!taskIdBySessionRecordingId[sessionRecordingId]+ const openingDebugChat = openingSessionRecordingId === sessionRecordingId+ const preparingTooltip = 'Loading the recording data for PostHog AI'++ if (hasDebugChat) {+ return (+ <LemonButton+ size="small"+ type="secondary"+ className="shrink-0"+ icon={<IconSparkles />}+ onClick={() => openDebugChat(sessionRecordingId)}+ loading={openingDebugChat || debugRecordingPreparing}+ tooltip={+ debugRecordingPreparing+ ? preparingTooltip+ : 'Opens the PostHog AI chat that debugged this recording.'+ }+ data-attr="replay-debug-chat-open"+ sideAction={{+ icon: <IconChevronDown />,+ dropdown: {+ placement: 'bottom-end',+ overlay: (+ <LemonMenuOverlay+ items={[+ {+ label: 'Debug again in a new chat',+ onClick: debugRecordingWithAI,+ 'data-attr': 'replay-debug-with-ai-again',+ },+ ]}+ />+ ),+ },+ divider: false,+ disabledReason: debugRecordingPreparing ? preparingTooltip : null,+ 'aria-label': 'More debug options',+ 'data-attr': 'replay-debug-chat-more',+ }}+ >+ Open debug chat+ </LemonButton>+ )+ }++ return (+ <LemonButton+ size="small"+ type="secondary"+ className="shrink-0"+ icon={<IconSparkles />}+ onClick={debugRecordingWithAI}+ loading={debugRecordingPreparing}+ tooltip={+ debugRecordingPreparing+ ? preparingTooltip+ : 'Sends the recording JSON to PostHog AI and asks what went wrong.'+ }+ data-attr="replay-debug-with-ai"+ >+ Debug this replay+ </LemonButton>+ )+}diff --git a/frontend/src/scenes/session-recordings/player/player-meta/debugReplayChatLogic.test.ts b/frontend/src/scenes/session-recordings/player/player-meta/debugReplayChatLogic.test.tsnew file mode 100644index 000000000000..352ed64b4f63--- /dev/null+++ b/frontend/src/scenes/session-recordings/player/player-meta/debugReplayChatLogic.test.ts@@ -0,0 +1,44 @@+import { MAX_SIDE_PANEL_ID } from 'scenes/max/components/PhaiSidePanelChat'++import { initKeaTests } from '~/test/init'++import { ActiveCreation, runnerPanelLogic } from 'products/posthog_ai/frontend/api/logics'++import { debugReplayChatLogic } from './debugReplayChatLogic'++describe('debugReplayChatLogic', () => {+ let logic: ReturnType<typeof debugReplayChatLogic.build>+ let panel: ReturnType<typeof runnerPanelLogic.build>++ beforeEach(() => {+ localStorage.clear()+ initKeaTests()+ logic = debugReplayChatLogic()+ logic.mount()+ panel = runnerPanelLogic({ panelId: MAX_SIDE_PANEL_ID })+ })++ afterEach(() => {+ logic?.unmount()+ })++ test.each<[string, ActiveCreation[], Record<string, string>]>([+ [+ 'the task the panel creates for the debug prompt',+ [{ streamKey: 'draft-1' }, { streamKey: 'draft-1', taskId: 'task-1', runId: 'run-1' }],+ { 'session-1': 'task-1' },+ ],+ ['no task when the user opens another chat from history', [{ streamKey: 'run-9', taskId: 'task-9' }], {}],+ [+ 'no task when the user leaves the pending run for another chat',+ [{ streamKey: 'draft-1' }, { streamKey: 'run-9', taskId: 'task-9', runId: 'run-9' }],+ {},+ ],+ ])('remembers %s', (_, creations, expected) => {+ logic.actions.debugChatRequested('session-1')+ for (const creation of creations) {+ panel.actions.setActiveCreation(creation)+ }+ expect(logic.values.taskIdBySessionRecordingId).toEqual(expected)+ })+})diff --git a/frontend/src/scenes/session-recordings/player/player-meta/debugReplayChatLogic.ts b/frontend/src/scenes/session-recordings/player/player-meta/debugReplayChatLogic.tsnew file mode 100644index 000000000000..baac3ad66dd5--- /dev/null+++ b/frontend/src/scenes/session-recordings/player/player-meta/debugReplayChatLogic.ts@@ -0,0 +1,187 @@+import { MakeLogicType, actions, connect, kea, listeners, path, reducers } from 'kea'+import { router } from 'kea-router'++import { lemonToast } from '@posthog/lemon-ui'++import { MAX_SIDE_PANEL_ID } from 'scenes/max/components/PhaiSidePanelChat'+import { PhaiViewMode, maxGlobalLogic } from 'scenes/max/maxGlobalLogic'+import { projectLogic } from 'scenes/projectLogic'+import { sessionRecordingEventUsageLogic } from 'scenes/session-recordings/sessionRecordingEventUsageLogic'+import { urls } from 'scenes/urls'++import { sidePanelStateLogic } from '~/layout/navigation-3000/sidepanel/sidePanelStateLogic'+import { SidePanelTab } from '~/types'++import { ActiveCreation, runnerPanelLogic } from 'products/posthog_ai/frontend/api/logics'+import { tasksRetrieve } from 'products/tasks/frontend/generated/api'++// Local storage holds one entry per debugged recording, so the oldest entries are dropped past this count.+const MAX_REMEMBERED_DEBUG_CHATS = 200++/** A debug prompt that was sent to the side panel and whose task does not exist yet. */+export interface PendingDebugChat {+ sessionRecordingId: string+ /** The panel's client key for the optimistic run. It is null until the panel opens that run. */+ streamKey: string | null+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface debugReplayChatLogicValues {+ effectivePhaiView: PhaiViewMode // maxGlobalLogic+ currentProjectId: number | null // projectLogic+ openingSessionRecordingId: string | null+ pendingDebugChat: PendingDebugChat | null+ taskIdBySessionRecordingId: Record<string, string>+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface debugReplayChatLogicActions {+ clearActiveCreation: () => {+ value: true+ } // runnerPanelLogic+ setActiveCreation: (creation: ActiveCreation) => {+ creation: ActiveCreation+ } // runnerPanelLogic+ reportRecordingDebugChatReopened: () => {+ value: true+ } // sessionRecordingEventUsageLogic+ openSidePanel: (+ tab: SidePanelTab,+ options?: string | undefined+ ) => {+ options: string | undefined+ tab: SidePanelTab+ } // sidePanelStateLogic+ debugChatRequested: (sessionRecordingId: string) => {+ sessionRecordingId: string+ }+ forgetDebugChat: (sessionRecordingId: string) => {+ sessionRecordingId: string+ }+ openDebugChat: (sessionRecordingId: string) => {+ sessionRecordingId: string+ }+ openDebugChatFinished: () => {+ value: true+ }+ rememberDebugChat: (+ sessionRecordingId: string,+ taskId: string+ ) => {+ sessionRecordingId: string+ taskId: string+ }+}++export type debugReplayChatLogicType = MakeLogicType<debugReplayChatLogicValues, debugReplayChatLogicActions>++/**+ * Remembers which PostHog AI chat debugged each recording, so that the player can reopen that chat.+ *+ * A task has no reference to a recording on the server. The link exists only in this browser's local storage.+ */+export const debugReplayChatLogic = kea<debugReplayChatLogicType>([+ path(['scenes', 'session-recordings', 'player', 'player-meta', 'debugReplayChatLogic']),+ connect(() => ({+ values: [maxGlobalLogic, ['effectivePhaiView'], projectLogic, ['currentProjectId']],+ actions: [+ runnerPanelLogic({ panelId: MAX_SIDE_PANEL_ID }),+ ['setActiveCreation', 'clearActiveCreation'],+ sidePanelStateLogic,+ ['openSidePanel'],+ sessionRecordingEventUsageLogic,+ ['reportRecordingDebugChatReopened'],+ ],+ })),+ actions({+ debugChatRequested: (sessionRecordingId: string) => ({ sessionRecordingId }),+ rememberDebugChat: (sessionRecordingId: string, taskId: string) => ({ sessionRecordingId, taskId }),+ forgetDebugChat: (sessionRecordingId: string) => ({ sessionRecordingId }),+ openDebugChat: (sessionRecordingId: string) => ({ sessionRecordingId }),+ openDebugChatFinished: true,+ }),+ reducers({+ taskIdBySessionRecordingId: [+ {} as Record<string, string>,+ { persist: true },+ {+ rememberDebugChat: (state, { sessionRecordingId, taskId }) => {+ // Reinserting moves the recording to the end, so the entries stay ordered oldest first.+ const { [sessionRecordingId]: _, ...rest } = state+ const entries = [...Object.entries(rest), [sessionRecordingId, taskId]]+ return Object.fromEntries(entries.slice(-MAX_REMEMBERED_DEBUG_CHATS))+ },+ forgetDebugChat: (state, { sessionRecordingId }) => {+ const { [sessionRecordingId]: _, ...rest } = state+ return rest+ },+ },+ ],+ pendingDebugChat: [+ null as PendingDebugChat | null,+ {+ debugChatRequested: (_, { sessionRecordingId }) => ({ sessionRecordingId, streamKey: null }),+ setActiveCreation: (state, { creation }) => {+ if (!state) {+ return state+ }+ if (state.streamKey === null) {+ // The run for the prompt opens without a task. A creation that already has a task is+ // a chat the user opened from history, so the prompt was not sent.+ return creation.taskId ? null : { ...state, streamKey: creation.streamKey }+ }+ return creation.streamKey === state.streamKey ? state : null+ },+ clearActiveCreation: (state) => (state?.streamKey ? null : state),+ rememberDebugChat: () => null,+ },+ ],+ openingSessionRecordingId: [+ null as string | null,+ {+ openDebugChat: (_, { sessionRecordingId }) => sessionRecordingId,+ openDebugChatFinished: () => null,+ },+ ],+ }),+ listeners(({ actions, values }) => ({+ setActiveCreation: ({ creation }) => {+ const pending = values.pendingDebugChat+ // The panel sets the task on the optimistic run after the server creates it.+ if (pending?.streamKey === creation.streamKey && creation.taskId) {+ actions.rememberDebugChat(pending.sessionRecordingId, creation.taskId)+ }+ },+ openDebugChat: async ({ sessionRecordingId }) => {+ const taskId = values.taskIdBySessionRecordingId[sessionRecordingId]+ if (!taskId || values.currentProjectId === null) {+ actions.openDebugChatFinished()+ return+ }+ try {+ const task = await tasksRetrieve(String(values.currentProjectId), taskId)+ actions.reportRecordingDebugChatReopened()+ if (values.effectivePhaiView === 'new' && task.latest_run) {+ actions.openSidePanel(SidePanelTab.Max)+ actions.setActiveCreation({+ streamKey: task.latest_run.id,+ taskId: task.id,+ runId: task.latest_run.id,+ })+ } else {+ // The legacy chat panel cannot show a task, and a task without a run has no thread to show.+ router.actions.push(urls.taskDetail(task.id))+ }+ } catch (error) {+ if ((error as { status?: number } | null)?.status === 404) {+ actions.forgetDebugChat(sessionRecordingId)+ lemonToast.error('That chat no longer exists. Debug this replay again to start a new one.')+ } else {+ lemonToast.error("Couldn't open the chat. Try again in a moment.")+ }+ } finally {+ actions.openDebugChatFinished()+ }+ },+ })),+])diff --git a/frontend/src/scenes/session-recordings/player/player-meta/debugReplayData.test.ts b/frontend/src/scenes/session-recordings/player/player-meta/debugReplayData.test.tsnew file mode 100644index 000000000000..0a2803574e04--- /dev/null+++ b/frontend/src/scenes/session-recordings/player/player-meta/debugReplayData.test.ts@@ -0,0 +1,93 @@+import { EventType } from 'posthog-js/rrweb-types'++import { RecordingSnapshot } from '~/types'++import { ExportedSessionRecordingFileV2 } from '../../file-playback/types'+import { buildDebugReplayData } from './debugReplayData'++const START = 1_700_000_000_000++function consoleSnapshot(offsetMs: number, level: string, message: string): RecordingSnapshot {+ return {+ type: EventType.Plugin,+ timestamp: START + offsetMs,+ windowId: 1,+ data: { plugin: 'rrweb/console@1', payload: { level, payload: [message], trace: ['at app.js:1'] } },+ } as unknown as RecordingSnapshot+}++function exportOf(snapshots: RecordingSnapshot[]): ExportedSessionRecordingFileV2 {+ return { version: '2023-04-28', data: { id: 'session-1', person: undefined, snapshots } }+}++describe('buildDebugReplayData', () => {+ it('keeps page, console and network entries and drops DOM snapshot content', () => {+ const result = JSON.parse(+ buildDebugReplayData(+ exportOf([+ {+ type: EventType.Meta,+ timestamp: START,+ windowId: 1,+ data: { href: 'https://example.com/checkout', width: 1200, height: 800 },+ } as unknown as RecordingSnapshot,+ {+ type: EventType.FullSnapshot,+ timestamp: START + 10,+ windowId: 1,+ data: { node: { secretMarkup: 'dom-content-that-must-not-be-sent' } },+ } as unknown as RecordingSnapshot,+ consoleSnapshot(2500, 'error', 'Payment failed'),+ {+ type: EventType.Plugin,+ timestamp: START + 4000,+ windowId: 1,+ data: {+ plugin: 'rrweb/network@1',+ payload: {+ requests: [+ {+ name: 'https://example.com/api/pay',+ method: 'POST',+ responseStatus: 500,+ duration: 120.4,+ initiatorType: 'fetch',+ },+ ],+ },+ },+ } as unknown as RecordingSnapshot,+ ])+ )+ )++ expect(result).toMatchObject({+ session_id: 'session-1',+ duration_seconds: 4,+ snapshot_counts: { Meta: 1, FullSnapshot: 1, Plugin: 2 },+ timeline: [+ { t: 0, kind: 'page', url: 'https://example.com/checkout', viewport: '1200x800' },+ { t: 2.5, kind: 'console', level: 'error', message: 'Payment failed', trace: ['at app.js:1'] },+ { t: 4, kind: 'network', method: 'POST', url: 'https://example.com/api/pay', status: 500 },+ ],+ })+ expect(result.omitted).toBeUndefined()+ expect(JSON.stringify(result)).not.toContain('dom-content-that-must-not-be-sent')+ })++ it('stays within budget and parseable, dropping plain logs before errors', () => {+ const snapshots = [+ ...Array.from({ length: 200 }, (_, i) => consoleSnapshot(i, 'info', `noise ${i} ${'x'.repeat(100)}`)),+ consoleSnapshot(900, 'error', 'the one error'),+ ]++ const serialized = buildDebugReplayData(exportOf(snapshots), 4000)+ const result = JSON.parse(serialized)++ expect(serialized.length).toBeLessThanOrEqual(4000)+ expect(result.timeline).toContainEqual(expect.objectContaining({ level: 'error', message: 'the one error' }))+ expect(result.omitted).toMatchObject({ problems: 0 })+ expect(result.omitted.other).toBeGreaterThan(0)+ expect(result.timeline.length + result.omitted.other).toBe(201)+ })+})diff --git a/frontend/src/scenes/session-recordings/player/player-meta/debugReplayData.ts b/frontend/src/scenes/session-recordings/player/player-meta/debugReplayData.tsnew file mode 100644index 000000000000..63f26f7b3d91--- /dev/null+++ b/frontend/src/scenes/session-recordings/player/player-meta/debugReplayData.ts@@ -0,0 +1,155 @@+import { EventType } from 'posthog-js/rrweb-types'++import { RRWebRecordingConsoleLogPayload, RecordingSnapshot } from '~/types'++import { getPerformanceEvents } from '../../apm/performance-event-utils'+import { ExportedSessionRecordingFileV2 } from '../../file-playback/types'++/** The context block rides on every message of the conversation, so the recording data gets a fixed budget. */+export const DEBUG_REPLAY_DATA_MAX_CHARS = 64_000++const CONSOLE_LOG_PLUGIN_NAME = 'rrweb/console@1'+const MAX_MESSAGE_CHARS = 500+const MAX_URL_CHARS = 300++interface DebugReplayEntry {+ t: number+ kind: 'page' | 'console' | 'network' | 'custom'+ [field: string]: unknown+}++interface PrioritizedEntry {+ entry: DebugReplayEntry+ important: boolean+}++function truncate(value: string, maxChars: number): string {+ return value.length > maxChars ? `${value.slice(0, maxChars)}…[truncated]` : value+}++function relativeSeconds(timestampMs: number, startMs: number): number {+ return Math.max(0, Math.round((timestampMs - startMs) / 100) / 10)+}++function snapshotToEntries(snapshot: RecordingSnapshot, startMs: number): PrioritizedEntry[] {+ const t = relativeSeconds(snapshot.timestamp, startMs)++ if (snapshot.type === EventType.Meta) {+ const { href, width, height } = snapshot.data+ return [+ {+ entry: { t, kind: 'page', url: truncate(href ?? '', MAX_URL_CHARS), viewport: `${width}x${height}` },+ important: true,+ },+ ]+ }++ if (snapshot.type === EventType.Custom) {+ const payload = JSON.stringify(snapshot.data.payload ?? null) ?? 'null'+ return [+ {+ entry: { t, kind: 'custom', tag: snapshot.data.tag, payload: truncate(payload, MAX_URL_CHARS) },+ important: false,+ },+ ]+ }++ if (snapshot.type !== EventType.Plugin) {+ return []+ }++ if (snapshot.data.plugin === CONSOLE_LOG_PLUGIN_NAME) {+ const data = snapshot.data.payload as RRWebRecordingConsoleLogPayload | undefined+ if (!data) {+ return []+ }+ const lines = (Array.isArray(data.payload) ? data.payload : [data.payload]).filter((x) => !!x)+ const isProblem = data.level === 'error' || data.level === 'warn'+ const entry: DebugReplayEntry = {+ t,+ kind: 'console',+ level: data.level,+ message: truncate(lines.join('\n'), MAX_MESSAGE_CHARS),+ }+ if (data.level === 'error' && Array.isArray(data.trace) && data.trace.length > 0) {+ entry.trace = data.trace.slice(0, 3).map((line) => truncate(String(line), MAX_URL_CHARS))+ }+ return [{ entry, important: isProblem }]+ }++ return []+}++export function buildDebugReplayData(+ exported: ExportedSessionRecordingFileV2,+ maxChars: number = DEBUG_REPLAY_DATA_MAX_CHARS+): string {+ const snapshots = exported.data.snapshots ?? []+ const startMs = snapshots.reduce((min, snapshot) => Math.min(min, snapshot.timestamp), Infinity)+ const endMs = snapshots.reduce((max, snapshot) => Math.max(max, snapshot.timestamp), -Infinity)++ const snapshotCounts: Record<string, number> = {}+ const prioritized: PrioritizedEntry[] = []+ for (const snapshot of snapshots) {+ const typeName = EventType[snapshot.type] ?? String(snapshot.type)+ snapshotCounts[typeName] = (snapshotCounts[typeName] ?? 0) + 1+ prioritized.push(...snapshotToEntries(snapshot, startMs))+ }+ // The recorder has two network payload formats. The inspector's parser reads both.+ for (const request of getPerformanceEvents({ all: snapshots })) {+ const status = typeof request.response_status === 'number' ? request.response_status : undefined+ prioritized.push({+ entry: {+ t: relativeSeconds(new Date(request.timestamp).valueOf(), startMs),+ kind: 'network',+ method: request.method,+ url: truncate(String(request.name ?? ''), MAX_URL_CHARS),+ status,+ initiator: request.initiator_type,+ duration_ms: typeof request.duration === 'number' ? Math.round(request.duration) : undefined,+ },+ // Status 0 is how the browser reports a request that never got a response.+ important: status !== undefined && (status >= 400 || status === 0),+ })+ }+ prioritized.sort((a, b) => a.entry.t - b.entry.t)++ const base = {+ session_id: exported.data.id,+ start_time: snapshots.length > 0 ? new Date(startMs).toISOString() : null,+ duration_seconds: snapshots.length > 0 ? Math.round((endMs - startMs) / 1000) : 0,+ snapshot_counts: snapshotCounts,+ }++ let remaining =+ maxChars - JSON.stringify({ ...base, timeline: [], omitted: { problems: 0, other: 0 } }).length - 200+ const kept = new Set<PrioritizedEntry>()+ for (const important of [true, false]) {+ for (const item of prioritized) {+ if (item.important !== important) {+ continue+ }+ const cost = JSON.stringify(item.entry).length + 1+ if (cost > remaining) {+ continue+ }+ remaining -= cost+ kept.add(item)+ }+ }++ const omitted = prioritized.filter((item) => !kept.has(item))+ return JSON.stringify({+ ...base,+ timeline: prioritized.filter((item) => kept.has(item)).map((item) => item.entry),+ ...(omitted.length > 0+ ? {+ omitted: {+ problems: omitted.filter((item) => item.important).length,+ other: omitted.filter((item) => !item.important).length,+ note: 'Entries were left out to fit the size limit. Query the session for the rest.',+ },+ }+ : {}),+ })+}diff --git a/frontend/src/scenes/session-recordings/player/player-meta/debugReplayPrompt.ts b/frontend/src/scenes/session-recordings/player/player-meta/debugReplayPrompt.tsnew file mode 100644index 000000000000..bd697590435e--- /dev/null+++ b/frontend/src/scenes/session-recordings/player/player-meta/debugReplayPrompt.ts@@ -0,0 +1,63 @@+import { colonDelimitedDuration } from 'lib/utils/durations'++import { AttachedContextItem } from 'products/posthog_ai/frontend/api/types'++const DEBUG_REPLAY_DISMISS_GROUP = 'session_recording_player'++// Trusted context must stay a build-time string: the session ID travels on the untrusted item below.+const DEBUG_REPLAY_INSTRUCTIONS_CONTEXT_ITEM: AttachedContextItem = {+ type: 'instructions',+ hidden: true,+ dismissGroup: DEBUG_REPLAY_DISMISS_GROUP,+ value:+ "The user has a session recording open in the replay player. The session_recording item's key is the " ++ 'session ID of that recording, and "this replay" or "this recording" means that session. When a ' ++ 'session_recording_data item is present, it is JSON extracted from that recording: a timeline of page ' ++ 'loads, console output, network requests and custom events, where t is seconds from the start of the ' ++ 'recording. Read it first. DOM snapshots are counted in snapshot_counts but not included, and an omitted ' ++ 'field means entries were left out for size. When a file whose name ends in -ph-recording.json is ' ++ 'attached, it is the complete export of the recording, including every rrweb snapshot. It can be many ' ++ 'megabytes, so query it with tools such as jq and do not print it whole. For anything else, load the ' ++ 'investigating-replay skill and fetch the recording with session-recording-get. Do not ask the user for ' ++ 'the session ID.',+}++export function buildDebugReplayDataContextItem(recordingDataJson: string): AttachedContextItem {+ return {+ type: 'session_recording_data',+ value: recordingDataJson,+ label: 'Recording data',+ dismissGroup: DEBUG_REPLAY_DISMISS_GROUP,+ }+}++export function buildDebugReplayContextItems(sessionRecordingId: string): AttachedContextItem[] {+ return [+ {+ type: 'session_recording',+ key: sessionRecordingId,+ label: 'Current session',+ dismissGroup: DEBUG_REPLAY_DISMISS_GROUP,+ },+ DEBUG_REPLAY_INSTRUCTIONS_CONTEXT_ITEM,+ ]+}++// The trusted instruction above identifies the attached export by this suffix.+export function debugReplayFileName(sessionRecordingId: string): string {+ return `export-${sessionRecordingId}-ph-recording.json`+}++export function buildDebugReplayPrompt(sessionRecordingId: string, playerTimeSeconds: number): string {+ return [+ 'Debug this session replay.',+ '',+ `Session ID: ${sessionRecordingId}`,+ `I am ${colonDelimitedDuration(playerTimeSeconds, 2)} into the recording.`,+ '',+ 'The recording JSON is attached. Use it to find what went wrong for the user in this session. ' ++ 'Check exceptions, console errors, failed or slow ' ++ 'network requests, rage clicks, and dead clicks. For each problem, tell me when it happens in the ' ++ 'recording, the likely cause, and how to fix it. Start with whatever is closest to where I am now.',+ ].join('\n')+}diff --git a/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.ts b/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.tsindex 8969e24c867f..da83fb75a541 100644--- a/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.ts+++ b/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.ts@@ -43,9 +43,19 @@ import { downloadFile } from 'lib/utils/dom'import { clamp } from 'lib/utils/numbers'import { objectsEqual } from 'lib/utils/objects'import { openBillingPopupModal } from 'scenes/billing/BillingPopup'+import { MAX_SIDE_PANEL_ID } from 'scenes/max/components/PhaiSidePanelChat'+import { PhaiViewMode, maxGlobalLogic } from 'scenes/max/maxGlobalLogic'+import { autoRunMaxPrompt } from 'scenes/max/maxPrompt'import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'import { playerCommentModel } from 'scenes/session-recordings/player/commenting/playerCommentModel'import { sessionPlayerModalLogic } from 'scenes/session-recordings/player/modal/sessionPlayerModalLogic'+import { debugReplayChatLogic } from 'scenes/session-recordings/player/player-meta/debugReplayChatLogic'+import { buildDebugReplayData } from 'scenes/session-recordings/player/player-meta/debugReplayData'+import {+ buildDebugReplayDataContextItem,+ buildDebugReplayPrompt,+ debugReplayFileName,+} from 'scenes/session-recordings/player/player-meta/debugReplayPrompt'import {isWithinIngestionGracePeriod,SessionRecordingDataCoordinatorLogicProps,@@ -55,8 +65,23 @@ import { MatchingEventsMatchType } from 'scenes/session-recordings/playlist/sessimport { urls } from 'scenes/urls'import { userLogic } from 'scenes/userLogic'-import { AvailableFeature, ExporterFormat, RecordingSegment, SessionPlayerData, SessionPlayerState } from '~/types'+import { sidePanelStateLogic } from '~/layout/navigation-3000/sidepanel/sidePanelStateLogic'+import {+ AvailableFeature,+ ExporterFormat,+ RecordingSegment,+ SessionPlayerData,+ SessionPlayerState,+ SidePanelTab,+} from '~/types'+import {+ ATTACHMENT_MAX_SIZE_BYTES,+ attachedContextLogic,+ composerAttachmentsLogic,+ runnerPanelLogic,+} from 'products/posthog_ai/frontend/api/logics'+import { AttachedContextItem } from 'products/posthog_ai/frontend/api/types'import { analysisNudgeLogic } from 'products/replay_vision/frontend/logics/analysisNudgeLogic'import {MAX_REPLAY_IFRAME_HTML_CHARS,@@ -65,6 +90,7 @@ import {persistReplayIframeData,} from 'products/web_analytics/frontend/heatmaps/replayIframeData'+import type { PendingAttachment } from '../../../../../products/posthog_ai/frontend/utils/attachments'import type { FeatureFlagsSet } from '../../../lib/logic/featureFlagLogic'import type { PreflightStatus, SessionRecordingSnapshotSource, SessionRecordingType, UserType } from '../../../types'import { deletedRecordingsLogic } from '../deletedRecordingsLogic'@@ -723,8 +749,10 @@ function scheduleDiagnosticsFlush(// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface sessionRecordingPlayerLogicValues {+ sidePanelAttachments: PendingAttachment[] // composerAttachmentsLogichasReachedExportFullVideoLimit: boolean // exportsLogicfeatureFlags: FeatureFlagsSet // featureFlagLogic+ effectivePhaiView: PhaiViewMode // maxGlobalLogicplayerControlsOverlay: boolean // playerSettingsLogicshowMetadataFooter: boolean // playerSettingsLogicskipInactivitySetting: boolean // playerSettingsLogic@@ -776,6 +804,7 @@ export interface sessionRecordingPlayerLogicValues {currentTimestamp: number | undefinedcurrentURL: string | undefineddataBufferedUntilTimestamp: number | null+ debugRecordingPreparing: booleandebugSettings: {incrementalSources: IncrementalSource[]types: EventType[]@@ -850,6 +879,25 @@ export interface sessionRecordingPlayerLogicValues {// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface sessionRecordingPlayerLogicActions {+ deregisterContext: (providerId: string) => {+ providerId: string+ } // attachedContextLogic+ registerContext: (+ providerId: string,+ items: AttachedContextItem[]+ ) => {+ items: AttachedContextItem[]+ providerId: string+ } // attachedContextLogic+ addFiles: (files: File[]) => {+ files: File[]+ } // composerAttachmentsLogic+ removeAttachments: (ids: string[]) => {+ ids: string[]+ } // composerAttachmentsLogic+ debugChatRequested: (sessionRecordingId: string) => {+ sessionRecordingId: string+ } // debugReplayChatLogicaddDeletedRecordings: (ids: string[]) => {ids: string[]} // deletedRecordingsLogic@@ -893,6 +941,12 @@ export interface sessionRecordingPlayerLogicActions {setSpeed: (speed: number) => {speed: number} // playerSettingsLogic+ clearActiveCreation: () => {+ value: true+ } // runnerPanelLogic+ setHistoryExpanded: (expanded: boolean) => {+ expanded: boolean+ } // runnerPanelLogicloadRecordingData: () => {value: true} // sessionRecordingDataCoordinatorLogic@@ -915,9 +969,19 @@ export interface sessionRecordingPlayerLogicActions {reportNextRecordingTriggered: (automatic: boolean) => {automatic: boolean} // sessionRecordingEventUsageLogic+ reportRecordingDebuggedWithAI: (playerTimeSeconds: number) => {+ playerTimeSeconds: number+ } // sessionRecordingEventUsageLogicreportRecordingExportedToFile: (format: 'json' | 'mp4') => {format: 'json' | 'mp4'} // sessionRecordingEventUsageLogic+ openSidePanel: (+ tab: SidePanelTab,+ options?: string | undefined+ ) => {+ options: string | undefined+ tab: SidePanelTab+ } // sidePanelStateLogicloadAllSources: () => {value: true} // snapshotDataLogic@@ -983,6 +1047,9 @@ export interface sessionRecordingPlayerLogicActions {config: Record<string, any>integrationId: number}+ debugRecordingWithAI: () => {+ value: true+ }deleteRecording: () => {value: true}@@ -1100,6 +1167,9 @@ export interface sessionRecordingPlayerLogicActions {setCurrentTimestamp: (timestamp: number) => {timestamp: number}+ setDebugRecordingPreparing: (preparing: boolean) => {+ preparing: boolean+ }setDebugSnapshotIncrementalSources: (incrementalSources: IncrementalSource[]) => {incrementalSources: IncrementalSource[]}@@ -1360,6 +1430,59 @@ export type sessionRecordingPlayerLogicType = MakeLogicType<sessionRecordingPlayerLogicMeta>+function encodeRecording(recording: ExportedSessionRecordingFileV2): string[] {+ let output = [+ `{"version":"${recording.version}",`,+ `"data":{"id":"${recording.data.id}",`,+ `"person":${JSON.stringify(recording.data.person)},`,+ `"snapshots":[`,+ ]++ // Stringify the snapshots one-by-one to allow exports to work for very large recordings+ for (const snapshot of recording.data.snapshots) {+ output.push(JSON.stringify(snapshot))+ output.push(',')+ }+ if (recording.data.snapshots.length > 0) {+ output.pop()+ }+ output.push(']}}')++ return output+}++async function loadAllSnapshots(+ values: Pick<sessionRecordingPlayerLogicValues, 'sessionPlayerData'>,+ actions: { loadAllSources: () => void; loadNextSnapshotSource: () => void }+): Promise<void> {+ actions.loadAllSources()++ const delayTime = 1000+ const maxStallIterations = 15+ let stallCount = 0+ let lastSnapshotCount = 0+ while (!values.sessionPlayerData.fullyLoaded) {+ const currentCount = values.sessionPlayerData.snapshotsByWindowId+ ? Object.values(values.sessionPlayerData.snapshotsByWindowId).reduce((sum, snaps) => sum + snaps.length, 0)+ : 0+ if (currentCount > lastSnapshotCount) {+ stallCount = 0+ lastSnapshotCount = currentCount+ } else {+ stallCount+++ }+ if (stallCount >= maxStallIterations) {+ throw new Error('Timeout waiting for recording to load')+ }+ actions.loadNextSnapshotSource()+ await delay(delayTime)+ }+}++function debugReplayContextProviderId(props: SessionRecordingPlayerLogicProps): string {+ return `replay-debug-${props.playerKey}-${props.sessionRecordingId}`+}+export const sessionRecordingPlayerLogic = kea<sessionRecordingPlayerLogicType>([path((key) => ['scenes', 'session-recordings', 'player', 'sessionRecordingPlayerLogic', key]),props({} as SessionRecordingPlayerLogicProps),@@ -1398,6 +1521,10 @@ export const sessionRecordingPlayerLogic = kea<sessionRecordingPlayerLogicType>(['featureFlags'],exportsLogic,['hasReachedExportFullVideoLimit'],+ composerAttachmentsLogic({ attachmentsKey: MAX_SIDE_PANEL_ID }),+ ['attachments as sidePanelAttachments'],+ maxGlobalLogic,+ ['effectivePhaiView'],],actions: [snapshotDataLogic(props),@@ -1418,7 +1545,17 @@ export const sessionRecordingPlayerLogic = kea<sessionRecordingPlayerLogicType>(playerSettingsLogic,['setSpeed', 'setSkipInactivitySetting', 'setPlayerControlsOverlay'],sessionRecordingEventUsageLogic,- ['reportNextRecordingTriggered', 'reportRecordingExportedToFile'],+ ['reportNextRecordingTriggered', 'reportRecordingExportedToFile', 'reportRecordingDebuggedWithAI'],+ sidePanelStateLogic,+ ['openSidePanel'],+ attachedContextLogic,+ ['registerContext', 'deregisterContext'],+ composerAttachmentsLogic({ attachmentsKey: MAX_SIDE_PANEL_ID }),+ ['addFiles', 'removeAttachments'],+ runnerPanelLogic({ panelId: MAX_SIDE_PANEL_ID }),+ ['clearActiveCreation', 'setHistoryExpanded'],+ debugReplayChatLogic,+ ['debugChatRequested'],exportsLogic,['startReplayExport'],deletedRecordingsLogic,@@ -1467,6 +1604,8 @@ export const sessionRecordingPlayerLogic = kea<sessionRecordingPlayerLogicType>(flushDoctorDiagnostics: (diagnostics: DoctorDiagnostics) => ({ diagnostics }),syncSnapshotsWithPlayer: true,exportRecordingToFile: true,+ debugRecordingWithAI: true,+ setDebugRecordingPreparing: (preparing: boolean) => ({ preparing }),deleteRecording: true,openExplorer: true,takeScreenshot: true,@@ -1514,6 +1653,12 @@ export const sessionRecordingPlayerLogic = kea<sessionRecordingPlayerLogicType>(}),}),reducers(({ props }) => ({+ debugRecordingPreparing: [+ false as boolean,+ {+ setDebugRecordingPreparing: (_, { preparing }) => preparing,+ },+ ],// used in visual regression testing to make sure the player is pausedpauseForced: [false as boolean,@@ -3517,6 +3662,59 @@ export const sessionRecordingPlayerLogic = kea<sessionRecordingPlayerLogicType>(cache.pausedMediaElements = []},+ debugRecordingWithAI: async () => {+ if (!values.sessionRecordingId || values.debugRecordingPreparing) {+ return+ }+ actions.setDebugRecordingPreparing(true)+ try {+ await loadAllSnapshots(values, actions)+ } catch {+ lemonToast.error(+ "Couldn't load the recording data for PostHog AI. Wait for the recording to finish loading, then try again."+ )+ return+ } finally {+ actions.setDebugRecordingPreparing(false)+ }+ const exportedRecording = values.createExportJSON()+ // Registered before the panel opens so that the auto-submitted prompt carries the data.+ actions.registerContext(debugReplayContextProviderId(props), [+ buildDebugReplayDataContextItem(buildDebugReplayData(exportedRecording)),+ ])++ // An open run in the panel would take the prompt as a follow-up. Start a new chat for it.+ actions.clearActiveCreation()+ actions.setHistoryExpanded(false)+ const fileName = debugReplayFileName(props.sessionRecordingId)+ const recordingFile = new File(encodeRecording(exportedRecording), fileName, { type: 'application/json' })+ actions.removeAttachments(+ values.sidePanelAttachments.filter(({ file }) => file.name === fileName).map(({ id }) => id)+ )+ if (values.effectivePhaiView !== 'new') {+ lemonToast.warning(+ 'This version of PostHog AI chat cannot take file attachments. It gets a summary of the recording instead.'+ )+ } else if (recordingFile.size <= ATTACHMENT_MAX_SIZE_BYTES) {+ actions.addFiles([recordingFile])+ } else {+ lemonToast.warning(+ 'This recording is too large to attach as a file. PostHog AI gets a summary of it instead.'+ )+ }+ if (values.effectivePhaiView === 'new') {+ // The legacy chat does not create a task, so it leaves no chat to reopen.+ actions.debugChatRequested(values.sessionRecordingId)+ }+ // The side panel renders behind a fullscreen player.+ actions.setIsFullScreen(false)+ actions.openSidePanel(+ SidePanelTab.Max,+ autoRunMaxPrompt(buildDebugReplayPrompt(values.sessionRecordingId, values.currentPlayerTimeSeconds))+ )+ actions.reportRecordingDebuggedWithAI(values.currentPlayerTimeSeconds)+ },+exportRecordingToFile: async () => {if (!values.sessionPlayerData) {return@@ -3531,54 +3729,9 @@ export const sessionRecordingPlayerLogic = kea<sessionRecordingPlayerLogicType>(return}- const encodeRecording = (recording: ExportedSessionRecordingFileV2): string[] => {- let output = [- `{"version":"${recording.version}",`,- `"data":{"id":"${recording.data.id}",`,- `"person":${JSON.stringify(recording.data.person)},`,- `"snapshots":[`,- ]-- // Stringify the snapshots one-by-one to allow exports to work for very large recordings- for (const snapshot of recording.data.snapshots) {- output.push(JSON.stringify(snapshot))- output.push(',')- }- if (recording.data.snapshots.length > 0) {- output.pop()- }- output.push(']}}')-- return output- }-const doExport = async (): Promise<void> => {actions.setPause()- actions.loadAllSources()-- const delayTime = 1000- const maxStallIterations = 15- let stallCount = 0- let lastSnapshotCount = 0- while (!values.sessionPlayerData.fullyLoaded) {- const currentCount = values.sessionPlayerData.snapshotsByWindowId- ? Object.values(values.sessionPlayerData.snapshotsByWindowId).reduce(- (sum, snaps) => sum + snaps.length,- 0- )- : 0- if (currentCount > lastSnapshotCount) {- stallCount = 0- lastSnapshotCount = currentCount- } else {- stallCount++- }- if (stallCount >= maxStallIterations) {- throw new Error('Timeout waiting for recording to load')- }- actions.loadNextSnapshotSource()- await delay(delayTime)- }+ await loadAllSnapshots(values, actions)const exportedRecording = values.createExportJSON()@@ -3844,6 +3997,7 @@ export const sessionRecordingPlayerLogic = kea<sessionRecordingPlayerLogicType>(actions.setPlayer(null)actions.setRootFrame(null)+ actions.deregisterContext(debugReplayContextProviderId(props))if (props.mode === SessionRecordingPlayerMode.Preview) {returndiff --git a/frontend/src/scenes/session-recordings/sessionRecordingEventUsageLogic.ts b/frontend/src/scenes/session-recordings/sessionRecordingEventUsageLogic.tsindex 5ad7b9d828c2..def6b68ee5d7 100644--- a/frontend/src/scenes/session-recordings/sessionRecordingEventUsageLogic.ts+++ b/frontend/src/scenes/session-recordings/sessionRecordingEventUsageLogic.ts@@ -48,6 +48,12 @@ export interface sessionRecordingEventUsageLogicActions {reportNextRecordingTriggered: (automatic: boolean) => {automatic: boolean}+ reportRecordingDebugChatReopened: () => {+ value: true+ }+ reportRecordingDebuggedWithAI: (playerTimeSeconds: number) => {+ playerTimeSeconds: number+ }reportRecordingExportedToFile: (format: 'json' | 'mp4') => {format: 'json' | 'mp4'}@@ -181,6 +187,8 @@ export const sessionRecordingEventUsageLogic = kea<sessionRecordingEventUsageLogautomatic,}),reportRecordingExportedToFile: (format: 'json' | 'mp4') => ({ format }),+ reportRecordingDebuggedWithAI: (playerTimeSeconds: number) => ({ playerTimeSeconds }),+ reportRecordingDebugChatReopened: true,reportRecordingLoadedFromFile: (data: { success: boolean; error?: string }) => data,reportRecordingListVisibilityToggled: (type: string, visible: boolean) => ({ type, visible }),reportRecordingPinnedToList: (pinned: boolean) => ({ pinned }),@@ -268,6 +276,12 @@ export const sessionRecordingEventUsageLogic = kea<sessionRecordingEventUsageLogreportRecordingExportedToFile: ({ format }) => {posthog.capture('recording exported to file', { format })},+ reportRecordingDebuggedWithAI: ({ playerTimeSeconds }) => {+ posthog.capture('recording debugged with ai', { player_time_seconds: playerTimeSeconds })+ },+ reportRecordingDebugChatReopened: () => {+ posthog.capture('recording debug chat reopened')+ },reportRecordingLoadedFromFile: (properties) => {posthog.capture('recording loaded from file', properties)},diff --git a/products/posthog_ai/frontend/api/logics.ts b/products/posthog_ai/frontend/api/logics.tsindex 87181c775cad..099849f5ea39 100644--- a/products/posthog_ai/frontend/api/logics.ts+++ b/products/posthog_ai/frontend/api/logics.ts@@ -88,4 +88,6 @@ export type { RunnerPanelLogicProps, ActiveCreation } from '../logics/runnerPane// A one-shot store that lets a host seed a not-yet-mounted composer with an initial prompt (optionally// auto-submitting it); the paired `taskTrackerSceneLogic` consumes it on mount or when it arrives.export { composerSeedLogic } from '../logics/composerSeedLogic'+export { composerAttachmentsLogic } from '../logics/composerAttachmentsLogic'+export { ATTACHMENT_MAX_SIZE_BYTES } from '../utils/attachments'export type { ComposerSeed, ComposerSeedLogicProps } from '../logics/composerSeedLogic'diff --git a/products/replay_vision/frontend/components/ObservationsDock.tsx b/products/replay_vision/frontend/components/ObservationsDock.tsxindex f9c618534bea..15c73e5a5e77 100644--- a/products/replay_vision/frontend/components/ObservationsDock.tsx+++ b/products/replay_vision/frontend/components/ObservationsDock.tsx@@ -36,7 +36,12 @@ const DEFAULT_EXPANDED_HEIGHT = 480const MIN_EXPANDED_HEIGHT = 120const MAX_EXPANDED_HEIGHT = 800-export function ObservationsDock(): JSX.Element | null {+export function ObservationsDock({+ extraActions,+}: {+ /** Recording actions the host places beside the summarize button. */+ extraActions?: React.ReactNode+}): JSX.Element | null {const { sessionRecordingId, logicProps } = useValues(sessionRecordingPlayerLogic)// The dock is a sibling of the player frame, so it kept its summarize button on screen even when// the frame had swapped itself for the "Recording not found" or "deleted" screen — a control that@@ -46,7 +51,7 @@ export function ObservationsDock(): JSX.Element | null {if (!sessionRecordingId || isNotFound || isRecordingDeleted) {return null}- return <ObservationsDockContent sessionId={sessionRecordingId} />+ return <ObservationsDockContent sessionId={sessionRecordingId} extraActions={extraActions} />}/**@@ -229,7 +234,13 @@ function SummarizeExplainer(): JSX.Element {)}-function ObservationsDockContent({ sessionId }: { sessionId: string }): JSX.Element {+function ObservationsDockContent({+ sessionId,+ extraActions,+}: {+ sessionId: string+ extraActions?: React.ReactNode+}): JSX.Element {const logic = observationsDockLogic({ sessionId })const { observations, observationsLoading, dockOpen, retryingObservationIds, defaultSummarizer, summarizePending } =useValues(logic)@@ -278,6 +289,7 @@ function ObservationsDockContent({ sessionId }: { sessionId: string }): JSX.Elem<div className="flex items-center gap-2 lg:gap-3 h-11 px-3 shrink-0"><SummarizeButton sessionId={sessionId} scanBlock={scanBlock} /><SummarizeExplainer />+ {extraActions}{summarizeBlockedReason &&!hasContent && (// Collapsed with nothing to expand, the disabled button's tooltip is the only place