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-vision): tooltips for prompts and ui fixes (#74207)

Hayne Ryu39982f45cf1c
diff --git a/products/replay_vision/backend/temporal/activities/emit_observation_event.py b/products/replay_vision/backend/temporal/activities/emit_observation_event.py
index fc2970a807ed..b89e69247225 100644
--- a/products/replay_vision/backend/temporal/activities/emit_observation_event.py
+++ b/products/replay_vision/backend/temporal/activities/emit_observation_event.py
@@ -64,8 +64,7 @@ def _emit_event(inputs: EmitObservationEventInputs) -> None:
"triggered_by_user_id": observation.triggered_by_user_id,
"model_used": snapshot.model,
"provider_used": snapshot.provider,
- # Priced at emit time and frozen into the event, so spend charts can drift from
- # quota.py's repriced-at-current-rates totals after a price change.
+ # Priced at emit time, so it can drift from quota.py's repriced-at-current-rates totals.
"credits": observation_credits_for_model(snapshot.model),
"emits_signals": snapshot.emits_signals,
# Flatten scanner output so HogQL can query individual fields without a JSON extract.
diff --git a/products/replay_vision/frontend/components/ObservationCard.tsx b/products/replay_vision/frontend/components/ObservationCard.tsx
index 0ab820dd3bda..ab635dab2ce3 100644
--- a/products/replay_vision/frontend/components/ObservationCard.tsx
+++ b/products/replay_vision/frontend/components/ObservationCard.tsx
@@ -35,9 +35,16 @@ export function ObservationStatusTag({
return <LemonTag type="success">Succeeded</LemonTag>
}
if (status === 'failed') {
- // Raw exception text lives in `FailureDetail`; tooltip is the description only.
+ // Raw exception text lives in `FailureDetail`.
const parsed = errorReason ? parseFailureReason(errorReason) : null
- const tooltip = parsed ? failureKindDescription(parsed.kind) : errorReason || null
+ const tooltip = parsed ? (
+ <div className="flex flex-col gap-1">
+ <div>{parsed.label}</div>
+ <div className="text-xs opacity-80">{failureKindDescription(parsed.kind)}</div>
+ </div>
+ ) : (
+ errorReason || null
+ )
return (
<Tooltip title={tooltip}>
<LemonTag type="danger">Failed</LemonTag>
@@ -141,7 +148,10 @@ export function ObservationPrimaryOutput({
}
const scannerType = snapshot.scanner_type
const config = configFromSnapshot(snapshot)
- const prompt = showPrompt ? (config?.prompt ?? null) : null
+ const promptText = config?.prompt ?? null
+ const prompt = showPrompt ? promptText : null
+ // Tooltip carries the prompt only when it isn't printed inline.
+ const promptTooltip = prompt ? null : promptText
const summaryClass = expandSummary ? 'text-sm whitespace-pre-wrap' : compact ? 'text-sm truncate' : 'text-sm'
const bodyClass = compact ? 'text-sm truncate' : 'text-sm'
const promptClass = 'text-xs text-muted'
@@ -161,9 +171,11 @@ export function ObservationPrimaryOutput({
verdict === 'yes' ? 'Yes' : verdict === 'no' ? 'No' : verdict === 'inconclusive' ? 'Inconclusive' : '—'
return (
<div className="flex flex-col gap-1">
- <LemonTag size="medium" type={tagType} className="self-start">
- {tagLabel}
- </LemonTag>
+ <Tooltip title={promptTooltip}>
+ <LemonTag size="medium" type={tagType} className="self-start">
+ {tagLabel}
+ </LemonTag>
+ </Tooltip>
{prompt && <span className={promptClass}>{prompt}</span>}
</div>
)
@@ -283,11 +295,13 @@ export function ObservationPrimaryOutput({
const displayLabel = resultLabel ?? scaleLabel
return (
<div className="flex flex-col gap-1">
- <span className="text-sm">
- <span className="font-semibold text-base">{score ?? '—'}</span>
- {scaleMax !== null && <span className="text-muted"> / {scaleMax}</span>}
- {displayLabel && <span className="text-muted"> — {displayLabel}</span>}
- </span>
+ <Tooltip title={promptTooltip}>
+ <span className="text-sm self-start">
+ <span className="font-semibold text-base">{score ?? '—'}</span>
+ {scaleMax !== null && <span className="text-muted"> / {scaleMax}</span>}
+ {displayLabel && <span className="text-muted"> — {displayLabel}</span>}
+ </span>
+ </Tooltip>
{prompt && <span className={promptClass}>{prompt}</span>}
</div>
)
diff --git a/products/replay_vision/frontend/replay_scanners/components/ScannerObservationsTable.tsx b/products/replay_vision/frontend/replay_scanners/components/ScannerObservationsTable.tsx
index 214114c55afe..e2403a96eb29 100644
--- a/products/replay_vision/frontend/replay_scanners/components/ScannerObservationsTable.tsx
+++ b/products/replay_vision/frontend/replay_scanners/components/ScannerObservationsTable.tsx
@@ -1,6 +1,6 @@
import { useActions, useValues } from 'kea'
-import { IconEye, IconPlay, IconRefresh } from '@posthog/icons'
+import { IconCopy, IconEye, IconPlay, IconRefresh } from '@posthog/icons'
import { LemonButton, LemonInput, LemonTable, LemonTag, LemonTagType, Link, Tooltip } from '@posthog/lemon-ui'
import { DateFilter } from 'lib/components/DateFilter/DateFilter'
@@ -99,6 +99,7 @@ export function ScannerObservationsTable({ scannerId }: { scannerId: string }):
scanner,
triggeringOnDemandObservation,
retryingObservationIds,
+ copyingAllObservations,
} = useValues(logic)
const {
refreshObservations,
@@ -112,6 +113,7 @@ export function ScannerObservationsTable({ scannerId }: { scannerId: string }):
setObservationSubjectFilter,
setObservationDateRange,
clearObservationFilters,
+ copyAllObservations,
} = useActions(logic)
const scannerType = scanner?.scanner_type
const tagFilterOptions = availableTags.map((tag) => ({ value: tag, label: tag }))
@@ -299,6 +301,19 @@ export function ScannerObservationsTable({ scannerId }: { scannerId: string }):
</LemonButton>
</>
)}
+ {scannerType === 'summarizer' && observationStats.total > 0 && (
+ <LemonButton
+ size="small"
+ type="secondary"
+ icon={<IconCopy />}
+ onClick={() => copyAllObservations()}
+ loading={copyingAllObservations}
+ tooltip="Copies the filtered summaries as plain text, ready to paste into a doc or an LLM"
+ data-attr="vision-observations-copy-all"
+ >
+ Copy all
+ </LemonButton>
+ )}
<Tooltip
title={
hasObservationsInFlight
diff --git a/products/replay_vision/frontend/replay_scanners/components/VisionUsageTab.tsx b/products/replay_vision/frontend/replay_scanners/components/VisionUsageTab.tsx
index 8ac4b0db778f..bd505168092f 100644
--- a/products/replay_vision/frontend/replay_scanners/components/VisionUsageTab.tsx
+++ b/products/replay_vision/frontend/replay_scanners/components/VisionUsageTab.tsx
@@ -1,7 +1,7 @@
import { useActions, useValues } from 'kea'
import { useMemo } from 'react'
-import { LemonSegmentedButton, LemonTable, LemonTag, Link } from '@posthog/lemon-ui'
+import { LemonSegmentedButton, LemonTable, LemonTag, Link, Tooltip } from '@posthog/lemon-ui'
import { LemonProgress } from 'lib/lemon-ui/LemonProgress'
import { LemonTableColumns } from 'lib/lemon-ui/LemonTable'
@@ -11,7 +11,7 @@ import { InsightVizNode, NodeKind, ProductKey } from '~/queries/schema/schema-ge
import { BaseMathType, ChartDisplayType, InsightLogicProps, PropertyFilterType, PropertyOperator } from '~/types'
import { visionQuotaLogic } from '../../logics/visionQuotaLogic'
-import { formatCredits } from '../../utils/credits'
+import { creditsToUsd, formatCreditCount, formatCredits, formatCreditsRange } from '../../utils/credits'
import { exhaustionForecast, hasCreditLimit, projectQuota } from '../../utils/quotaProjection'
import { OBSERVATION_CREDITS_BY_MODEL, ReplayScanner, modelName } from '../types'
import { SpendChartInterval, visionUsageLogic } from '../visionUsageLogic'
@@ -23,19 +23,14 @@ const SPEND_CHART_INTERVAL_OPTIONS: { value: SpendChartInterval; label: string }
{ value: 'day', label: 'Daily' },
{ value: 'week', label: 'Weekly' },
{ value: 'month', label: 'Monthly' },
- { value: 'year', label: 'Yearly' },
]
-// Daily covers the current billing period (set at query time); the rest widen the window to fit the bucket size.
const SPEND_CHART_DATE_FROM: Record<Exclude<SpendChartInterval, 'day'>, string> = {
week: '-90d',
month: '-365d',
- year: 'all',
}
-// Spend is counted per model and priced in the formula rather than summing the `credits` event property:
-// events emitted before that property existed would otherwise read as zero spend. Pricing counts at current
-// rates matches how the table's totals are computed. Retired models missing from the price table are omitted.
+// Counted per model and priced in the formula: events predating the `credits` property would sum to zero.
const SPEND_CHART_MODEL_PRICES = Object.entries(OBSERVATION_CREDITS_BY_MODEL)
const SPEND_CHART_SERIES = SPEND_CHART_MODEL_PRICES.map(([model]) => ({
kind: NodeKind.EventsNode as const,
@@ -68,10 +63,8 @@ export function VisionUsageTab(): JSX.Element {
const spenders = usageScanners.filter((s: ReplayScanner) => s.credits_this_month > 0)
const zeroSpendCount = usageScanners.length - spenders.length
const totalCredits = spenders.reduce((sum: number, s: ReplayScanner) => sum + s.credits_this_month, 0)
- const maxCredits = spenders.length > 0 ? spenders[0].credits_this_month : 0
- // Memoized so a re-render (e.g. quota arriving) can't churn the query and abort an in-flight load.
- // `tags.productKey` is required for ClickHouse query tagging; without it the runner aborts.
+ // Memoized so re-renders can't churn the query; `tags.productKey` is required or the runner aborts.
const spendChartQuery = useMemo<InsightVizNode>(
() => ({
kind: NodeKind.InsightVizNode,
@@ -80,7 +73,7 @@ export function VisionUsageTab(): JSX.Element {
series: SPEND_CHART_SERIES,
trendsFilter: {
display: ChartDisplayType.ActionsLineGraph,
- // 1 credit = $0.01; the /100 in the formula charts dollars to match the table.
+ // The /100 charts dollars (1 credit = $0.01).
formulaNodes: [{ formula: SPEND_CHART_FORMULA, custom_name: 'Spend' }],
aggregationAxisPrefix: '$',
},
@@ -155,14 +148,13 @@ export function VisionUsageTab(): JSX.Element {
width: '30%',
render: (_, scanner) => {
const sharePct = totalCredits > 0 ? Math.round((scanner.credits_this_month / totalCredits) * 100) : 0
- const barPct = maxCredits > 0 ? Math.round((scanner.credits_this_month / maxCredits) * 100) : 0
return (
- <div className="flex items-center gap-2 pr-6">
- <LemonProgress percent={barPct} className="flex-1" />
- <span className="text-sm tabular-nums whitespace-nowrap w-32 text-right">
- {formatCredits(scanner.credits_this_month)}{' '}
- <span className="text-muted">({sharePct}%)</span>
+ <div className="flex flex-col gap-1">
+ <span className="text-sm tabular-nums flex items-baseline justify-between gap-2">
+ {formatCredits(scanner.credits_this_month)}
+ <span className="text-muted">{sharePct}%</span>
</span>
+ <LemonProgress percent={sharePct} />
</div>
)
},
@@ -176,11 +168,19 @@ export function VisionUsageTab(): JSX.Element {
<h3 className="text-base font-semibold m-0">Spend over time</h3>
<div className="flex items-center gap-3">
{quota && (
- <span className="text-xs text-muted tabular-nums">
- {formatCredits(quota.credits_used)}
- {hasCap ? ` of ${formatCredits(quota.credit_limit ?? 0)}` : ''} this period
- {projection.resetsOn ? `, resets ${projection.resetsOn}` : ''}
- </span>
+ <Tooltip
+ title={`≈ ${creditsToUsd(quota.credits_used)}${
+ hasCap ? ` of ${creditsToUsd(quota.credit_limit ?? 0)}` : ''
+ }`}
+ >
+ <span className="text-xs text-muted tabular-nums">
+ {hasCap
+ ? formatCreditsRange(quota.credits_used, quota.credit_limit ?? 0)
+ : formatCreditCount(quota.credits_used)}{' '}
+ this period
+ {projection.resetsOn ? `, resets ${projection.resetsOn}` : ''}
+ </span>
+ </Tooltip>
)}
<LemonSegmentedButton
size="small"
diff --git a/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts b/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts
index fc3333c14a53..ecfd67ed824d 100644
--- a/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts
+++ b/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts
@@ -18,6 +18,7 @@ import { actionToUrl, beforeUnload, router, urlToAction } from 'kea-router'
import { CombinedLocation } from 'kea-router/lib/utils'
import { lemonToast } from 'lib/lemon-ui/LemonToast'
+import { copyToClipboard } from 'lib/utils/copyToClipboard'
import { objectsEqual } from 'lib/utils/objects'
import { recordingsQueryToUniversalFilters } from 'scenes/session-recordings/filters/recordingsQueryConversions'
import { teamLogic } from 'scenes/teamLogic'
@@ -47,6 +48,7 @@ import type { ScannerTypeEnumApi } from '../generated/api.schemas'
import { OBSERVE_POLL_GRACE_MS, scheduleObservationPoll, shouldPollObservations } from '../logics/observationPolling'
import { requestObservationRetry } from '../logics/observationRetry'
import { refreshVisionQuota } from '../logics/visionQuotaLogic'
+import { observationClipboardText } from '../utils/observation'
import { type UrlSorting, parseCsvParam, parseSortParam, serializeSortParam } from '../utils/urlParams'
import { clampDurationFilter, durationFilterError } from './durationBounds'
import { SCANNER_EDITOR_STEPS, scannerEditorSceneLogic, scannerStepUrl } from './scannerEditorSceneLogic'
@@ -76,6 +78,8 @@ const OBSERVATION_TRIGGERED_BY_VALUES: readonly ObservationTriggeredByValue[] =
const OBSERVATION_VERDICT_VALUES: readonly ObservationVerdictValue[] = ['yes', 'no', 'inconclusive']
export const OBSERVATIONS_PAGE_SIZE = 50
+// Past this many rows the clipboard is the wrong tool.
+const COPY_ALL_OBSERVATIONS_LIMIT = 500
function currentTemplateKey(): string | null {
const value = router.values.searchParams.template
@@ -213,6 +217,7 @@ export interface replayScannerLogicValues {
availableTags: string[]
chartDateFrom: string | null
chartDateTo: string | null
+ copyingAllObservations: boolean
durationValidationError: string | null
estimateRequestVersion: number
hasActiveObservationFilters: boolean
@@ -278,6 +283,12 @@ export interface replayScannerLogicActions {
clearObservationFilters: () => {
value: true
}
+ copyAllObservations: () => {
+ value: true
+ }
+ copyAllObservationsFinished: () => {
+ value: true
+ }
dismissTagSuggestions: () => {
value: true
}
@@ -601,6 +612,8 @@ export const replayScannerLogic = kea<replayScannerLogicType>([
retryObservationSuccess: (observationId: string) => ({ observationId }),
retryObservationFailure: (observationId: string) => ({ observationId }),
refreshObservations: true,
+ copyAllObservations: true,
+ copyAllObservationsFinished: true,
}),
forms(({ props, values, actions }) => ({
@@ -787,6 +800,13 @@ export const replayScannerLogic = kea<replayScannerLogicType>([
triggerOnDemandObservationFailure: () => false,
},
],
+ copyingAllObservations: [
+ false,
+ {
+ copyAllObservations: () => true,
+ copyAllObservationsFinished: () => false,
+ },
+ ],
onDemandObservationSuccessCount: [
0,
{
@@ -1312,6 +1332,36 @@ export const replayScannerLogic = kea<replayScannerLogicType>([
refreshObservations: () => reloadObservationsAndStats(),
+ copyAllObservations: async (_, breakpoint) => {
+ try {
+ const teamId = teamLogic.values.currentTeamId
+ if (props.id === 'new' || !teamId) {
+ return
+ }
+ // Only succeeded rows have a result body to paste.
+ const params = {
+ ...buildObservationListParams(values, COPY_ALL_OBSERVATIONS_LIMIT, 0),
+ status: 'succeeded',
+ }
+ const response = await visionScannersObservationsList(String(teamId), props.id, params)
+ breakpoint()
+ const results = (response.results ?? []) as ReplayObservationApi[]
+ const texts = results.map(observationClipboardText).filter((text): text is string => text !== null)
+ if (texts.length === 0) {
+ lemonToast.info('No results to copy for the current filters.')
+ return
+ }
+ const count = response.count ?? texts.length
+ const description =
+ count > results.length
+ ? `the latest ${texts.length.toLocaleString()} of ${count.toLocaleString()} results`
+ : `${texts.length.toLocaleString()} result${texts.length === 1 ? '' : 's'}`
+ await copyToClipboard(texts.join('\n\n---\n\n'), description)
+ } finally {
+ actions.copyAllObservationsFinished()
+ }
+ },
+
loadObservations: async (_, breakpoint) => {
if (props.id === 'new') {
actions.loadObservationsSuccess([], 0)
diff --git a/products/replay_vision/frontend/replay_scanners/visionUsageLogic.ts b/products/replay_vision/frontend/replay_scanners/visionUsageLogic.ts
index e63989ae059d..3dcbe66744da 100644
--- a/products/replay_vision/frontend/replay_scanners/visionUsageLogic.ts
+++ b/products/replay_vision/frontend/replay_scanners/visionUsageLogic.ts
@@ -8,7 +8,7 @@ import { IntervalType } from '~/types'
import { visionScannersList } from '../generated/api'
import type { ReplayScanner } from './types'
-export type SpendChartInterval = Extract<IntervalType, 'day' | 'week' | 'month' | 'year'>
+export type SpendChartInterval = Extract<IntervalType, 'day' | 'week' | 'month'>
interface visionUsageLogicValues {
usageScanners: ReplayScanner[]
diff --git a/products/replay_vision/frontend/utils/observation.test.ts b/products/replay_vision/frontend/utils/observation.test.ts
new file mode 100644
index 000000000000..0a28509f05fe
--- /dev/null
+++ b/products/replay_vision/frontend/utils/observation.test.ts
@@ -0,0 +1,44 @@
+import type { ReplayObservationApi } from '../generated/api.schemas'
+import { observationClipboardText } from './observation'
+
+function makeObservation(
+ scannerType: string,
+ modelOutput: Record<string, unknown> | null,
+ status: ReplayObservationApi['status'] = 'succeeded'
+): ReplayObservationApi {
+ return {
+ id: 'obs-1',
+ session_id: 'sess-1',
+ status,
+ created_at: '2026-07-27T10:00:00Z',
+ scanner_snapshot: { scanner_type: scannerType },
+ scanner_result: modelOutput ? { model_output: modelOutput } : null,
+ } as unknown as ReplayObservationApi
+}
+
+describe('observationClipboardText', () => {
+ it.each<{ name: string; obs: ReplayObservationApi; expected: string | null }>([
+ {
+ name: 'summarizer: title headline, summary body with citations as plain timestamps',
+ obs: makeObservation('summarizer', { title: 'Checkout rage', summary: 'Rage clicked pay (t 161).' }),
+ expected: '[2026-07-27 · sess-1] Checkout rage\nRage clicked pay (02:41).',
+ },
+ {
+ name: 'monitor: verdict headline, reasoning body',
+ obs: makeObservation('monitor', { verdict: 'yes', reasoning: 'Error toast shown.' }),
+ expected: '[2026-07-27 · sess-1] Verdict: yes\nError toast shown.',
+ },
+ {
+ name: 'failed observations are excluded',
+ obs: makeObservation('monitor', { verdict: 'yes' }, 'failed'),
+ expected: null,
+ },
+ {
+ name: 'no output yields nothing',
+ obs: makeObservation('summarizer', null),
+ expected: null,
+ },
+ ])('$name', ({ obs, expected }) => {
+ expect(observationClipboardText(obs)).toBe(expected)
+ })
+})
diff --git a/products/replay_vision/frontend/utils/observation.ts b/products/replay_vision/frontend/utils/observation.ts
index d5a82060c7b4..7d8a4805893b 100644
--- a/products/replay_vision/frontend/utils/observation.ts
+++ b/products/replay_vision/frontend/utils/observation.ts
@@ -1,4 +1,7 @@
+import { dayjs } from 'lib/dayjs'
+
import type { ReplayObservationApi } from '../generated/api.schemas'
+import { citedTextToPlainText } from './citations'
export function readModelOutput(obs: ReplayObservationApi): Record<string, unknown> | null {
const out = obs.scanner_result?.model_output
@@ -47,3 +50,42 @@ export function readFreeformTags(obs: ReplayObservationApi): string[] {
export function readTags(obs: ReplayObservationApi): string[] {
return [...readFixedTags(obs), ...readFreeformTags(obs)]
}
+
+/** One succeeded observation as clipboard text: a metadata line, then the result body. */
+export function observationClipboardText(obs: ReplayObservationApi): string | null {
+ const output = readModelOutput(obs)
+ if (!output || obs.status !== 'succeeded') {
+ return null
+ }
+ const headlineParts: string[] = []
+ let body: string | null = null
+ if (obs.scanner_snapshot?.scanner_type === 'summarizer') {
+ const title = typeof output.title === 'string' && output.title ? output.title : null
+ const summary = typeof output.summary === 'string' && output.summary ? output.summary : null
+ if (title) {
+ headlineParts.push(title)
+ }
+ body = summary ? citedTextToPlainText(summary, output.summary_segments) : null
+ } else {
+ const verdict = readVerdict(obs)
+ if (verdict) {
+ headlineParts.push(`Verdict: ${verdict}`)
+ }
+ const score = readScore(obs)
+ if (score !== null) {
+ headlineParts.push(`Score: ${score}`)
+ }
+ const tags = readTags(obs)
+ if (tags.length > 0) {
+ headlineParts.push(tags.join(', '))
+ }
+ const reasoning = readReasoning(obs)
+ body = reasoning ? citedTextToPlainText(reasoning, output.reasoning_segments) : null
+ }
+ if (headlineParts.length === 0 && !body) {
+ return null
+ }
+ const meta = `[${dayjs(obs.created_at).format('YYYY-MM-DD')} · ${obs.session_id}]`
+ const headline = headlineParts.length > 0 ? `${meta} ${headlineParts.join(' · ')}` : meta
+ return [headline, body].filter(Boolean).join('\n')
+}