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.

feat(replay): quill twins for summarize and the observations empty state (#129018)

Hayne Ryu7e3a563a2d4c
diff --git a/products/replay_vision/frontend/components/QuillCitedMarkdown.tsx b/products/replay_vision/frontend/components/QuillCitedMarkdown.tsx
new file mode 100644
index 000000000000..4900513f05c6
--- /dev/null
+++ b/products/replay_vision/frontend/components/QuillCitedMarkdown.tsx
@@ -0,0 +1,31 @@
+import { useMemo } from 'react'
+
+import { LemonMarkdown } from 'lib/lemon-ui/LemonMarkdown'
+
+import { citedMarkdown } from '../utils/citations'
+import { QuillTimestampCitation } from './QuillTimestampCitation'
+
+/** Cited scanner output as markdown. The text is hostile, so it renders no request, link or mention. */
+export function QuillCitedMarkdown({
+ text,
+ segments,
+ onSeek,
+}: {
+ text: string
+ segments: unknown
+ onSeek?: (timestampMs: number) => void
+}): JSX.Element {
+ const markdown = useMemo(() => citedMarkdown(text, segments), [text, segments])
+ return (
+ <LemonMarkdown
+ className="text-sm"
+ lowKeyHeadings
+ disableImages="all"
+ disableLinks
+ disableMentions
+ renderTimestampRef={(timestampMs) => <QuillTimestampCitation timestampMs={timestampMs} onSeek={onSeek} />}
+ >
+ {markdown}
+ </LemonMarkdown>
+ )
+}
diff --git a/products/replay_vision/frontend/components/QuillCitedText.tsx b/products/replay_vision/frontend/components/QuillCitedText.tsx
new file mode 100644
index 000000000000..90e5860d88f2
--- /dev/null
+++ b/products/replay_vision/frontend/components/QuillCitedText.tsx
@@ -0,0 +1,28 @@
+import { parseCitedSegments } from '../utils/citations'
+import { QuillTimestampCitation } from './QuillTimestampCitation'
+
+export function QuillCitedText({
+ text,
+ segments,
+ onSeek,
+}: {
+ text: string
+ segments: unknown
+ onSeek?: (timestampMs: number) => void
+}): JSX.Element {
+ const list = parseCitedSegments(text, segments)
+ if (list.length === 0) {
+ return <>{text}</>
+ }
+ return (
+ <>
+ {list.map((segment, i) =>
+ segment.kind === 'text' ? (
+ <span key={i}>{segment.value}</span>
+ ) : (
+ <QuillTimestampCitation key={i} timestampMs={segment.timestamp_ms} onSeek={onSeek} />
+ )
+ )}
+ </>
+ )
+}
diff --git a/products/replay_vision/frontend/components/QuillLabeledRow.tsx b/products/replay_vision/frontend/components/QuillLabeledRow.tsx
new file mode 100644
index 000000000000..d28aeeda3bf2
--- /dev/null
+++ b/products/replay_vision/frontend/components/QuillLabeledRow.tsx
@@ -0,0 +1,33 @@
+import { IconInfo } from '@posthog/icons'
+import { Tooltip, TooltipContent, TooltipTrigger } from '@posthog/quill'
+
+/** A label-above-content row for observation detail panes. */
+export function QuillLabeledRow({
+ label,
+ tooltip,
+ aside,
+ children,
+}: {
+ label: string
+ tooltip?: string
+ aside?: React.ReactNode
+ children: React.ReactNode
+}): JSX.Element {
+ return (
+ <div>
+ <div className="flex items-center gap-1 text-xs text-muted-foreground mb-0.5">
+ {label}
+ {tooltip && (
+ <Tooltip>
+ <TooltipTrigger render={<span className="flex" />}>
+ <IconInfo className="text-sm" />
+ </TooltipTrigger>
+ <TooltipContent>{tooltip}</TooltipContent>
+ </Tooltip>
+ )}
+ {aside && <span className="ml-1">{aside}</span>}
+ </div>
+ <div className="text-sm min-w-0">{children}</div>
+ </div>
+ )
+}
diff --git a/products/replay_vision/frontend/components/QuillObservationErrorDetail.tsx b/products/replay_vision/frontend/components/QuillObservationErrorDetail.tsx
new file mode 100644
index 000000000000..c875a7432e68
--- /dev/null
+++ b/products/replay_vision/frontend/components/QuillObservationErrorDetail.tsx
@@ -0,0 +1,39 @@
+import type { ReplayObservationApi } from '../generated/api.schemas'
+import {
+ failureKindDescription,
+ ineligibleKindDescription,
+ parseFailureReason,
+ parseIneligibleReason,
+} from '../replay_scanners/types'
+import { QuillLabeledRow } from './QuillLabeledRow'
+
+/** Why a failed or ineligible observation stopped, as a reason line and the raw detail under it. */
+export function QuillObservationErrorDetail({
+ status,
+ errorReason,
+}: {
+ status: Extract<ReplayObservationApi['status'], 'failed' | 'ineligible'>
+ errorReason: string
+}): JSX.Element {
+ const failed = status === 'failed'
+ const failure = failed ? parseFailureReason(errorReason) : null
+ const ineligible = failed ? null : parseIneligibleReason(errorReason)
+ const reason = failure
+ ? failureKindDescription(failure.kind)
+ : ineligible
+ ? ineligibleKindDescription(ineligible.kind)
+ : errorReason
+ const message = failure?.message ?? ineligible?.message
+ return (
+ <div className="flex flex-col gap-2">
+ <QuillLabeledRow label="Reason">
+ <p className="text-sm m-0 leading-snug">{reason}</p>
+ </QuillLabeledRow>
+ {message && (
+ <QuillLabeledRow label="Details">
+ <p className={`text-sm m-0 leading-snug${failed ? ' font-mono' : ''}`}>{message}</p>
+ </QuillLabeledRow>
+ )}
+ </div>
+ )
+}
diff --git a/products/replay_vision/frontend/components/QuillObservationPrimaryOutput.tsx b/products/replay_vision/frontend/components/QuillObservationPrimaryOutput.tsx
new file mode 100644
index 000000000000..ce213ccb1962
--- /dev/null
+++ b/products/replay_vision/frontend/components/QuillObservationPrimaryOutput.tsx
@@ -0,0 +1,206 @@
+import { IconCopy, IconSparkles } from '@posthog/icons'
+import { Badge, Button, Tooltip, TooltipContent, TooltipTrigger } from '@posthog/quill'
+
+import { copyToClipboard } from 'lib/utils/copyToClipboard'
+
+import type { ReplayObservationApi } from '../generated/api.schemas'
+import { type ClassifierScannerConfig, type ScorerScannerConfig, configFromSnapshot } from '../replay_scanners/types'
+import { citedTextToPlainText } from '../utils/citations'
+import { VERDICT_LABEL, isSummaryScannerType, readReasoning } from '../utils/observation'
+import { readResult } from './ObservationCard'
+import { QuillCitedText } from './QuillCitedText'
+
+function WithReasoning({ tooltip, children }: { tooltip: string | null; children: JSX.Element }): JSX.Element {
+ if (!tooltip) {
+ return children
+ }
+ return (
+ <Tooltip>
+ <TooltipTrigger render={<span className="flex self-start" />}>{children}</TooltipTrigger>
+ <TooltipContent className="max-w-96 whitespace-pre-wrap">{tooltip}</TooltipContent>
+ </Tooltip>
+ )
+}
+
+export function QuillObservationPrimaryOutput({
+ observation,
+ compact = false,
+ showPrompt = true,
+ onSeek,
+ expandSummary = false,
+ copyable = false,
+ reasoningTooltip = false,
+}: {
+ observation: ReplayObservationApi
+ compact?: boolean
+ showPrompt?: boolean
+ /** Called with timestamp_ms when a citation chip is clicked. If omitted, citations render as plain text. */
+ onSeek?: (timestampMs: number) => void
+ /** When true, summarizer body wraps in full; when false, single-line truncate. */
+ expandSummary?: boolean
+ /** Shows a copy button on summarizer output with citations as plain timestamps. */
+ copyable?: boolean
+ /** Hovering the result shows its reasoning, for rows with nowhere else to print it. */
+ reasoningTooltip?: boolean
+}): JSX.Element | null {
+ const snapshot = observation.scanner_snapshot
+ const result = readResult(observation)
+ if (!snapshot || !result) {
+ return null
+ }
+ const scannerType = snapshot.scanner_type
+ const config = configFromSnapshot(snapshot)
+ const prompt = showPrompt ? (config?.prompt ?? null) : null
+ const reasoning = reasoningTooltip ? readReasoning(observation) : null
+ const resultTooltip = reasoning ? citedTextToPlainText(reasoning, result.reasoning_segments) : null
+ const summaryClass = expandSummary ? 'text-sm whitespace-pre-wrap' : compact ? 'text-sm truncate' : 'text-sm'
+ const promptLine = prompt ? <span className="text-xs text-muted-foreground">{prompt}</span> : null
+
+ if (scannerType === 'monitor') {
+ const verdict = result.verdict
+ const known = verdict === 'yes' || verdict === 'no' || verdict === 'inconclusive'
+ return (
+ <div className="flex flex-col gap-1">
+ <WithReasoning tooltip={resultTooltip}>
+ {/* Neutral accent, not success-green: a "yes" verdict isn't inherently good. */}
+ <Badge
+ variant={verdict === 'yes' ? 'info' : 'default'}
+ className={verdict === 'no' ? undefined : known ? undefined : 'opacity-70'}
+ >
+ {known ? VERDICT_LABEL[verdict] : '—'}
+ </Badge>
+ </WithReasoning>
+ {promptLine}
+ </div>
+ )
+ }
+
+ if (isSummaryScannerType(scannerType)) {
+ const title = typeof result.title === 'string' ? result.title : null
+ const summary = typeof result.summary === 'string' ? result.summary : null
+ const showCopy = copyable && summary !== null
+ return (
+ <div className="flex flex-col gap-1">
+ {(title || showCopy) && (
+ <div className="flex items-start justify-between gap-2">
+ {title && <span className="font-semibold text-sm">{title}</span>}
+ {showCopy && (
+ <Button
+ size="icon-xs"
+ tooltip="Copy summary"
+ aria-label="Copy summary"
+ className="ml-auto -my-1"
+ onClick={() =>
+ void copyToClipboard(
+ [title, citedTextToPlainText(summary, result.summary_segments)]
+ .filter(Boolean)
+ .join('\n\n'),
+ 'summary'
+ )
+ }
+ data-attr="vision-copy-summary"
+ >
+ <IconCopy />
+ </Button>
+ )}
+ </div>
+ )}
+ {summary && (
+ <span className={summaryClass}>
+ <QuillCitedText text={summary} segments={result.summary_segments} onSeek={onSeek} />
+ </span>
+ )}
+ </div>
+ )
+ }
+
+ if (scannerType === 'classifier') {
+ const fixedTags = Array.isArray(result.tags) ? (result.tags as string[]) : []
+ const freeformTags = Array.isArray(result.tags_freeform) ? (result.tags_freeform as string[]) : []
+ const configuredTags = Array.isArray((config as ClassifierScannerConfig | null)?.tags)
+ ? (config as ClassifierScannerConfig).tags
+ : []
+ const chosen = new Set(fixedTags)
+ const empty = fixedTags.length === 0 && freeformTags.length === 0
+ const freeform = freeformTags.map((tag, index) => (
+ <Badge key={`freeform-${index}-${tag}`} className="gap-1">
+ <IconSparkles />
+ {tag}
+ </Badge>
+ ))
+ if (compact || (configuredTags.length === 0 && empty)) {
+ return (
+ <div className="flex flex-col gap-1">
+ <div className="flex flex-wrap gap-1">
+ {empty ? (
+ <span className="text-muted-foreground text-sm">No categories</span>
+ ) : (
+ <>
+ {fixedTags.map((tag, index) => (
+ <Badge key={`fixed-${index}-${tag}`} variant="info">
+ {tag}
+ </Badge>
+ ))}
+ {freeform}
+ </>
+ )}
+ </div>
+ {promptLine}
+ </div>
+ )
+ }
+ return (
+ <div className="flex flex-col gap-3">
+ <div className="flex flex-wrap items-center gap-1">
+ {configuredTags.map((tag, index) => (
+ <Badge
+ key={`fixed-${index}-${tag}`}
+ variant={chosen.has(tag) ? 'info' : 'default'}
+ className={chosen.has(tag) ? undefined : 'opacity-50 line-through'}
+ >
+ {tag}
+ </Badge>
+ ))}
+ {freeform}
+ </div>
+ {promptLine}
+ </div>
+ )
+ }
+
+ if (scannerType === 'scorer') {
+ const score = typeof result.score === 'number' ? result.score : null
+ const resultLabel = typeof result.label === 'string' ? result.label : null
+ const scale = (config as ScorerScannerConfig | null)?.scale ?? null
+ const scaleMax = typeof scale?.max === 'number' ? scale.max : null
+ const scaleLabel = typeof scale?.label === 'string' ? scale.label : null
+ // The per-observation label is specific; the configured scale label is the axis name.
+ const displayLabel = resultLabel ?? scaleLabel
+ return (
+ <div className="flex flex-col gap-1">
+ <WithReasoning tooltip={resultTooltip}>
+ <span className="text-sm self-start">
+ <span className="font-semibold text-base">{score ?? '—'}</span>
+ {scaleMax !== null && <span className="text-muted-foreground"> / {scaleMax}</span>}
+ {displayLabel && <span className="text-muted-foreground"> — {displayLabel}</span>}
+ </span>
+ </WithReasoning>
+ {promptLine}
+ </div>
+ )
+ }
+
+ const summary = typeof result.summary === 'string' ? result.summary : null
+ const userType = typeof result.user_type === 'string' ? result.user_type : null
+ return (
+ <div className="flex flex-col gap-1">
+ {summary && <span className={compact ? 'text-sm truncate' : 'text-sm'}>{summary}</span>}
+ {userType && (
+ <span className="text-muted-foreground text-xs">
+ <span className="font-medium">User: </span>
+ {userType}
+ </span>
+ )}
+ </div>
+ )
+}
diff --git a/products/replay_vision/frontend/components/QuillObservationResultSummary.tsx b/products/replay_vision/frontend/components/QuillObservationResultSummary.tsx
new file mode 100644
index 000000000000..4ac5b563e22c
--- /dev/null
+++ b/products/replay_vision/frontend/components/QuillObservationResultSummary.tsx
@@ -0,0 +1,15 @@
+import type { ReplayObservationApi } from '../generated/api.schemas'
+import { readResult } from './ObservationCard'
+import { QuillObservationPrimaryOutput } from './QuillObservationPrimaryOutput'
+
+export function QuillObservationResultSummary({ observation }: { observation: ReplayObservationApi }): JSX.Element {
+ if (
+ observation.status === 'ineligible' ||
+ observation.status === 'failed' ||
+ !observation.scanner_snapshot ||
+ !readResult(observation)
+ ) {
+ return <span className="text-muted-foreground text-sm">—</span>
+ }
+ return <QuillObservationPrimaryOutput observation={observation} compact showPrompt={false} reasoningTooltip />
+}
diff --git a/products/replay_vision/frontend/components/QuillObservationStatusTag.tsx b/products/replay_vision/frontend/components/QuillObservationStatusTag.tsx
new file mode 100644
index 000000000000..8967a938c714
--- /dev/null
+++ b/products/replay_vision/frontend/components/QuillObservationStatusTag.tsx
@@ -0,0 +1,90 @@
+import { Badge, Spinner, Tooltip, TooltipContent, TooltipTrigger } from '@posthog/quill'
+
+import type { ReplayObservationApi } from '../generated/api.schemas'
+import {
+ failureKindDescription,
+ ineligibleKindDescription,
+ parseFailureReason,
+ parseIneligibleReason,
+} from '../replay_scanners/types'
+
+function BadgeWithTooltip({
+ tooltip,
+ variant,
+ className,
+ children,
+}: {
+ tooltip: React.ReactNode
+ variant: 'destructive' | 'default'
+ className?: string
+ children: string
+}): JSX.Element {
+ const badge = (
+ <Badge variant={variant} className={className}>
+ {children}
+ </Badge>
+ )
+ if (!tooltip) {
+ return badge
+ }
+ return (
+ <Tooltip>
+ <TooltipTrigger render={<span className="flex" />}>{badge}</TooltipTrigger>
+ <TooltipContent className="max-w-72">{tooltip}</TooltipContent>
+ </Tooltip>
+ )
+}
+
+export function QuillObservationStatusTag({
+ status,
+ errorReason,
+}: {
+ status: ReplayObservationApi['status']
+ // Required, not optional: an omitted reason silently drops the tooltip that explains a failed or ineligible status.
+ errorReason: string | null
+}): JSX.Element {
+ if (status === 'succeeded') {
+ return <Badge variant="success">Succeeded</Badge>
+ }
+ if (status === 'failed') {
+ const parsed = errorReason ? parseFailureReason(errorReason) : null
+ const tooltip = parsed ? (
+ <span className="flex flex-col gap-1">
+ <span>{parsed.label}</span>
+ <span className="text-xs opacity-80">{failureKindDescription(parsed.kind)}</span>
+ </span>
+ ) : (
+ errorReason || null
+ )
+ return (
+ <BadgeWithTooltip tooltip={tooltip} variant="destructive">
+ Failed
+ </BadgeWithTooltip>
+ )
+ }
+ if (status === 'ineligible') {
+ // Muted, not destructive: the session was skipped at the gate, not a scanner failure.
+ const parsed = errorReason ? parseIneligibleReason(errorReason) : null
+ const tooltip = parsed ? (
+ <span className="flex flex-col gap-1">
+ <span>{ineligibleKindDescription(parsed.kind)}</span>
+ {parsed.message && <span className="text-xs opacity-80">{parsed.message}</span>}
+ </span>
+ ) : (
+ errorReason || null
+ )
+ return (
+ <BadgeWithTooltip tooltip={tooltip} variant="default" className="opacity-70">
+ Ineligible
+ </BadgeWithTooltip>
+ )
+ }
+ if (status === 'running') {
+ return (
+ <Badge variant="warning" className="gap-1">
+ <Spinner /> Running
+ </Badge>
+ )
+ }
+ return <Badge>Pending</Badge>
+}
diff --git a/products/replay_vision/frontend/components/QuillScanList.tsx b/products/replay_vision/frontend/components/QuillScanList.tsx
index 9636ce01448d..fa01ea00fa64 100644
--- a/products/replay_vision/frontend/components/QuillScanList.tsx
+++ b/products/replay_vision/frontend/components/QuillScanList.tsx
@@ -16,16 +16,13 @@ import { scannerTypeLabel } from '../replay_scanners/types'
import { RECORDING_ORIGIN, currentReturnPath, observationFromOriginUrl } from '../utils/breadcrumbs'
import { isSummaryObservation, readModelOutput, readReasoning, scannerLabel } from '../utils/observation'
import { citedMoments } from '../utils/recordingTimeline'
-import { CitedMarkdown } from './CitedMarkdown'
-import {
- FailureDetail,
- IneligibleDetail,
- ObservationPrimaryOutput,
- ObservationResultSummary,
- ObservationStatusTag,
-} from './ObservationCard'
+import { QuillCitedMarkdown } from './QuillCitedMarkdown'
+import { QuillObservationErrorDetail } from './QuillObservationErrorDetail'
+import { QuillObservationPrimaryOutput } from './QuillObservationPrimaryOutput'
import { QuillObservationProgressBar } from './QuillObservationProgressBar'
+import { QuillObservationResultSummary } from './QuillObservationResultSummary'
import { QuillObservationRetryButton } from './QuillObservationRetryButton'
+import { QuillObservationStatusTag } from './QuillObservationStatusTag'
import { QuillScannerTypeBadge } from './QuillScannerTypeBadge'
const NEAR_PLAYHEAD_MS = 60_000
@@ -40,12 +37,12 @@ function defaultFocus(observations: ReplayObservationApi[]): ReplayObservationAp
function RunResult({ observation }: { observation: ReplayObservationApi }): JSX.Element | null {
if (observation.status !== 'succeeded') {
- return <ObservationStatusTag status={observation.status} errorReason={observation.error_reason} />
+ return <QuillObservationStatusTag status={observation.status} errorReason={observation.error_reason} />
}
if (isSummaryObservation(observation)) {
return null
}
- return <ObservationResultSummary observation={observation} />
+ return <QuillObservationResultSummary observation={observation} />
}
function MomentTicks({
@@ -118,14 +115,13 @@ function FocusPane({
<div ref={contentRef}>
{(observation.error_reason || isInFlight(observation)) && (
<div className="flex flex-col gap-2 px-3 pb-2">
- <span data-not-quill className="contents">
- {observation.status === 'failed' && observation.error_reason && (
- <FailureDetail errorReason={observation.error_reason} />
- )}
- {observation.status === 'ineligible' && observation.error_reason && (
- <IneligibleDetail errorReason={observation.error_reason} />
+ {(observation.status === 'failed' || observation.status === 'ineligible') &&
+ observation.error_reason && (
+ <QuillObservationErrorDetail
+ status={observation.status}
+ errorReason={observation.error_reason}
+ />
)}
- </span>
{observation.error_reason && (
<div>
<QuillObservationRetryButton
@@ -147,9 +143,9 @@ function FocusPane({
)}
<div className="flex flex-col gap-2 px-3 py-2">
{hasText && (
- <div className="text-sm max-w-[120ch]" data-not-quill>
+ <div className="text-sm max-w-[120ch]">
{isSummary ? (
- <ObservationPrimaryOutput
+ <QuillObservationPrimaryOutput
observation={observation}
showPrompt={false}
expandSummary
@@ -157,7 +153,7 @@ function FocusPane({
onSeek={onSeek}
/>
) : (
- <CitedMarkdown
+ <QuillCitedMarkdown
text={reasoning ?? ''}
segments={readModelOutput(observation)?.reasoning_segments}
onSeek={onSeek}
@@ -241,10 +237,7 @@ export function QuillScanList({
<span className="min-w-0 truncate text-sm @[760px]:shrink-0 @[760px]:max-w-[40%]">
{scannerLabel(observation)}
</span>
- <span
- className="flex items-center gap-2 min-w-0 shrink-0 max-w-[40%]"
- data-not-quill
- >
+ <span className="flex items-center gap-2 min-w-0 shrink-0 max-w-[40%]">
<RunResult observation={observation} />
</span>
{!isFocused && observation.summary_line && (
diff --git a/products/replay_vision/frontend/components/QuillTimestampCitation.tsx b/products/replay_vision/frontend/components/QuillTimestampCitation.tsx
new file mode 100644
index 000000000000..a3f52013be0e
--- /dev/null
+++ b/products/replay_vision/frontend/components/QuillTimestampCitation.tsx
@@ -0,0 +1,30 @@
+import { IconRewindPlay } from '@posthog/icons'
+import { Button } from '@posthog/quill'
+
+import { colonDelimitedDuration } from 'lib/utils/durations'
+
+/** One cited moment: a seek control into the recording, or a plain timestamp where no player is on screen. */
+export function QuillTimestampCitation({
+ timestampMs,
+ onSeek,
+}: {
+ timestampMs: number
+ onSeek?: (timestampMs: number) => void
+}): JSX.Element {
+ const label = colonDelimitedDuration(Math.max(0, Math.floor(timestampMs / 1000)), null)
+ if (!onSeek) {
+ return <span className="text-muted-foreground font-mono ml-0.5">{label}</span>
+ }
+ return (
+ <Button
+ variant="link"
+ size="inline"
+ className="ml-0.5 align-baseline"
+ onClick={() => onSeek(timestampMs)}
+ data-attr="vision-observation-citation"
+ >
+ <IconRewindPlay className="inline-block align-text-bottom" />
+ <span className="font-mono">{label}</span>
+ </Button>
+ )
+}