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): render ranked tags as pills again (#75549)

Arno Hillen503ea5f21a71
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index edaa06a0ff13..4394db8d9bd8 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -6907,9 +6907,9 @@ snapshots:
scenes-app-replay-vision--scanners-list--light:
hash: v1.k794b7964.99f5f4499dca089b44d7bce7dee60424c7bdeefb860a8882d5ca8cbf06abce69.MHJZLg5-Q8USBaHeY-N_hqBMtEfuRArXAsAgnwEk4gs
scenes-app-replay-vision--summarizer-overview--dark:
- hash: v1.k794b7964.c801b1da1f1c38a3e6560c462008a090ecb86373896e7974c4996c07b9bcef0d.G0L7uSVxm7HgUbRrYPlfWLNTq4K1uLVER89MMY9yQj0
+ hash: v1.k794b7964.e5827be3112c9cb7af5526a41eb02da1c5ef1982eb9d2af887e0649119f8def5.-yMhrm4zkIgcYpOcdAKwqy1w5SEDHRXT5pTfaNENKFg
scenes-app-replay-vision--summarizer-overview--light:
- hash: v1.k794b7964.6c3926b9189f1b772238b9fcdcb356c659f069faea561727fc50bf9aae40c620.umdwMDJ9PO4HQvOsDy5ry_XAuke9swpQAjZVowYt8tQ
+ hash: v1.k794b7964.f4cd388175bf16358030e2ad02abff949e1dccb34b702bb9ce8c4ce65ff32dfe.gfKH-mJ2VVS664K3yW1pg4gqSkPEBoFSspoe-446uOc
scenes-app-saved-insights--empty-state--dark:
hash: v1.k794b7964.43545664c9133c8afd354be6a6ed8f808c35b381101325d9605114632fcdc0c9.l8w9uEOEmrH6Xl1kNd9ueRtg_51cJUSjWLdjWDM0Fko
scenes-app-saved-insights--empty-state--light:
diff --git a/products/replay_vision/frontend/replay_scanners/components/ScannerOverview.tsx b/products/replay_vision/frontend/replay_scanners/components/ScannerOverview.tsx
index b06f347cd286..7cacda40df5b 100644
--- a/products/replay_vision/frontend/replay_scanners/components/ScannerOverview.tsx
+++ b/products/replay_vision/frontend/replay_scanners/components/ScannerOverview.tsx
@@ -56,16 +56,25 @@ function PanelEmpty({ loading, message }: { loading: boolean; message: string })
// Cap the rows so a panel can't outgrow the one beside it.
const RANKED_ROWS = 5
-// The bar is the row background rather than a column, so long friction phrases wrap instead of truncating.
+/**
+ * Two row shapes, because the terms differ in kind:
+ * - `tag` renders short vocabulary terms as pills, which is what marks them as tags rather than prose.
+ * - `phrase` renders model-written sentences as plain text with the bar behind the row, so they wrap
+ * instead of being truncated into a pill.
+ */
+type RankedTermVariant = 'tag' | 'phrase'
+
function RankedTermList({
ranked,
loading,
emptyMessage,
+ variant,
renderAction,
}: {
ranked: [string, number][]
loading: boolean
emptyMessage: string
+ variant: RankedTermVariant
renderAction?: (term: string) => JSX.Element
}): JSX.Element {
if (ranked.length === 0) {
@@ -75,6 +84,34 @@ function RankedTermList({
const maxCount = top[0][1]
// When no term repeats, every bar is full width and falsely reads as "these all dominate", so drop the bars.
const showBars = maxCount > 1
+ const percent = (count: number): number => Math.round((count / maxCount) * 100)
+
+ if (variant === 'tag') {
+ return (
+ <div className="space-y-1.5">
+ {top.map(([term, count]) => (
+ <div key={term} className="flex items-center gap-2">
+ {/* Fixed-width label column so every bar shares the same left edge and their lengths stay comparable. */}
+ <div className="w-40 shrink-0 flex">
+ <LemonTag type="option" title={term} className="max-w-full truncate">
+ {term}
+ </LemonTag>
+ </div>
+ {showBars ? (
+ <LemonProgress percent={percent(count)} className="flex-1" />
+ ) : (
+ <div className="flex-1" />
+ )}
+ <span className="text-xs text-muted tabular-nums text-right whitespace-nowrap shrink-0 w-12">
+ {count.toLocaleString()}
+ </span>
+ {renderAction?.(term)}
+ </div>
+ ))}
+ </div>
+ )
+ }
+
return (
<div className="space-y-1">
{top.map(([term, count]) => (
@@ -84,7 +121,7 @@ function RankedTermList({
className="absolute inset-y-0 left-0 bg-accent-highlight-secondary"
// Width is data-derived, so it can't live in a class.
// eslint-disable-next-line react/forbid-dom-props
- style={{ width: `${Math.round((count / maxCount) * 100)}%` }}
+ style={{ width: `${percent(count)}%` }}
/>
)}
<div className="relative flex items-baseline justify-between gap-2 px-2 py-1">
@@ -245,6 +282,7 @@ function ClassifierOverview({ scannerId }: { scannerId: string }): JSX.Element |
ranked={fixedRanked}
loading={overviewStatsApiLoading}
emptyMessage={fixedEmpty}
+ variant="tag"
renderAction={cohortAction}
/>
</OverviewPanel>
@@ -260,6 +298,7 @@ function ClassifierOverview({ scannerId }: { scannerId: string }): JSX.Element |
ranked={freeformRanked}
loading={overviewStatsApiLoading}
emptyMessage={freeformEmpty}
+ variant="tag"
renderAction={cohortAction}
/>
) : (
@@ -344,10 +383,16 @@ function SummarizerOverview({ scannerId }: { scannerId: string }): JSX.Element |
ranked={frictionRanked}
loading={overviewStatsApiLoading}
emptyMessage={frictionEmpty}
+ variant="phrase"
/>
</OverviewPanel>
<OverviewPanel title="Common keywords" subtitle={keywordSubtitle} fill>
- <RankedTermList ranked={keywordRanked} loading={overviewStatsApiLoading} emptyMessage={keywordEmpty} />
+ <RankedTermList
+ ranked={keywordRanked}
+ loading={overviewStatsApiLoading}
+ emptyMessage={keywordEmpty}
+ variant="tag"
+ />
</OverviewPanel>
</div>
)