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(aio): mark self-driving beta and sort the evals table (#81862)

Radu Raiceaf46b54f70ca4
diff --git a/products/ai_observability/frontend/AIObservabilityScene.tsx b/products/ai_observability/frontend/AIObservabilityScene.tsx
index 0336b6f09468..487dea7c6531 100644
--- a/products/ai_observability/frontend/AIObservabilityScene.tsx
+++ b/products/ai_observability/frontend/AIObservabilityScene.tsx
@@ -2,7 +2,7 @@ import { BindLogic, useActions, useValues } from 'kea'
import { combineUrl, router } from 'kea-router'
import React from 'react'
-import { LemonButton, LemonTab, LemonTabs, Link, Spinner } from '@posthog/lemon-ui'
+import { LemonButton, LemonTab, LemonTabs, LemonTag, Link, Spinner } from '@posthog/lemon-ui'
import { AccessControlAction } from 'lib/components/AccessControlAction'
import { DateFilter } from 'lib/components/DateFilter/DateFilter'
@@ -479,26 +479,20 @@ function AIObservabilitySceneContent(): JSX.Element {
useShortcut({
name: 'AIObservabilityTab2',
keybind: [keyBinds.tab2],
- intent: selfDrivingEnabled ? 'Go to Self-driving' : 'Go to Traces',
+ intent: 'Go to Traces',
interaction: 'function',
- callback: () =>
- push(
- combineUrl(
- selfDrivingEnabled ? urls.aiObservabilitySelfDriving() : urls.aiObservabilityTraces(),
- searchParams
- ).url
- ),
+ callback: () => push(combineUrl(urls.aiObservabilityTraces(), searchParams).url),
scope: Scene.AIObservability,
})
useShortcut({
name: 'AIObservabilityTab3',
keybind: [keyBinds.tab3],
- intent: selfDrivingEnabled ? 'Go to Traces' : 'Go to Generations',
+ intent: selfDrivingEnabled ? 'Go to Self-driving' : 'Go to Generations',
interaction: 'function',
callback: () =>
push(
combineUrl(
- selfDrivingEnabled ? urls.aiObservabilityTraces() : urls.aiObservabilityGenerations(),
+ selfDrivingEnabled ? urls.aiObservabilitySelfDriving() : urls.aiObservabilityGenerations(),
searchParams
).url
),
@@ -569,9 +563,16 @@ function AIObservabilitySceneContent(): JSX.Element {
]
if (selfDrivingEnabled) {
- tabs.splice(1, 0, {
+ tabs.splice(2, 0, {
key: 'self-driving',
- label: 'Self-driving',
+ label: (
+ <>
+ Self-driving{' '}
+ <LemonTag type="completion" size="small" className="ml-1">
+ Beta
+ </LemonTag>
+ </>
+ ),
content: <AIObservabilitySelfDriving />,
link: combineUrl(urls.aiObservabilitySelfDriving(), searchParams).url,
'data-attr': 'self-driving-tab',
diff --git a/products/ai_observability/frontend/selfDriving/AIObservabilitySelfDriving.test.tsx b/products/ai_observability/frontend/selfDriving/AIObservabilitySelfDriving.test.tsx
index 2c0ff9c2c8a8..4c201654ffbc 100644
--- a/products/ai_observability/frontend/selfDriving/AIObservabilitySelfDriving.test.tsx
+++ b/products/ai_observability/frontend/selfDriving/AIObservabilitySelfDriving.test.tsx
@@ -185,6 +185,31 @@ describe('AIObservabilitySelfDriving', () => {
expect(router.values.searchParams).toEqual(expect.objectContaining({ evaluation_tab: 'configuration' }))
})
+ it('sorts evals by report columns', async () => {
+ render(
+ <Provider>
+ <AIObservabilitySelfDriving />
+ </Provider>
+ )
+
+ const evalNames = (): string[] =>
+ Array.from(
+ document.querySelectorAll(
+ '[data-attr="ai-observability-evaluations-table"] tbody tr td:first-child span:first-child'
+ )
+ ).map((nameSpan) => nameSpan.textContent ?? '')
+
+ expect(await screen.findByText('Correctness check')).toBeInTheDocument()
+ expect(evalNames()).toEqual(['Correctness check', 'Tone check'])
+
+ // The eval with no report counts as zero, so ascending order puts it first.
+ await userEvent.click(screen.getByText('Reports generated'))
+ expect(evalNames()).toEqual(['Tone check', 'Correctness check'])
+
+ await userEvent.click(screen.getByText('Reports generated'))
+ expect(evalNames()).toEqual(['Correctness check', 'Tone check'])
+ })
+
it('guides users without evals to templates or their agent', async () => {
jest.mocked(aiObservabilityApi.evaluationsList).mockResolvedValue({
count: 0,
diff --git a/products/ai_observability/frontend/selfDriving/AIObservabilitySelfDriving.tsx b/products/ai_observability/frontend/selfDriving/AIObservabilitySelfDriving.tsx
index 4de24f4ee844..d566a73f7d4e 100644
--- a/products/ai_observability/frontend/selfDriving/AIObservabilitySelfDriving.tsx
+++ b/products/ai_observability/frontend/selfDriving/AIObservabilitySelfDriving.tsx
@@ -7,6 +7,7 @@ import { LemonBanner, LemonButton, LemonCard, LemonSkeleton, LemonTable, LemonTa
import { MCPUseCaseCard } from 'lib/components/MCPHint/MCPUseCaseCard'
import { TZLabel } from 'lib/components/TZLabel'
import { FEATURE_FLAGS } from 'lib/constants'
+import { dayjs } from 'lib/dayjs'
import { LemonTableColumns } from 'lib/lemon-ui/LemonTable'
import { Link } from 'lib/lemon-ui/Link'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
@@ -18,6 +19,7 @@ import { scoutFleetLogic } from 'products/signals/frontend/inbox/logics/scoutFle
import { llmEvaluationsLogic } from '../evaluations/llmEvaluationsLogic'
import type { EvaluationConfig } from '../evaluations/types'
+import type { EvaluationReportApi } from '../generated/api.schemas'
import {
AI_OBSERVABILITY_SCOUT_TEMPLATES,
AIObservabilityScoutTemplate,
@@ -78,11 +80,14 @@ export function AIObservabilitySelfDriving(): JSX.Element {
const { loadSelfDrivingEvaluationReports } = useActions(aiObservabilitySelfDrivingLogic)
const aiObservabilityScouts = scoutConfigs?.filter(isAIObservabilityScout) ?? []
+ const reportFor = (evaluation: EvaluationConfig): EvaluationReportApi | null =>
+ evaluationReportsByEvaluationId?.[evaluation.id] ?? null
const evaluationColumns: LemonTableColumns<EvaluationConfig> = [
{
title: 'Name',
key: 'name',
width: '40%',
+ sorter: (a, b) => a.name.localeCompare(b.name),
render: (_, evaluation) => (
<div className="flex min-w-0 flex-col">
<span className="truncate font-semibold">{evaluation.name}</span>
@@ -93,6 +98,7 @@ export function AIObservabilitySelfDriving(): JSX.Element {
{
title: 'Eval reports',
key: 'reports',
+ sorter: (a, b) => Number(reportFor(a)?.enabled ?? false) - Number(reportFor(b)?.enabled ?? false),
render: (_, evaluation) => {
if (evaluationReportsByEvaluationId === null) {
return <LemonTag type="muted">Unavailable</LemonTag>
@@ -108,6 +114,7 @@ export function AIObservabilitySelfDriving(): JSX.Element {
{
title: 'Reports generated',
key: 'generated_report_count',
+ sorter: (a, b) => (reportFor(a)?.generated_report_count ?? 0) - (reportFor(b)?.generated_report_count ?? 0),
render: (_, evaluation) => {
if (evaluationReportsByEvaluationId === null) {
return 'Unavailable'
@@ -119,6 +126,10 @@ export function AIObservabilitySelfDriving(): JSX.Element {
{
title: 'Last generated',
key: 'last_generated_at',
+ // Never-generated evals sort as the oldest rather than mixing into the middle of the list.
+ sorter: (a, b) =>
+ dayjs(reportFor(a)?.last_generated_at ?? 0).valueOf() -
+ dayjs(reportFor(b)?.last_generated_at ?? 0).valueOf(),
render: (_, evaluation) => {
if (evaluationReportsByEvaluationId === null) {
return 'Unavailable'