: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
fix(inbox): Correct session problem card timecodes and play affordance (#66799)
Michael Matloka743d35cfd7d4
diff --git a/ee/hogai/chat_agent/memory/prompts.py b/ee/hogai/chat_agent/memory/prompts.pyindex ce272a8c35a3..e85ab186271f 100644--- a/ee/hogai/chat_agent/memory/prompts.py+++ b/ee/hogai/chat_agent/memory/prompts.py@@ -202,6 +202,7 @@ We use the Oxford comma.Do not create links like "here" or "click here". All links should have relevant anchor text that describes what they link to.We always use sentence case rather than title case, including in titles, headings, subheadings, or bold text. However if quoting provided text, we keep the original case.When writing numbers in the thousands to the billions, it's acceptable to abbreviate them (like 10M or 100B - capital letter, no space). If you write out the full number, use commas (like 15,000,000).+Session replay is the product name; the sessions it captures are called session recordings. Refer to them as "session recordings" (not "session replays").</writing_style>""".strip()diff --git a/ee/hogai/chat_agent/prompts/base.py b/ee/hogai/chat_agent/prompts/base.pyindex 1e509bf9dab0..daa7aad22693 100644--- a/ee/hogai/chat_agent/prompts/base.py+++ b/ee/hogai/chat_agent/prompts/base.py@@ -27,6 +27,7 @@ We always use sentence case rather than title case, including in titles, headingWhen writing numbers in the thousands to the billions, it's acceptable to abbreviate them (like 10M or 100B - capital letter, no space). If you write out the full number, use commas (like 15,000,000).You can use light Markdown formatting for readability. Never use the em-dash (—) if you can use the en-dash (–).For headers, use sentence case rather than title case.+Session replay is the product name; the sessions it captures are called session recordings. Refer to them as "session recordings" (not "session replays").</writing_style>""".strip()diff --git a/frontend/src/scenes/inbox/components/signalCards/SessionReplaySignalCard.tsx b/frontend/src/scenes/inbox/components/signalCards/SessionReplaySignalCard.tsxindex 4a3029f76c78..75a2296f519a 100644--- a/frontend/src/scenes/inbox/components/signalCards/SessionReplaySignalCard.tsx+++ b/frontend/src/scenes/inbox/components/signalCards/SessionReplaySignalCard.tsx@@ -1,17 +1,20 @@-import { useValues } from 'kea'-import { useState } from 'react'+import clsx from 'clsx'+import { useActions, useValues } from 'kea'+import { useEffect, useState } from 'react'-import { IconBug, IconCursorClick, IconExternal, IconGlobe, IconKeyboard, IconPlay } from '@posthog/icons'-import { LemonButton, LemonTag, Link } from '@posthog/lemon-ui'+import { IconBug, IconCursorClick, IconGlobe, IconKeyboard, IconPlay } from '@posthog/icons'+import { LemonButton, LemonTag } from '@posthog/lemon-ui'import type { LemonTagType } from '@posthog/lemon-ui'-import ViewRecordingButton, { RecordingPlayerType } from 'lib/components/ViewRecordingButton/ViewRecordingButton'-import { dayjs } from 'lib/dayjs'+import { sessionRecordingInfoLogic } from 'lib/components/ViewRecordingButton/sessionRecordingInfoLogic'+import ViewRecordingButton, {+ RecordingPlayerType,+ useRecordingButton,+} from 'lib/components/ViewRecordingButton/ViewRecordingButton'+import { Dayjs, dayjs } from 'lib/dayjs'import { LemonMarkdown } from 'lib/lemon-ui/LemonMarkdown'-import { humanFriendlyDetailedTime } from 'lib/utils/datetime'-import { humanFriendlyDuration } from 'lib/utils/durations'+import { humanFriendlyDuration, reverseColonDelimitedDuration } from 'lib/utils/durations'import { teamLogic } from 'scenes/teamLogic'-import { urls } from 'scenes/urls'import { getExportsContentRetrieveUrl } from '~/generated/core/api'import type { SessionProblemEventEntry, SessionProblemSignalExtra } from '~/queries/schema/schema-signals'@@ -37,6 +40,18 @@ export function isSessionProblemExtra(return typeof extra.session_id === 'string' && 'problem_type' in extra}+/**+ * Segment and event times arrive as recording-relative offsets (`MM:SS` / `HH:MM:SS`), not datetimes.+ * Combine the offset with the session start to get an absolute timestamp the player can seek to.+ */+function recordingSeekTime(sessionStartTime: string | undefined, offset: string | undefined): Dayjs | undefined {+ const offsetSeconds = reverseColonDelimitedDuration(offset)+ if (!sessionStartTime || offsetSeconds === null) {+ return undefined+ }+ return dayjs(sessionStartTime).add(offsetSeconds, 'second')+}+/** Picks a glyph for a timeline event based on its interaction type. */function EventGlyph({ entry }: { entry: SessionProblemEventEntry }): JSX.Element {const className = 'size-3.5 shrink-0 text-tertiary'@@ -57,7 +72,15 @@ function EventGlyph({ entry }: { entry: SessionProblemEventEntry }): JSX.Element}/** A single row in the problem-event timeline; its time opens the recording at that moment. */-function TimelineRow({ entry, sessionId }: { entry: SessionProblemEventEntry; sessionId: string }): JSX.Element {+function TimelineRow({+ entry,+ sessionId,+ sessionStartTime,+}: {+ entry: SessionProblemEventEntry+ sessionId: string+ sessionStartTime: string | undefined+}): JSX.Element {const primaryText = entry.interaction_text?.trim() || entry.eventreturn (<li className="flex items-start gap-2 py-0.5">@@ -70,11 +93,11 @@ function TimelineRow({ entry, sessionId }: { entry: SessionProblemEventEntry; se</div><ViewRecordingButtonsessionId={sessionId}- timestamp={entry.timestamp}+ timestamp={recordingSeekTime(sessionStartTime, entry.timestamp)}openPlayerIn={RecordingPlayerType.Modal}size="xsmall"type="tertiary"- label={humanFriendlyDetailedTime(entry.timestamp)}+ label={entry.timestamp}/></li>)@@ -94,8 +117,22 @@ export function SessionReplaySignalCard({ signal }: SignalCardProps): JSX.Elemen? getExportsContentRetrieveUrl(String(currentTeamId), extra.exported_asset_id as number): undefined- const replayUrl = urls.replaySingle(extra.session_id, {- unixTimestampMillis: dayjs(extra.start_time).valueOf(),+ const segmentSeekTime = recordingSeekTime(extra.session_start_time, extra.start_time)++ // Mirror ViewRecordingButton's `checkRecordingExists`: batch-check the recording so the play+ // affordance disables (rather than opening an empty player) when the recording wasn't captured.+ const { checkRecordingInfo } = useActions(sessionRecordingInfoLogic)+ const { getRecordingExists } = useValues(sessionRecordingInfoLogic)+ useEffect(() => {+ checkRecordingInfo(extra.session_id)+ }, [extra.session_id, checkRecordingInfo])+ const hasRecording = getRecordingExists(extra.session_id)++ const { onClick: openRecording, disabledReason } = useRecordingButton({+ sessionId: extra.session_id,+ timestamp: segmentSeekTime,+ openPlayerIn: RecordingPlayerType.Modal,+ hasRecording,})const events = extra.event_history ?? []@@ -124,50 +161,42 @@ export function SessionReplaySignalCard({ signal }: SignalCardProps): JSX.Elemen</LemonMarkdown>)}- {/* 16:9 framed preview: eager thumbnail when an export exists, otherwise a play affordance. */}- <div className="relative w-full aspect-video rounded overflow-hidden border bg-surface-secondary mb-2">- {thumbnailSrc ? (- <>- <img- src={thumbnailSrc}- alt={`Recording preview for ${extra.segment_title}`}- className="absolute inset-0 size-full object-cover"- onError={() => setThumbnailFailed(true)}- />- <div className="absolute inset-0 flex items-center justify-center bg-black/20">- <ViewRecordingButton- sessionId={extra.session_id}- timestamp={extra.start_time}- openPlayerIn={RecordingPlayerType.Modal}- checkRecordingExists- size="small"- type="primary"- label="Play"- />- </div>- </>- ) : (- <div className="absolute inset-0 flex flex-col items-center justify-center gap-1 text-tertiary">- <IconPlay className="size-6" aria-hidden />- <ViewRecordingButton- sessionId={extra.session_id}- timestamp={extra.start_time}- openPlayerIn={RecordingPlayerType.Modal}- checkRecordingExists- size="small"- type="secondary"- label="Play recording"- />- </div>+ {/* The 16:9 preview frame is itself the play affordance — clicking it opens the recording at the segment. */}+ <button+ type="button"+ onClick={openRecording}+ disabled={!!disabledReason}+ title={typeof disabledReason === 'string' ? disabledReason : undefined}+ aria-label="Play recording"+ className="group relative w-full aspect-video rounded overflow-hidden border bg-surface-secondary mb-2 cursor-pointer disabled:cursor-default disabled:opacity-70"+ >+ {thumbnailSrc && (+ <img+ src={thumbnailSrc}+ alt={`Recording preview for ${extra.segment_title}`}+ className="absolute inset-0 size-full object-cover"+ onError={() => setThumbnailFailed(true)}+ />)}- </div>+ <div+ className={clsx(+ 'absolute inset-0 flex items-center justify-center transition-colors',+ thumbnailSrc ? 'bg-black/20 group-hover:bg-black/30' : 'group-hover:bg-fill-highlight-100'+ )}+ >+ <IconPlay+ className={clsx('size-10 drop-shadow', thumbnailSrc ? 'text-white' : 'text-tertiary')}+ aria-hidden+ />+ </div>+ </button>{/* Dot-separated meta line: affected user, segment window, active/total duration. */}<div className="flex items-center gap-1.5 flex-wrap text-xs text-tertiary mb-2"><span className="font-mono">{extra.distinct_id.slice(0, 10)}…</span><span>·</span>- <span>- {humanFriendlyDetailedTime(extra.start_time)} – {humanFriendlyDetailedTime(extra.end_time)}+ <span className="font-mono">+ {extra.start_time} – {extra.end_time}</span>{(activeDuration || totalDuration) && (<>@@ -190,6 +219,7 @@ export function SessionReplaySignalCard({ signal }: SignalCardProps): JSX.Elemenkey={`${entry.timestamp}-${index}`}entry={entry}sessionId={extra.session_id}+ sessionStartTime={extra.session_start_time}/>))}</ul>@@ -205,13 +235,6 @@ export function SessionReplaySignalCard({ signal }: SignalCardProps): JSX.Elemen)}</div>)}-- <div className="flex items-center mt-2">- <span className="flex-1" />- <Link to={replayUrl} className="flex items-center gap-1 text-xs font-medium shrink-0">- Open replay <IconExternal className="size-3" />- </Link>- </div></SignalCardShell>)}diff --git a/products/posthog_ai/backend/services/system_prompt/prompt.py b/products/posthog_ai/backend/services/system_prompt/prompt.pyindex bcec5757f9a8..dfa6b10a98bf 100644--- a/products/posthog_ai/backend/services/system_prompt/prompt.py+++ b/products/posthog_ai/backend/services/system_prompt/prompt.py@@ -64,4 +64,5 @@ Do not use acronyms when you can avoid them. Acronyms have the effect of excludiWe always use sentence case rather than title case, including in titles, headings, subheadings, or bold text. However if quoting provided text, we keep the original case.When writing numbers in the thousands to the billions, it's acceptable to abbreviate them (like 10M or 100B - capital letter, no space). If you write out the full number, use commas (like 15,000,000).You can use light Markdown formatting for readability. Never use the em-dash (—) if you can use the en-dash (–).+Session replay is the product name; the sessions it captures are called session recordings. Refer to them as "session recordings" (not "session replays")."""diff --git a/products/signals/backend/report_generation/research.py b/products/signals/backend/report_generation/research.pyindex 3dd008b70e45..d21e5daff179 100644--- a/products/signals/backend/report_generation/research.py+++ b/products/signals/backend/report_generation/research.py@@ -330,6 +330,7 @@ We use the Oxford comma.We always use sentence case rather than title case, including in titles, headings, subheadings, or bold text. However if quoting provided text, we keep the original case.When writing numbers in the thousands to the billions, it's acceptable to abbreviate them (like 10M or 100B - capital letter, no space). If you write out the full number, use commas (like 15,000,000).We never use the em-dash, only the en-dash (–).+Session replay is the product name; the sessions it captures are called session recordings. Refer to them as "session recordings" (not "session replays").</writing_guide>You have two investigation tools:diff --git a/products/signals/backend/scout_harness/prompt.py b/products/signals/backend/scout_harness/prompt.pyindex 02729687b02a..66f9087eed51 100644--- a/products/signals/backend/scout_harness/prompt.py+++ b/products/signals/backend/scout_harness/prompt.py@@ -453,6 +453,15 @@ you this run.run (emit / remember / summary) exactly as you would otherwise.- Never put customer PII or sensitive query content in a feedback field."""+_WRITING_STYLE = """# Writing style++- We use American English and the Oxford comma.+- Sentence case rather than title case, including in titles, headings, subheadings, and bold text (keep the original case when quoting provided text).+- When writing numbers in the thousands to the billions, abbreviate them (like 10M or 100B, capital letter, no space) or write the full number with commas (like 15,000,000).+- Never use the em-dash (—); use the en-dash (–).+- Session replay is the product name; the sessions it captures are called session recordings. Refer to them as "session recordings" (not "session replays")."""++_OUTPUT_FORMAT = """# Output formatRespond at end_turn with a single JSON object matching this schema:@@ -469,6 +478,7 @@ _SIGNAL_TAIL_SECTIONS = [_FINDING_SCHEMA,_TAGGING,_WRITING_DESCRIPTION_SIGNAL,+ _WRITING_STYLE,_WRITING_SUMMARY,_BUSINESS_KNOWLEDGE,_DEDUPE_RULES_SIGNAL,@@ -511,6 +521,7 @@ def _report_tail_sections(*, can_emit: bool, can_edit: bool) -> list[str]:_SCRATCHPAD_KEYS,_RECENCY_LENS,*channel_sections,+ _WRITING_STYLE,_WRITING_SUMMARY,_BUSINESS_KNOWLEDGE,_GROUND_RULES,diff --git a/products/signals/backend/test/test_scout_harness.py b/products/signals/backend/test/test_scout_harness.pyindex 0cbd63e58f97..0014bc69b092 100644--- a/products/signals/backend/test/test_scout_harness.py+++ b/products/signals/backend/test/test_scout_harness.py@@ -185,6 +185,9 @@ class TestPromptBuilder(BaseTest):# surface (markdown, front-loaded into the ~300-char collapsed preview),# while leaving a skill body free to impose its own structure.assert "Writing the description (how it renders in the inbox)" in prompt+ # The writing-style section is wired into the tail, carrying the+ # session-replay-vs-recording terminology rule scouts must follow.+ assert "session recordings" in prompt# A signal scout never sees the report-channel guidance — it fires weak# signals, it does not author reports.assert "signals-scout-emit-report" not in prompt