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(aio): stop showing "no runs yet" when runs load fails or a filter hides them (#88777)

posthog[bot]9b80d4861700
diff --git a/products/ai_observability/frontend/evaluations/components/EvaluationRunsTable.test.tsx b/products/ai_observability/frontend/evaluations/components/EvaluationRunsTable.test.tsx
new file mode 100644
index 000000000000..995921cef945
--- /dev/null
+++ b/products/ai_observability/frontend/evaluations/components/EvaluationRunsTable.test.tsx
@@ -0,0 +1,98 @@
+import '@testing-library/jest-dom'
+
+import { cleanup, render, screen } from '@testing-library/react'
+import { BindLogic, Provider } from 'kea'
+
+import { useMocks } from '~/mocks/jest'
+import { initKeaTests } from '~/test/init'
+
+import { llmEvaluationLogic } from '../llmEvaluationLogic'
+import { EvaluationRun } from '../types'
+import { EvaluationRunsTable } from './EvaluationRunsTable'
+
+const props = { evaluationId: 'eval-123' }
+
+function renderTable(): void {
+ render(
+ <Provider>
+ <BindLogic logic={llmEvaluationLogic} props={props}>
+ <EvaluationRunsTable />
+ </BindLogic>
+ </Provider>
+ )
+}
+
+const passingRun: EvaluationRun = {
+ id: 'run-1',
+ evaluation_id: 'eval-123',
+ evaluation_name: 'Test Evaluation',
+ generation_id: 'gen-1',
+ trace_id: 'trace-1',
+ timestamp: '2024-01-01T10:00:00Z',
+ result: true,
+ reasoning: 'Good',
+ status: 'completed',
+}
+
+describe('EvaluationRunsTable', () => {
+ let logic: ReturnType<typeof llmEvaluationLogic.build>
+
+ beforeEach(() => {
+ useMocks({
+ get: {
+ '/api/environments/:teamId/llm_analytics/provider_keys/': { results: [] },
+ '/api/environments/:teamId/llm_analytics/evaluation_config/': {
+ active_provider_key: null,
+ created_at: '2024-01-01T00:00:00Z',
+ updated_at: '2024-01-01T00:00:00Z',
+ },
+ '/api/projects/:teamId/evaluations/:id/': {},
+ },
+ })
+ initKeaTests()
+ logic = llmEvaluationLogic(props)
+ logic.mount()
+ })
+
+ afterEach(() => {
+ cleanup()
+ logic?.unmount()
+ })
+
+ it('shows a retry action instead of the empty state when the query failed', () => {
+ logic.actions.loadEvaluationRunsFailure('boom')
+ renderTable()
+
+ expect(screen.getByText('Could not load evaluation runs')).toBeInTheDocument()
+ expect(screen.getByText('Retry')).toBeInTheDocument()
+ expect(screen.queryByText('No evaluation runs yet')).not.toBeInTheDocument()
+ })
+
+ it('warns that rows are stale when a refresh fails with runs already on screen', () => {
+ logic.actions.loadEvaluationRunsSuccess([passingRun])
+ logic.actions.loadEvaluationRunsFailure('boom')
+ renderTable()
+
+ expect(
+ screen.getByText("We couldn't refresh the evaluation runs. The runs below may be out of date.")
+ ).toBeInTheDocument()
+ expect(document.querySelector('[data-attr="llma-evaluation-runs-stale-retry"]')).toBeInTheDocument()
+ expect(screen.getByText('Good')).toBeInTheDocument()
+ })
+
+ it('says a filter is hiding rows when the evaluation has runs but none match', () => {
+ logic.actions.loadEvaluationRunsSuccess([passingRun])
+ logic.actions.setEvaluationRunsFilter('fail', 'all')
+ renderTable()
+
+ expect(screen.getByText('No runs match this filter')).toBeInTheDocument()
+ expect(screen.queryByText('No evaluation runs yet')).not.toBeInTheDocument()
+ })
+
+ it('shows the never-ran empty state when the evaluation truly has no runs', () => {
+ logic.actions.loadEvaluationRunsSuccess([])
+ renderTable()
+
+ expect(screen.getByText('No evaluation runs yet')).toBeInTheDocument()
+ })
+})
diff --git a/products/ai_observability/frontend/evaluations/components/EvaluationRunsTable.tsx b/products/ai_observability/frontend/evaluations/components/EvaluationRunsTable.tsx
index 869b08ec5d03..254aaa9f3b41 100644
--- a/products/ai_observability/frontend/evaluations/components/EvaluationRunsTable.tsx
+++ b/products/ai_observability/frontend/evaluations/components/EvaluationRunsTable.tsx
@@ -1,7 +1,7 @@
import { useActions, useValues } from 'kea'
import { IconRefresh } from '@posthog/icons'
-import { LemonButton, LemonSegmentedButton, LemonTable, LemonTag, Tooltip } from '@posthog/lemon-ui'
+import { LemonBanner, LemonButton, LemonSegmentedButton, LemonTable, LemonTag, Tooltip } from '@posthog/lemon-ui'
import { TZLabel } from 'lib/components/TZLabel'
import { LemonTableColumns } from 'lib/lemon-ui/LemonTable'
@@ -38,11 +38,48 @@ function SentimentEvaluationRunsFilters(): JSX.Element {
}
export function EvaluationRunsTable(): JSX.Element {
- const { filteredEvaluationRuns, evaluation, evaluationRunsLoading } = useValues(llmEvaluationLogic)
+ const { filteredEvaluationRuns, evaluationRuns, evaluationRunsError, evaluation, evaluationRunsLoading } =
+ useValues(llmEvaluationLogic)
const { refreshEvaluationRuns } = useActions(llmEvaluationLogic)
const showOutcomeFilters = evaluationSupportsRunOutcomes(evaluation)
const showSentimentFilters = evaluation?.evaluation_type === 'sentiment'
+ // A filter is hiding rows when the evaluation has runs but none match the current filter.
+ const filterHidesRuns = evaluationRuns.length > 0 && filteredEvaluationRuns.length === 0
+ // LemonTable drops its empty state as soon as it has rows, so a failed refresh over rows that
+ // are already on screen needs its own surface. Without it the spinner just stops and the user
+ // reads the stale rows as current.
+ const showStaleRunsBanner = evaluationRunsError && filteredEvaluationRuns.length > 0
+
+ const emptyState = evaluationRunsError ? (
+ <div className="text-center py-8">
+ <div className="text-muted mb-2">Could not load evaluation runs</div>
+ <div className="text-sm text-muted mb-3">The query failed. This is usually temporary. Try again.</div>
+ <LemonButton
+ type="secondary"
+ icon={<IconRefresh />}
+ onClick={refreshEvaluationRuns}
+ loading={evaluationRunsLoading}
+ size="small"
+ data-attr="llma-evaluation-runs-retry"
+ >
+ Retry
+ </LemonButton>
+ </div>
+ ) : filterHidesRuns ? (
+ <div className="text-center py-8">
+ <div className="text-muted mb-2">No runs match this filter</div>
+ <div className="text-sm text-muted">Change the filter above to see this evaluation's other runs.</div>
+ </div>
+ ) : (
+ <div className="text-center py-8">
+ <div className="text-muted mb-2">No evaluation runs yet</div>
+ <div className="text-sm text-muted">
+ Runs will appear here once this evaluation starts executing based on your triggers.
+ </div>
+ </div>
+ )
+
const columns: LemonTableColumns<EvaluationRun> = [
{
title: 'Timestamp',
@@ -111,6 +148,19 @@ export function EvaluationRunsTable(): JSX.Element {
</LemonButton>
</div>
+ {showStaleRunsBanner && (
+ <LemonBanner
+ type="error"
+ action={{
+ children: 'Try again',
+ onClick: refreshEvaluationRuns,
+ 'data-attr': 'llma-evaluation-runs-stale-retry',
+ }}
+ >
+ We couldn't refresh the evaluation runs. The runs below may be out of date.
+ </LemonBanner>
+ )}
+
<LemonTable
columns={columns}
dataSource={filteredEvaluationRuns}
@@ -119,14 +169,7 @@ export function EvaluationRunsTable(): JSX.Element {
pagination={{
pageSize: 50,
}}
- emptyState={
- <div className="text-center py-8">
- <div className="text-muted mb-2">No evaluation runs yet</div>
- <div className="text-sm text-muted">
- Runs will appear here once this evaluation starts executing based on your triggers.
- </div>
- </div>
- }
+ emptyState={emptyState}
/>
</div>
)
diff --git a/products/ai_observability/frontend/evaluations/llmEvaluationLogic.test.ts b/products/ai_observability/frontend/evaluations/llmEvaluationLogic.test.ts
index a42b07a05972..8251276a26b0 100644
--- a/products/ai_observability/frontend/evaluations/llmEvaluationLogic.test.ts
+++ b/products/ai_observability/frontend/evaluations/llmEvaluationLogic.test.ts
@@ -1080,6 +1080,27 @@ return result`,
})
})
})
+
+ // Without this the failed query keeps the default empty list, and the table shows "no runs
+ // yet" instead of a failure state — the bug this fix addresses.
+ describe('evaluationRunsError', () => {
+ it('records the failure so the table can show an error state', async () => {
+ logic.actions.loadEvaluationRunsFailure('boom')
+
+ await expectLogic(logic).toMatchValues({
+ evaluationRunsError: true,
+ })
+ })
+
+ it('clears the error on the next successful load', async () => {
+ logic.actions.loadEvaluationRunsFailure('boom')
+ logic.actions.loadEvaluationRunsSuccess(mockRuns)
+
+ await expectLogic(logic).toMatchValues({
+ evaluationRunsError: false,
+ })
+ })
+ })
})
describe('hog evaluation type', () => {
diff --git a/products/ai_observability/frontend/evaluations/llmEvaluationLogic.ts b/products/ai_observability/frontend/evaluations/llmEvaluationLogic.ts
index a4a69fa684c0..9e622bf81d31 100644
--- a/products/ai_observability/frontend/evaluations/llmEvaluationLogic.ts
+++ b/products/ai_observability/frontend/evaluations/llmEvaluationLogic.ts
@@ -229,6 +229,7 @@ export interface llmEvaluationLogicValues {
evaluationLoading: boolean
evaluationProviderKeyIssue: LLMProviderKey | null
evaluationRuns: EvaluationRun[]
+ evaluationRunsError: boolean
evaluationRunsFilter: EvaluationRunsFilter
evaluationRunsLoading: boolean
filteredEvaluationRuns: EvaluationRun[]
@@ -732,6 +733,16 @@ export const llmEvaluationLogic = kea<llmEvaluationLogicType>([
loadEvaluationRunsFailure: () => false,
},
],
+ // The runs loader keeps its default empty list when the query fails. Track the failure so
+ // the table can show a real error state with retry instead of the "no runs yet" empty state.
+ evaluationRunsError: [
+ false as boolean,
+ {
+ loadEvaluationRuns: () => false,
+ loadEvaluationRunsSuccess: () => false,
+ loadEvaluationRunsFailure: () => true,
+ },
+ ],
evaluationLoading: [
false,
{