: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 scan states (#128465)
Hayne Ryu99bbbc4a8f6f
diff --git a/products/replay_vision/frontend/replay_scanners/components/QuillHighlightPicksBlockedState.tsx b/products/replay_vision/frontend/replay_scanners/components/QuillHighlightPicksBlockedState.tsxnew file mode 100644index 000000000000..63e561105b6b--- /dev/null+++ b/products/replay_vision/frontend/replay_scanners/components/QuillHighlightPicksBlockedState.tsx@@ -0,0 +1,167 @@+import { useActions, useMountedLogic, useValues } from 'kea'+import { useState } from 'react'++import * as asleepPng from '@posthog/brand/hoggies/png/asleep'+import { Button, Item, ItemContent, Switch } from '@posthog/quill'++import { pngHoggie } from 'lib/brand/hoggies'+import { TZLabel } from 'lib/components/TZLabel'+import { LinkPrimitive } from 'lib/lemon-ui/Link'+import { urls } from 'scenes/urls'++import type { ReplayScannerApi } from '../../generated/api.schemas'+import { visionQuotaLogic } from '../../logics/visionQuotaLogic'+import { getReplayVisionEditDisabledReason } from '../../utils/accessControl'+import { formatCreditsMaybeUsd } from '../../utils/credits'+import { highlightPicksLogic } from '../highlightPicksLogic'+import { highlightPicksStaleLogic } from '../highlightPicksStaleLogic'+import { stoppedByFreeCredits } from '../scannerCopy'+import { QuillHighlightPicksStateFrame } from './QuillHighlightPicksStateFrame'++const RAISE_FACTOR = 1.5+const HedgehogAsleep = pngHoggie(asleepPng)++export function QuillHighlightPicksBlockedState({+ reason,+ size = 'small',+}: {+ reason: 'all-disabled' | 'all-capped' | 'quota-exhausted'+ size?: 'small' | 'large'+}): JSX.Element {+ const picksLogic = useMountedLogic(highlightPicksLogic)+ const logic = highlightPicksStaleLogic(picksLogic.props)+ const { scanners, quota, busyScannerId } = useValues(logic)+ const { showUsd } = useValues(visionQuotaLogic)+ const { toggleScanner, raiseLimit } = useActions(logic)+ const [raising, setRaising] = useState<string | null>(null)+ const editDisabledReason = getReplayVisionEditDisabledReason()++ if (reason === 'all-disabled') {+ return (+ <QuillHighlightPicksStateFrame+ size={size}+ image={HedgehogAsleep}+ title="None of your scanners are running"+ body="Turn one on and picks appear after the next matching recording."+ dataAttr="vision-highlight-picks-block-disabled"+ footer={+ <Button+ variant="link"+ size="inline"+ className="mt-1"+ render={<LinkPrimitive to={urls.replayVision()} />}+ data-attr="vision-highlight-picks-block-open"+ >+ Open Replay vision+ </Button>+ }+ >+ <div className="flex flex-col divide-y divide-border rounded border border-border bg-background text-left">+ {scanners.map((scanner: ReplayScannerApi) => (+ <div key={scanner.id} className="flex items-center justify-between gap-2 px-3 py-2">+ <div className="min-w-0">+ <div className="truncate text-xs font-semibold text-foreground">{scanner.name}</div>+ <div className="text-xs text-muted-foreground">+ Off since <TZLabel time={scanner.updated_at} showPopover={false} noStyles />+ </div>+ </div>+ <Switch+ size="sm"+ checked={scanner.enabled ?? false}+ disabled={busyScannerId === scanner.id}+ disabledReason={editDisabledReason}+ onCheckedChange={(checked) => toggleScanner(scanner.id, checked)}+ data-attr="vision-highlight-picks-block-toggle"+ />+ </div>+ ))}+ </div>+ </QuillHighlightPicksStateFrame>+ )+ }++ const capped = reason === 'all-capped' ? scanners.filter((scanner) => scanner.enabled && scanner.limit_reached) : []+ const resetsAt = quota?.period_end+ const freeSampleUsedUp = capped.length > 0 && capped.every((scanner) => stoppedByFreeCredits(scanner))+ return (+ <Item+ data-quill+ variant="outline"+ tone="warning"+ className="m-2"+ data-attr="vision-highlight-picks-block-capped"+ >+ <ItemContent className="gap-2">+ <span className="font-semibold">+ {reason === 'quota-exhausted'+ ? 'Scanners paused: your Replay vision credits are used up for this period'+ : freeSampleUsedUp+ ? 'Scanners paused: your free sample is used up'+ : 'Scanners paused: every running scanner reached its credit limit'}+ </span>+ <span className="text-xs">+ {freeSampleUsedUp ? 'Set a budget to keep scanning, or wait. ' : ''}+ {resetsAt ? (+ <>+ Resets <TZLabel time={resetsAt} showPopover={false} noStyles />. Picks stop until then.+ </>+ ) : (+ 'Picks stop until the period resets.'+ )}+ </span>+ {capped.map((scanner) => {+ const current = scanner.credit_limit ?? 0+ const next = Math.ceil((current * RAISE_FACTOR) / 100) * 100 || 500+ const freeOnly = stoppedByFreeCredits(scanner)+ return (+ <div key={scanner.id} className="flex flex-wrap items-center justify-between gap-2 text-xs">+ <span className="font-semibold">{scanner.name}</span>+ {raising === scanner.id ? (+ <span className="flex items-center gap-1">+ <Button+ variant="primary"+ size="xs"+ loading={busyScannerId === scanner.id}+ onClick={() => {+ raiseLimit(scanner.id, next)+ setRaising(null)+ }}+ data-attr="vision-highlight-picks-block-raise-confirm"+ >+ Set {formatCreditsMaybeUsd(next, showUsd)} a month+ </Button>+ <Button+ size="xs"+ onClick={() => setRaising(null)}+ data-attr="vision-highlight-picks-block-raise-cancel"+ >+ Cancel+ </Button>+ </span>+ ) : (+ <Button+ variant="outline"+ size="xs"+ disabledReason={editDisabledReason}+ onClick={() => setRaising(scanner.id)}+ data-attr="vision-highlight-picks-block-raise"+ >+ {freeOnly ? 'Set a budget' : 'Raise limit'}+ </Button>+ )}+ </div>+ )+ })}+ <Button+ variant="link"+ size="inline"+ className="self-start text-xs"+ render={<LinkPrimitive to={`${urls.replayVision()}?tab=usage`} />}+ data-attr="vision-highlight-picks-block-usage"+ >+ See usage+ </Button>+ </ItemContent>+ </Item>+ )+}diff --git a/products/replay_vision/frontend/replay_scanners/components/QuillHighlightPicksEmptyState.tsx b/products/replay_vision/frontend/replay_scanners/components/QuillHighlightPicksEmptyState.tsxindex cdeff10fd83f..b083abed2647 100644--- a/products/replay_vision/frontend/replay_scanners/components/QuillHighlightPicksEmptyState.tsx+++ b/products/replay_vision/frontend/replay_scanners/components/QuillHighlightPicksEmptyState.tsx@@ -10,8 +10,8 @@ import { visionQuotaLogic } from '../../logics/visionQuotaLogic'import { visionScannersListLogic } from '../../logics/visionScannersListLogic'import { resolveHighlightFeedEmptyReason } from '../highlightFeedEmptyState'import { highlightPicksLogic } from '../highlightPicksLogic'-import { HighlightPicksBlockedState } from './HighlightPicksBlockedState'import { HighlightPicksShadowPreview } from './HighlightPicksShadowPreview'+import { QuillHighlightPicksBlockedState } from './QuillHighlightPicksBlockedState'import { QuillHighlightPicksNoRecordingsState } from './QuillHighlightPicksNoRecordingsState'import { QuillHighlightPicksQuietState } from './QuillHighlightPicksQuietState'import { QuillHighlightPicksReplayOffState } from './QuillHighlightPicksReplayOffState'@@ -65,7 +65,7 @@ export function QuillHighlightPicksEmptyState({ size }: { size: 'small' | 'large)}if (reason === 'all-disabled' || reason === 'all-capped' || reason === 'quota-exhausted') {- return <HighlightPicksBlockedState reason={reason} size={size} />+ return <QuillHighlightPicksBlockedState reason={reason} size={size} />}return (diff --git a/products/replay_vision/frontend/replay_scanners/components/QuillHighlightPicksList.tsx b/products/replay_vision/frontend/replay_scanners/components/QuillHighlightPicksList.tsxindex 74f3d5807e8c..a5913ace6daf 100644--- a/products/replay_vision/frontend/replay_scanners/components/QuillHighlightPicksList.tsx+++ b/products/replay_vision/frontend/replay_scanners/components/QuillHighlightPicksList.tsx@@ -7,12 +7,12 @@ import { LinkPrimitive } from 'lib/lemon-ui/Link'import { visionDocsUrl } from '../../components/DocsLink'import { highlightPicksLogic } from '../highlightPicksLogic'import { highlightPicksStarterLogic } from '../highlightPicksStarterLogic'-import { HighlightPicksScanningState } from './HighlightPicksScanningState'-import { HighlightPicksStarterStatus } from './HighlightPicksStarterStatus'import { QuillHighlightPickRow } from './QuillHighlightPickRow'import { QuillHighlightPicksEmptyState } from './QuillHighlightPicksEmptyState'import { QuillHighlightPicksExtraRows } from './QuillHighlightPicksExtraRows'+import { QuillHighlightPicksScanningState } from './QuillHighlightPicksScanningState'import { QuillHighlightPicksStaleBanner } from './QuillHighlightPicksStaleBanner'+import { QuillHighlightPicksStarterStatus } from './QuillHighlightPicksStarterStatus'const LIST_TOP_COUNT = 5@@ -56,10 +56,10 @@ export function QuillHighlightPicksList(): JSX.Element {</div>) : !picks || picks.length === 0 ? (startedScanner && !burstDone ? (- <HighlightPicksScanningState size="small" />+ <QuillHighlightPicksScanningState size="small" />) : startedScanner ? (<>- <HighlightPicksStarterStatus />+ <QuillHighlightPicksStarterStatus /><QuillHighlightPicksExtraRows /></>) : (@@ -67,7 +67,7 @@ export function QuillHighlightPicksList(): JSX.Element {)) : (<>- {burstActive ? <HighlightPicksStarterStatus /> : <QuillHighlightPicksStaleBanner />}+ {burstActive ? <QuillHighlightPicksStarterStatus /> : <QuillHighlightPicksStaleBanner />}<div className="flex flex-col gap-0.5 p-1">{picks.map((item, index) => (<QuillHighlightPickRowdiff --git a/products/replay_vision/frontend/replay_scanners/components/QuillHighlightPicksScanningState.tsx b/products/replay_vision/frontend/replay_scanners/components/QuillHighlightPicksScanningState.tsxnew file mode 100644index 000000000000..4dc847386327--- /dev/null+++ b/products/replay_vision/frontend/replay_scanners/components/QuillHighlightPicksScanningState.tsx@@ -0,0 +1,42 @@+import { useMountedLogic, useValues } from 'kea'++import * as magnifyingGlassPng from '@posthog/brand/hoggies/png/magnifying-glass'+import { Progress, Skeleton } from '@posthog/quill'++import { pngHoggie } from 'lib/brand/hoggies'++import { highlightPicksLogic } from '../highlightPicksLogic'+import { highlightPicksStarterLogic } from '../highlightPicksStarterLogic'+import { QuillHighlightPicksStateFrame } from './QuillHighlightPicksStateFrame'++const HedgehogMagnifyingGlass = pngHoggie(magnifyingGlassPng)+const PLACEHOLDER_ROWS = 3++export function QuillHighlightPicksScanningState({ size }: { size: 'small' | 'large' }): JSX.Element {+ const picksLogic = useMountedLogic(highlightPicksLogic)+ const { burstSessionIds, burstCounts } = useValues(highlightPicksStarterLogic(picksLogic.props))+ const total = burstSessionIds.length+ const finished = burstCounts.succeeded + burstCounts.failed++ return (+ <>+ <QuillHighlightPicksStateFrame+ size={size}+ image={HedgehogMagnifyingGlass}+ title="Scanning your sessions"+ body="Highlights show up here a few minutes after scans finish."+ dataAttr="vision-highlight-picks-scanning"+ >+ <Progress value={total === 0 ? 100 : (finished / total) * 100} />+ <span className="text-xs text-muted-foreground" translate="no">+ {finished} of {total} scanned+ </span>+ </QuillHighlightPicksStateFrame>+ <div data-quill className="flex flex-col gap-2 p-2" aria-busy>+ {Array.from({ length: Math.min(PLACEHOLDER_ROWS, Math.max(1, total - finished)) }, (_, i) => (+ <Skeleton key={i} className="h-16 rounded" />+ ))}+ </div>+ </>+ )+}diff --git a/products/replay_vision/frontend/replay_scanners/components/QuillHighlightPicksStaleBanner.tsx b/products/replay_vision/frontend/replay_scanners/components/QuillHighlightPicksStaleBanner.tsxindex c032cfbe3321..9513f40deb1e 100644--- a/products/replay_vision/frontend/replay_scanners/components/QuillHighlightPicksStaleBanner.tsx+++ b/products/replay_vision/frontend/replay_scanners/components/QuillHighlightPicksStaleBanner.tsx@@ -14,7 +14,7 @@ import { highlightPicksLogic } from '../highlightPicksLogic'import { highlightPicksStaleLogic } from '../highlightPicksStaleLogic'import { scannerEditUrl } from '../scannerEditorSceneLogic'import { markScannerGoalDraftIntent } from '../scannerHandoffIntent'-import { HighlightPicksBlockedState } from './HighlightPicksBlockedState'+import { QuillHighlightPicksBlockedState } from './QuillHighlightPicksBlockedState'import { SCANNER_GOAL_STARTERS } from './scannerGoalStarters'const QUIET_WEEK_GOAL_KEYS = ['dead_end', 'frustration_score']@@ -54,7 +54,7 @@ export function QuillHighlightPicksStaleBanner(): JSX.Element | null {return null}if (staleReason === 'all-disabled' || staleReason === 'all-capped' || staleReason === 'quota-exhausted') {- return <HighlightPicksBlockedState reason={staleReason} />+ return <QuillHighlightPicksBlockedState reason={staleReason} />}const newest = (picks ?? []).reduce<string | null>(diff --git a/products/replay_vision/frontend/replay_scanners/components/QuillHighlightPicksStarterStatus.tsx b/products/replay_vision/frontend/replay_scanners/components/QuillHighlightPicksStarterStatus.tsxnew file mode 100644index 000000000000..1bc76e4f8477--- /dev/null+++ b/products/replay_vision/frontend/replay_scanners/components/QuillHighlightPicksStarterStatus.tsx@@ -0,0 +1,106 @@+import { useActions, useMountedLogic, useValues } from 'kea'++import { Button, Item, ItemContent, Progress, Spinner } from '@posthog/quill'++import { LinkPrimitive } from 'lib/lemon-ui/Link'+import { pluralize } from 'lib/utils/strings'+import { urls } from 'scenes/urls'++import { highlightPicksLogic } from '../highlightPicksLogic'+import { highlightPicksStarterLogic } from '../highlightPicksStarterLogic'++export function QuillHighlightPicksStarterStatus(): JSX.Element | null {+ const picksLogic = useMountedLogic(highlightPicksLogic)+ const { picks } = useValues(picksLogic)+ const logic = highlightPicksStarterLogic(picksLogic.props)+ const { startedScanner, burstSessionIds, burstCounts, burstDone, burstStalled, scannedAnyway, feedWindowOpen } =+ useValues(logic)+ const { showScannedAnyway } = useActions(logic)++ if (!startedScanner) {+ return null+ }+ const total = burstSessionIds.length+ const burstPicks = (picks ?? []).filter(+ (pick) =>+ pick.observation.scanner_id === startedScanner.id && burstSessionIds.includes(pick.observation.session_id)+ ).length+ const finished = Math.max(burstCounts.succeeded + burstCounts.failed, burstPicks)+ const hasPicks = (picks?.length ?? 0) > 0++ if (burstDone && !hasPicks) {+ return (+ <div data-quill className="flex flex-col gap-1 p-2" data-attr="vision-highlight-picks-starter-nothing">+ <Item variant="outline" tone="info">+ <ItemContent className="gap-2">+ <span className="font-semibold">+ {total === 0+ ? 'Your scanner is on'+ : feedWindowOpen+ ? `${pluralize(burstCounts.succeeded, 'recording')} scanned`+ : `${pluralize(burstCounts.succeeded, 'recording')} scanned, nothing stood out`}+ </span>+ <span className="text-xs">+ {burstStalled && burstCounts.pending > 0+ ? `${pluralize(burstCounts.pending, 'scan')} still running. New recordings are scanned as they finish and picks show up here.`+ : feedWindowOpen+ ? 'Highlights show up here a few minutes after scans finish.'+ : 'That happens on a quiet day. New recordings are scanned as they finish and picks show up here.'}+ </span>+ <div className="flex flex-wrap gap-2">+ {burstCounts.succeeded > 0 && scannedAnyway === null && (+ <Button+ variant="outline"+ size="xs"+ onClick={showScannedAnyway}+ data-attr="vision-highlight-picks-starter-show-anyway"+ >+ Show them anyway+ </Button>+ )}+ <Button+ size="xs"+ render={<LinkPrimitive to={urls.replayVisionNewScanner()} />}+ data-attr="vision-highlight-picks-starter-another"+ >+ Try another scanner+ </Button>+ </div>+ </ItemContent>+ </Item>+ </div>+ )+ }++ if (burstDone) {+ return burstStalled && burstCounts.pending > 0 ? (+ <div+ data-quill+ className="border-b border-border px-3 py-2 text-xs text-muted-foreground"+ data-attr="vision-highlight-picks-starter-stalled"+ >+ {pluralize(burstCounts.pending, 'scan')} still running. They show up here when they finish.+ </div>+ ) : null+ }++ return (+ <div+ data-quill+ className="flex flex-col gap-1 border-b border-border px-3 py-2 text-xs text-foreground"+ data-attr="vision-highlight-picks-starter-running"+ >+ <div className="flex items-center justify-between gap-2">+ <span className="flex items-center gap-1 font-semibold">+ <Spinner className="size-3.5" />+ Scanning sessions+ </span>+ <span className="text-muted-foreground">+ {finished} / {total}+ </span>+ </div>+ <Progress value={total === 0 ? 100 : (finished / total) * 100} />+ <span className="text-muted-foreground">Highlights show up here a few minutes after scans finish.</span>+ </div>+ )+}