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(data-modeling): illustrated healthy state on the models overview (#103948)

Thiago Salvatore676f40400e22
diff --git a/docs/internal/data-quality-checks.md b/docs/internal/data-quality-checks.md
index cf2ec6265fcf..b8ab34e1c0de 100644
--- a/docs/internal/data-quality-checks.md
+++ b/docs/internal/data-quality-checks.md
@@ -62,6 +62,14 @@ Notification recipient checks retain the existing global warehouse-resource poli
Catalog access is a project permission resource. Notification visibility follows that permission, including after access is revoked.
+## Models overview
+
+The models overview reports one status for the whole project. It shows the status panel only when the model list and the check list have both answered, and when no model and no check needs attention. A request that failed is reported as a failure, so an unanswered request never reads as an all-clear.
+
+The panel's text follows the check results. It claims that all data quality checks passed only when every check passed on its last run. A check that was skipped or has never run is not a passed check, so the panel then says that no checks are failing and some have not passed yet. The overview reads one page of checks, so a project that fills that page gets the same text as a project with the data quality tab off: a check on a later page could be failing. A project with no checks is asked to add some. When the data quality tab is not available, the panel speaks about the models alone.
+
+A project that has no models and no saved views gets the first-view text instead of a status claim.
+
## Subject schedules
A subject whose checks run on a recurring schedule has one Temporal Schedule in its canonical project. Metrics and PostHog tables are those subjects; a warehouse table's and a view's checks run when their data changes instead. A PostHog table is never synced or materialized, so a schedule is the only trigger its checks have. The first check creates an enabled daily schedule after the check transaction commits and starts an initial run. Available intervals are one hour, six hours, twelve hours, one day, and one week. A deterministic offset spreads recurring executions across each interval.
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 6d7671198337..64ea4814c43b 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -6016,6 +6016,30 @@ snapshots:
hash: v1.k794b7964.727a524bea080ccdd40b9d0d0d24fa11124956af6de43b8d1c7c55ecac8396fe.65eGhlez_kvcvkBca8RfUE_Vaw5E2KlZeBOB4vTHpgE
products-data-modeling-model-view-summary--one-dependent-model--light:
hash: v1.k794b7964.dfec6463b360d4256744023dcd168e8d00f4a15b49d0ab102389e63b73a16365.u5HZ_NMmZXGGMkfZG2ggcYyw--1BmBQ3OINd9m_arTE
+ products-data-modeling-models-overview--first-view--dark:
+ hash: v1.k794b7964.4662f3b1f56358510a0df8317b0ccc1d3433e0d1463756c2f36206e59a23a209.p0Zm_YMIsUxgtbz6aZzyIB-h56I6y2KJG8hMyP2gPBk
+ products-data-modeling-models-overview--first-view--light:
+ hash: v1.k794b7964.53c852464a09daa99f4fbc932e7baebb997f3e9bc5703d6e96b1d1bd765d1672.Kimk7IzdviRzmLHXyCJEPD81s0ftcoVGW87PAJNxl8k
+ products-data-modeling-models-overview--healthy--dark:
+ hash: v1.k794b7964.33a4e6635e379244b282fcdac6dcbc1b921a81c0bf107b722a6b28e209a04b61.FzcG1UAipCRC080eSXU-kP6EjDBd5FcBIfXxB03ASzA
+ products-data-modeling-models-overview--healthy--light:
+ hash: v1.k794b7964.a0f971eeeb05d6b7c69fb46da41202a3818ad1fd8dbb1dddd00823bb3f03a3f7.WsGaxY4f-EiIAWk8N3pybmLGR4DroahIXuP3obb0Wzk
+ products-data-modeling-models-overview--healthy-narrow--dark:
+ hash: v1.k794b7964.afba425b824ad7c8ec470d3a36754c5737dcb83a92354e2136da9e830fde5fc9.01diZppOafpB1fgzk2RrDqLnDbDyZMm5Rx-mfJeZ0Mo
+ products-data-modeling-models-overview--healthy-narrow--light:
+ hash: v1.k794b7964.bce82ef74f0174eba639d728902e23ceac2cbc06b326ed89afbeb89e5611c384.KgqSdeQ9G6RzxEvDSG9Hv7SNG5uQfxzAPNyDdJLBHks
+ products-data-modeling-models-overview--healthy-with-checks-not-run--dark:
+ hash: v1.k794b7964.3f2fd53b9be376fa33ce37c805a522cc67f917ff670447c5cc4bf2ef4038273f.LBo7z2BbqtmXZ25linp5FztXqPOM6b_81NJZ_hr28zM
+ products-data-modeling-models-overview--healthy-with-checks-not-run--light:
+ hash: v1.k794b7964.4259355f7d4ff729576d40af282d74a44b5065db2a05ea27542e0c23329d8d7f.-sEbjEO0wpUjCES2bDvCOmADt-Kd21vvdgv9G6068rU
+ products-data-modeling-models-overview--healthy-with-data-quality-disabled--dark:
+ hash: v1.k794b7964.0f3b08bc92cf73d3879f0c7740addb892044057a61dc9664f0e0ad792abe8277.r-y6mzu5XrZBUELRuQmHQLBm8qvymp4GAqSvo--1XJs
+ products-data-modeling-models-overview--healthy-with-data-quality-disabled--light:
+ hash: v1.k794b7964.d089cacb28fb150619edc9c26313886bd30625d17984efeb15f757d9add922d1.mcei4KR6JINsES5OPVdRQDTLHe8XV49ySS4jGmZp5kE
+ products-data-modeling-models-overview--healthy-without-checks--dark:
+ hash: v1.k794b7964.fa41cba0989fef0a2c838801d3644c1e4ca8eac937bb3dbf725a7f6a7ef604aa.kelUPDbmBhJYptOGC9w-g3iE44re-pPeiVlL78ezLeU
+ products-data-modeling-models-overview--healthy-without-checks--light:
+ hash: v1.k794b7964.80a51ff1336207682dd9fbe4157ea086f18974ceebb841ea0df8a6c43cbc9a84.NdRL-UCZH1KSqc-cXsLgMFmO78BtuRY2SOvo8p4dr2c
products-data-modeling-models-overview--narrow--dark:
hash: v1.k794b7964.b05ce52737a3aafe04e7bf7219f0cf117abe1ddf8e4324032638a2217275e8b0.l_KcmfKVER-Bg-A4q9C7tT6boC18cfFhdQ5LuoPYpH0
products-data-modeling-models-overview--narrow--light:
diff --git a/frontend/src/scenes/data-warehouse/saved_queries/dataWarehouseViewsLogic.tsx b/frontend/src/scenes/data-warehouse/saved_queries/dataWarehouseViewsLogic.tsx
index c0f2a142ec0b..cdddcc42d7e6 100644
--- a/frontend/src/scenes/data-warehouse/saved_queries/dataWarehouseViewsLogic.tsx
+++ b/frontend/src/scenes/data-warehouse/saved_queries/dataWarehouseViewsLogic.tsx
@@ -55,6 +55,8 @@ export interface dataWarehouseViewsLogicValues {
views: DatabaseSchemaViewTable[] // databaseTableListLogic
user: UserType | null // userLogic
dataWarehouseSavedQueries: DataWarehouseSavedQuerySummary[]
+ dataWarehouseSavedQueriesFailed: boolean
+ dataWarehouseSavedQueriesLoaded: boolean
dataWarehouseSavedQueriesLoading: boolean
dataWarehouseSavedQueryFolders: DataWarehouseSavedQueryFolder[]
dataWarehouseSavedQueryFoldersById: Record<string, DataWarehouseSavedQueryFolder>
@@ -358,6 +360,21 @@ export const dataWarehouseViewsLogic = kea<dataWarehouseViewsLogicType>([
loadDataWarehouseSavedQueriesFailure: () => false,
},
],
+ dataWarehouseSavedQueriesLoaded: [
+ false,
+ {
+ loadDataWarehouseSavedQueriesSuccess: () => true,
+ loadDataWarehouseSavedQueriesFailure: () => false,
+ },
+ ],
+ dataWarehouseSavedQueriesFailed: [
+ false,
+ {
+ loadDataWarehouseSavedQueries: () => false,
+ loadDataWarehouseSavedQueriesSuccess: () => false,
+ loadDataWarehouseSavedQueriesFailure: () => true,
+ },
+ ],
updatingDataWarehouseSavedQuery: [
false,
{
diff --git a/frontend/src/scenes/models/modelsSceneLogic.test.ts b/frontend/src/scenes/models/modelsSceneLogic.test.ts
index bdac8b25b611..55907c2a1c06 100644
--- a/frontend/src/scenes/models/modelsSceneLogic.test.ts
+++ b/frontend/src/scenes/models/modelsSceneLogic.test.ts
@@ -168,6 +168,63 @@ describe('modelsSceneLogic', () => {
expect(broken.skippedCount).toEqual(2)
})
+ it.each<[string, string, any, string]>([
+ ['the model list', '/api/environments/:team_id/data_modeling_nodes/', lineageDataLogic, 'loadNodesFailure'],
+ [
+ 'the view list',
+ '/api/projects/:team_id/warehouse_saved_queries/',
+ dataWarehouseViewsLogic,
+ 'loadDataWarehouseSavedQueriesFailure',
+ ],
+ ])('reports a failure instead of resolving when %s fails to load', async (_case, path, failedLogic, action) => {
+ useMocks({ get: { [path]: () => [500, {}] } })
+ await mount('/models')
+ await expectLogic(failedLogic).toDispatchActions([action])
+
+ expect(logic.values.modelsFailed).toBe(true)
+ expect(logic.values.modelsResolved).toBe(false)
+ })
+
+ it.each<[string, DataModelingNode[], Record<string, any>[], boolean]>([
+ ['neither models nor views', [], [], true],
+ ['a view that is not a model yet', [], [{ id: 'query-1', name: 'a_view', columns: [] }], false],
+ [
+ 'a warehouse source table and nothing else',
+ [buildNode('source-table', { type: 'table', saved_query_id: undefined })],
+ [],
+ true,
+ ],
+ ])('reports a project with %s as new: %s', async (_case, nodes, savedQueries, expected) => {
+ useMocks({
+ get: {
+ '/api/environments/:team_id/data_modeling_nodes/': { count: nodes.length, results: nodes },
+ '/api/projects/:team_id/warehouse_saved_queries/': {
+ count: savedQueries.length,
+ results: savedQueries,
+ },
+ },
+ })
+ await mount('/models')
+ await expectLogic(lineageDataLogic).toDispatchActions(['loadNodesSuccess'])
+ await expectLogic(dataWarehouseViewsLogic).toDispatchActions(['loadDataWarehouseSavedQueriesSuccess'])
+
+ expect(logic.values.modelsResolved).toBe(true)
+ expect(logic.values.noModelsYet).toBe(expected)
+ })
+
+ it('stops reporting the model list resolved once a reload fails', async () => {
+ await mount('/models')
+ await expectLogic(lineageDataLogic).toDispatchActions(['loadNodesSuccess'])
+ await expectLogic(dataWarehouseViewsLogic).toDispatchActions(['loadDataWarehouseSavedQueriesSuccess'])
+ expect(logic.values.modelsResolved).toBe(true)
+
+ useMocks({ get: { '/api/environments/:team_id/data_modeling_nodes/': () => [500, {}] } })
+ lineageDataLogic.actions.loadNodes()
+ await expectLogic(lineageDataLogic).toDispatchActions(['loadNodesFailure'])
+
+ expect(logic.values.modelsResolved).toBe(false)
+ })
+
it('lists models behind schedule, minus the ones already listed as broken', async () => {
await mount('/models')
await expectLogic(lineageDataLogic).toDispatchActions(['loadNodesSuccess', 'loadEdgesSuccess'])
diff --git a/frontend/src/scenes/models/modelsSceneLogic.ts b/frontend/src/scenes/models/modelsSceneLogic.ts
index b7db52805dab..e26bf0978d4c 100644
--- a/frontend/src/scenes/models/modelsSceneLogic.ts
+++ b/frontend/src/scenes/models/modelsSceneLogic.ts
@@ -7,7 +7,7 @@ import type { DataWarehouseSavedQuerySummary } from 'scenes/data-warehouse/saved
import { dataWarehouseViewsLogic } from 'scenes/data-warehouse/saved_queries/dataWarehouseViewsLogic'
import { urls } from 'scenes/urls'
-import { DataModelingEdge, DataModelingNode } from '~/types'
+import { DataModelingEdge, DataModelingNode, DataModelingNodeType } from '~/types'
import { BehindScheduleModel, modelsBehindSchedule } from 'products/data_modeling/frontend/freshness'
import { NodeSuspensionApi } from 'products/data_modeling/frontend/generated/api.schemas'
@@ -17,6 +17,8 @@ import { servingSuspension } from 'products/data_modeling/frontend/suspension'
import type { FeatureFlagsSet } from '../../lib/logic/featureFlagLogic'
+const MODEL_NODE_TYPES = new Set<DataModelingNodeType>(['view', 'matview', 'endpoint'])
+
export type ModelsSceneTab = 'overview' | 'models' | 'lineage' | 'data-quality'
const MODELS_SCENE_TABS: ModelsSceneTab[] = ['overview', 'models', 'lineage', 'data-quality']
@@ -36,6 +38,8 @@ export interface AttentionModel {
export interface modelsSceneLogicValues {
dataWarehouseSavedQueries: DataWarehouseSavedQuerySummary[] // dataWarehouseViewsLogic
+ dataWarehouseSavedQueriesFailed: boolean // dataWarehouseViewsLogic
+ dataWarehouseSavedQueriesLoaded: boolean // dataWarehouseViewsLogic
dataWarehouseSavedQueriesLoading: boolean // dataWarehouseViewsLogic
featureFlags: FeatureFlagsSet // featureFlagLogic
receivedFeatureFlags: boolean // featureFlagLogic
@@ -43,6 +47,8 @@ export interface modelsSceneLogicValues {
dataQualityTabEnabled: boolean
nodes: DataModelingNode[] // lineageDataLogic
nodesLoading: boolean // lineageDataLogic
+ nodesLoaded: boolean // lineageDataLogic
+ nodesFailed: boolean // lineageDataLogic
edges: DataModelingEdge[] // lineageDataLogic
now: number
savedQueryIdToNodeId: Record<string, string>
@@ -51,10 +57,14 @@ export interface modelsSceneLogicValues {
suspensionBySavedQueryId: Record<string, NodeSuspensionApi | undefined>
attentionModels: AttentionModel[]
behindSchedule: BehindScheduleModel[]
+ modelsResolved: boolean
+ modelsFailed: boolean
+ noModelsYet: boolean
}
export interface modelsSceneLogicActions {
loadDataWarehouseSavedQueries: () => any // dataWarehouseViewsLogic
+ loadNodes: () => any // lineageDataLogic
setFeatureFlags: (flags: string[], variants: Record<string, boolean | string>) => any // featureFlagLogic
setActiveTab: (tab: ModelsSceneTab) => { tab: ModelsSceneTab }
setNow: (now: number) => { now: number }
@@ -79,6 +89,9 @@ export interface modelsSceneLogicMeta {
attentionModels: AttentionModel[],
now: number
) => BehindScheduleModel[]
+ modelsResolved: (nodesLoaded: boolean, dataWarehouseSavedQueriesLoaded: boolean) => boolean
+ modelsFailed: (nodesFailed: boolean, dataWarehouseSavedQueriesFailed: boolean) => boolean
+ noModelsYet: (nodes: DataModelingNode[], savedQueries: DataWarehouseSavedQuerySummary[]) => boolean
}
}
@@ -94,13 +107,25 @@ export const modelsSceneLogic = kea<modelsSceneLogicType>([
connect(() => ({
values: [
dataWarehouseViewsLogic,
- ['dataWarehouseSavedQueries', 'dataWarehouseSavedQueriesLoading'],
+ [
+ 'dataWarehouseSavedQueries',
+ 'dataWarehouseSavedQueriesFailed',
+ 'dataWarehouseSavedQueriesLoaded',
+ 'dataWarehouseSavedQueriesLoading',
+ ],
featureFlagLogic,
['featureFlags', 'receivedFeatureFlags'],
lineageDataLogic,
- ['nodes', 'nodesLoading', 'edges'],
+ ['nodes', 'nodesLoading', 'nodesLoaded', 'nodesFailed', 'edges'],
+ ],
+ actions: [
+ dataWarehouseViewsLogic,
+ ['loadDataWarehouseSavedQueries'],
+ featureFlagLogic,
+ ['setFeatureFlags'],
+ lineageDataLogic,
+ ['loadNodes'],
],
- actions: [dataWarehouseViewsLogic, ['loadDataWarehouseSavedQueries'], featureFlagLogic, ['setFeatureFlags']],
})),
actions({
setActiveTab: (tab: ModelsSceneTab) => ({ tab }),
@@ -214,6 +239,21 @@ export const modelsSceneLogic = kea<modelsSceneLogicType>([
return modelsBehindSchedule(nodes, now).filter((row) => !reported.has(row.node.id))
},
],
+ modelsResolved: [
+ (s) => [s.nodesLoaded, s.dataWarehouseSavedQueriesLoaded],
+ (nodesLoaded: boolean, dataWarehouseSavedQueriesLoaded: boolean): boolean =>
+ nodesLoaded && dataWarehouseSavedQueriesLoaded,
+ ],
+ modelsFailed: [
+ (s) => [s.nodesFailed, s.dataWarehouseSavedQueriesFailed],
+ (nodesFailed: boolean, dataWarehouseSavedQueriesFailed: boolean): boolean =>
+ nodesFailed || dataWarehouseSavedQueriesFailed,
+ ],
+ noModelsYet: [
+ (s) => [s.nodes, s.dataWarehouseSavedQueries],
+ (nodes: DataModelingNode[], savedQueries: DataWarehouseSavedQuerySummary[]): boolean =>
+ !nodes.some((node) => MODEL_NODE_TYPES.has(node.type)) && savedQueries.length === 0,
+ ],
dataQualityTabEnabled: [
(s) => [s.featureFlags],
(featureFlags: FeatureFlagsSet): boolean => !!featureFlags[FEATURE_FLAGS.DATA_QUALITY_CHECKS],
diff --git a/frontend/src/scenes/models/tabs/ModelsOverviewTab.tsx b/frontend/src/scenes/models/tabs/ModelsOverviewTab.tsx
index 7d42c130a288..e0d12b9630e3 100644
--- a/frontend/src/scenes/models/tabs/ModelsOverviewTab.tsx
+++ b/frontend/src/scenes/models/tabs/ModelsOverviewTab.tsx
@@ -1,6 +1,5 @@
import { useActions, useValues } from 'kea'
-import { IconCheckCircle } from '@posthog/icons'
import { LemonBanner, LemonTableColumns, LemonTag, Link, Tooltip } from '@posthog/lemon-ui'
import { TZLabel } from 'lib/components/TZLabel'
@@ -11,6 +10,10 @@ import { urls } from 'scenes/urls'
import { BehindScheduleModel } from 'products/data_modeling/frontend/freshness'
import { ModelNameLink } from 'products/data_modeling/frontend/ModelNameLink'
+import {
+ ModelsOverviewChecksStatus,
+ ModelsOverviewEmptyState,
+} from 'products/data_modeling/frontend/ModelsOverviewEmptyState'
import { ModelsOverviewTable } from 'products/data_modeling/frontend/ModelsOverviewTable'
import { checkDisplayName } from 'products/data_quality/frontend/checksConstants'
import { CheckStatusCell } from 'products/data_quality/frontend/CheckStatusCell'
@@ -168,43 +171,53 @@ const CHECK_COLUMNS: LemonTableColumns<DataQualityOverviewCheckApi> = [
function OverviewBody({
failingChecks,
+ checksStatus,
checksLoading,
checksLoaded,
checksError,
onRetryChecks,
}: {
failingChecks: DataQualityOverviewCheckApi[]
+ checksStatus: ModelsOverviewChecksStatus
checksLoading: boolean
/** False while the checks request is in flight, so an empty list is not yet an answer. */
checksLoaded: boolean
checksError: string | null
onRetryChecks?: () => void
}): JSX.Element {
- const { attentionModels, behindSchedule, nodesLoading, dataQualityTabEnabled } = useValues(modelsSceneLogic)
+ const { attentionModels, behindSchedule, nodesLoading, modelsFailed, modelsResolved, noModelsYet } =
+ useValues(modelsSceneLogic)
+ const { loadNodes, loadDataWarehouseSavedQueries } = useActions(modelsSceneLogic)
- const nothingWrong =
- !nodesLoading &&
+ const reloadModels = (): void => {
+ loadNodes()
+ loadDataWarehouseSavedQueries()
+ }
+
+ const nothingToReport =
+ modelsResolved &&
+ !modelsFailed &&
checksLoaded &&
!checksError &&
attentionModels.length === 0 &&
behindSchedule.length === 0 &&
failingChecks.length === 0
- if (nothingWrong) {
- return (
- <div className="flex items-center gap-2" data-attr="models-overview-healthy">
- <IconCheckCircle className="text-success text-xl" />
- <span>
- {dataQualityTabEnabled
- ? 'Every model is up to date and every check passed.'
- : 'Every model is up to date.'}
- </span>
- </div>
- )
+ if (nothingToReport) {
+ return <ModelsOverviewEmptyState variant={noModelsYet ? 'first-view' : 'healthy'} checksStatus={checksStatus} />
}
return (
<div className="flex flex-col gap-6">
+ {modelsFailed && (
+ <LemonBanner
+ type="error"
+ action={{ children: 'Try again', onClick: reloadModels }}
+ data-attr="models-overview-models-error"
+ >
+ Your models could not be loaded, so this page cannot say which ones need attention.
+ </LemonBanner>
+ )}
{(nodesLoading || attentionModels.length > 0) && (
<Section
title="Models needing attention"
@@ -275,12 +288,13 @@ function OverviewBody({
/** Split out so the checks request is only made where the tab exists. */
function OverviewWithChecks(): JSX.Element {
- const { checks, overviewLoading, snapshotLoaded, overviewError } = useValues(dataQualityOverviewLogic)
+ const { checks, checksStatus, overviewLoading, snapshotLoaded, overviewError } = useValues(dataQualityOverviewLogic)
const { loadOverview } = useActions(dataQualityOverviewLogic)
return (
<OverviewBody
failingChecks={checks.filter((check) => check.last_status === 'failed' || check.last_status === 'errored')}
+ checksStatus={checksStatus}
checksLoading={overviewLoading}
checksLoaded={snapshotLoaded}
checksError={overviewError}
@@ -295,6 +309,12 @@ export function ModelsOverviewTab(): JSX.Element {
return dataQualityTabEnabled ? (
<OverviewWithChecks />
) : (
- <OverviewBody failingChecks={[]} checksLoading={false} checksLoaded checksError={null} />
+ <OverviewBody
+ failingChecks={[]}
+ checksStatus="disabled"
+ checksLoading={false}
+ checksLoaded
+ checksError={null}
+ />
)
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index b04b0244172b..12d844606699 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -3104,6 +3104,9 @@ importers:
products/data_modeling:
dependencies:
+ '@posthog/brand':
+ specifier: 'catalog:'
+ version: 0.11.0([email protected])
'@posthog/icons':
specifier: 'catalog:'
diff --git a/products/data_modeling/frontend/ModelsOverviewEmptyState.test.tsx b/products/data_modeling/frontend/ModelsOverviewEmptyState.test.tsx
new file mode 100644
index 000000000000..8cedec7e95b9
--- /dev/null
+++ b/products/data_modeling/frontend/ModelsOverviewEmptyState.test.tsx
@@ -0,0 +1,68 @@
+import { cleanup, render, screen } from '@testing-library/react'
+
+import { initKeaTests } from '~/test/init'
+import { AccessControlLevel, AccessControlResourceType, AppContext } from '~/types'
+
+import { ModelsOverviewChecksStatus, ModelsOverviewEmptyState } from './ModelsOverviewEmptyState'
+
+describe('ModelsOverviewEmptyState', () => {
+ let priorAppContext: AppContext | undefined
+
+ function setWarehouseAccess(level: AccessControlLevel): void {
+ window.POSTHOG_APP_CONTEXT = {
+ ...window.POSTHOG_APP_CONTEXT,
+ resource_access_control: {
+ ...window.POSTHOG_APP_CONTEXT?.resource_access_control,
+ [AccessControlResourceType.WarehouseObjects]: level,
+ },
+ } as AppContext
+ }
+
+ beforeEach(() => {
+ initKeaTests()
+ priorAppContext = window.POSTHOG_APP_CONTEXT
+ setWarehouseAccess(AccessControlLevel.Editor)
+ })
+
+ afterEach(() => {
+ cleanup()
+ window.POSTHOG_APP_CONTEXT = priorAppContext
+ })
+
+ it('sends each action to the surface it names', () => {
+ render(<ModelsOverviewEmptyState variant="healthy" checksStatus="all-passed" />)
+
+ expect(screen.getByTestId('models-overview-create-view').getAttribute('href')).toContain('source=view')
+ expect(screen.getByTestId('models-overview-checks').getAttribute('href')).toContain('tab=data-quality')
+ expect(screen.getByTestId('models-overview-lineage').getAttribute('href')).toContain('tab=lineage')
+ })
+
+ it.each([
+ ['disabled' as const, undefined],
+ ['none' as const, 'Set up checks'],
+ ['all-passed' as const, 'View checks'],
+ ['some-not-passed' as const, 'View checks'],
+ ])('offers %s checks as %s', (checksStatus: ModelsOverviewChecksStatus, label: string | undefined) => {
+ render(<ModelsOverviewEmptyState variant="healthy" checksStatus={checksStatus} />)
+
+ expect(screen.queryByTestId('models-overview-checks')?.textContent).toEqual(label)
+ })
+
+ it('drops the lineage action before a project has any models', () => {
+ render(<ModelsOverviewEmptyState variant="first-view" checksStatus="none" />)
+
+ expect(screen.getByText('Create your first view')).toBeTruthy()
+ expect(screen.queryByTestId('models-overview-lineage')).toBeNull()
+ })
+
+ it.each([
+ [AccessControlLevel.Editor, 'false'],
+ [AccessControlLevel.Viewer, 'true'],
+ ])('renders create view for a %s as aria-disabled=%s', (level: AccessControlLevel, expected: string) => {
+ setWarehouseAccess(level)
+
+ render(<ModelsOverviewEmptyState variant="healthy" checksStatus="none" />)
+
+ expect(screen.getByTestId('models-overview-create-view').getAttribute('aria-disabled')).toBe(expected)
+ })
+})
diff --git a/products/data_modeling/frontend/ModelsOverviewEmptyState.tsx b/products/data_modeling/frontend/ModelsOverviewEmptyState.tsx
new file mode 100644
index 000000000000..8416ed7d3e84
--- /dev/null
+++ b/products/data_modeling/frontend/ModelsOverviewEmptyState.tsx
@@ -0,0 +1,82 @@
+import * as float from '@posthog/brand/hoggies/png/float'
+import { LemonButton } from '@posthog/lemon-ui'
+
+import { pngHoggie } from 'lib/brand/hoggies'
+import { AccessControlAction } from 'lib/components/AccessControlAction'
+import { ProductIntroduction } from 'lib/components/ProductIntroduction/ProductIntroduction'
+import { urls } from 'scenes/urls'
+
+import { AccessControlLevel, AccessControlResourceType } from '~/types'
+
+const HedgehogFloat = pngHoggie(float)
+
+export type ModelsOverviewChecksStatus = 'disabled' | 'unknown' | 'none' | 'all-passed' | 'some-not-passed'
+
+const HEALTHY_DESCRIPTIONS: Record<ModelsOverviewChecksStatus, string> = {
+ disabled: 'Your models are up to date.',
+ unknown: 'Your models are up to date.',
+ none: 'Your models are up to date. Add data quality checks to test your data.',
+ 'all-passed': 'Your models are up to date and all data quality checks passed.',
+ 'some-not-passed': 'Your models are up to date. No checks are failing, but some have not passed yet.',
+}
+
+export interface ModelsOverviewEmptyStateProps {
+ variant: 'healthy' | 'first-view'
+ checksStatus: ModelsOverviewChecksStatus
+}
+
+export function ModelsOverviewEmptyState({ variant, checksStatus }: ModelsOverviewEmptyStateProps): JSX.Element {
+ const firstView = variant === 'first-view'
+
+ return (
+ <div data-attr={firstView ? 'models-overview-first-view' : 'models-overview-healthy'}>
+ <ProductIntroduction
+ thingName="model"
+ titleOverride={firstView ? 'Create your first view' : 'No models need attention'}
+ description={
+ firstView
+ ? 'Save a SQL query as a view to start building your models.'
+ : HEALTHY_DESCRIPTIONS[checksStatus]
+ }
+ customHog={HedgehogFloat}
+ hogLayout="responsive"
+ useMainContentContainerQueries
+ className="border border-solid bg-surface-primary my-0"
+ actionElementOverride={
+ <>
+ <AccessControlAction
+ resourceType={AccessControlResourceType.WarehouseObjects}
+ minAccessLevel={AccessControlLevel.Editor}
+ >
+ <LemonButton
+ type="primary"
+ to={urls.sqlEditor({ source: 'view' })}
+ data-attr="models-overview-create-view"
+ >
+ Create view
+ </LemonButton>
+ </AccessControlAction>
+ {checksStatus !== 'disabled' && (
+ <LemonButton
+ type="secondary"
+ to={urls.models('data-quality')}
+ data-attr="models-overview-checks"
+ >
+ {checksStatus === 'none' ? 'Set up checks' : 'View checks'}
+ </LemonButton>
+ )}
+ {!firstView && (
+ <LemonButton
+ type="secondary"
+ to={urls.models('lineage')}
+ data-attr="models-overview-lineage"
+ >
+ View lineage
+ </LemonButton>
+ )}
+ </>
+ }
+ />
+ </div>
+ )
+}
diff --git a/products/data_modeling/frontend/ModelsOverviewTab.stories.tsx b/products/data_modeling/frontend/ModelsOverviewTab.stories.tsx
index e29358adcc36..89b4501649dd 100644
--- a/products/data_modeling/frontend/ModelsOverviewTab.stories.tsx
+++ b/products/data_modeling/frontend/ModelsOverviewTab.stories.tsx
@@ -1,4 +1,4 @@
-import type { Meta, StoryObj } from '@storybook/react'
+import type { Decorator, Meta, StoryObj } from '@storybook/react'
import { fireEvent, waitFor, within } from '@testing-library/dom'
import { FEATURE_FLAGS } from 'lib/constants'
@@ -6,6 +6,8 @@ import { ModelsOverviewTab } from 'scenes/models/tabs/ModelsOverviewTab'
import { urls } from 'scenes/urls'
import { mswDecorator } from '~/mocks/browser'
+import type { Mocks } from '~/mocks/utils'
+import { AccessControlLevel, AccessControlResourceType } from '~/types'
const nodes = ['attention', 'behind'].flatMap((group) =>
Array.from({ length: 12 }, (_, index) => ({
@@ -33,9 +35,69 @@ const checks = Array.from({ length: 12 }, (_, index) => ({
last_status: 'failed',
}))
+const healthyNodes = Array.from({ length: 3 }, (_, index) => ({
+ id: `healthy-${index + 1}`,
+ name: `healthy_model_${index + 1}`,
+ type: 'matview',
+ dag: 'example-dag',
+ created_at: '2026-01-01T00:00:00Z',
+ updated_at: '2026-01-01T00:00:00Z',
+ last_run_at: '2026-09-15T00:00:00Z',
+ last_run_status: 'Completed',
+ last_run_error: null,
+ sync_interval: '24hour',
+ upstream_count: 0,
+ downstream_count: 0,
+}))
+const passingChecks = [
+ {
+ id: 'check-1',
+ name: 'Example check',
+ check_type: 'not_null',
+ subject_type: 'view',
+ subject_name: 'example_view',
+ subject_node_id: 'healthy-1',
+ last_status: 'passed',
+ },
+]
+const neverRunChecks = passingChecks.map((check) => ({ ...check, last_status: '' }))
+
+function healthyMocks(checkRows: Record<string, any>[]): { mocks: Mocks } {
+ return {
+ mocks: {
+ get: {
+ '/api/environments/:team_id/data_modeling_nodes/': {
+ results: healthyNodes,
+ count: healthyNodes.length,
+ },
+ '/api/projects/:team_id/data_quality_checks/': { results: checkRows, count: checkRows.length },
+ },
+ },
+ }
+}
+
+const inMainContent =
+ (widthClass: string): Decorator =>
+ (Story) => (
+ <div className={`@container/main-content ${widthClass}`}>
+ <Story />
+ </div>
+ )
+
const meta: Meta<typeof ModelsOverviewTab> = {
title: 'Products/Data modeling/Models overview',
component: ModelsOverviewTab,
+ beforeEach: () => {
+ const context = window.POSTHOG_APP_CONTEXT!
+ const previous = context.resource_access_control
+ context.resource_access_control = {
+ ...previous,
+ [AccessControlResourceType.WarehouseObjects]: AccessControlLevel.Editor,
+ }
+ return () => {
+ context.resource_access_control = previous
+ }
+ },
decorators: [mswDecorator({})],
parameters: {
featureFlags: [FEATURE_FLAGS.DATA_QUALITY_CHECKS],
@@ -102,3 +164,42 @@ export const NarrowPartialLastPage: Story = {
...Narrow,
play: PartialLastPage.play,
}
+
+export const Healthy: Story = {
+ decorators: [inMainContent('w-256')],
+ parameters: { msw: healthyMocks(passingChecks) },
+}
+
+export const HealthyWithoutChecks: Story = {
+ decorators: [inMainContent('w-256')],
+ parameters: { msw: healthyMocks([]) },
+}
+
+export const HealthyWithChecksNotRun: Story = {
+ decorators: [inMainContent('w-256')],
+ parameters: { msw: healthyMocks(neverRunChecks) },
+}
+
+export const HealthyWithDataQualityDisabled: Story = {
+ decorators: [inMainContent('w-256')],
+ parameters: { featureFlags: [], msw: healthyMocks(passingChecks) },
+}
+
+export const HealthyNarrow: Story = {
+ decorators: [inMainContent('w-128')],
+ parameters: { msw: healthyMocks(passingChecks) },
+}
+
+export const FirstView: Story = {
+ decorators: [inMainContent('w-256')],
+ parameters: {
+ msw: {
+ mocks: {
+ get: {
+ '/api/environments/:team_id/data_modeling_nodes/': { results: [], count: 0 },
+ '/api/projects/:team_id/data_quality_checks/': { results: [], count: 0 },
+ },
+ },
+ },
+ },
+}
diff --git a/products/data_modeling/frontend/lineage/lineageDataLogic.ts b/products/data_modeling/frontend/lineage/lineageDataLogic.ts
index 21039ef434af..4e6f3d8079d0 100644
--- a/products/data_modeling/frontend/lineage/lineageDataLogic.ts
+++ b/products/data_modeling/frontend/lineage/lineageDataLogic.ts
@@ -1,4 +1,4 @@
-import { MakeLogicType, afterMount, kea, path } from 'kea'
+import { MakeLogicType, afterMount, kea, path, reducers } from 'kea'
import { loaders } from 'kea-loaders'
import api, { PaginatedResponse } from 'lib/api'
@@ -8,6 +8,8 @@ import { DataModelingEdge, DataModelingNode } from '~/types'
export interface lineageDataLogicValues {
nodes: DataModelingNode[]
nodesLoading: boolean
+ nodesLoaded: boolean
+ nodesFailed: boolean
edges: DataModelingEdge[]
edgesLoading: boolean
}
@@ -50,6 +52,23 @@ export const lineageDataLogic = kea<lineageDataLogicType>([
loadEdges: async () => loadAllPages(() => api.dataModelingEdges.list()),
},
}),
+ reducers({
+ nodesLoaded: [
+ false,
+ {
+ loadNodesSuccess: () => true,
+ loadNodesFailure: () => false,
+ },
+ ],
+ nodesFailed: [
+ false,
+ {
+ loadNodes: () => false,
+ loadNodesSuccess: () => false,
+ loadNodesFailure: () => true,
+ },
+ ],
+ }),
afterMount(({ actions }) => {
actions.loadNodes()
actions.loadEdges()
diff --git a/products/data_modeling/package.json b/products/data_modeling/package.json
index 0548e33ecf22..75b95362ea65 100644
--- a/products/data_modeling/package.json
+++ b/products/data_modeling/package.json
@@ -16,6 +16,7 @@
"kea-test-utils": "catalog:"
},
"peerDependencies": {
+ "@posthog/brand": "catalog:",
"@posthog/icons": "catalog:",
"@testing-library/dom": "*",
"@types/react": "*",
diff --git a/products/data_quality/frontend/overview/dataQualityOverviewLogic.test.ts b/products/data_quality/frontend/overview/dataQualityOverviewLogic.test.ts
index 93d82dff8a06..00eac78705bf 100644
--- a/products/data_quality/frontend/overview/dataQualityOverviewLogic.test.ts
+++ b/products/data_quality/frontend/overview/dataQualityOverviewLogic.test.ts
@@ -20,6 +20,7 @@ import type {
DataQualitySuiteRunApi,
} from 'products/data_quality/frontend/generated/api.schemas'
+import type { OverviewChecksStatus } from './dataQualityOverviewLogic'
import {
NEW_CHECK_ACTION_ID,
dataQualityOverviewLogic,
@@ -329,17 +330,29 @@ describe('dataQualityOverviewLogic', () => {
expect(logic.values.overviewSummary).toEqual('1 of 1 checks failing, across 1 tables, views, and metrics.')
})
- it.each<[string, (string | null)[], string]>([
+ it.each<[string, (string | null)[], string | null, OverviewChecksStatus]>([
// The regression: a not-failing check was reported as passed, so a page of never-run checks
// read as an all-clear the moment they were created.
- ['never-run checks as not run, never as passed', [null, null], 'None of your checks have run yet.'],
- ['a fully passing project as all passed', ['passed', 'passed'], 'All 2 checks passed on their last run.'],
+ [
+ 'never-run checks as not run, never as passed',
+ [null, null],
+ 'None of your checks have run yet.',
+ 'some-not-passed',
+ ],
+ [
+ 'a fully passing project as all passed',
+ ['passed', 'passed'],
+ 'All 2 checks passed on their last run.',
+ 'all-passed',
+ ],
[
'a mix without claiming the unrun ones passed',
['passed', null],
'1 of 2 checks passed on their last run, 1 not run yet.',
+ 'some-not-passed',
],
- ])('summarises %s', async (_case, statuses, expected) => {
+ ['a project with no checks as having none', [], null, 'none'],
+ ])('summarises %s', async (_case, statuses, expected, expectedStatus) => {
;(dataQualityChecksList as jest.Mock).mockResolvedValue({
results: statuses.map((status, index) => buildCheck(`check-${index}`, 'orders', status)),
})
@@ -347,6 +360,17 @@ describe('dataQualityOverviewLogic', () => {
await mountLogic()
expect(logic.values.overviewSummary).toEqual(expected)
+ expect(logic.values.checksStatus).toEqual(expectedStatus)
+ })
+
+ it('does not claim every check passed when the checks fill the page', async () => {
+ ;(dataQualityChecksList as jest.Mock).mockResolvedValue({
+ results: Array.from({ length: 500 }, (_, index) => buildCheck(`check-${index}`, 'orders', 'passed')),
+ })
+ ;(dataQualityChecksHealthList as jest.Mock).mockResolvedValue([])
+ await mountLogic()
+
+ expect(logic.values.checksStatus).toEqual('unknown')
})
it('sends no ids when running everything', async () => {
diff --git a/products/data_quality/frontend/overview/dataQualityOverviewLogic.ts b/products/data_quality/frontend/overview/dataQualityOverviewLogic.ts
index b0e2935a9e22..958aefb534dc 100644
--- a/products/data_quality/frontend/overview/dataQualityOverviewLogic.ts
+++ b/products/data_quality/frontend/overview/dataQualityOverviewLogic.ts
@@ -32,6 +32,8 @@ const CHECKS_LIMIT = 500
export type OverviewStatusFilter = 'all' | 'failing' | 'never_run'
+export type OverviewChecksStatus = 'unknown' | 'none' | 'all-passed' | 'some-not-passed'
+
export interface OverviewFilters {
search: string
status: OverviewStatusFilter
@@ -139,6 +141,7 @@ export interface dataQualityOverviewLogicValues {
allSubjectKeys: string[]
checkRunsByCheckId: Record<string, DataQualityCheckRunApi[]>
checks: DataQualityOverviewCheckApi[]
+ checksStatus: OverviewChecksStatus
deletingCheckIds: Record<string, boolean>
expandedSubjectKeys: string[]
expansionInitialized: boolean
@@ -289,6 +292,7 @@ export interface dataQualityOverviewLogicMeta {
__keaTypeGenInternalSelectorTypes: {
checks: (overview: OverviewSnapshot | null) => DataQualityOverviewCheckApi[]
subjectHealth: (overview: OverviewSnapshot | null) => DataQualitySubjectHealthApi[]
+ checksStatus: (checks: DataQualityOverviewCheckApi[]) => OverviewChecksStatus
scheduleBySubjectKey: (
subjectSchedules: DataQualitySubjectScheduleApi[]
) => Record<string, DataQualitySubjectScheduleApi>
@@ -478,6 +482,18 @@ export const dataQualityOverviewLogic = kea<dataQualityOverviewLogicType>([
selectors({
checks: [(s) => [s.overview], (overview: OverviewSnapshot | null) => overview?.checks ?? []],
subjectHealth: [(s) => [s.overview], (overview: OverviewSnapshot | null) => overview?.health ?? []],
+ checksStatus: [
+ (s) => [s.checks],
+ (checks: DataQualityOverviewCheckApi[]): OverviewChecksStatus => {
+ if (checks.length === 0) {
+ return 'none'
+ }
+ if (!checks.every((check) => check.last_status === 'passed')) {
+ return 'some-not-passed'
+ }
+ return checks.length < CHECKS_LIMIT ? 'all-passed' : 'unknown'
+ },
+ ],
scheduleBySubjectKey: [
(s) => [s.subjectSchedules],
(subjectSchedules: DataQualitySubjectScheduleApi[]): Record<string, DataQualitySubjectScheduleApi> =>