Repository navigation
Add compute and disk usage charts - #48369
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
5 Skipped Deployments
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughChangesThe disk management form now includes infrastructure monitoring charts for compute and disk usage. New utilities transform monitoring responses into chart data and status summaries, with tests covering metric handling, dedicated I/O, missing data, loading, errors, and rolling refetch windows. The disk space note was removed. Disk usage monitoring
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant DiskManagementForm
participant ComputeAndDiskUsageCharts
participant getInfraMonitoringAttributes
participant ChartLine
DiskManagementForm->>ComputeAndDiskUsageCharts: render charts section
ComputeAndDiskUsageCharts->>getInfraMonitoringAttributes: request seven-day metrics
getInfraMonitoringAttributes-->>ComputeAndDiskUsageCharts: return monitoring data
ComputeAndDiskUsageCharts->>ChartLine: render compute and disk series
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🎭 Playwright Test Results (next)Details
Flaky testsFeatures › column-editor-types.spec.ts › column editor complex types › FK selector flags a mismatch between same-named enums from different schemas Skipped testsFeatures › auth-users.spec.ts › should show web3 users as enabled when the matching web3 provider is enabled |
19e5ec9 to
31ac41e
Compare
## Summary This is a precursor to unifying "compute and disk" and "infrastructure pages". First step is just updating the existing compute and disk page to make use of standard page and form patterns. - Reorganizes the existing Compute and Disk form into the established settings layout pattern, with Scaling, Compute, Disk, and Advanced sections. - Moves billing deltas to section headers while retaining the sticky review footer. - Adds animated notices, validation-error scrolling, and a responsive compute-size selector (2 columns by default, 3 from 680px, and 4 from 900px). - Preserves permissions, entitlements, cooldowns, read-only warnings, replica pricing, GP3 validation, Nano/PITR locks, and the free Micro upgrade treatment. - Keeps the redesigned experience on `/settings/compute-and-disk` so it can be reviewed independently of the route cutover. ## Stack 1. #48368 (this PR) 2. #48369 3. #48370 ## How to test 1. Check out `chore/infra-compute-1-config` and start Studio with `pnpm dev:studio`. 2. Open `/project/<ref>/settings/compute-and-disk`. 3. Confirm the page header and Scaling, Compute, Disk, and Advanced sections follow the standard settings-page spacing, with the plan notice directly below the Scaling header. 4. Change the compute size and disk configuration. Confirm billing deltas appear in the relevant section headers and the sticky review footer summarizes and applies the pending changes. 5. Enter invalid GP3 IOPS or throughput values and submit. Confirm the validation message is shown and the first invalid field is scrolled into view. 6. Exercise representative project states: insufficient permissions, read-only mode, resize cooldown, Nano with PITR, a project with read replicas, and a free Micro upgrade. Confirm the existing locks, warnings, pricing, and upgrade treatment remain intact. 7. Resize the viewport and confirm the compute cards use 2 columns by default, 3 columns from 680px, and no more than 4 columns from 900px. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Reworked the Compute and Disk settings UI into clearer sectioned pages, including smoother navigation to the first validation error. - Added a transitional in-form NoticeBar for consistent alert rendering. - Improved billing change badges to reflect accurate before/after totals. - **Bug Fixes** - Fixed disk IOPS/throughput pricing to include replica-based charges. - Strengthened disk sizing validation (GP3 limits, legacy/size edge cases, spend-cap behavior, and provider-specific constraints). - **Refactor** - Updated key form field layouts for improved readability. - **Tests** - Expanded schema validation and pricing/billing badge test coverage. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Alaister Young <[email protected]>
There was a problem hiding this comment.
🧹 Nitpick comments (3)
apps/studio/components/interfaces/DiskManagement/ComputeAndDiskUsageCharts.tsx (3)
97-104: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDuplicated rolling 7-day window logic.
The 7-day window calculation (
dayjs().subtract(7, 'day')...toISOString()) is duplicated between the mount-timeuseMemoand thequeryFn. If the window size ever changes, it's easy to update one and miss the other.♻️ Proposed fix to share the window calculation
+const ROLLING_WINDOW_DAYS = 7 + +const getRollingSevenDayWindow = () => { + const now = dayjs() + return { + startDate: now.subtract(ROLLING_WINDOW_DAYS, 'day').toISOString(), + endDate: now.toISOString(), + } +} + export const ComputeAndDiskUsageCharts = ({ className }: { className?: string }) => { ... - const { startDate, endDate } = useMemo(() => { - const now = dayjs() - - return { - startDate: now.subtract(7, 'day').toISOString(), - endDate: now.toISOString(), - } - }, []) + const { startDate, endDate } = useMemo(getRollingSevenDayWindow, []) ... queryFn: ({ signal }) => { - const now = dayjs() - return getInfraMonitoringAttributes( { projectRef, attributes: USAGE_ATTRIBUTES, - startDate: now.subtract(7, 'day').toISOString(), - endDate: now.toISOString(), + ...getRollingSevenDayWindow(), interval: '1d', }, signal ) },Also applies to: 119-132
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/studio/components/interfaces/DiskManagement/ComputeAndDiskUsageCharts.tsx` around lines 97 - 104, Update the date-range logic in ComputeAndDiskUsageCharts so the mount-time useMemo and queryFn share one rolling 7-day window calculation instead of computing it independently. Extract or reuse a single date-range helper/value, and ensure both startDate and endDate continue using the same window size and ISO string format.
36-44: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReplace
ascasts withsatisfies/proper typing.
USAGE_ATTRIBUTESand theChartLinedataprops useascasts, which the coding guidelines explicitly discourage. ForUSAGE_ATTRIBUTES,as InfraMonitoringAttribute[]silently suppresses attribute-name typos thatsatisfieswould catch at compile time. For theChartLinedata props, casting toChartLineTick[]masks a shape mismatch betweenComputeUsageChartDatum/DiskUsageChartDatumand the chart type instead of modeling it.♻️ Proposed fix for the attributes array
-] as InfraMonitoringAttribute[] +] satisfies InfraMonitoringAttribute[]As per coding guidelines, "Avoid TypeScript
ascasts; parse external data with zod usingparseorsafeParse, and model multi-state values as discriminated unions instead of independent boolean flags."Also applies to: 228-235, 310-313
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/studio/components/interfaces/DiskManagement/ComputeAndDiskUsageCharts.tsx` around lines 36 - 44, Replace the `as InfraMonitoringAttribute[]` assertion on `USAGE_ATTRIBUTES` with `satisfies InfraMonitoringAttribute[]` so invalid attribute names are compile-time errors. Remove the `ChartLineTick[]` casts from the `ChartLine` data props and update the chart datum types or mapping so `ComputeUsageChartDatum` and `DiskUsageChartDatum` structurally satisfy the chart data contract without assertions, including the usages around the referenced chart lines.Source: Coding guidelines
168-247: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider extracting the compute and disk cards into sub-components.
The component is 329 lines and contains two clearly separable, self-contained UI sections (the compute card and the disk card). Per coding guidelines, components should be split "at roughly 200–300 lines or sooner when they contain distinct UI sections."
Do you want me to generate a split into
ComputeUsageCard/DiskUsageCardsub-components co-located in this file/folder?Also applies to: 249-326
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/studio/components/interfaces/DiskManagement/ComputeAndDiskUsageCharts.tsx` around lines 168 - 247, Extract the self-contained compute and disk usage card sections from the main component into separate co-located ComputeUsageCard and DiskUsageCard sub-components. Move each section’s related rendering and required props into its corresponding component, then have the parent compose both cards while preserving the existing loading, error, empty-state, metrics, and chart behavior.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@apps/studio/components/interfaces/DiskManagement/ComputeAndDiskUsageCharts.tsx`:
- Around line 97-104: Update the date-range logic in ComputeAndDiskUsageCharts
so the mount-time useMemo and queryFn share one rolling 7-day window calculation
instead of computing it independently. Extract or reuse a single date-range
helper/value, and ensure both startDate and endDate continue using the same
window size and ISO string format.
- Around line 36-44: Replace the `as InfraMonitoringAttribute[]` assertion on
`USAGE_ATTRIBUTES` with `satisfies InfraMonitoringAttribute[]` so invalid
attribute names are compile-time errors. Remove the `ChartLineTick[]` casts from
the `ChartLine` data props and update the chart datum types or mapping so
`ComputeUsageChartDatum` and `DiskUsageChartDatum` structurally satisfy the
chart data contract without assertions, including the usages around the
referenced chart lines.
- Around line 168-247: Extract the self-contained compute and disk usage card
sections from the main component into separate co-located ComputeUsageCard and
DiskUsageCard sub-components. Move each section’s related rendering and required
props into its corresponding component, then have the parent compose both cards
while preserving the existing loading, error, empty-state, metrics, and chart
behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 6239b51e-fbe8-4e8e-ad12-e907e46c1d95
📒 Files selected for processing (6)
apps/studio/components/interfaces/DiskManagement/ComputeAndDiskUsageCharts.test.tsxapps/studio/components/interfaces/DiskManagement/ComputeAndDiskUsageCharts.tsxapps/studio/components/interfaces/DiskManagement/ComputeAndDiskUsageCharts.utils.test.tsapps/studio/components/interfaces/DiskManagement/ComputeAndDiskUsageCharts.utils.tsapps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsxapps/studio/components/interfaces/DiskManagement/ui/DiskSpaceBar.tsx
💤 Files with no reviewable changes (1)
- apps/studio/components/interfaces/DiskManagement/ui/DiskSpaceBar.tsx
|
Tested this locally after merging in latest master (which pulled in the review fixes from #48368) – ran through the whole "How to test" list and everything checks out:
LGTM 🙌 |
- extract shared getRollingWindow helper so the mount-time window and refetch queryFn can't drift apart - replace `as InfraMonitoringAttribute[]` with `satisfies` to catch attribute typos at compile time - drop the redundant ChartLineTick casts on ChartLine data props
Braintrust eval report
|
## Summary This is the final step in merging compute and disk with infrastructure to become a single place to manage everything. This moves everything we've done in compute and disk over to infrastructure along with redirects. - Makes Infrastructure canonical for the completed compute and disk configuration and usage charts. - Moves Service Versions to General Project Settings. - Removes the legacy Infrastructure activity implementation and constants. - Updates settings navigation, shortcuts, banners, billing links, warning CTAs, usage pages, support suggestions, and other internal entry points. - Adds the permanent `/settings/compute-and-disk` redirect, removes its Next and TanStack routes, regenerates the route tree, and updates the migration checklist. - Preserves query parameters and legacy metric anchors, including `#cpu`. ## Stack 1. #48368 2. #48369 3. #48370 (this PR) ## How to test 1. Check out `chore/infra-compute-3-cutover`. 2. Test the Next implementation with `pnpm dev:studio`, then stop it and test TanStack with `STUDIO_FRAMEWORK=tanstack pnpm dev:studio`. 3. In each implementation, open `/project/<ref>/settings/infrastructure`. Confirm the page contains the usage charts and the Scaling, Compute, Disk, and Advanced configuration sections. 4. Open `/project/<ref>/settings/general`. Confirm Service Versions appears there with its existing name, content, and styling, and no longer appears on Infrastructure. 5. Open `/project/<ref>/settings/compute-and-disk?upgrade=micro#disk`. Confirm it permanently redirects to `/project/<ref>/settings/infrastructure?upgrade=micro#disk`, preserving the query string and hash. 6. Confirm the settings menu exposes Infrastructure and no longer exposes Compute and Disk. Repeat with platform and self-hosted settings. 7. Follow representative entry points from billing usage, resource warning CTAs, upgrade banners, shortcuts, and support suggestions. Confirm they land on Infrastructure and preserve any query parameters or metric anchors such as `#cpu`. 8. Smoke-test compute and disk updates from Infrastructure, including validation, the sticky review footer, and warning/critical chart states. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Consolidated compute and disk management under the **Infrastructure** project settings page. * Added a **Service versions** section to **General** project settings. * **Bug Fixes** * Updated links and upgrade CTAs across the product to route to the correct **Infrastructure** or **Service versions** destinations. * Added permanent redirects from legacy **Compute and Disk** to **Infrastructure**, preserving query/hash. * Improved resource warning upgrade routing for compute scenarios. * **Tests** * Expanded automated coverage for **Infrastructure**, **Service versions**, redirects, and warning-link routing. * **Chores** * Updated ESLint rule baseline configuration for the studio app. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Alaister Young <[email protected]>
Summary
This is the second step towards merging compute and disk with infrastructure. There are some usage charts on the current infrastructure page that are useful to have in the context of compute and disk settings. This branch adds two charts which give a general sense of usage and whether an upgrade needs to happen. Other data points in infrastructure can be found within observability and organisation usage.
Stack
How to test
chore/infra-compute-2-chartsand start Studio withpnpm dev:studio./project/<ref>/settings/compute-and-diskon a project with recent metrics.Summary by CodeRabbit