: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): quill twins for the highlights list in the watch layouts (#128326)
Hayne Ryu8c6436f8c136
diff --git a/frontend/src/scenes/session-recordings/playlist/ReplayListColumnWithPicks.tsx b/frontend/src/scenes/session-recordings/playlist/ReplayListColumnWithPicks.tsxindex c4ae2b1beb97..7031e4f76000 100644--- a/frontend/src/scenes/session-recordings/playlist/ReplayListColumnWithPicks.tsx+++ b/frontend/src/scenes/session-recordings/playlist/ReplayListColumnWithPicks.tsx@@ -1,7 +1,7 @@import { useActions, useMountedLogic, useValues } from 'kea'import { ReactNode } from 'react'-import { HighlightPicksList } from 'products/replay_vision/frontend/replay_scanners/components/HighlightPicksList'+import { QuillHighlightPicksList } from 'products/replay_vision/frontend/replay_scanners/components/QuillHighlightPicksList'import { highlightPicksLogic } from 'products/replay_vision/frontend/replay_scanners/highlightPicksLogic'import { highlightPicksStarterLogic } from 'products/replay_vision/frontend/replay_scanners/highlightPicksStarterLogic'@@ -26,7 +26,7 @@ export function ReplayListColumnWithPicks({logicKey={logicKey}recordingsList={recordingsList}collections={collections}- picksList={<HighlightPicksList />}+ picksList={<QuillHighlightPicksList />}picksMode={effectiveListMode}unwatchedPicksCount={unwatchedCount}onPicksSelected={(selected) => setListMode(selected ? 'picks' : 'recordings')}diff --git a/products/replay_vision/frontend/replay_scanners/components/QuillHighlightPickRow.tsx b/products/replay_vision/frontend/replay_scanners/components/QuillHighlightPickRow.tsxnew file mode 100644index 000000000000..196e77f23dae--- /dev/null+++ b/products/replay_vision/frontend/replay_scanners/components/QuillHighlightPickRow.tsx@@ -0,0 +1,87 @@+import { useActions, useValues } from 'kea'++import { Button, Tooltip, TooltipContent, TooltipTrigger } from '@posthog/quill'++import { useAutoMarkRead } from 'lib/components/NotificationsMenu/useAutoMarkRead'+import { TZLabel } from 'lib/components/TZLabel'+import { cn } from 'lib/utils/css-classes'++import { ObservationThumbnail } from '../../components/ObservationThumbnail'+import type { HighlightFeedItemApi } from '../../generated/api.schemas'+import { citedTextToPlainText } from '../../utils/citations'+import { CARD_SEEN_DWELL_MS } from '../highlightFeedTelemetry'+import { highlightPicksLogic } from '../highlightPicksLogic'+import { highlightPickSummary } from '../highlightPickSummary'+import { highlightReasonCopy } from './HighlightFeedCard'+import { HighlightPickPreview } from './HighlightPickPreview'+import { HighlightPickRankBadge } from './HighlightPickRankBadge'++interface QuillHighlightPickRowProps {+ item: HighlightFeedItemApi+ position: number+ isActive: boolean+ rank?: number+}++export function QuillHighlightPickRow({ item, position, isActive, rank }: QuillHighlightPickRowProps): JSX.Element {+ const { highlightPick, cardSeen } = useActions(highlightPicksLogic)+ const { picksLoad } = useValues(highlightPicksLogic)+ const { observation, reason } = item+ const { title, scannerName } = highlightPickSummary(observation)+ const rowRef = useAutoMarkRead(true, () => cardSeen(item, position), CARD_SEEN_DWELL_MS, picksLoad?.feedLoadId)++ return (+ <Tooltip>+ <TooltipTrigger+ render={+ <Button+ ref={rowRef}+ size="row"+ left+ onClick={() => highlightPick(item, position)}+ className={cn('h-auto min-w-0', isActive && 'bg-fill-selected')}+ aria-current={isActive || undefined}+ data-attr="vision-highlight-pick"+ />+ }+ >+ <span className={cn('flex w-full min-w-0 items-center gap-3 py-1', observation.viewed && 'opacity-60')}>+ <span className="relative w-28 shrink-0">+ <ObservationThumbnail+ observation={observation}+ className="w-full"+ size="small"+ retryKey={picksLoad?.feedLoadId}+ />+ {rank !== undefined && <HighlightPickRankBadge rank={rank} size="small" />}+ {!observation.viewed && (+ <span className="absolute inset-y-0 left-0 w-1 rounded-l bg-primary" aria-hidden />+ )}+ </span>+ <span className="flex min-w-0 flex-1 flex-col gap-0.5">+ <span className="truncate text-sm font-semibold">+ {!observation.viewed && <span className="sr-only">New: </span>}+ {title}+ </span>+ <span className="truncate text-xs font-normal text-muted-foreground">+ <span>{scannerName}</span>+ <span> · </span>+ <TZLabel+ time={observation.created_at}+ showPopover={false}+ noStyles+ className="whitespace-nowrap"+ />+ </span>+ <span className="truncate text-xs font-normal text-muted-foreground">+ {citedTextToPlainText(highlightReasonCopy(reason), undefined)}+ </span>+ </span>+ </span>+ </TooltipTrigger>+ <TooltipContent side="right">+ <HighlightPickPreview item={item} />+ </TooltipContent>+ </Tooltip>+ )+}diff --git a/products/replay_vision/frontend/replay_scanners/components/QuillHighlightPicksExtraRows.tsx b/products/replay_vision/frontend/replay_scanners/components/QuillHighlightPicksExtraRows.tsxnew file mode 100644index 000000000000..38babdca0a39--- /dev/null+++ b/products/replay_vision/frontend/replay_scanners/components/QuillHighlightPicksExtraRows.tsx@@ -0,0 +1,49 @@+import { useMountedLogic, useValues } from 'kea'+import { useEffect, useRef } from 'react'++import type { HighlightFeedItemApi } from '../../generated/api.schemas'+import { highlightPicksLogic } from '../highlightPicksLogic'+import { highlightPicksStaleLogic } from '../highlightPicksStaleLogic'+import { highlightPicksStarterLogic } from '../highlightPicksStarterLogic'+import { QuillHighlightPickRow } from './QuillHighlightPickRow'++export function QuillHighlightPicksExtraRows(): JSX.Element | null {+ const picksLogic = useMountedLogic(highlightPicksLogic)+ const { nextBest } = useValues(highlightPicksStaleLogic(picksLogic.props))+ const { scannedAnyway } = useValues(highlightPicksStarterLogic(picksLogic.props))+ const ref = useRef<HTMLDivElement>(null)+ const rows = scannedAnyway ?? nextBest++ useEffect(() => {+ if (rows) {+ ref.current?.scrollIntoView({ block: 'nearest' })+ }+ }, [rows])++ if (!rows) {+ return null+ }+ return (+ <div+ ref={ref}+ className="flex flex-col gap-0.5 border-t border-border p-1"+ data-attr="vision-highlight-picks-extra-rows"+ >+ <span className="px-2 pt-1 text-xs font-semibold text-muted-foreground">+ {scannedAnyway ? 'Scanned, nothing notable' : 'Newest results, not ranked'}+ </span>+ {rows.length === 0 ? (+ <span className="px-2 pb-1 text-xs text-muted-foreground">No finished scans this week.</span>+ ) : (+ rows.map((observation, index) => (+ <QuillHighlightPickRow+ key={observation.id}+ item={{ observation, reason: { kind: 'recent' } } as HighlightFeedItemApi}+ position={index}+ isActive={false}+ />+ ))+ )}+ </div>+ )+}diff --git a/products/replay_vision/frontend/replay_scanners/components/QuillHighlightPicksList.tsx b/products/replay_vision/frontend/replay_scanners/components/QuillHighlightPicksList.tsxnew file mode 100644index 000000000000..8a2def2832ca--- /dev/null+++ b/products/replay_vision/frontend/replay_scanners/components/QuillHighlightPicksList.tsx@@ -0,0 +1,107 @@+import { useActions, useMountedLogic, useValues } from 'kea'++import { Button, Skeleton } from '@posthog/quill'++import { LinkPrimitive } from 'lib/lemon-ui/Link'++import { visionDocsUrl } from '../../components/DocsLink'+import { highlightPicksLogic } from '../highlightPicksLogic'+import { highlightPicksStarterLogic } from '../highlightPicksStarterLogic'+import { HighlightPicksEmptyState } from './HighlightPicksEmptyState'+import { HighlightPicksScanningState } from './HighlightPicksScanningState'+import { HighlightPicksStarterStatus } from './HighlightPicksStarterStatus'+import { QuillHighlightPickRow } from './QuillHighlightPickRow'+import { QuillHighlightPicksExtraRows } from './QuillHighlightPicksExtraRows'+import { QuillHighlightPicksStaleBanner } from './QuillHighlightPicksStaleBanner'++const LIST_TOP_COUNT = 5++export function QuillHighlightPicksList(): JSX.Element {+ const picksLogic = useMountedLogic(highlightPicksLogic)+ const { picks, picksLoading, picksFailed, activeSessionId } = useValues(picksLogic)+ const { loadPicks, docsOpened } = useActions(picksLogic)+ const { startedScanner, burstDone, burstStalled } = useValues(highlightPicksStarterLogic(picksLogic.props))+ const burstActive = startedScanner !== null && (!burstDone || burstStalled)++ return (+ <div+ data-quill+ className="flex h-full w-full min-w-60 flex-col overflow-hidden rounded border border-border bg-background text-foreground contain-inline-size"+ data-attr="vision-highlight-picks-list"+ >+ <div className="min-h-0 flex-1 overflow-y-auto">+ {picks === null && !picksFailed ? (+ <div className="flex flex-col gap-2 p-2" aria-busy>+ {[0, 1, 2, 3].map((i) => (+ <Skeleton key={i} className="h-16 rounded" />+ ))}+ </div>+ ) : picksFailed ? (+ <div+ className="flex flex-col items-center gap-2 p-4 text-center text-xs text-muted-foreground"+ data-attr="vision-highlight-picks-failed"+ >+ <span className="text-sm font-semibold text-foreground">Couldn't load highlights</span>+ <span>Something went wrong on our side. Try again in a moment.</span>+ <Button+ variant="outline"+ size="sm"+ className="mt-1"+ loading={picksLoading}+ onClick={loadPicks}+ data-attr="vision-highlight-picks-retry"+ >+ Try again+ </Button>+ </div>+ ) : !picks || picks.length === 0 ? (+ startedScanner && !burstDone ? (+ <HighlightPicksScanningState size="small" />+ ) : startedScanner ? (+ <>+ <HighlightPicksStarterStatus />+ <QuillHighlightPicksExtraRows />+ </>+ ) : (+ <HighlightPicksEmptyState size="small" />+ )+ ) : (+ <>+ {burstActive ? <HighlightPicksStarterStatus /> : <QuillHighlightPicksStaleBanner />}+ <div className="flex flex-col gap-0.5 p-1">+ {picks.map((item, index) => (+ <QuillHighlightPickRow+ key={item.observation.id}+ item={item}+ position={index}+ rank={index < LIST_TOP_COUNT ? index + 1 : undefined}+ isActive={item.observation.session_id === activeSessionId}+ />+ ))}+ </div>+ <QuillHighlightPicksExtraRows />+ </>+ )}+ </div>+ {picks && picks.length > 0 && (+ <div className="flex items-center justify-between gap-2 border-t border-border px-3 py-1.5 text-xs text-muted-foreground">+ <span>Picks from the last 7 days</span>+ <Button+ variant="link"+ size="inline"+ render={+ <LinkPrimitive+ to={`${visionDocsUrl('what-to-watch')}?utm_medium=in-product&utm_campaign=empty-state-docs-link`}+ target="_blank"+ />+ }+ onClick={docsOpened}+ data-attr="vision-highlight-picks-how-chosen"+ >+ How picks are chosen+ </Button>+ </div>+ )}+ </div>+ )+}diff --git a/products/replay_vision/frontend/replay_scanners/components/QuillHighlightPicksStaleBanner.tsx b/products/replay_vision/frontend/replay_scanners/components/QuillHighlightPicksStaleBanner.tsxnew file mode 100644index 000000000000..c032cfbe3321--- /dev/null+++ b/products/replay_vision/frontend/replay_scanners/components/QuillHighlightPicksStaleBanner.tsx@@ -0,0 +1,195 @@+import { useActions, useMountedLogic, useValues } from 'kea'+import { combineUrl } from 'kea-router'+import { ReactNode } from 'react'++import { Button, Item, ItemContent, Skeleton } from '@posthog/quill'++import { TZLabel } from 'lib/components/TZLabel'+import { LinkPrimitive } from 'lib/lemon-ui/Link'+import { pluralize } from 'lib/utils/strings'+import { urls } from 'scenes/urls'++import { getReplayVisionEditDisabledReason } from '../../utils/accessControl'+import { highlightPicksLogic } from '../highlightPicksLogic'+import { highlightPicksStaleLogic } from '../highlightPicksStaleLogic'+import { scannerEditUrl } from '../scannerEditorSceneLogic'+import { markScannerGoalDraftIntent } from '../scannerHandoffIntent'+import { HighlightPicksBlockedState } from './HighlightPicksBlockedState'+import { SCANNER_GOAL_STARTERS } from './scannerGoalStarters'++const QUIET_WEEK_GOAL_KEYS = ['dead_end', 'frustration_score']+const quietWeekGoals = SCANNER_GOAL_STARTERS.filter((starter) => QUIET_WEEK_GOAL_KEYS.includes(starter.key))++function ReviewFiltersLink({ scannerId }: { scannerId: string }): JSX.Element {+ return (+ <Button+ variant="link"+ size="inline"+ render={<LinkPrimitive to={scannerEditUrl(scannerId, null)} />}+ data-attr="vision-highlight-picks-stale-review"+ >+ Review filters+ </Button>+ )+}++export function QuillHighlightPicksStaleBanner(): JSX.Element | null {+ const picksLogic = useMountedLogic(highlightPicksLogic)+ const logic = highlightPicksStaleLogic(picksLogic.props)+ const { picks } = useValues(picksLogic)+ const {+ staleReason,+ droughtScanners,+ scanners,+ busyScannerId,+ backfillTotals,+ quietWeek,+ nextBest,+ nextBestLoading,+ } = useValues(logic)+ const { startBackfill, loadNextBest, pickSharperGoal } = useActions(logic)+ const editDisabledReason = getReplayVisionEditDisabledReason()++ if (!staleReason) {+ return null+ }+ if (staleReason === 'all-disabled' || staleReason === 'all-capped' || staleReason === 'quota-exhausted') {+ return <HighlightPicksBlockedState reason={staleReason} />+ }++ const newest = (picks ?? []).reduce<string | null>(+ (latest, pick) => (!latest || pick.observation.created_at > latest ? pick.observation.created_at : latest),+ null+ )+ const runningScanners = scanners.filter((scanner) => scanner.enabled && !scanner.limit_reached)+ const running = runningScanners.length++ if (staleReason === 'drought') {+ return (+ <Item variant="outline" tone="warning" className="m-2" data-attr="vision-highlight-picks-stale-drought">+ <ItemContent className="gap-2 text-xs">+ {droughtScanners.map((scanner) => {+ const total = backfillTotals[scanner.id]+ return (+ <div key={scanner.id} className="flex flex-col gap-1">+ <span className="font-semibold">+ {scanner.name} has not matched anything since you changed it+ </span>+ {total === undefined ? (+ <div className="flex flex-wrap items-center gap-2">+ <Button+ variant="outline"+ size="xs"+ loading={busyScannerId === scanner.id}+ disabledReason={editDisabledReason}+ onClick={() => startBackfill(scanner.id)}+ data-attr="vision-highlight-picks-stale-backfill"+ >+ Scan the last 7 days now+ </Button>+ <ReviewFiltersLink scannerId={scanner.id} />+ </div>+ ) : total === 0 ? (+ <span>+ No recording in the last 7 days passes its filters.{' '}+ <ReviewFiltersLink scannerId={scanner.id} />+ </span>+ ) : (+ <span>+ Scanning {pluralize(total, 'recording')}. Results land here as they finish.+ </span>+ )}+ </div>+ )+ })}+ </ItemContent>+ </Item>+ )+ }++ if (staleReason === 'caught-up') {+ return (+ <div+ className="border-b border-border px-3 py-2 text-xs text-muted-foreground"+ data-attr="vision-highlight-picks-stale-caught-up"+ >+ <span className="font-semibold text-foreground">You are caught up.</span>{' '}+ {newest && (+ <>+ Last pick <TZLabel time={newest} showPopover={false} noStyles />.{' '}+ </>+ )}+ {pluralize(running, 'scanner')} running. New picks appear here without a refresh.+ </div>+ )+ }++ const stats: [string, ReactNode][] = [+ ['Scanned', quietWeek ? String(quietWeek.scanned) : null],+ ['Picks', String((picks ?? []).length)],+ ['Last pick', newest ? <TZLabel key="last-pick" time={newest} showPopover={false} noStyles /> : null],+ ]+ return (+ <div+ className="flex flex-col gap-2 border-b border-border px-3 py-2 text-xs"+ data-attr="vision-highlight-picks-stale-quiet"+ >+ <div className="flex items-baseline justify-between gap-2">+ <span className="font-semibold">Quiet week</span>+ {runningScanners.length === 1 && (+ <span className="truncate text-muted-foreground">{runningScanners[0].name}</span>+ )}+ </div>+ <div className="flex gap-4">+ {stats.map(([label, value]) => (+ <div key={label} className="flex flex-col">+ <span className="text-xxs font-bold uppercase tracking-wide text-muted-foreground">+ {label}+ </span>+ {value ? (+ <span className="text-base font-bold leading-tight">{value}</span>+ ) : (+ <Skeleton className="h-5 w-8" />+ )}+ </div>+ ))}+ </div>+ <span className="text-muted-foreground">Nothing stood out this week. Try a sharper goal.</span>+ {quietWeekGoals.map((starter) => (+ <Button+ key={starter.key}+ variant="outline"+ size="sm"+ left+ className="h-auto w-full"+ disabledReason={editDisabledReason}+ render={+ <LinkPrimitive to={combineUrl(urls.replayVisionNewScanner(), { goal: starter.goal }).url} />+ }+ onClick={() => {+ markScannerGoalDraftIntent({ goal: starter.goal })+ pickSharperGoal(starter.key)+ }}+ data-attr={`vision-highlight-picks-stale-goal-${starter.key}`}+ >+ {starter.icon}+ <span className="flex min-w-0 flex-col text-left">+ <span>{starter.question}</span>+ <span className="truncate text-xxs font-normal text-muted-foreground">{starter.goal}</span>+ </span>+ </Button>+ ))}+ {nextBest === null ? (+ <Button+ size="xs"+ className="self-start"+ loading={nextBestLoading}+ onClick={loadNextBest}+ data-attr="vision-highlight-picks-stale-next-best"+ >+ Show the newest results anyway+ </Button>+ ) : null}+ </div>+ )+}