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.

chore(llma): tame colored borders on cluster cards (#60134)

Fernando Gomes40fbf573e285
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index c01000261e2a..452e27e47d35 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -3874,6 +3874,22 @@ snapshots:
hash: v1.k794b7964.e55e3f17536c13f7561cd6275dc2c63e9950e7f83394de972364ba0b51211c58.S9fUa5v1eSxXT-D7D7lmS3os0kSj8a1gIhb7EPsivNc
replay-tabs-home-success--second-recording-in-list--light:
hash: v1.k794b7964.36ceb39895861de3d53bf2bb36ab9803c836b8cdef6a7ac4fb1d7dfee1bf3e26.OVDv2SGgEZpivhEYSsajGdVchscMaXMBMLAY-YDW3dw
+ scenes-app-ai-observability-clustercard--default--dark:
+ hash: v1.k794b7964.b52003430ca42f6ccab28d62f0fe64ad91f127545e84bd43fb64c1ed4d3e81bc.t3RP33V9PWx79luc4NgTcByuAMALgAuejhiT7VqHTnw
+ scenes-app-ai-observability-clustercard--default--light:
+ hash: v1.k794b7964.591cf6ff422c6513b940049ed617718ef29076c538da7ec3d43bf0cfda930334.J3lT3Gdg7QQbBkuoXR03yxGoYW1TwH79QHpri8BWEs8
+ scenes-app-ai-observability-clustercard--grid--dark:
+ hash: v1.k794b7964.77fe7bd587009395d844e80d94b0493f7b22d0dcde4f3e536fcf8f55f657c1e4.CM3issGmaz4l9lHijMQjqlMPlsFQACRQNKX1HznBoeY
+ scenes-app-ai-observability-clustercard--grid--light:
+ hash: v1.k794b7964.20f47d4512844cd6752c6ef6c6585e9d33a45e934bfe0ae0568902a283b7b18a.xmbyIYS2nLDC1kEiRylhzKh7Qo3SsrQSEPmc_JPc-TA
+ scenes-app-ai-observability-clustercard--outlier-cluster--dark:
+ hash: v1.k794b7964.62c1fa128a6d81faf023ef07b64573b65bc63ad134a5dc1d1fc799060ec5bb31.4k11QyYYgyzFC-FDWNfJnXKBnczssQJdxs8IPDUpGYQ
+ scenes-app-ai-observability-clustercard--outlier-cluster--light:
+ hash: v1.k794b7964.7fac8faa9ff9b6569f876cc2fe371289411fcf7dc10562263b55121953a9e4cc.03ixIQOl__kh4Kr_0W7vN7SSKzvCViAyYNfZCYX24Kc
+ scenes-app-ai-observability-clustercard--without-metrics--dark:
+ hash: v1.k794b7964.4ae457c288f6aa7cd869268709ef94d72973df06f58478d69ff79feb47a1296a.i_GgGzKI_nl7bJT3mzTCEMgFFNWYCKKJd5NtLIc6GZM
+ scenes-app-ai-observability-clustercard--without-metrics--light:
+ hash: v1.k794b7964.0d79d8c30ef8057a40264755a73acc3f8e8bdf04e227fd6f089f3acc411c3cf5.bjusiYCt_UzXBYxiJDAgVu7GFlVKug1lP_tkmTsR6dU
scenes-app-ai-observability-conversation-display--anthropic--dark:
hash: v1.k794b7964.9c97c85c94605b8ce34469ddb269688ff84d0c3aa87818e6f9c94745c114a434.o6eqWM3HKURlW-MBuPGhIw6sslncdZGR6-pBuz1FVBM
scenes-app-ai-observability-conversation-display--anthropic--light:
diff --git a/products/llm_analytics/frontend/clusters/ClusterCard.stories.tsx b/products/llm_analytics/frontend/clusters/ClusterCard.stories.tsx
new file mode 100644
index 000000000000..2c3decdbc8a1
--- /dev/null
+++ b/products/llm_analytics/frontend/clusters/ClusterCard.stories.tsx
@@ -0,0 +1,118 @@
+import type { Meta, StoryObj } from '@storybook/react'
+
+import { ClusterCard } from './ClusterCard'
+import { NOISE_CLUSTER_ID } from './constants'
+import { Cluster, ClusterMetrics } from './types'
+
+const baseCluster: Cluster = {
+ cluster_id: 3,
+ size: 128,
+ title: 'Refund and cancellation requests',
+ description:
+ 'Users asking the assistant to refund a charge, cancel a subscription, or reverse a recent payment. Often references an order ID or invoice number.',
+ traces: {},
+ centroid: [],
+ centroid_x: 0,
+ centroid_y: 0,
+}
+
+const baseMetrics: ClusterMetrics = {
+ avgCost: 0.0042,
+ avgLatency: 2.31,
+ avgTokens: 1840,
+ totalCost: 0.54,
+ errorRate: 0.02,
+ errorCount: 3,
+ itemCount: 128,
+}
+
+const meta: Meta<typeof ClusterCard> = {
+ title: 'Scenes-App/AI observability/ClusterCard',
+ component: ClusterCard,
+ parameters: {
+ layout: 'padded',
+ },
+}
+export default meta
+
+type Story = StoryObj<typeof ClusterCard>
+
+const baseArgs = {
+ cluster: baseCluster,
+ totalTraces: 500,
+ isExpanded: false,
+ onToggleExpand: () => {},
+ traceSummaries: {},
+ loadingTraces: false,
+ runId: '2_trace_20260101_120000',
+ clusteringLevel: 'trace' as const,
+ metrics: baseMetrics,
+ metricsLoading: false,
+}
+
+export const Default: Story = {
+ render: (args) => (
+ <div className="max-w-2xl">
+ <ClusterCard {...args} />
+ </div>
+ ),
+ args: baseArgs,
+}
+
+export const OutlierCluster: Story = {
+ render: (args) => (
+ <div className="max-w-2xl">
+ <ClusterCard {...args} />
+ </div>
+ ),
+ args: {
+ ...baseArgs,
+ cluster: {
+ ...baseCluster,
+ cluster_id: NOISE_CLUSTER_ID,
+ title: 'Outliers',
+ description: 'Items that did not fit cleanly into any cluster.',
+ size: 17,
+ },
+ },
+}
+
+export const WithoutMetrics: Story = {
+ render: (args) => (
+ <div className="max-w-2xl">
+ <ClusterCard {...args} />
+ </div>
+ ),
+ args: {
+ ...baseArgs,
+ metrics: undefined,
+ },
+}
+
+export const Grid: Story = {
+ render: (args) => (
+ <div className="grid grid-cols-1 lg:grid-cols-2 gap-4">
+ {[0, 1, 2, 3, 4, 5].map((id) => (
+ <ClusterCard
+ {...args}
+ key={id}
+ cluster={{
+ ...baseCluster,
+ cluster_id: id,
+ title: `Cluster ${id + 1}`,
+ }}
+ />
+ ))}
+ <ClusterCard
+ {...args}
+ cluster={{
+ ...baseCluster,
+ cluster_id: NOISE_CLUSTER_ID,
+ title: 'Outliers',
+ size: 12,
+ }}
+ />
+ </div>
+ ),
+ args: baseArgs,
+}
diff --git a/products/llm_analytics/frontend/clusters/ClusterCard.tsx b/products/llm_analytics/frontend/clusters/ClusterCard.tsx
index 580c0170c7e8..c487ae6d1fb2 100644
--- a/products/llm_analytics/frontend/clusters/ClusterCard.tsx
+++ b/products/llm_analytics/frontend/clusters/ClusterCard.tsx
@@ -1,3 +1,5 @@
+import clsx from 'clsx'
+
import { IconChevronDown, IconChevronRight } from '@posthog/icons'
import { LemonButton, LemonTag, Link, Tooltip } from '@posthog/lemon-ui'
@@ -7,7 +9,7 @@ import { urls } from 'scenes/urls'
import { formatErrorRate, formatLLMCost, formatLLMLatency, formatTokens } from '../utils'
import { ClusterDescription } from './ClusterDescriptionComponents'
import { ClusterTraceList } from './ClusterTraceList'
-import { NOISE_CLUSTER_ID, OUTLIER_COLOR } from './constants'
+import { NOISE_CLUSTER_ID } from './constants'
import { Cluster, ClusterMetrics, ClusteringLevel, TraceSummary } from './types'
interface ClusterCardProps {
@@ -40,7 +42,7 @@ export function ClusterCard({
const itemLabel =
clusteringLevel === 'generation' ? 'generations' : clusteringLevel === 'evaluation' ? 'evaluations' : 'traces'
- const clusterColor = isOutlierCluster ? OUTLIER_COLOR : getSeriesColor(cluster.cluster_id)
+ const clusterColor = isOutlierCluster ? undefined : getSeriesColor(cluster.cluster_id)
// Check if we have any metrics to show. Eval-specific metrics (passRate /
// naRate / dominantEvaluationName / dominantRuntime) count even when the
@@ -62,16 +64,10 @@ export function ClusterCard({
return (
<div
- className={`rounded-lg overflow-hidden transition-all border-y border-r ${
- isOutlierCluster ? 'bg-surface-primary border-dashed' : 'bg-surface-primary'
- }`}
- // eslint-disable-next-line react/forbid-dom-props
- style={{
- borderColor: isOutlierCluster ? 'var(--warning-dark)' : 'var(--border)',
- borderLeftWidth: 3,
- borderLeftColor: clusterColor,
- borderLeftStyle: isOutlierCluster ? 'dashed' : 'solid',
- }}
+ className={clsx(
+ 'rounded-lg overflow-hidden transition-all bg-surface-primary border border-primary',
+ isOutlierCluster && 'border-dashed'
+ )}
>
{/* Card Header */}
<div
@@ -81,7 +77,16 @@ export function ClusterCard({
>
<div className="flex items-start justify-between gap-2">
<div className="flex-1 min-w-0">
- <div className="flex items-baseline gap-2 mb-2">
+ <div className="flex items-center gap-2 mb-2">
+ <div
+ className={clsx(
+ 'w-2.5 h-2.5 rounded-full shrink-0',
+ isOutlierCluster && 'border border-dashed border-secondary'
+ )}
+ // eslint-disable-next-line react/forbid-dom-props
+ style={isOutlierCluster ? undefined : { backgroundColor: clusterColor }}
+ aria-hidden
+ />
<Link
to={urls.llmAnalyticsCluster(runId, cluster.cluster_id)}
className="font-semibold text-base truncate hover:underline"