The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat(studio): homepage usage charts backed by service-health, behind a flag (#46373)
Jordi Enric15ef851e6785
diff --git a/apps/studio/components/interfaces/ProjectHome/Home.tsx b/apps/studio/components/interfaces/ProjectHome/Home.tsxindex 6186810f5ea..9bb44825bc8 100644--- a/apps/studio/components/interfaces/ProjectHome/Home.tsx+++ b/apps/studio/components/interfaces/ProjectHome/Home.tsx@@ -1,6 +1,6 @@import { DndContext, DragEndEvent, PointerSensor, useSensor, useSensors } from '@dnd-kit/core'import { arrayMove, SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable'-import { useParams } from 'common'+import { useFlag, useParams } from 'common'import dayjs from 'dayjs'import { useEffect, useRef } from 'react'import { cn } from 'ui'@@ -10,6 +10,7 @@ import { ConnectSection } from './ConnectSection'import { CustomReportSection } from './CustomReportSection'import { DEFAULT_SECTION_ORDER, mergeSectionOrder } from './Home.utils'import { ProjectUsageSection } from './ProjectUsageSection'+import { ProjectUsageSectionDeltas } from './ProjectUsageSectionDeltas'import { SortableSection } from '@/components/interfaces/ProjectHome/SortableSection'import { TopSection } from '@/components/interfaces/ProjectHome/TopSection'import { ProjectNeedsSecuring } from '@/components/layouts/ProjectNeedsSecuring/ProjectNeedsSecuring'@@ -26,6 +27,8 @@ export const ProjectHome = () => {const { data: project } = useSelectedProjectQuery()const track = useTrack()+ const showHomepageUsageDeltas = useFlag('newHomepageUsageDeltas')+const isMatureProject = dayjs(project?.inserted_at).isBefore(dayjs().subtract(10, 'day'))const hasShownEnableBranchingModalRef = useRef(false)@@ -37,6 +40,8 @@ export const ProjectHome = () => {DEFAULT_SECTION_ORDER)+ const UsageSection = showHomepageUsageDeltas ? ProjectUsageSectionDeltas : ProjectUsageSection+const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 8 } }))const handleDragEnd = (event: DragEndEvent) => {@@ -104,7 +109,7 @@ export const ProjectHome = () => {className={cn(isComingUp && 'opacity-60 pointer-events-none')}><SortableSection id={id}>- <ProjectUsageSection />+ <UsageSection /></SortableSection></div>)diff --git a/apps/studio/components/interfaces/ProjectHome/ProjectUsage.metrics.test.ts b/apps/studio/components/interfaces/ProjectHome/ProjectUsage.metrics.test.tsindex 3b2479c1789..ed36fafdbe5 100644--- a/apps/studio/components/interfaces/ProjectHome/ProjectUsage.metrics.test.ts+++ b/apps/studio/components/interfaces/ProjectHome/ProjectUsage.metrics.test.ts@@ -1,46 +1,135 @@import { describe, expect, it } from 'vitest'import {+ buildSortedServiceCards,computeSuccessAndNonSuccessRates,+ getBucketLogRange,+ isServiceDisabled,+ sortServicesByTraffic,sumErrors,sumTotal,sumWarnings,- toLogsBarChartData,} from './ProjectUsage.metrics'describe('ProjectUsage.metrics', () => {- const rows = [+ const data = [{ timestamp: '2025-10-22T13:00:00Z', ok_count: 90, warning_count: 5, error_count: 5 },{ timestamp: '2025-10-22T13:01:00Z', ok_count: 50, warning_count: 10, error_count: 0 },]- it('toLogsBarChartData maps and coerces fields correctly', () => {- const data = toLogsBarChartData(rows)- expect(data).toHaveLength(2)- expect(data[0]).toEqual({- timestamp: '2025-10-22T13:00:00Z',- ok_count: 90,- warning_count: 5,- error_count: 5,- })- })-it('sum helpers compute totals correctly', () => {- const data = toLogsBarChartData(rows)expect(sumTotal(data)).toBe(160)expect(sumWarnings(data)).toBe(15)expect(sumErrors(data)).toBe(5)})it('computeSuccessAndNonSuccessRates returns expected percentages', () => {- const data = toLogsBarChartData(rows)const total = sumTotal(data)const warns = sumWarnings(data)const errs = sumErrors(data)const { successRate, nonSuccessRate } = computeSuccessAndNonSuccessRates(total, warns, errs)- // success = 160 - (15 + 5) = 140 → 87.5%+ // success = 160 - (15 + 5) = 140 -> 87.5%expect(successRate).toBeCloseTo(87.5)expect(nonSuccessRate).toBeCloseTo(12.5)})++ it('computeSuccessAndNonSuccessRates returns zeroes when there are no requests', () => {+ expect(computeSuccessAndNonSuccessRates(0, 0, 0)).toEqual({ successRate: 0, nonSuccessRate: 0 })+ })++ describe('sortServicesByTraffic', () => {+ it('orders services by total descending', () => {+ const sorted = sortServicesByTraffic([+ { key: 'a', total: 10 },+ { key: 'b', total: 100 },+ { key: 'c', total: 50 },+ ])+ expect(sorted.map((s) => s.key)).toEqual(['b', 'c', 'a'])+ })++ it('pushes services with no traffic to the end', () => {+ const sorted = sortServicesByTraffic([+ { key: 'empty', total: 0 },+ { key: 'busy', total: 25 },+ { key: 'idle', total: 0 },+ ])+ expect(sorted.map((s) => s.key)).toEqual(['busy', 'empty', 'idle'])+ })++ it('does not mutate the input array', () => {+ const input = [+ { key: 'a', total: 1 },+ { key: 'b', total: 2 },+ ]+ sortServicesByTraffic(input)+ expect(input.map((s) => s.key)).toEqual(['a', 'b'])+ })+ })++ describe('isServiceDisabled', () => {+ it('is not disabled while loading', () => {+ expect(isServiceDisabled(0, true)).toBe(false)+ })++ it('is disabled when settled with no traffic', () => {+ expect(isServiceDisabled(0, false)).toBe(true)+ })++ it('is not disabled when there is traffic', () => {+ expect(isServiceDisabled(42, false)).toBe(false)+ })+ })++ describe('getBucketLogRange', () => {+ const timestamp = '2024-01-15T12:00:00.000Z'++ it('returns the bucket start unchanged and a one-minute window for 1hr', () => {+ expect(getBucketLogRange(timestamp, '1hr')).toEqual({+ start: timestamp,+ end: '2024-01-15T12:01:00.000Z',+ })+ })++ it('returns a one-hour window for 1day', () => {+ expect(getBucketLogRange(timestamp, '1day')).toEqual({+ start: timestamp,+ end: '2024-01-15T13:00:00.000Z',+ })+ })++ it('returns a one-day window for 7day', () => {+ expect(getBucketLogRange(timestamp, '7day')).toEqual({+ start: timestamp,+ end: '2024-01-16T12:00:00.000Z',+ })+ })++ it('parses a timestamp without a timezone designator as UTC', () => {+ expect(getBucketLogRange('2024-01-15T12:00:00', '1hr').end).toBe('2024-01-15T12:01:00.000Z')+ })+ })++ describe('buildSortedServiceCards', () => {+ const stats = (total: number, warningCount = 0, errorCount = 0) => ({+ eventChartData: [],+ total,+ warningCount,+ errorCount,+ })++ it('drops disabled services, maps stats, and sorts by traffic', () => {+ const cards = buildSortedServiceCards(+ [+ { key: 'a', enabled: true },+ { key: 'b', enabled: false },+ { key: 'c', enabled: true },+ ],+ { a: stats(10, 1, 2), b: stats(999), c: stats(50) }+ )++ expect(cards.map((c) => c.key)).toEqual(['c', 'a'])+ expect(cards[1]).toMatchObject({ key: 'a', total: 10, warn: 1, err: 2, data: [] })+ })+ })})diff --git a/apps/studio/components/interfaces/ProjectHome/ProjectUsage.metrics.ts b/apps/studio/components/interfaces/ProjectHome/ProjectUsage.metrics.tsindex 59355e32378..f6c88ed638d 100644--- a/apps/studio/components/interfaces/ProjectHome/ProjectUsage.metrics.ts+++ b/apps/studio/components/interfaces/ProjectHome/ProjectUsage.metrics.ts@@ -1,3 +1,8 @@+import dayjs from 'dayjs'+import utc from 'dayjs/plugin/utc'++dayjs.extend(utc)+export type LogsBarChartDatum = {timestamp: stringerror_count: number@@ -5,16 +10,7 @@ export type LogsBarChartDatum = {warning_count: number}-export const toLogsBarChartData = (- rows: Array<Record<string, unknown>> = []-): LogsBarChartDatum[] => {- return rows.map((r) => ({- timestamp: r.timestamp?.toString() ?? '',- ok_count: Number(r.ok_count) || 0,- warning_count: Number(r.warning_count) || 0,- error_count: Number(r.error_count) || 0,- }))-}+export type ChartIntervalKey = '1hr' | '1day' | '7day'export const sumTotal = (data: LogsBarChartDatum[]): number =>data.reduce((acc, r) => acc + r.ok_count + r.warning_count + r.error_count, 0)@@ -35,3 +31,58 @@ export const computeSuccessAndNonSuccessRates = (const successRate = 100 - nonSuccessRatereturn { successRate, nonSuccessRate }}++export const sortServicesByTraffic = <T extends { total: number }>(services: T[]): T[] =>+ [...services].sort((a, b) => b.total - a.total)++export const isServiceDisabled = (total: number, isLoading: boolean): boolean =>+ !isLoading && total <= 0++export type ServiceCardStats = {+ eventChartData: LogsBarChartDatum[]+ total: number+ warningCount: number+ errorCount: number+}++export type ServiceCard<Entry> = Entry & {+ data: LogsBarChartDatum[]+ total: number+ warn: number+ err: number+}++/** Maps enabled services to card data and orders them by traffic. */+export const buildSortedServiceCards = <+ Key extends string,+ Entry extends { key: Key; enabled: boolean },+>(+ services: Entry[],+ statsByKey: Record<Key, ServiceCardStats>+): ServiceCard<Entry>[] =>+ sortServicesByTraffic(+ services+ .filter((service) => service.enabled)+ .map((service) => {+ const stats = statsByKey[service.key]+ return {+ ...service,+ data: stats.eventChartData,+ total: stats.total,+ warn: stats.warningCount,+ err: stats.errorCount,+ }+ })+ )++/** One-bucket-wide window for a clicked chart bar; the timestamp is the UTC bucket start. */+export const getBucketLogRange = (+ timestamp: string,+ interval: ChartIntervalKey+): { start: string; end: string } => {+ const unit = interval === '1hr' ? 'minute' : interval === '1day' ? 'hour' : 'day'+ return {+ start: timestamp,+ end: dayjs.utc(timestamp).add(1, unit).toISOString(),+ }+}diff --git a/apps/studio/components/interfaces/ProjectHome/ProjectUsageSectionDeltas.tsx b/apps/studio/components/interfaces/ProjectHome/ProjectUsageSectionDeltas.tsxnew file mode 100644index 00000000000..60a8268f1a6--- /dev/null+++ b/apps/studio/components/interfaces/ProjectHome/ProjectUsageSectionDeltas.tsx@@ -0,0 +1,253 @@+import { useParams } from 'common'+import Link from 'next/link'+import { useRouter } from 'next/router'+import { useMemo, useState } from 'react'+import { Card, CardContent, CardHeader, CardTitle, cn, Loading } from 'ui'+import { Row } from 'ui-patterns'+import { LogsBarChart } from 'ui-patterns/LogsBarChart'++import {+ buildSortedServiceCards,+ computeSuccessAndNonSuccessRates,+ getBucketLogRange,+ isServiceDisabled,+ type ChartIntervalKey,+ type LogsBarChartDatum,+} from './ProjectUsage.metrics'+import { useServiceHealthMetrics } from '@/components/interfaces/Observability/useServiceHealthMetrics'+import NoDataPlaceholder from '@/components/ui/Charts/NoDataPlaceholder'+import { ChartIntervalDropdown } from '@/components/ui/Logs/ChartIntervalDropdown'+import { CHART_INTERVALS } from '@/components/ui/Logs/logs.utils'+import { useCheckEntitlements } from '@/hooks/misc/useCheckEntitlements'+import { useIsDataApiEnabled } from '@/hooks/misc/useIsDataApiEnabled'+import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'+import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'+import { useTrack } from '@/lib/telemetry/track'++// Services the homepage shows; matches the telemetry event types.+type HomeServiceKey = 'db' | 'functions' | 'auth' | 'storage' | 'realtime' | 'data_api'++const isChartIntervalKey = (value: string): value is ChartIntervalKey =>+ value === '1hr' || value === '1day' || value === '7day'++type ServiceEntry = {+ key: HomeServiceKey+ title: string+ href?: string+ route: string+ enabled: boolean+}++export const ProjectUsageSectionDeltas = () => {+ const router = useRouter()+ const { ref: projectRef } = useParams()+ const { data: organization } = useSelectedOrganizationQuery()+ const track = useTrack()+ const { projectAuthAll: authEnabled, projectStorageAll: storageEnabled } = useIsFeatureEnabled([+ 'project_auth:all',+ 'project_storage:all',+ ])+ const { isEnabled: dataApiEnabled } = useIsDataApiEnabled({ projectRef })+ const { getEntitlementMax } = useCheckEntitlements('log.retention_days')+ const retentionDays = getEntitlementMax()++ const [userInterval, setUserInterval] = useState<ChartIntervalKey | undefined>(undefined)+ const interval: ChartIntervalKey =+ userInterval ?? (retentionDays !== undefined && retentionDays < 7 ? '1hr' : '1day')++ const selectedInterval = CHART_INTERVALS.find((i) => i.key === interval) || CHART_INTERVALS[1]+ const datetimeFormat = selectedInterval.format || 'MMM D, ha'++ const { services: serviceData, isLoading } = useServiceHealthMetrics(+ projectRef ?? '',+ interval,+ 0+ )++ const serviceBase: ServiceEntry[] = useMemo(+ () => [+ {+ key: 'db',+ title: 'Postgres',+ href: `/project/${projectRef}/editor`,+ route: '/logs/postgres-logs',+ enabled: true,+ },+ {+ key: 'functions',+ title: 'Edge Functions',+ route: '/logs/edge-functions-logs',+ enabled: true,+ },+ {+ key: 'auth',+ title: 'Auth',+ href: `/project/${projectRef}/auth/users`,+ route: '/logs/auth-logs',+ enabled: authEnabled,+ },+ {+ key: 'storage',+ title: 'Storage',+ href: `/project/${projectRef}/storage/buckets`,+ route: '/logs/storage-logs',+ enabled: storageEnabled,+ },+ {+ key: 'realtime',+ title: 'Realtime',+ route: '/logs/realtime-logs',+ enabled: true,+ },+ {+ key: 'data_api',+ title: 'API Gateway',+ route: '/logs/edge-logs',+ enabled: dataApiEnabled,+ },+ ],+ [projectRef, authEnabled, storageEnabled, dataApiEnabled]+ )++ const services = useMemo(+ () => buildSortedServiceCards(serviceBase, serviceData),+ [serviceBase, serviceData]+ )++ const totalRequests = services.reduce((sum, s) => sum + s.total, 0)+ const totalErrors = services.reduce((sum, s) => sum + s.err, 0)+ const totalWarnings = services.reduce((sum, s) => sum + s.warn, 0)++ const { successRate } = computeSuccessAndNonSuccessRates(+ totalRequests,+ totalWarnings,+ totalErrors+ )++ const handleBarClick =+ (logRoute: string, serviceKey: HomeServiceKey) => (datum: LogsBarChartDatum) => {+ if (!datum?.timestamp) return++ // Logs explorer reads the range from `its`/`ite` (iso_timestamp_start/end+ // only set the label).+ const { start, end } = getBucketLogRange(datum.timestamp, interval)++ const queryParams = new URLSearchParams({+ its: start,+ ite: end,+ })++ router.push(`/project/${projectRef}${logRoute}?${queryParams.toString()}`)++ track('home_project_usage_chart_clicked', {+ service_type: serviceKey,+ bar_timestamp: datum.timestamp,+ })+ }++ return (+ <div className="space-y-6">+ <div className="flex flex-row justify-between items-center gap-x-2">+ <div className="flex flex-col md:flex-row md:items-center md:gap-6">+ <div className="flex items-start gap-2 heading-section text-foreground-light">+ <span className="text-foreground">{totalRequests.toLocaleString()}</span>+ <span>Total Requests</span>+ </div>+ <div className="flex items-start gap-2 heading-section text-foreground-light">+ <span className="text-foreground">{successRate.toFixed(1)}%</span>+ <span>Success Rate</span>+ </div>+ </div>+ <ChartIntervalDropdown+ value={interval}+ onChange={(next) => {+ if (isChartIntervalKey(next)) setUserInterval(next)+ }}+ organizationSlug={organization?.slug}+ dropdownAlign="end"+ tooltipSide="left"+ />+ </div>+ <Row maxColumns={4} minWidth={280}>+ {services.map((s) => {+ const disabled = isServiceDisabled(s.total, isLoading)+ return (+ <Card+ key={s.key}+ className={cn('mb-0 md:mb-0 flex flex-col h-64', disabled && 'opacity-60')}+ >+ <CardHeader className="flex flex-row items-end justify-between gap-2 space-y-0 pb-0 border-b-0">+ <div className="flex items-center gap-2">+ <div className="flex flex-col">+ <CardTitle className="text-xs font-mono uppercase text-foreground-light">+ {s.href && !disabled ? (+ <Link+ href={s.href}+ onClick={() => {+ track('home_project_usage_service_clicked', {+ service_type: s.key,+ total_requests: s.total,+ error_count: s.err,+ })+ }}+ >+ {s.title}+ </Link>+ ) : (+ s.title+ )}+ </CardTitle>+ <span className="text-foreground text-xl">{s.total.toLocaleString()}</span>+ </div>+ </div>+ <div className="flex items-end gap-4 text-foreground-light">+ <div className="flex flex-col items-end">+ <div className="flex items-center gap-2">+ <div className="w-1.5 h-1.5 bg-warning rounded-full" />+ <span className="heading-meta">Warn</span>+ </div>+ <span className="text-foreground text-base">{s.warn.toLocaleString()}</span>+ </div>+ <div className="flex flex-col items-end">+ <div className="flex items-center gap-2">+ <div className="w-1.5 h-1.5 bg-destructive rounded-full" />+ <span className="heading-meta">Err</span>+ </div>+ <span className="text-foreground text-base">{s.err.toLocaleString()}</span>+ </div>+ </div>+ </CardHeader>+ <CardContent className="p-card flex-1 h-full overflow-hidden">+ <Loading isFullHeight active={isLoading}>+ <LogsBarChart+ isFullHeight+ data={s.data}+ DateTimeFormat={datetimeFormat}+ onBarClick={disabled ? undefined : handleBarClick(s.route, s.key)}+ hideZeroValues={true}+ chartConfig={{+ error_count: { label: 'Errors' },+ warning_count: { label: 'Warnings' },+ ok_count: { label: 'Requests' },+ }}+ EmptyState={+ isLoading ? (+ <></>+ ) : (+ <NoDataPlaceholder+ size="small"+ message="No data for selected period"+ isFullHeight+ />+ )+ }+ />+ </Loading>+ </CardContent>+ </Card>+ )+ })}+ </Row>+ </div>+ )+}diff --git a/apps/studio/components/layouts/ProjectNeedsSecuring/ProjectNeedsSecuring.tsx b/apps/studio/components/layouts/ProjectNeedsSecuring/ProjectNeedsSecuring.tsxindex 7392403e73b..b3b96dc883b 100644--- a/apps/studio/components/layouts/ProjectNeedsSecuring/ProjectNeedsSecuring.tsx+++ b/apps/studio/components/layouts/ProjectNeedsSecuring/ProjectNeedsSecuring.tsx@@ -37,7 +37,7 @@ const ProjectNeedsSecuringGate = ({ children }: PropsWithChildren) => {const isProjectHomeRoute = router.pathname === PROJECT_HOME_PATHNAME- const { data: lints = [], isPending: isLoadingLints } = useProjectLintsQuery(+ const { data: lints = [] } = useProjectLintsQuery({ projectRef },{ enabled: isProjectHomeRoute && !!projectRef })@@ -146,44 +146,38 @@ const ProjectNeedsSecuringGate = ({ children }: PropsWithChildren) => {)}, [rlsIssueKeys, tablePrivileges, tables])- if (!isProjectHomeRoute || !projectRef || isLoadingLints || !hasRlsIssues) {+ // Keep children in one stable position when not gating. Changing their wrapper+ // once lints load used to remount the homepage and reload the charts.+ if (!isProjectHomeRoute || !projectRef) {return <>{children}</>}return (- <AnimatePresence mode="wait">- {shouldRenderGate ? (- <motion.div- key="project-needs-securing"- className="flex flex-1 min-h-0 w-full"- initial={{ opacity: 0 }}- animate={{ opacity: 1 }}- exit={{ opacity: 0 }}- transition={{ duration: 0.2, ease: 'easeOut' }}- >- <ProjectNeedsSecuringView- projectRef={projectRef}- issueCount={rlsIssueKeys.size}- tables={tableRows}- isLoading={isLoadingTables || isLoadingPostgrestConfig || isLoadingTablePrivileges}- error={tablesError ?? postgrestConfigError ?? tablePrivilegesError}- onDismiss={() => setSecurityDismissedAt(new Date().toISOString())}- onTrackAction={handleTrackAction}- />- </motion.div>- ) : (- <motion.div- key="project-needs-securing-children"- className="flex flex-1 min-h-0 w-full"- initial={{ opacity: 0 }}- animate={{ opacity: 1 }}- exit={{ opacity: 0 }}- transition={{ duration: 0.2, ease: 'easeOut' }}- >- {children}- </motion.div>- )}- </AnimatePresence>+ <>+ <AnimatePresence>+ {shouldRenderGate && (+ <motion.div+ key="project-needs-securing"+ className="flex flex-1 min-h-0 w-full"+ initial={{ opacity: 0 }}+ animate={{ opacity: 1 }}+ exit={{ opacity: 0 }}+ transition={{ duration: 0.2, ease: 'easeOut' }}+ >+ <ProjectNeedsSecuringView+ projectRef={projectRef}+ issueCount={rlsIssueKeys.size}+ tables={tableRows}+ isLoading={isLoadingTables || isLoadingPostgrestConfig || isLoadingTablePrivileges}+ error={tablesError ?? postgrestConfigError ?? tablePrivilegesError}+ onDismiss={() => setSecurityDismissedAt(new Date().toISOString())}+ onTrackAction={handleTrackAction}+ />+ </motion.div>+ )}+ </AnimatePresence>+ {!shouldRenderGate && children}+ </>)}diff --git a/packages/common/telemetry-constants.ts b/packages/common/telemetry-constants.tsindex 3042a480427..603f511089b 100644--- a/packages/common/telemetry-constants.ts+++ b/packages/common/telemetry-constants.ts@@ -1897,7 +1897,7 @@ export interface HomeProjectUsageServiceClickedEvent {/*** The service that was clicked*/- service_type: 'db' | 'functions' | 'auth' | 'storage' | 'realtime'+ service_type: 'db' | 'functions' | 'auth' | 'storage' | 'realtime' | 'data_api'/*** Total requests for this service*/@@ -1923,7 +1923,7 @@ export interface HomeProjectUsageChartClickedEvent {/*** The service type for this chart*/- service_type: 'db' | 'functions' | 'auth' | 'storage' | 'realtime'+ service_type: 'db' | 'functions' | 'auth' | 'storage' | 'realtime' | 'data_api'/*** Timestamp of the bar clicked*/diff --git a/packages/ui-patterns/src/Row/index.tsx b/packages/ui-patterns/src/Row/index.tsxindex f2251907b99..478991d3fed 100644--- a/packages/ui-patterns/src/Row/index.tsx+++ b/packages/ui-patterns/src/Row/index.tsx@@ -105,7 +105,9 @@ export const Row = forwardRef<HTMLDivElement, RowProps>(function Row(const pendingDeltaRef = useRef(0)const handleWheel: React.WheelEventHandler<HTMLDivElement> = (e) => {- if (e.deltaX === 0) return+ // Only scroll sideways when horizontal intent wins. Trackpads report a small+ // deltaX on vertical scrolls, so a deltaX === 0 check would hijack them.+ if (Math.abs(e.deltaX) <= Math.abs(e.deltaY)) returnconst delta = Math.abs(e.deltaX) * 2 * (e.deltaX > 0 ? 1 : -1)pendingDeltaRef.current += delta