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(data-modeling): show skeletons while model usage loads (#128109)

Jovan Sakovic2bfaf592892d
diff --git a/docs/published/handbook/engineering/data-warehouse.md b/docs/published/handbook/engineering/data-warehouse.md
index 4825333a3f1f..689250828c87 100644
--- a/docs/published/handbook/engineering/data-warehouse.md
+++ b/docs/published/handbook/engineering/data-warehouse.md
@@ -27,6 +27,7 @@ This reservation does not add qualified names to existing models or require a na
## Model materialization usage
The Models **Usage** tab shows bytes read, CPU time, and run counts for materializations over a preset or custom range of complete UTC days.
+The initial load keeps section titles visible and shows skeletons for the metric values, charts, model table, and job rows. Refreshes keep the loaded data visible while new data loads.
The totals and model breakdown follow saved-query access controls. The breakdown sorts by bytes read and includes soft-deleted models while their saved queries and job history exist.
Usage includes schema checks, retries, failed runs, and canceled runs, and is attributed to the UTC day each run finished.
The date and materialized-view filters apply to the whole tab. The jobs table also has a status filter. Projects with the Trino managed warehouse enabled also get a tab-level engine filter, daily bars stacked by engine, and separate ClickHouse and managed warehouse byte totals per model. Legacy Duckgres runs are not included.
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 6ee4628eff61..b4bc88312359 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -7470,6 +7470,14 @@ snapshots:
hash: v1.k794b7964.d86155a022ceb20146a8e3205658363719405340ba6b12ef192f185a2ed94517.psnvg2y41RTvk23YHh-Yw83qEmHJQX2yN9e29Hzwj38
products-data-modeling-models-usage--filtered-by-failed-models--light:
hash: v1.k794b7964.e84292c0ba7e56506892fcb4b9a277e3eae2b329a6b6223b6344a5a7a73b9095.vUeKLNLoFEq-wVgm57zS4Pp_jMfg62B7rksPkMxfDBc
+ products-data-modeling-models-usage--loading--dark:
+ hash: v1.k794b7964.285a873b8f14a9f46c8a514124479f12d5f579900f220f6d29b5a055e8b3c7d5.zyPYRs7Wsv6Nq3KtOGst5l0_odS3npE0KalObH1TXf0
+ products-data-modeling-models-usage--loading--light:
+ hash: v1.k794b7964.f2e02c8cccddb2119cc4ddee9c6b29b6976337468bc86bea827671f25c2d9252.YYhsLO95XE_u82hb6BjFxOHa8kLhDEfZOHbDyN0LWIk
+ products-data-modeling-models-usage--loading-narrow--dark:
+ hash: v1.k794b7964.6be95516356691442a89c80841e886ea224f03e76cc38a367c40944a46af1dde.c1JiH5bnrzt57v0P_EEeGyf5lSap0aOo1SVxWm0mxZ0
+ products-data-modeling-models-usage--loading-narrow--light:
+ hash: v1.k794b7964.14ac55ca26a88f595afc4e26f91f631ee1e0e68265328f751131c7b2457c0d66.evNvzC7M09_LvRYf8Q6BTEBSfi4WpuhyQ4JcIuN-Os0
products-data-modeling-models-usage--narrow--dark:
hash: v1.k794b7964.8fdf7fdef92c582579c0d0c958231a45beeee74a24eacaf796465436b1be6968.IbckVCux4Vhe7hhhO9iCjrHDUiz1ZWVdwE-pOMNuo5E
products-data-modeling-models-usage--narrow--light:
diff --git a/products/data_modeling/frontend/MaterializationJobsTable.tsx b/products/data_modeling/frontend/MaterializationJobsTable.tsx
index e0dd817ae672..bc7176a84cdd 100644
--- a/products/data_modeling/frontend/MaterializationJobsTable.tsx
+++ b/products/data_modeling/frontend/MaterializationJobsTable.tsx
@@ -24,6 +24,7 @@ import {
SelectItem,
SelectTrigger,
SelectValue,
+ Skeleton,
Spinner,
Table,
TableBody,
@@ -208,14 +209,30 @@ export function MaterializationJobsTable({
})}
</TableBody>
) : jobsLoading && !materializationJobs ? (
- <TableBody>
- <TableRow>
- <TableCell colSpan={managedWarehouseEnabled ? 7 : 6}>
- <div className="flex justify-center py-8">
- <Spinner />
- </div>
- </TableCell>
- </TableRow>
+ <TableBody aria-label="Loading materialization jobs">
+ {Array.from({ length: 4 }, (_, index) => (
+ <TableRow key={index} aria-hidden="true">
+ <TableCell expand>
+ <Skeleton className="motion-reduce:animate-none h-4 w-40 max-w-full" />
+ </TableCell>
+ <TableCell>
+ <Skeleton className="motion-reduce:animate-none h-4 w-20" />
+ </TableCell>
+ {managedWarehouseEnabled ? (
+ <TableCell>
+ <Skeleton className="motion-reduce:animate-none h-4 w-24" />
+ </TableCell>
+ ) : null}
+ {Array.from({ length: 4 }, (_, column) => (
+ <TableCell
+ key={column}
+ className="hidden @min-[48rem]/main-content:table-cell"
+ >
+ <Skeleton className="motion-reduce:animate-none h-4 w-16" />
+ </TableCell>
+ ))}
+ </TableRow>
+ ))}
</TableBody>
) : (
<TableEmpty className="py-8 text-secondary">
diff --git a/products/data_modeling/frontend/ModelsUsageSkeleton.tsx b/products/data_modeling/frontend/ModelsUsageSkeleton.tsx
new file mode 100644
index 000000000000..4b165eecff7b
--- /dev/null
+++ b/products/data_modeling/frontend/ModelsUsageSkeleton.tsx
@@ -0,0 +1,64 @@
+import { Card, CardContent, CardDescription, CardHeader, CardTitle, Skeleton, Text } from 'lib/ui/quill'
+
+export function ModelsUsageSkeleton(): JSX.Element {
+ return (
+ <div role="status" aria-label="Loading model usage" aria-busy="true">
+ <div className="space-y-4">
+ <div className="grid grid-cols-1 gap-4 @min-[36rem]/main-content:grid-cols-3">
+ {['Bytes read', 'CPU time', 'Runs'].map((title) => (
+ <Card key={title} size="sm" className="min-w-0">
+ <CardContent>
+ <Text size="sm">{title}</Text>
+ <Skeleton className="motion-reduce:animate-none mt-2 h-8 w-32 max-w-full" />
+ </CardContent>
+ </Card>
+ ))}
+ </div>
+ <div className="grid grid-cols-1 gap-4 @min-[64rem]/main-content:grid-cols-2">
+ {[
+ {
+ title: 'Bytes read by day',
+ description:
+ 'Usage is attributed to the day each run finished. Gaps have no measured usage.',
+ },
+ {
+ title: 'Models by latest run status',
+ description: 'Latest run for each model and engine in the selected complete-day range.',
+ },
+ ].map(({ title, description }) => (
+ <Card key={title} size="sm" className="min-w-0">
+ <CardHeader>
+ <CardTitle role="heading" aria-level={3}>
+ {title}
+ </CardTitle>
+ <CardDescription>{description}</CardDescription>
+ </CardHeader>
+ <CardContent>
+ <Skeleton className="motion-reduce:animate-none h-64 w-full" />
+ </CardContent>
+ </Card>
+ ))}
+ </div>
+ <Card size="sm" className="min-w-0">
+ <CardHeader>
+ <CardTitle role="heading" aria-level={3}>
+ Usage by model
+ </CardTitle>
+ <CardDescription>
+ Review refresh schedules and query filters for models with high usage.
+ </CardDescription>
+ </CardHeader>
+ <CardContent className="space-y-4">
+ {Array.from({ length: 4 }, (_, index) => (
+ <div key={index} className="flex items-center gap-4">
+ <Skeleton className="motion-reduce:animate-none h-4 w-1/2" />
+ <Skeleton className="motion-reduce:animate-none h-4 flex-1" />
+ <Skeleton className="motion-reduce:animate-none h-4 flex-1" />
+ </div>
+ ))}
+ </CardContent>
+ </Card>
+ </div>
+ </div>
+ )
+}
diff --git a/products/data_modeling/frontend/ModelsUsageTab.stories.tsx b/products/data_modeling/frontend/ModelsUsageTab.stories.tsx
index ef370e144b6e..3a72d2f67b51 100644
--- a/products/data_modeling/frontend/ModelsUsageTab.stories.tsx
+++ b/products/data_modeling/frontend/ModelsUsageTab.stories.tsx
@@ -349,6 +349,27 @@ export default meta
type Story = StoryObj<typeof ModelsUsageTab>
export const Populated: Story = { decorators: [inMainContent('w-256')] }
+export const Loading: Story = {
+ decorators: [inMainContent('w-256')],
+ parameters: {
+ testOptions: {
+ waitForLoadersToDisappear: false,
+ waitForSelector: '[aria-label="Loading model usage"]',
+ },
+ msw: {
+ mocks: {
+ get: {
+ '/api/projects/:team_id/data_modeling_usage/': (): Promise<never> => new Promise(() => {}),
+ '/api/projects/:team_id/data_modeling_jobs/': (): Promise<never> => new Promise(() => {}),
+ },
+ },
+ },
+ },
+}
+export const LoadingNarrow: Story = {
+ ...Loading,
+ decorators: [inMainContent('w-128')],
+}
export const Narrow: Story = {
decorators: [inMainContent('w-128')],
}
diff --git a/products/data_modeling/frontend/ModelsUsageTab.tsx b/products/data_modeling/frontend/ModelsUsageTab.tsx
index 12114bedfdf5..60b0e3cc7176 100644
--- a/products/data_modeling/frontend/ModelsUsageTab.tsx
+++ b/products/data_modeling/frontend/ModelsUsageTab.tsx
@@ -44,6 +44,7 @@ import {
modelStatusLabel,
modelsUsageLogic,
} from './modelsUsageLogic'
+import { ModelsUsageSkeleton } from './ModelsUsageSkeleton'
const DATE_OPTIONS: DateMappingOption[] = [7, 30, 90].map((days) => ({
key: `Last ${days} complete days`,
@@ -236,9 +237,7 @@ export function ModelsUsageTab({
</CardContent>
</Card>
) : !usage ? (
- <div className="flex justify-center py-16">
- <Spinner />
- </div>
+ <ModelsUsageSkeleton />
) : usage.overview.runs === 0 && statusChartLabels.length === 0 ? (
<Card size="sm">
<CardContent>