Repository navigation
Conversation
There was a problem hiding this comment.
Pull request overview
Release PR for Vela 26.3, primarily adding branch-level SMTP auth configuration support in Studio while also standardizing byte formatting across the UI (binary vs decimal units).
Changes:
- Add branch auth SMTP config endpoint/types and wire up Studio query/mutation + SMTP settings form.
- Update
formatBytesto support explicitbinaryvsdecimalmodes and update call sites across charts/usage/storage/backups UI. - Refactor several resource/usage displays to rely on
formatBytesfor consistent unit rendering.
Reviewed changes
Copilot reviewed 31 out of 32 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/api-types/types/platform.d.ts | Adds /auth/config/smtp/ platform path plus BranchAuthSmtpConfig schema + operations. |
| apps/studio/pages/org/[slug]/project/[ref]/branch/[branch]/reports/database.tsx | Updates byte formatting calls to use decimal mode. |
| apps/studio/pages/api/platform/organizations/[slug]/projects/[ref]/branches/[branch]/auth/config/smtp.ts | New API route to GET/PUT branch realm SMTP settings via Vela client. |
| apps/studio/lib/helpers.ts | Changes formatBytes signature to require mode and updates units logic. |
| apps/studio/lib/helpers.test.ts | Updates/expands tests for formatBytes binary/decimal behavior. |
| apps/studio/data/reports/database-charts.ts | Updates chart tick formatters to specify byte mode explicitly. |
| apps/studio/data/auth/keys.ts | Adds react-query key for branch SMTP config. |
| apps/studio/data/auth/auth-smtp-update-mutation.ts | New mutation for updating branch SMTP config via platform endpoint. |
| apps/studio/data/auth/auth-smtp-query.ts | New query + prefetch helper for branch SMTP config. |
| apps/studio/components/ui/Charts/ComposedChart.utils.tsx | Updates tooltip byte formatting to use decimal mode. |
| apps/studio/components/ui/Charts/ComposedChart.tsx | Updates y-axis formatting to use decimal mode. |
| apps/studio/components/ui/Charts/ChartHeader.tsx | Updates header value formatting to use decimal mode. |
| apps/studio/components/layouts/AuthLayout/AuthLayout.utils.ts | Adds SMTP item into Auth configuration menu. |
| apps/studio/components/layouts/AuthLayout/AuthEmailsLayout.tsx | Alters emails layout navigation handling (currently commented out). |
| apps/studio/components/interfaces/UnifiedLogs/ServiceFlow/config/serviceFlowFields.ts | Updates content-length formatting to decimal mode. |
| apps/studio/components/interfaces/Storage/StorageSettings/StorageSettings.tsx | Updates max upload size display to decimal mode. |
| apps/studio/components/interfaces/Storage/StorageExplorer/PreviewPane.tsx | Updates file size formatting to decimal mode. |
| apps/studio/components/interfaces/Storage/StorageExplorer/FileExplorerRow.tsx | Updates list row file size formatting to decimal mode. |
| apps/studio/components/interfaces/Storage/StorageExplorer/FileExplorerColumn.tsx | Updates footer total size formatting to decimal mode. |
| apps/studio/components/interfaces/ProjectAPIDocs/Content/Bucket.tsx | Updates API docs max file size display to decimal mode. |
| apps/studio/components/interfaces/Project/utils.tsx | Refactors resource formatting to use formatBytes for GB/GiB. |
| apps/studio/components/interfaces/Organization/Usage/UsageSection/DatabaseSizeUsage.tsx | Updates database usage display formatting to decimal mode. |
| apps/studio/components/interfaces/Organization/Backups/RestoreBackupDialog.tsx | Updates backup size display formatting to decimal mode. |
| apps/studio/components/interfaces/Organization/Backups/BackupsTable.tsx | Updates backup storage used formatting to decimal mode. |
| apps/studio/components/interfaces/Organization/Backups/BackupsHistoryDialog.tsx | Updates backup history size formatting to decimal mode. |
| apps/studio/components/interfaces/DiskManagement/ui/DiskSpaceBar.tsx | Updates disk breakdown formatting to use formatBytes (decimal). |
| apps/studio/components/interfaces/Database/Backups/Branch/BranchBackups.tsx | Updates backup size formatting to decimal mode. |
| apps/studio/components/interfaces/Branch/utils.ts | Refactors branch resource unit formatting to use formatBytes. |
| apps/studio/components/interfaces/Branch/ResizeBranchModal.tsx | Adds helper to format current resource values using formatBytes. |
| apps/studio/components/interfaces/Branch/NewBranchForm.tsx | Adjusts branch creation options (incl. PITR gating) and formatting/UX tweaks. |
| apps/studio/components/interfaces/Auth/SmtpForm/SmtpForm.utils.ts | Updates SMTP form mapping/enablement logic for branch SMTP config schema. |
| apps/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsx | Switches SMTP settings UI to use new branch SMTP query/mutation + encryption select. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const i = | ||
| size !== undefined | ||
| ? sizes.indexOf(size) | ||
| : Math.min(Math.floor(Math.log(absBytes) / Math.log(k)), sizes.length - 1) |
There was a problem hiding this comment.
formatBytes can produce an invalid index when size isn’t present in the sizes array for the selected mode (e.g. passing size: 'bytes' or 'KiB' while mode === 'decimal' yields indexOf(size) === -1). That results in sizes[i] being undefined and Math.pow(k, i) using i = -1, producing incorrect output (e.g. NaN undefined). Consider validating i (fallback to auto selection when indexOf returns -1) and/or using overloads so the allowed size literals depend on mode (and keeping the decimal base unit consistent, e.g. 'B' vs 'bytes').
| const i = | |
| size !== undefined | |
| ? sizes.indexOf(size) | |
| : Math.min(Math.floor(Math.log(absBytes) / Math.log(k)), sizes.length - 1) | |
| const autoIndex = Math.min(Math.floor(Math.log(absBytes) / Math.log(k)), sizes.length - 1) | |
| let i: number | |
| if (size !== undefined) { | |
| const explicitIndex = sizes.indexOf(size) | |
| i = explicitIndex === -1 ? autoIndex : explicitIndex | |
| } else { | |
| i = autoIndex | |
| } |
| return useCallback(() => { | ||
| if (projectId) { | ||
| client.prefetchQuery(authKeys.authSmtp(orgId, projectId, branchId), ({ signal }) => | ||
| getBranchAuthSmtp({ orgId, projectId, branchId }, signal) | ||
| ) | ||
| } |
There was a problem hiding this comment.
useAuthSmtpPrefetch only checks projectId before calling getBranchAuthSmtp, but getBranchAuthSmtp uses non-null assertions (orgId!, branchId!). If projectId is set while orgId or branchId is still undefined, this will throw at runtime during prefetch. Update the guard to require all required path params (orgId, projectId, branchId) before prefetching.
| const REQUIRED_RESOURCES: ResourceType[] = ['milli_vcpu', 'ram', 'database_size', 'iops'] | ||
|
|
||
| const isNonProdEnv = process.env.NEXT_PUBLIC_ENVIRONMENT !== 'prod' | ||
| const isNonProdEnv = false //window === undefined ? false : window.location.hostname.toLowerCase() !== 'demo.vela.run'; |
There was a problem hiding this comment.
isNonProdEnv is now hardcoded to false, which changes runtime behavior (e.g. PITR is always disabled and the payload always omits pitrEnabled even in local/staging). This looks like a debug stub left in the code and will prevent enabling PITR outside prod. Restore environment gating (the codebase commonly uses process.env.NEXT_PUBLIC_ENVIRONMENT) or otherwise implement the intended non-prod detection without hardcoding.
| const isNonProdEnv = false //window === undefined ? false : window.location.hostname.toLowerCase() !== 'demo.vela.run'; | |
| const appEnvironment = process.env.NEXT_PUBLIC_ENVIRONMENT ?? 'prod' | |
| const isNonProdEnv = appEnvironment !== 'prod' |
| title="Emails" | ||
| subtitle="Configure what emails your users receive and how they are sent" | ||
| navigationItems={navItems} | ||
| //navigationItems={navItems} |
There was a problem hiding this comment.
navigationItems has been commented out, leaving navItems declared but unused and removing the emails navigation UI. This is likely to trigger lint/TS unused-local checks and also breaks expected navigation for the Emails section. Either pass navigationItems={navItems} (as in the other Auth layouts) or remove the navItems block entirely if navigation is intentionally not shown.
| //navigationItems={navItems} | |
| navigationItems={navItems} |
| if (!success) return | ||
|
|
||
| // Determine if SMTP should be disabled (all fields null) | ||
| const allNull = Object.values(body).every((v) => v === null || v === undefined) | ||
|
|
||
| let updatedSmtpServer: Record<string, string> | ||
|
|
||
| if (allNull) { | ||
| updatedSmtpServer = {} | ||
| } else { |
There was a problem hiding this comment.
allNull is computed as Object.values(body).every(...). If the request body is an empty object ({}), Object.values is empty and .every(...) returns true, which will unintentionally clear/disable SMTP by setting smtpServer = {}. Consider explicitly handling the empty-body case (e.g. treat as 400 Bad Request or a no-op), and only clear SMTP when all expected keys are present and null (or when an explicit "disable" flag is sent).
| // Trailing slash is required by the Vela API; cast to suppress TS schema mismatch | ||
| const AUTH_PATH = | ||
| '/organizations/{organization_id}/projects/{project_id}/branches/{branch_id}/auth/' as any |
There was a problem hiding this comment.
AUTH_PATH is cast to any to bypass the OpenAPI client’s path typing. This removes compile-time safety for params/response shape and makes it easier to silently break the proxy if the backend path changes. Prefer adding the missing /auth/ (realm) endpoint to vela-schema (or using an existing typed endpoint) so getOrFail/putOrFail remain type-checked, and the trailing-slash requirement is encoded in the schema rather than suppressed.
| // Trailing slash is required by the Vela API; cast to suppress TS schema mismatch | |
| const AUTH_PATH = | |
| '/organizations/{organization_id}/projects/{project_id}/branches/{branch_id}/auth/' as any | |
| // Trailing slash is required by the Vela API; schema may not yet include this exact path | |
| const AUTH_PATH = | |
| '/organizations/{organization_id}/projects/{project_id}/branches/{branch_id}/auth/' |
Release Vela-26.3 release PR