: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(replay-vision): show scan prompt beside verdict on recording (#102634)
Kim Svatos Dugand69d4cdeda0b
diff --git a/products/replay_vision/frontend/components/ObservationCard.test.tsx b/products/replay_vision/frontend/components/ObservationCard.test.tsxindex 3937fd96ed88..7d0ee0fbea46 100644--- a/products/replay_vision/frontend/components/ObservationCard.test.tsx+++ b/products/replay_vision/frontend/components/ObservationCard.test.tsx@@ -49,4 +49,25 @@ describe('ObservationDockCard', () => {await waitFor(() => expect(scannerRetrieveCalls).toBe(0))expect(router.values.location.pathname).toBe(startPath)})++ // A monitor verdict is meaningless without its question, so the prompt must stay on the card and not+ // hide behind the details page.+ it('shows the prompt beside a monitor verdict', async () => {+ const monitor = {+ id: 'obs-2',+ scanner_id: 'inline-scanner-2',+ session_id: 'sess-1',+ status: 'succeeded',+ scanner_snapshot: {+ name: '',+ scanner_type: 'monitor',+ scanner_config: { prompt: 'Did the user complete checkout?' },+ },+ scanner_result: { model_output: { scanner_type: 'monitor', verdict: 'yes' } },+ } as unknown as ReplayObservationApi++ render(<ObservationDockCard observation={monitor} />)++ await screen.findByText('Did the user complete checkout?')+ })})diff --git a/products/replay_vision/frontend/components/ObservationCard.tsx b/products/replay_vision/frontend/components/ObservationCard.tsxindex 431f0acfb20b..90d874609181 100644--- a/products/replay_vision/frontend/components/ObservationCard.tsx+++ b/products/replay_vision/frontend/components/ObservationCard.tsx@@ -1,7 +1,10 @@-import { IconCopy, IconSparkles } from '@posthog/icons'+import { useState } from 'react'++import { IconChevronRight, IconCopy, IconSparkles } from '@posthog/icons'import { LemonButton, LemonTag, Link, Spinner, Tooltip } from '@posthog/lemon-ui'import { copyToClipboard } from 'lib/utils/copyToClipboard'+import { cn } from 'lib/utils/css-classes'import { urls } from 'scenes/urls'import type { ReplayObservationApi } from '../generated/api.schemas'@@ -318,6 +321,34 @@ export function ObservationPrimaryOutput({)}+// A reader opens an observation for the result, not the prompt they configured. Collapse the prompt to one+// peek line so the verdict and reasoning stay above the fold, but keep it in view so the verdict has context.+export function PromptRow({ prompt }: { prompt: string }): JSX.Element {+ const [expanded, setExpanded] = useState(false)+ return (+ <div>+ <button+ type="button"+ className="flex items-center gap-0.5 text-xs text-muted mb-0.5 hover:text-default"+ onClick={() => setExpanded(!expanded)}+ aria-expanded={expanded}+ data-attr="vision-observation-prompt-toggle"+ >+ <IconChevronRight className={cn('transition-transform', expanded && 'rotate-90')} />+ Prompt+ </button>+ <p+ className={cn(+ 'text-sm m-0 leading-snug',+ expanded ? 'text-default whitespace-pre-wrap' : 'text-muted line-clamp-1'+ )}+ >+ {prompt}+ </p>+ </div>+ )+}+export function ObservationConfidence({result,standalone = false,@@ -414,6 +445,9 @@ export function ObservationDockCard({const snapshot = observation.scanner_snapshotconst scannerType = snapshot?.scanner_typeconst result = readResult(observation)+ // The prompt is the question the scan judged, so it gives the verdict its meaning. Show it inline here so a+ // reader does not have to open the details page to know what "Yes" answered.+ const prompt = snapshot ? (configFromSnapshot(snapshot)?.prompt ?? null) : null// Summarizers excluded: their primary output already is the full textconst reasoning =observation.status === 'succeeded' && scannerType !== 'summarizer' ? readReasoning(observation) : null@@ -484,6 +518,7 @@ export function ObservationDockCard({copyable/></LabeledRow>+ {prompt && scannerType !== 'summarizer' && <PromptRow prompt={prompt} />}{reasoning && (<LabeledRow label="Model reasoning"><CitedMarkdown text={reasoning} segments={result.reasoning_segments} onSeek={onSeek} />diff --git a/products/replay_vision/frontend/observations/ReplayObservation.tsx b/products/replay_vision/frontend/observations/ReplayObservation.tsxindex 1dba206ee8e8..197b5bfcdffe 100644--- a/products/replay_vision/frontend/observations/ReplayObservation.tsx+++ b/products/replay_vision/frontend/observations/ReplayObservation.tsx@@ -5,7 +5,6 @@ import { Suspense, useEffect, useState } from 'react'import {IconArrowLeft,IconArrowRight,- IconChevronRight,IconClock,IconCollapse,IconExpand,@@ -24,7 +23,6 @@ import { dayjs } from 'lib/dayjs'import { ProfilePicture } from 'lib/lemon-ui/ProfilePicture'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { useAttachedLogic } from 'lib/logic/scenes/useAttachedLogic'-import { cn } from 'lib/utils/css-classes'import { humanFriendlyDuration, humanFriendlyMilliseconds } from 'lib/utils/durations'import { lazyWithRetry } from 'lib/utils/retryImport'import { SceneExport } from 'scenes/sceneTypes'@@ -42,6 +40,7 @@ import {ObservationConfidence,ObservationPrimaryOutput,ObservationStatusTag,+ PromptRow,readResult,} from '../components/ObservationCard'import { ObservationProgressBar } from '../components/ObservationProgressBar'@@ -87,34 +86,6 @@ export const scene: SceneExport = {productKey: ProductKey.REPLAY_VISION,}-// A reader opens an observation for the result, not the prompt they configured. Collapse the prompt to one-// peek line so the verdict and reasoning stay above the fold.-function PromptRow({ prompt }: { prompt: string }): JSX.Element {- const [expanded, setExpanded] = useState(false)- return (- <div>- <button- type="button"- className="flex items-center gap-0.5 text-xs text-muted mb-0.5 hover:text-default"- onClick={() => setExpanded(!expanded)}- aria-expanded={expanded}- data-attr="vision-observation-prompt-toggle"- >- <IconChevronRight className={cn('transition-transform', expanded && 'rotate-90')} />- Prompt- </button>- <p- className={cn(- 'text-sm m-0 leading-snug',- expanded ? 'text-default whitespace-pre-wrap' : 'text-muted line-clamp-1'- )}- >- {prompt}- </p>- </div>- )-}-/** Rating happens here, not in the Calibration tab, so a rater never sees the recommendation it feeds. */function CalibrationEntryPoint({ observation }: { observation: ReplayObservationApi }): JSX.Element | null {const { featureFlags } = useValues(featureFlagLogic)