Commit Graph
331 Commits
Author SHA1 Message Date
Alaister Young 2eb00165c3 chore(studio): improve AGENTS.md and skills from PR review data (#54467) 2026-12-03 18:30:27 +08:00
Danny WhiteandJoshen Lim 4dbb966b2e feat(studio): show Trusted Partner access on OAuth consent (#53583)
> [!WARNING]
> Live readiness checks require
[CTRL-2277](https://linear.app/supabase/issue/CTRL-2277) in the target
environment; production deployment is pending.

## Problem

Trusted Partner consent must explain direct database access and project
blockers before authorisation.
[DEPR-732](https://linear.app/supabase/issue/DEPR-732)

## Solution

- Show Direct database access alongside the requested permissions.
- Check selected projects, or every project page for organisation-wide
grants.
- Separate blocking issues from SSL notices; block authorisation during
loading or errors and offer retry.

| After |
| --- |
| <img width="1280" height="1323" alt="Authorize API Access Supabase"
src="https://github.com/user-attachments/assets/adb6367a-bace-4b62-81b5-68ba4c11396c"
/> |
| Consent screen with Direct database access (previously “Table data”)
and Database management |
| <img width="1280" height="1323" alt="Authorize API Access Supabase"
src="https://github.com/user-attachments/assets/0c35900c-1059-49cd-b1c5-4e0cf5441b9b"
/> |
| Selected-project blockers and the separate SSL notice |
| <img width="1280" height="1323" alt="95741"
src="https://github.com/user-attachments/assets/1fbef4f0-0433-4c93-b390-84d210dfb665"
/> |
| Organisation-wide blockers _without_ project-removal actions |

## Review instructions

1. Open the [staging consent
screen](https://studio-staging-git-dnywh-depr-732-trusted-partn-f24cfb-supabase.vercel.app/dashboard/authorize?auth_id=11666aa8-7f7e-4705-b33a-981903fd682e).
Enable `enableScopedOAuthConsent` in the dev toolbar’s **Flags** tab if
needed.
2. Open Chrome DevTools → **Network** and reload. Select the **GET**
request ending in `/platform/oauth/authorizations/{id}`.
3. Right-click that request → **Override content**. Choose a local
folder and click **Allow**. Add `database_token_access:read` and
`database_token_access:write` to `scopes`. Use only the read scope to
check read-only access. Keep every other field, save with
**Cmd/Ctrl+S**, then reload with DevTools open.
4. Select projects. Override each **GET** request ending in
`/platform/organizations/{slug}/oauth/authorizations/{id}/projects/{ref}/database-access`.
Use `{"issues":[],"enables_ssl":false}` for ready projects, then
`{"issues":[],"enables_ssl":true}` for an SSL notice. Save and reload
after each change. Check Direct database access and Database management
are separate, and SSL alone allows authorisation.
5. Change a readiness response to
`{"issues":["postgres_upgrade_required","platform_unsupported"],"enables_ssl":true}`.
Save and reload. Check blockers prevent authorisation, SSL stays
separate, and removing a blocked project clears its blockers.
6. Set `project_scoping_mode: false` in the authorisation override. Save
and reload. Check any blocked project prevents organisation-wide
authorisation, with no project-removal actions.
7. Block a database-access request in Network and reload. Check
authorisation stays disabled. Unblock it and choose **Retry checks**.
8. For a returning app, override `existing_grant.approved_scopes` in the
request ending in `/preflight`. Save and reload. Check added, removed
and unchanged permissions.
9. Disable **Sources → Overrides → Enable Local Overrides**. Repeat
ready and blocked project checks with a real staging authorisation
before approving live readiness behaviour.

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2026-12-02 16:19:30 +07:00
Alaister YoungandAlaister Young 0c97b9789b [FE-3107] chore(studio): remove remaining Next.js references (#54426)
Removes the remaining Next.js dependencies, compatibility shims, test
mocks, ESLint/TypeScript presets, and webpack/Next workarounds from
Studio following the TanStack Start migration.

Addresses FE-3107.

**Removed:**

- `next` and `next-router-mock` from `apps/studio/package.json` (and
updated `pnpm-lock.yaml`)
- Orphaned `apps/studio/compat/next/script.tsx` shim, `script.test.tsx`,
`compat/**` knip entry, and `nextCompat()` / `ssr.noExternal` `/^next/`
plumbing from `apps/studio/vite.config.ts`
- `apps/studio/tests/lib/route-mock.ts` and all `next-router-mock`
setup/imports across `tests/vitestSetup.ts`,
`tests/lib/custom-render.tsx`, and 12 test files
- `apps/studio/tests/pages/` directory (moved the 3 remaining tests to
`components/interfaces/Organization/Organization.utils.test.ts` and
`apps/studio/tests/routes/`)
- Unused `'use client'` directives across 23 Studio files
- Next.js/webpack workarounds: `graphiqlViteWorkers()` in
`vite.config.ts`, webpack `import.meta.glob` `try/catch` fallback in
`ConnectStepsSection.tsx`, shell `NODE_ENV=test` override in
`vite.config.ts` / root `package.json` / `studio-e2e-test.yml`, Next
`getPathMatch` and `_next` passthrough in `redirects.shared.*`,
`window.next?.router` check in `monaco-graphiql-coexistence.spec.ts`,
and unused `ANALYZE` env var in `apps/studio/turbo.jsonc`
- Next-only Sentry/chunk-load filters (`NEXT_NOT_FOUND`,
`NEXT_REDIRECT`, Next `/org/[slug]/` regex, `/app:\/\//`, dead
`includeThirdPartyErrorFilter` plumbing, webpack chunk error regex) and
stale Next/Pages Router comments, docs, and `#__next` CSS selector

**Changed:**

- `apps/studio/eslint.config.cjs`: switched from
`eslint-config-supabase/next` to the new `eslint-config-supabase/react`
preset (dropping `@next/next/no-img-element: off`, keeping `.next` /
`next-env.d.ts` ignored for local checkouts with stale pre-migration
build artifacts)
- `apps/studio/tsconfig.json`: extends `tsconfig/base.json` directly
instead of `tsconfig/nextjs.json` (identical resolved compiler options)
- `apps/studio/.github/eslint-rule-baselines.json`: pruned 33 stale
`pages/...` and `types/next.ts` entries without changing any rule
thresholds
- `apps/studio/tests/lib/custom-render.tsx`: backed
`TestFrameworkProvider` with TanStack Router instead of
`next-router-mock`
-
`apps/studio/components/interfaces/Integrations/GraphQL/GraphiQLTab.tsx`:
imports `graphiql/setup-workers/vite` directly
- `apps/studio/styles/globals.css`: replaced `@source
'../pages/**/*.{js,ts,jsx,tsx}'` with `@source
'../routes/**/*.{js,ts,jsx,tsx}'`
- `apps/studio/turbo.jsonc`: declared `"NEXT_PUBLIC_*"` in
`tasks.build.env` now that Turborepo infers `nitro` instead of `nextjs`
-
`apps/studio/components/interfaces/Organization/Organization.utils.ts`:
narrowed `buildOrgUrl`'s `slug` parameter to `string[] | undefined`

**Added:**

- `packages/eslint-config-supabase/shared.js` and
`packages/eslint-config-supabase/react.js` (plus `presets.test.ts`),
decoupling non-Next React apps from `eslint-config-next` with verified
zero non-`@next/*` rule drift while keeping
`eslint-config-supabase/next` unchanged for the Next.js apps

## To test

- Run `pnpm --filter eslint-config-supabase run test` and confirm preset
parity tests pass
- Run `pnpm --filter studio run lint`, `pnpm --filter studio run
lint:ratchet`, `pnpm --filter studio run typecheck`, `pnpm knip
--workspace apps/studio`, and `pnpm --filter studio run test`
- Run `pnpm --filter studio run build` and verify the production build,
prerendered routes, chunk-cycle check, and GraphiQL web workers succeed
- Smoke-test Studio locally (`pnpm dev:studio`): verify GraphiQL loads
cleanly, ConnectSheet framework steps render, and Tailwind styles on
route pages are intact

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-12-02 17:01:50 +08:00
Alaister YoungandAlaister Young ccd691423b [FE-5114] (part 6) – refactor(studio): migrate platform storage routes (#54033)
## Problem

Studio's `routes/api/platform/storage/**` routes still run legacy Next
Pages Router handlers through `compat/next/api.ts`, and
`buckets/$id/objects/download.ts` has no remaining callers. Part 6 of 7
for
[FE-5114](https://linear.app/supabase/issue/FE-5114/rewrite-api-routes-as-native-tanstack-start-handlers-and-remove-the)
migrates the 14 active storage routes to native TanStack Start handlers
and removes the unused download route.

## Solution

**Changed:**

- Migrated 14 `buckets/**` and `vector-buckets/**` routes to
`createApiHandlers` and `parseJsonBody`
- Replaced the `parseAsInt`/`parseAsString`/`parseAsStringEnum` helpers
in `buckets/index.ts` with a zod query schema that drops invalid values,
keeping the conditional spreads so unset keys aren't sent to storage-js
- Forwarded upstream `StorageError` status codes across all storage and
vector-bucket routes via `storageErrorResponse` /
`getStorageErrorStatus` (falling back to the route's default 400/500
when no valid HTTP status is present)
- Guarded missing/invalid `SUPABASE_PUBLIC_URL` with a `500` error
response in `objects/public-url`, `objects/sign`, and
`objects/sign-multi`
- Typed the `vector-buckets/$id/indexes` POST body from storage-js's
`createIndex` options
- Corrected stale `Allow` headers on `vector-buckets/$id` (`GET,
DELETE`) and `vector-buckets/$id/indexes/$indexName` (`DELETE`) via
`createApiHandlers`

**Added:**

- `lib/api/self-hosted/storage.ts` with `getStorageErrorStatus`,
`storageErrorResponse`, `getStoragePublicOrigin`,
`missingStoragePublicUrlResponse`, and `remapStoragePublicUrl`
- Unit tests for `buckets/index` query parsing,
`buckets/$id/objects/sign-multi` (`SUPABASE_PUBLIC_URL` guard, origin
remapping, and upstream error status), and `vector-buckets` POST
(exercising the real storage client through MSW)

**Removed:**

- Removed unused
`routes/api/platform/storage/$ref/buckets/$id/objects/download.ts` and
regenerated `routeTree.gen.ts`

**Behavior changes vs master:**

- `buckets` GET drops malformed `limit`/`offset`/sort values instead of
`parseInt`-truncating them (e.g. `offset=1.5` is ignored rather than
sent as `1`)
- `vector-buckets` POST validates the body with zod and returns `400`
when `bucketName` is missing or not a string
- Storage routes forward the upstream HTTP status code from
`StorageApiError` instead of hardcoding `400`/`500`
- `objects/public-url`, `objects/sign`, and `objects/sign-multi` return
a `500` JSON error when `SUPABASE_PUBLIC_URL` is unset or invalid
instead of throwing an uncaught `TypeError`
- Unused `buckets/$id/objects/download` route has been removed

## Review instructions

1. Run `pnpm --filter studio exec vitest run
tests/routes/api/platform/storage/`.
2. On self-hosted Studio, create/list/empty/delete a storage bucket,
upload/download/move/sign/delete an object, and check vector bucket
operations.

## Checklist

- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [ ] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-12-01 22:55:25 +08:00
Alaister YoungandAlaister Young 37414c5a61 [FE-5114] (part 5) – refactor(studio): migrate platform project routes (#54032)
## Problem

Studio's `routes/api/platform/projects/**` routes still run legacy Next
Pages Router handlers through `compat/next/api.ts`, and
`projects/$ref/config/index.ts` and `projects/$ref/billing/addons.ts`
are unused in self-hosted mode. Part 5 of 7 for
[FE-5114](https://linear.app/supabase/issue/FE-5114/rewrite-api-routes-as-native-tanstack-start-handlers-and-remove-the)
migrates the 19 active project routes to native TanStack Start handlers
and removes the 2 unused routes.

## Solution

**Changed:**

- Migrated 19 project routes — analytics (`endpoints/$name`,
`log-drains`, `log-drains/$uuid`), API proxies (`api/graphql`,
`api/rest`), content snippets & folders (`content/**`), and
config/settings/databases/lints/keys/monitoring routes — to
`createApiHandlers`
- Preserved FE-5124 fixes on `log-drains/$uuid` (empty-body `204` on
`DELETE`, `try`/`catch` + `!response.ok` → `500`); its `Allow: GET, PUT,
DELETE` and the previously stale `Allow` on `log-drains` (`GET, POST`)
now come from `createApiHandlers`
- Forwarded upstream error status and JSON body (falling back to `500` /
`{ error: { message } }`) in `api/graphql` and `api/rest`
- Parsed the JSON body once in `content/index.ts` `PUT` so the `not
found` create fallback does not attempt to re-read the request stream
- `content/index.ts` and `content/folders/index.ts` read query params
through `getSearchParamsRecord`, so repeated `ids` (and repeated GET
params on `content/index`) return `400` as they did with Next's query
parsing
- `run-lints` forwards headers via
`constructHeaders(Object.fromEntries(request.headers))`

**Added:**

- `getSearchParamsRecord` in `lib/api/apiHelpers.ts`: collects URL
search params into a record, mapping repeated keys to arrays so zod
string schemas reject them
- `folderQueryParamsSchema` and `listFolderContents(request, folderId?)`
in `lib/api/snippets.utils.ts`, shared by `content/folders/index` and
`content/folders/$id`
- `getLogflareConfig()` in `lib/api/self-hosted/logflare.ts`: reads the
Logflare env vars at call time (same `500` naming the missing vars) and
builds the request URLs and headers for `analytics/log-drains` and
`analytics/log-drains/$uuid`
- Unit tests for `getSearchParamsRecord`, `analytics/endpoints/$name`,
`analytics/log-drains/$uuid`, `content/index`, `content/folders`, and
`api/rest` (`HEAD` and upstream error forwarding)

**Removed:**

- Removed 2 unused routes
(`routes/api/platform/projects/$ref/config/index.ts` and
`routes/api/platform/projects/$ref/billing/addons.ts`) and regenerated
`routeTree.gen.ts`

**Behavior changes vs master:**

- `analytics/endpoints/$name` GET strips `name` and `ref` from the
forwarded query (parity with master, where they arrived as route params
in `req.query`)
- `content/folders` and `content/folders/$id` GET validate query params
and return `400` for invalid or repeated values
- `api/graphql` and `api/rest` forward upstream non-OK status codes and
error bodies instead of always returning `500`
- Unused `projects/$ref/config/index` and `projects/$ref/billing/addons`
routes have been removed

## Review instructions

1. Run `pnpm --filter studio exec vitest run lib/api/apiHelpers.test.ts
tests/routes/api/platform/projects/`.
2. On self-hosted Studio, create/update/delete a log drain,
create/save/delete a SQL snippet and folder, and verify REST/GraphQL API
docs load.

## Checklist

- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [ ] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-12-01 22:38:58 +08:00
Alaister YoungandAlaister Young be32a941cd [FE-5114] (part 4) – refactor(studio): migrate platform auth and misc routes (#54031)
## Problem

Studio's `routes/api/platform/auth/**` and platform misc/stub routes
still run legacy Next Pages Router handlers through
`compat/next/api.ts`, and 4 legacy database/props routes have no callers
left. Part 4 of 7 for
[FE-5114](https://linear.app/supabase/issue/FE-5114/rewrite-api-routes-as-native-tanstack-start-handlers-and-remove-the)
migrates the 16 active routes to native TanStack Start handlers and
removes the 4 unused ones.

## Solution

**Changed:**

- Migrated `platform/auth/$ref/{invite,magiclink,otp,recover}` to
one-line `createAuthSenderHandlers` routes, and `users/index`,
`users/$id/index`, and `users/$id/factors` to `createApiHandlers`,
preserving the FE-5124 fixes (`Promise.all` MFA factor deletion, `code
?? 500` on auth senders, `Allow: PATCH, DELETE` on `users/$id`, now
derived by `createApiHandlers`)
- Migrated 9 platform misc/stub routes (`deployment-mode`,
`integrations/{$slug,github/*}`,
`organizations/{index,$slug/billing/subscription}`, `profile/index`, and
`telemetry/event`)
- Moved the `FETCH_TYPE_BYPASS_EXCEPTIONS` entries for the four sender
routes in `eslint.config.cjs` to `lib/api/self-hosted/auth-senders.ts`

**Added:**

- `createAuthSenderHandlers(endpoint, field)` in
`lib/api/self-hosted/auth-senders.ts`: shared POST handler for the
self-hosted GoTrue `invite`, `magiclink`, `otp`, and `recover` endpoints
(forwards only `email` or `phone`, uses `constructHeaders` with the
service role key, and passes upstream errors through with `code ?? 500`)
- Regression tests for `auth/$ref/users/$id/factors`,
`auth/$ref/users/$id`, and all four auth sender routes

**Removed:**

- Removed 4 unused routes (`platform/database/$ref/pooling`,
`platform/props/org/$slug`, `platform/props/project/$ref/index`, and
`platform/props/project/$ref/api`) and regenerated `routeTree.gen.ts`

## Review instructions

1. Run `pnpm --filter studio exec vitest run
tests/routes/api/platform/auth/`.
2. On self-hosted Studio, invite/ban/delete a user, remove MFA factors
for a user, and confirm `GET /api/platform/auth/default/users/<id>`
returns `405` with `Allow: PATCH, DELETE`.

## Checklist

- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [ ] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-12-01 22:30:19 +08:00
Alaister YoungandAlaister Young 20a5212c42 [FE-5114] (part 3) – refactor(studio): migrate pg-meta and v1 routes (#54030)
## Problem

Studio's `routes/api/platform/pg-meta/**` and `routes/api/v1/**` routes
still run legacy Next Pages Router handlers through
`compat/next/api.ts`, and 10 legacy `pg-meta` GET proxy routes are no
longer called anywhere in the repo. Part 3 of 7 for
[FE-5114](https://linear.app/supabase/issue/FE-5114/rewrite-api-routes-as-native-tanstack-start-handlers-and-remove-the)
migrates the 9 active routes to native TanStack Start handlers and
deletes the 10 unused proxy routes.

## Solution

**Changed:**

- Migrated `platform/pg-meta/$ref/query/index.ts` and all 8 `v1` routes
(`api-keys`, `api-keys/$id`, `config/auth/signing-keys/{index,legacy}`,
`database/migrations`, `functions/{index,$slug/index}`,
`types/typescript`) to `createApiHandlers`; `query` and
`database/migrations` share `pgMetaErrorResponse`
- Enabled `{ withAuth: true }` on `api-keys`, `api-keys/$id`, and
`config/auth/signing-keys/{index,legacy}` for consistency with the other
`v1` routes
- Updated `api-keys` route tests to use `callRoute`

**Added:**

- `pgMetaErrorResponse(error)` in `lib/api/self-hosted/pg-meta.ts`
(keeps a `PgMetaDatabaseError`'s status and `{ message, formattedError
}` payload expected by `data/error-classification.ts`, otherwise `500`)
- Unit test for `pg-meta/$ref/query`
(`tests/routes/api/platform/pg-meta/$ref/query/index.test.ts`)

**Removed:**

- Removed all 10 unused `pg-meta` GET proxy routes (`column-privileges`,
`extensions`, `foreign-tables`, `materialized-views`, `policies`,
`publications`, `tables`, `triggers`, `types`, `views`), removed their
`FETCH_TYPE_BYPASS_EXCEPTIONS` entries from `eslint.config.cjs`, and
regenerated `routeTree.gen.ts`
- Removed `getPgMetaRedirectUrl` (`lib/api/apiHelpers.ts`) and
`parseRevealQuery` (`lib/api/self-hosted/api-keys.ts`)

**Behavior changes vs master:**

- Routes forward only `cookie` and `x-connection-encrypted` to pg-meta
via `constructHeaders(Object.fromEntries(request.headers))`, matching
what master's adapter forwarded
- `database/migrations` GET now forwards headers to
`listMigrationVersions` (master passed them as the wrong argument)
- `v1/projects/$ref/api-keys*` and `config/auth/signing-keys*` now pass
`{ withAuth: true }` (no-op in self-hosted mode; consistent with the
other `v1` routes)
- The 10 unused `pg-meta` GET proxy routes have been removed
(`pg-meta/$ref/query` and `v1/projects/$ref/types/typescript` remain)

## Review instructions

1. Run `pnpm --filter studio exec vitest run tests/routes/api/v1/
tests/routes/api/platform/pg-meta/`.
2. On self-hosted Studio, load tables/views/policies/extensions, run a
query in the SQL Editor, check API keys, and generate TypeScript types.

## Checklist

- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [ ] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-12-01 21:44:59 +08:00
Joaquim Moreno Prusi a27ef81d2e feat(studio): enable advanced V3 deployment for allowlisted organizations (#53158)
## Problem

Currently, in production, the Supabase UI doesn't allow for a set of
advanced deployment options, that we need to properly test new clusters
before getting those into production.

## Solution

Allow production dashboard requests to specify an AWS_K8S cluster when
the organization is included in the comma-separated
`orgsAllowedToUseV3AdvancedDeployment` setting.

Limited the exception to cluster placement fields. Preserve existing
permissions and cluster validation, require force for cordoned clusters,
and keep system requests supported. Default the allowlist to empty.

Updated the API descriptions and document ConfigCat setup.

## Review instructions
-

## Checklist

Check all before review:

- [X] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [X] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
2026-12-01 14:18:26 +01:00
Alaister YoungandAlaister Young b6c391a058 [FE-5114] (part 1) – refactor(studio): add native API helpers & routes (#54028)
## Problem

Studio's `routes/api/**` server routes still run legacy Next Pages
Router handlers through the `toWebHandler` shim in `compat/next/api.ts`.
Part 1 of 7 for
[FE-5114](https://linear.app/supabase/issue/FE-5114/rewrite-api-routes-as-native-tanstack-start-handlers-and-remove-the)
adds native TanStack Start (`Request` → `Response`) helpers and migrates
the top-level utility routes so we can remove the adapter at the end of
the stack.

## Solution

**Added:**

- `createApiHandlers` in `lib/api/apiWrapper.ts`: wraps native TanStack
Start route handlers with optional platform JWT auth, JSON `400` (`{
error: { message: 'Invalid JSON' } }`) on `InvalidJsonError`, Sentry
capture + generic `500` on unexpected throws, and an `ANY` handler that
returns `405` with an `Allow` header derived from the registered
methods. Exports `ApiHandler` / `ApiHandlerContext` (`params` is
`Record<string, string>`)
- `authenticateRequest` in `lib/api/apiAuthenticate.ts` (Web `Request`
counterpart of `apiAuthenticate`, same error messages)
- `InvalidJsonError` and `parseJsonBody` in `lib/api/apiHelpers.ts`
- `callRoute(route, request, params)` test helper in
`tests/lib/server-route.ts`
- Unit tests for `createApiHandlers` (exercising real
`authenticateRequest` through MSW in
`lib/api/createApiHandlers.test.ts`), `authenticateRequest`,
`parseJsonBody`, `/api/generate-attachment-url`, and
`/api/integrations/stripe-sync`

**Changed:**

- Updated `getRouteHandler` in `tests/lib/server-route.ts` to mirror
TanStack Start's `HEAD` → `GET` → `ANY` dispatch order
- Migrated 11 top-level API routes (`check-cname`,
`cli-release-version`, `content/graphql`, `edge-functions/test`,
`enabled-features-overrides`, `generate-attachment-url`,
`get-deployment-commit`, `get-ip-address`, `get-s3-keys`,
`get-utc-time`, `integrations/stripe-sync`) to native handlers
- Added `withAuth: true` to `check-cname`, `content/graphql`, and
`integrations/stripe-sync`, and updated `check-cname-mutation.ts` and
`data/graphql/execute.ts` to attach `constructHeaders()`
- Reused `withAuth` `claims` in `generate-attachment-url` to avoid a
duplicate GoTrue lookup in platform mode
- Converted `tests/routes/api/get-deployment-commit.test.ts` to
`callRoute`

**Removed:**

- Removed 2 unused routes (`routes/api/connect/index.ts` and
`routes/api/parse-query.ts`), dropped `/parse-query` from
`lib/hosted-api-allowlist.ts`, removed Nitro's `traceDeps:
['libpg-query*']` in `vite.config.ts` (no server runtime route imports
`libpg-query` anymore), and regenerated `routeTree.gen.ts`

**Behavior changes vs master:**

- Methods a route doesn't register now get a JSON `405` with an `Allow`
header (previously they fell through to the SSR app). `HEAD` requests
that TanStack Start dispatches to a `GET` handler also get `405`,
matching master's method switches
- `InvalidJsonError` returns JSON `{ error: { message: 'Invalid JSON' }
}` (`400`) instead of plain text
- `check-cname`, `content/graphql`, and `integrations/stripe-sync` now
verify the platform JWT via `withAuth: true`
- Unexpected throws return a generic `500` with `{ error: { message:
'Internal Server Error' } }`
- Unused `/api/connect` and `/api/parse-query` routes have been removed

## Review instructions

1. Run `pnpm --filter studio exec vitest run
lib/api/apiAuthenticate.test.ts lib/api/apiHelpers.test.ts
lib/api/apiWrappers.test.ts lib/api/createApiHandlers.test.ts
tests/routes/api/ scripts/__tests__/server-source-maps.test.ts`.
2. Smoke-test `/api/get-deployment-commit`, `/api/check-cname`,
`/api/content/graphql`, `/api/generate-attachment-url`, and
`/api/edge-functions/test` in Studio and confirm unsupported HTTP
methods return `405` with an `Allow` header.

## Checklist

- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [ ] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-12-01 20:53:57 +08:00
Alaister YoungandAlaister Young 477e2c136f [FE-5109] (part 6) chore(studio): remove next/router shims, aliases, and test mocks (#54058)
Part 6 (final) of a 6-PR stack migrating all `next/router` and
`next/compat/router` imports in `apps/studio` onto TanStack Router hooks
and removing the router shims.

| Part | PR | Scope |
| --- | --- | --- |
| 1 | #54053 | Core navigation helpers, `hooks/**`, `lib/**`,
`data/prefetchers/**` |
| 2 | #54054 | `components/ui/**` |
| 3 | #54055 | `components/layouts/**` and `state/tabs.tsx` |
| 4 | #54056 | Database, Branching, Compute, Edge Functions, Explorer,
SQL Editor, Storage, Table Editor |
| 5 | #54057 | Remaining `components/interfaces/**` and
`QueryInsightsTable` router events |
| **6** | **#54058 ← this PR** | **Remove `next/router` &
`next/compat/router` shims, `_router-events.ts`, Vite aliases, and test
mocks** |

Now that no files in `apps/studio` (or `packages/**`) import
`next/router` or `next/compat/router`, deletes the router shims,
`_router-events.ts`, their Vite aliases, and the obsolete router test
mocks. `RouteValidationWrapper` is intentionally left for FE-3107.

**Removed:**

- `apps/studio/compat/next/router.ts`,
`apps/studio/compat/next/compat/router.ts`, and
`apps/studio/compat/next/_router-events.ts`
- `'next/router'` and `'next/compat/router'` entries from `nextShims` in
`apps/studio/vite.config.ts`
- Global `vi.mock('next/router', ...)` and
`vi.mock('next/compat/router', ...)` in
`apps/studio/tests/vitestSetup.ts`, `mockNextRouter` in
`apps/studio/tests/lib/route-aware-hooks.ts`, and the unused
`vi.mock('next/router')` in `tests/features/logs/LogTable.test.tsx`
- Obsolete shim tests and test helpers: `compat/next/router.test.ts`,
`compat/next/router-navigation.test.tsx`, `tests/config/router.tsx`, and
`tests/config/router.test.tsx`

**Changed:**

- Simplified `createNavigationHandler` in
`apps/studio/lib/navigation.ts` (and `navigation.test.ts`) to accept
TanStack's `UseNavigateResult<string>` only, dropping the `NextRouter`
union branch
- Updated `compat/next/link-basepath-navigation.test.tsx` (renamed from
`router-basepath-navigation.test.tsx`), `lib/router-url-shape.test.tsx`,
and `tests/lib/route-render.test.tsx` to exercise TanStack Router hooks
directly instead of the removed router shim
- Cleaned up stale `next/router` comments in `compat/next/link.tsx`,
`lib/internal-url.ts`, `router.tsx`, and `tests/lib/route-mock.ts`

**Simplified:**

- Removed `routerMock` setup from about 19 tests that no longer read it.
`next-router-mock` stays for now, because the test `FrameworkProvider`
still feeds `useParams` from it.
- `AGENTS.md` and the `vite.config.ts` error text now say only
`next/link` and `next/script` are shimmed
- Renamed `compat/next/router-basepath-navigation.test.tsx` to
`link-basepath-navigation.test.tsx`, and removed stale router-shim
references from comments

Addresses
[FE-5109](https://linear.app/supabase/issue/FE-5109/replace-the-nextrouter-shims-with-tanstack-router-hooks)

## To test

- [ ] Confirm `git grep -E "next/(compat/)?router|_router-events"
apps/studio` returns no code or config imports (only the prose guideline
in `apps/studio/AGENTS.md`)
- [ ] Confirm `pnpm --filter studio run typecheck`, `pnpm --filter
studio run lint`, `pnpm --filter studio run build`, Knip, and the full
Studio Vitest suite pass
- [ ] Spot-check basePath navigation (`next/link` + `navigateToUrl`) and
multi-line query param URLs in Studio

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-12-01 15:04:27 +08:00
Alaister YoungandAlaister Young 57d40e4705 [FE-5109] (part 3) refactor(studio): migrate layout components off next/router (#54055)
Part 3 of a 6-PR stack migrating all `next/router` and
`next/compat/router` imports in `apps/studio` onto TanStack Router hooks
and removing the router shims.

| Part | PR | Scope |
| --- | --- | --- |
| 1 | #54053 | Core navigation helpers, `hooks/**`, `lib/**`,
`data/prefetchers/**` |
| 2 | #54054 | `components/ui/**` |
| **3** | **#54055 ← this PR** | **`components/layouts/**` and
`state/tabs.tsx`** |
| 4 | #54056 | Database, Branching, Compute, Edge Functions, Explorer,
SQL Editor, Storage, Table Editor |
| 5 | #54057 | Remaining `components/interfaces/**` and
`QueryInsightsTable` router events |
| 6 | #54058 | Remove `next/router` & `next/compat/router` shims,
`_router-events.ts`, Vite aliases, and test mocks |

Migrates all `apps/studio/components/layouts/**` files and the studio
tab router integration off `next/router`.

**Added:**

- `useTabRouter()` in `apps/studio/state/tabs.tsx` so tab state actions
navigate via TanStack's `useNavigate` + `navigateToUrl` instead of
taking a `NextRouter` instance

**Changed:**

- Replaced `useRouter` across all layout directories (`AccountLayout`,
`AdvisorsLayout`, `AppLayout`, `AuthLayout`, `BranchLayout`,
`ComputeLayout`, `DatabaseLayout`, `DefaultLayout`,
`EdgeFunctionsLayout`, `ExplorerLayout`, `LogsLayout`, `Navigation/*`,
`ObservabilityLayout`, `OrganizationLayout`, `ProjectLayout`,
`ProjectNeedsSecuring`, `ProjectSettingsLayout`, `RealtimeLayout`,
`SQLEditorLayout`, `SignInLayout`, and `Tabs`) with TanStack Router
hooks (`useNavigate`, `useLocation`, `useRoutePattern`) and `useParams`
from `common`
- Updated `ProjectDropdown.utils.ts` and `ProjectDropdown.test.ts` to
work with TanStack `$param` route templates
- Updated layout component tests (`AccountLayout.selfhosted.test.tsx`,
`AdvisorsNavigationShortcuts.test.tsx`, `BranchLink.test.tsx`,
`ExplorerLayout.test.tsx`, `ExplorerNavChats.test.tsx`,
`ObservabilityMenu.utils.test.tsx`,
`MobileIssuesNavigation.platform.test.tsx`,
`ProjectLayout/index.test.tsx`, `ProjectNeedsSecuring.test.tsx`,
`ProjectDropdown.test.tsx`)

**Simplified:**

- `OrganizationLayout` and `SettingsLayout` match against
`useRoutePattern()` instead of the real pathname. An org slug ending in
a settings segment (e.g. `acmeapps`) no longer gets the settings title.
- `ProjectSettings.Commands` opens the Connect sheet through nuqs, the
same way `Connect.Commands` does
- `OrgMenuContent`, `OrganizationSettingsMenu` and `useTabRouter` read
`orgSlug`/`schema` from `useParams` instead of casting `location.search`
- Removed the dead `getPathnameWithoutQuery` helpers and their tests
- `usePreservedQueryParams` builds its string in the `useLocation`
selector (no `useMemo`), and `UnhealthyState` only navigates when `ref`
is set
- Moved `MobileIssuesNavigation.platform.test.tsx` onto a TanStack test
router. It now covers the active-route logic again.
- Tests use the shared `createTestRouter` and `customRender` router

Addresses
[FE-5109](https://linear.app/supabase/issue/FE-5109/replace-the-nextrouter-shims-with-tanstack-router-hooks)

## To test

- [ ] Switching projects, organizations, and branches from the top
header dropdowns preserves the current sub-route where supported
- [ ] Opening, switching, and closing Table Editor / SQL Editor tabs
updates the URL and active tab cleanly
- [ ] Active sidebar item highlighting works across Database, Auth, Edge
Functions, Observability, Logs, Realtime, Explorer, and Project Settings
layouts
- [ ] Mobile navigation menu and floating toolbar sheets open and
navigate properly

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-12-01 14:30:25 +08:00
anthony lio 11943b34fe chore(studio): test setup polyfills (#54039)
## Problem

- `apps/studio/tests/setup/radix.js` holds the jsdom stubs for
`ResizeObserver` and `scrollIntoView` but nothing in it is specific to
radix
- studio already keeps its jsdom stubs in `tests/setup/polyfills.ts`

## Solution

- moves the `ResizeObserver` and `scrollIntoView` stubs into
`tests/setup/polyfills.ts` + removes `radix.js` from the vitest setup
files
- changes the studio-testing skill to name the one dom setup file that
remains

<!--
## Preview links

If relevant, include links to changed pages for easy review access.

Copy the preview base URL from the Vercel bot comment on this PR. Use
the following table as an example template.

| Site | Live | Preview | Search for |
| -------------- |
-------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------------------
| ----------------------------- |
| WWW | [/blog/your-post](https://supabase.com/blog/your-post) |
[/blog/your-post](https://zone-www-dot-com-git-branch-name-supabase.vercel.app/blog/your-post)
| unique phrase from the change |
| Docs |
[/docs/guides/your-page](https://supabase.com/docs/guides/your-page) |
[/docs/guides/your-page](https://docs-git-branch-name-supabase.vercel.app/docs/guides/your-page)
| unique phrase from the change |
| Studio | [/dashboard](https://supabase.com/dashboard) |
[/dashboard](https://studio-git-branch-name-supabase.vercel.app/dashboard)
| unique phrase from the change |
| Design system | [/design-system](https://supabase.com/design-system) |
[/design-system](https://design-system-git-branch-name-supabase.vercel.app/design-system)
| unique phrase from the change |
| UI library | [/library](https://supabase.com/library) |
[/library](https://ui-library-git-branch-name-supabase.vercel.app/library)
| unique phrase from the change |
| Knowledge base |
[/kb/guides/your-page](https://supabase.com/kb/guides/your-page) |
[/kb/guides/your-page](https://kb-git-branch-name-supabase.vercel.app/kb/guides/your-page)
| unique phrase from the change |
-->

<!-- ## Additional context

Optionally add any other context or screenshots.

-->

## Review instructions

1. run `pnpm test:studio` and make sure that the run reports no
unhandled errors
2. make sure that the failures are the same as on `master`

## Checklist

Check all before review:

- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [ ] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
2026-11-30 20:40:38 +02:00
39b359a70e chore: keep db partner roles out of picker (#54019)
## Problem

Newly added trusted partner roles appear as user selectable /
manageable. Resolves DEPR-735.

## Solution

Trusted partner roles should not be selectable in temporary access. And
should not appear as modifiable in the database roles tab.

| Before | After |
| --- | --- |
| <img width="553" height="398" alt="CleanShot 2026-11-27 at 12 24 43"
src="https://github.com/user-attachments/assets/14affc16-2f00-496f-a124-d918acd93bf0"
/> | <img width="553" height="363" alt="CleanShot 2026-11-27 at 12 25
00"
src="https://github.com/user-attachments/assets/de06002f-d063-453e-a9da-00eee8e0616d"
/> |
| _This partner role `this_is_a_test` shouldn’t be here._ | _Partner
role `this_is_a_test` is no longer in the list of options._ |
| <img width="940" height="305" alt="CleanShot 2026-11-30 at 10 34 52"
src="https://github.com/user-attachments/assets/bdface9f-b3f4-4620-b567-cba8d829205e"
/> | <img width="935" height="299" alt="CleanShot 2026-11-30 at 10 37
40"
src="https://github.com/user-attachments/assets/da1abaa3-5a98-4837-9e8f-35be84b6be4c"
/> |
| _Previous definition._ | _Broadened definition to better encompass
roles we generally manage
([context](https://github.com/supabase/supabase/pull/54019#discussion_r4716757425))._
|

## How to test

1. Open the [Studio staging
preview](https://studio-staging-git-chore-depr-735-supabase.vercel.app)
and select a staging test project. If **Temporary access** is off in
**Feature previews**, enable it there. Then go to **Database → Settings
→ Temporary access** and make sure it is enabled for the test project.
2. Go to **Database → Roles**. Open Chrome DevTools, select **Network**,
and reload. Filter for `key=database-roles`. Right-click the matching
request and select **Override content**.
3. Append this test role to the roles array. Save the override and
reload.

```json
{
  "id": 99999,
  "name": "this_is_a_test",
  "isSuperuser": false,
  "canCreateDb": false,
  "canCreateRole": false,
  "inheritRole": true,
  "canLogin": true,
  "isReplicationRole": false,
  "canBypassRls": false,
  "activeConnections": 0,
  "connectionLimit": 90,
  "validUntil": null,
  "comment": "{\"_supabase\":{\"oauth_app_id\":\"app\"}}",
  "config": {}
}
```

4. In **Database → Roles**, make sure that `this_is_a_test` appears
under **Supabase managed roles** without edit or delete controls.
5. Go to **Database → Settings → Temporary access**, select **Add
rule**, and open the role picker. The test role should be absent.
6. Set the test role's `comment` to `null` in the override and reload.
Open **Add rule** again and make sure that the role is now selectable.
Close the form without saving and remove the override.

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
Co-authored-by: Danny White <3104761+dnywh@users.noreply.github.com>
2026-11-30 15:35:30 +01:00
anthony lio f05fe34966 feat(ui): scroll area (#54023)
## Problem

- on `/kb/guides/migrate-from-auth0` in safari 27 on macos, the mouse
wheel does not scroll the page and a trackpad does
- radix scroll area bar in the table of contents adds a non-passive
`wheel` listener on `document`
- webkit stops mouse-wheel page scroll when that listener meets
`overscroll-behavior-y: none` on `html`, which kb sets

## Solution

- replaces radix with base ui in the `ui` scroll area parts because base
ui binds its wheel listener to the scrollbar element
- replaces the radix `display: table` workarounds in the studio token
sheets and the connect sheet with a reset of the base ui content
`min-width`
- changes the docs ask ai scroll area to use the `ui` scroll area
- adds an inset focus ring to the scroll area viewport because base ui
makes an overflowing viewport focusable
- adds a `getAnimations` stub to the jsdom test setups because the base
ui viewport calls it
- adds `@base-ui/react` to the pnpm catalog + points the design system
scroll area page at the base ui docs

<!--
## Preview links

If relevant, include links to changed pages for easy review access.

Copy the preview base URL from the Vercel bot comment on this PR. Use
the following table as an example template.

| Site | Live | Preview | Search for |
| -------------- |
-------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------------------
| ----------------------------- |
| WWW | [/blog/your-post](https://supabase.com/blog/your-post) |
[/blog/your-post](https://zone-www-dot-com-git-branch-name-supabase.vercel.app/blog/your-post)
| unique phrase from the change |
| Docs |
[/docs/guides/your-page](https://supabase.com/docs/guides/your-page) |
[/docs/guides/your-page](https://docs-git-branch-name-supabase.vercel.app/docs/guides/your-page)
| unique phrase from the change |
| Studio | [/dashboard](https://supabase.com/dashboard) |
[/dashboard](https://studio-git-branch-name-supabase.vercel.app/dashboard)
| unique phrase from the change |
| Design system | [/design-system](https://supabase.com/design-system) |
[/design-system](https://design-system-git-branch-name-supabase.vercel.app/design-system)
| unique phrase from the change |
| UI library | [/library](https://supabase.com/library) |
[/library](https://ui-library-git-branch-name-supabase.vercel.app/library)
| unique phrase from the change |
| Knowledge base |
[/kb/guides/your-page](https://supabase.com/kb/guides/your-page) |
[/kb/guides/your-page](https://kb-git-branch-name-supabase.vercel.app/kb/guides/your-page)
| unique phrase from the change |
-->

<!-- ## Additional context

Optionally add any other context or screenshots.

-->

## Review instructions

1. open the preview
[/kb/guides/migrate-from-auth0](https://kb-git-antlio-ui-scroll-area-supabase.vercel.app/kb/guides/migrate-from-auth0)
in safari on macos with a mouse
2. turn the mouse wheel and make sure that the page scrolls and the
table of contents marks the active heading
3. open the preview
[/design-system/docs/components/scroll-area](https://design-system-git-antlio-ui-scroll-area-supabase.vercel.app/design-system/docs/components/scroll-area)
and make sure that each demo shows its bar on hover and scrolls with the
wheel
4. make sure that the horizontal demo scrolls sideways
5. press `tab` until a demo takes focus and make sure that it shows an
inset focus ring
6. open a project in the [studio
preview](https://studio-staging-git-antlio-ui-scroll-area-supabase.vercel.app/dashboard),
click `Connect` and make sure that a long code line scrolls inside its
code block and the sheet body does not scroll sideways
7. open the [docs
preview](https://docs-git-antlio-ui-scroll-area-supabase.vercel.app/docs),
press `cmd+k`, search for `auth` and make sure that the results list
scrolls

## Checklist

Check all before review:

- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [ ] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
2026-11-28 13:25:55 +02:00
Alaister YoungandAlaister Young d98f706b7c [FE-5109] (part 1) refactor(studio): migrate core hooks, lib, and prefetchers off next/router (#54053)
Part 1 of a 6-PR stack migrating all `next/router` and
`next/compat/router` imports in `apps/studio` onto TanStack Router hooks
and removing the router shims.

| Part | PR | Scope |
| --- | --- | --- |
| **1** | **#54053 ← this PR** | **Core navigation helpers, `hooks/**`,
`lib/**`, `data/prefetchers/**`** |
| 2 | #54054 | `components/ui/**` |
| 3 | #54055 | `components/layouts/**` and `state/tabs.tsx` |
| 4 | #54056 | Database, Branching, Compute, Edge Functions, Explorer,
SQL Editor, Storage, Table Editor |
| 5 | #54057 | Remaining `components/interfaces/**` and
`QueryInsightsTable` router events |
| 6 | #54058 | Remove `next/router` & `next/compat/router` shims,
`_router-events.ts`, Vite aliases, and test mocks |

Introduces the shared TanStack navigation helpers needed across the
stack and migrates `hooks/**`, `lib/**`, and `data/prefetchers/**` off
`next/router`.

**Added:**

- `navigateToUrl` in `apps/studio/lib/navigation.ts` (plus unit tests in
`lib/navigation.test.ts`): shared helper for navigating to internal
string URLs via TanStack's `useNavigate` (splitting pathname, search
params, and hash via `splitInternalUrl`, and handling
external/protocol-relative URLs)
- `useRoutePattern` in `apps/studio/hooks/misc/useRoutePattern.ts` (plus
`useRoutePattern.test.tsx`): returns the active matched TanStack route
template (e.g. `/project/$ref/editor/$id`) as the replacement for Next's
`router.pathname`

**Changed:**

- Migrated `hooks/misc/*` (`useHydratedQuery`,
`useStudioCommandMenuTelemetry`, `useTableEditorFiltersSort`,
`withAuth`) and `hooks/use-check-latest-deploy.tsx` to TanStack's
`useLocation`, `useNavigate`, `useRoutePattern`, and `useParams` from
`common`
- Migrated `lib/profile.tsx` and `lib/telemetry/track.ts` off
`next/router`
- Migrated `data/prefetchers/project.$ref.tsx`,
`project.$ref.editor.tsx`, and `project.$ref.editor.$id.tsx` to
`useRouter().preloadRoute`
- Wrapped `ReactQueryTestConfig` in `apps/studio/tests/helpers.tsx` with
`RouterContextProvider` and updated hook/navigation tests
(`useTableEditorFiltersSort*.test.*`,
`useFilterLifeCycle.navigation.test.tsx`,
`useTableFilter.navigation.test.tsx`, `useInboundBranding.test.ts`,
`state/tabs.test.ts`)

**Simplified:**

- `navigateToUrl` passes `replace` straight through and documents that
`url` must be an app-relative path or an external URL.
`StudioFrameworkProvider`'s `push` now reuses it.
- `useRoutePattern` reads matches and location in a single
`useRouterState` subscription
- `useTrack` and `useStudioCommandMenuTelemetry` take the pathname from
`useFramework()`, the same source as pageviews, so custom events and
pageviews always send the same pattern (e.g. `/project/[ref]/sql/[id]`).
New tests pin the strings sent, and `toRoutePattern` now has its own
unit tests.
- Removed `useCurrentPath` (a one-line wrapper with one consumer):
`OrganizationSettingsLayout` calls `useLocation` directly
- Dropped the no-op `.catch(() => {})` on `preloadRoute` in the
prefetchers (`preloadRoute` never rejects)
- `useTableEditorFiltersSort` builds the next search with a spread
instead of a delete loop
- Added `createTestRouter()` to `tests/lib/custom-render.tsx`, and
`customRender`/`customRenderHook` now return the `router`. The rest of
the stack uses these instead of hand-copied `createRouter` setups.

Addresses
[FE-5109](https://linear.app/supabase/issue/FE-5109/replace-the-nextrouter-shims-with-tanstack-router-hooks)

## To test

- [ ] Auth redirect flow (`withAuth`) still preserves `returnTo` query
parameters when redirecting unauthenticated users to `/sign-in`
- [ ] Table Editor sort and filter URL sync
(`useTableEditorFiltersSort`) persists and clears `?sort=` / `?filter=`
across table switches
- [ ] Hovering project and table editor links still triggers route/data
prefetching without console errors
- [ ] Page view and command menu telemetry still records route patterns
and paths accurately

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-11-27 09:37:49 +00:00
Pamela Chia 0755ba6556 feat(studio): use the onboarding survey in the AWS Marketplace org form (#53938) 2026-11-26 23:27:19 +08:00
Alaister YoungandAlaister Young 953e508a3e [FE-5110] refactor(studio): replace next/navigation with TanStack (#54041)
Moves the remaining `next/navigation` imports in Studio onto TanStack
Router hooks (and `useParams` from `common`), finishes migrating the
remaining `next/link` and `next/router` usages in the touched
components, and removes the `compat/next/navigation.ts` shim and its
Vite alias. Shared packages (`packages/**`) no longer import
`next/navigation`, so the alias can be dropped now.

**Removed:**

- `apps/studio/compat/next/navigation.ts` and the `'next/navigation'`
entry in `apps/studio/vite.config.ts`
- Global `next/navigation` mock in `apps/studio/tests/vitestSetup.ts`
and the obsolete `apps/studio/tests/lib/route-mock.test.tsx`

**Changed:**

- Replaced `usePathname` (12 files) and `useSearchParams` (3 files) with
`useLocation({ select })` from `@tanstack/react-router`
- Replaced `useRouter` in Storage bucket tables, SQL Editor commands,
and `SignInMfaForm` with `useNavigate` from `@tanstack/react-router`,
and updated `createNavigationHandler` in `lib/navigation.ts` to accept
either `NextRouter` or TanStack's `useNavigate`
- Replaced remaining `next/link` imports in touched components
(`SignInMfaForm`, `Restriction`, `DownloadLogsButton`,
`DownloadResultsButton`, `AuthEmailsLayout`, `AuthProvidersLayout`,
`JWTKeysLayout`, `StorageBucketsLayout`) with TanStack Router's `Link`
- Replaced `useParams` in `CreatePublishableAPIKeyDialog` with
`useParams` from `common` (matching `CreateSecretAPIKeyDialog`)
- Wrapped `CustomWrapper` (`tests/lib/custom-render.tsx`) in a default
TanStack `RouterContextProvider` (with optional `router` / `initialUrl`
overrides) and updated affected component tests to drop their
`next/navigation` mocks

Addresses
[FE-5110](https://linear.app/supabase/issue/FE-5110/replace-the-nextnavigation-shim-with-tanstack-router-hooks)

## To test

1. Check active tab highlighting and navigation across Auth Emails, Auth
Providers, JWT Keys, Storage Buckets, and Editor layouts
2. Verify clicking, Cmd/Ctrl-clicking, middle-clicking, and pressing
Enter on Storage bucket rows (Files, Analytics, Vector) navigates as
before
3. Run "Query a table..." and open SQL snippets from the Command Menu
and confirm `/project/$ref/sql/$id` opens with multi-line SQL preserved
in `?content=`
4. In the MFA sign-in flow, verify the recovery code link and
`forgot-password` completion preserve query params (`returnTo`,
`context=forgot-password`), and Cancel signs out and replaces history
with `/sign-in`
5. Confirm Table Editor sort/filter URL sync persists filters per table
without leaking across table switches

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-11-26 17:18:49 +08:00
Alaister YoungandAlaister Young 730010e450 [FE-5112] refactor(studio): remove next/head shim and usages (#54015)
Removes the last four `next/head` usages in Studio along with the
`compat/next/head.tsx` shim and its Vite alias. The shim was already a
fragment passthrough relying on React 19's native `<title>` and `<meta>`
hoisting, so the remaining callers can render those elements directly
just like the rest of Studio's routes.

**Changed:**

- `ApiAuthorization.Valid`, `AccountLayout`, `OrganizationLayout`, and
`ProjectLayout` – dropped `next/head` and `<Head>` wrappers in favor of
inline `<title>` and `<meta>` elements
- `AccountLayout.selfhosted.test.tsx` and `ProjectLayout/index.test.tsx`
– removed `next/head` mocks so they assert against React 19's native
title hoisting
- `OrganizationLayout.test.tsx` and `tests/routes/authorize.test.tsx` –
added `document.title` coverage for `OrganizationLayout` and the legacy
`/authorize` screen

**Removed:**

- `apps/studio/compat/next/head.tsx`
- `'next/head'` alias from `nextShims` in `apps/studio/vite.config.ts`

Addresses
[FE-5112](https://linear.app/supabase/issue/FE-5112/replace-the-nexthead-shim-with-tanstack-route-head).

## To test

- Navigate across a project page (e.g. Table Editor), an organization
page, and `/account/me` – browser tab title updates for each view
- Open `/authorize?auth_id=...` with the legacy OAuth flow – tab title
updates to `Authorize <app name> | Supabase` once the request loads

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-11-26 08:32:46 +00:00
Alaister YoungandAlaister Young d6e4089b1a feat(common): add FrameworkProvider and remove next imports (#53905)
Introduces a lightweight `FrameworkProvider` React context in
`packages/common` (`Link`, `Image`, `pathname`, `asPath`, `isReady`,
`params`, `push`), wires it up in the consuming apps, and removes the
`next` dependency from `packages/common`.

**Added:**

- `FrameworkProvider`, `useFramework`, `FrameworkLink`, and
`FrameworkImage` in `packages/common/framework.tsx`, with plain HTML
defaults (`DefaultFrameworkLink` / `DefaultFrameworkImage`).
`useFramework().push` always exists and falls back to
`window.location.assign`
- App-level framework providers wiring `next/link`, `next/image`, and
router state in `www` (App + Pages routers), `docs`, `design-system`,
`learn`, and `ui-library`, and native TanStack Router bindings in
`studio` (`StudioFrameworkProvider`)
- `StudioFrameworkProvider` reuses the common defaults (its image only
applies the basePath) and reports `isReady` once the first route load
commits, so the first page view carries the final route after any
redirect
- Unit tests for `StudioFrameworkProvider` (`useParams`,
`FrameworkLink`, `FrameworkImage`, query/hash-only navigation,
`isReady`) and for `PageTelemetry` route-change sends and the
`TelemetryTagManager` consent gate

**Changed:**

- `common/hooks/useParams.ts`: read params from `useFramework()` instead
of `next/compat/router`
- `common/telemetry.tsx`: replace `next/script` in `TelemetryTagManager`
with `useEffect` script injection, and read route state from
`useFramework()` in `PageTelemetry`
- `common/MetaFavicons/app-router.ts`: drop type-only `Metadata` import
from `next`
- Moved `MetaFaviconsPagesRouter` to
`apps/www/components/MetaFaviconsPagesRouter.tsx` (its sole consumer)
- Studio: `toRoutePattern` and `applyBasePath` now live once in
`lib/internal-url.ts`, shared by the provider and the `compat/next`
shims
- `PageTelemetry` throws outside production when no `FrameworkProvider`
is mounted, since it would otherwise send only the landing pageview.
`useFramework()` itself still falls back to the defaults
- `ui-library`: renamed its code-sample framework context to
`FrameworkPreferenceProvider` / `useFrameworkPreference` so
`FrameworkProvider` only means the `common` one

**Removed:**

- `learn`'s unused copy of that context (`useCourse` had no callers)

- `next` from `packages/common/package.json` peerDependencies

App Router adapters set `asPath` to the pathname only, same as the
`usePathname`-based telemetry on master (reading search params at the
root would opt static pages out of static rendering).

## To test

- Run `packages/common` tests and typecheck, and `apps/studio`
`StudioFrameworkProvider` / `route-render` / `telemetry` tests
- Navigate between routes in Studio, Docs, and WWW and confirm page
telemetry fires once per navigation (and does not duplicate on hash-only
changes)
- Load Studio at `/` (which redirects) and confirm the first page event
has the final route
- Verify URL params (`useParams`) continue resolving route and search
params in Studio

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-11-25 20:13:22 +08:00
K-Dog (Kevin) 653f914ca1 feat: post plan upgrade screen (#54003)
Right now, when customers upgrade from free → paid or even pro → team,
we simply redirect to the org billing page with a quick banner that
vanishes after 3 seconds confirming the plan was changed. it’s quite
unsatisfying and feels like a missed opportunity to display what the
customer now unlocked and next steps. I want to especially highlight
projects that are now upgradeable from nano → micro, but we can later
expand and make the “next steps” smarter and do it context-based.
2026-11-25 11:30:19 +00:00
Jordi Enric 15fcb7dc49 fix(studio): refresh observability charts for the selected range FE-5122 (#53931)
## Problem

A custom date range in a Storage report URL could show one window in the
header and another in the charts. Refresh also left Database Size and
several Auth charts showing cached results.

## Fix

Use the selected window for all Storage report requests, run the
Database Size query on refresh, and refresh Auth Usage, Errors and
Latency alongside the shared API charts.

## How to test

- Open Storage with a custom start and end time in the URL. Inspect the
chart requests on load and after Refresh. Both sets should use those
exact timestamps.
- Refresh the Database report and check that the large objects query
runs again.
- Open Auth with a fixed range and press Shift+R. The Usage, Errors,
Latency and API charts should request fresh data for the same range.

Fixes [FE-5122](https://linear.app/supabase/issue/FE-5122).
2026-11-24 15:31:11 +01:00
Gildas Garcia ea5cd851ed fix(studio): OAuth apps consent screen should always select the org provided in URL (#53727)
## Problem

The organization provided by its slug in the URL isn't selected unless a
project ref was also provided.

## Solution

Always select the org provided in URL

## Review instructions

- Publish an oauth app
- Use the oauth example and provide an org slug in the form
- Check the consent screen selected this org

Do check this with multiple different orgs to ensure you weren't lucky
with the org array sorting
2026-11-20 12:04:48 +01:00
anthony lio 3b12d2e167 feat(ui): switch component (#53379)
## Problem

* the shared switch in `packages/ui` uses the radix primitive
* the thumb does not react to hover or press, and only the track color
shows the state
* a click on a switch label toggles the switch, but the label keeps the
default cursor

## Solution

* replaces the radix switch with base ui, and keeps a native `<button>`,
so labels and `role="switch"` work as before
* changes the thumb to white and the resting track one step darker, so
the off state shows on light pages
* replaces the hover color change with a thumb stretch that grows more
on press, so the thumb reacts to the pointer
* adds a pointer cursor on labels next to an enabled switch, because a
click on the label toggles it
* removes the `PointerEvent` stand-in from the studio test setup,
because it blocks base ui switch clicks in jsdom
* changes the install step in the switch docs to `@base-ui/react`, so
the manual install matches the component

<!-- linear:table-colwidths:345,344 -->
<table>
<thead>
<tr>
<th></th>
<th>preview</th>
</tr>
</thead>
<tbody>
<tr>
<td>light</td>
<td>


https://github.com/user-attachments/assets/a7c33dda-3487-43b8-881b-344e28891650

</td>
</tr>
<tr>
<td>dark</td>
<td>


https://github.com/user-attachments/assets/9718057b-f983-4099-8f7e-82521001b625

</td>
</tr>
</tbody>
</table>

## Preview links

| Site | Live | Preview | Search for |
| -- | -- | -- | -- |
| Design system |
[/design-system/docs/components/switch](<https://supabase.com/design-system/docs/components/switch>)
|
[/design-system/docs/components/switch](<https://design-system-git-feat-switch-base-ui-supabase.vercel.app/design-system/docs/components/switch>)
| Airplane Mode |
| Studio |
[/dashboard/project/\_/storage/files](<https://supabase.com/dashboard/project/_/storage/files>)
|
[/dashboard/project/\_/storage/files](<https://studio-git-feat-switch-base-ui-supabase.vercel.app/dashboard/project/_/storage/files>)
| Public bucket |

## Review instructions

1. open
[/design-system/docs/components/switch](<https://supabase.com/design-system/docs/components/switch>)
and
[/design-system/docs/components/switch](<https://design-system-git-feat-switch-base-ui-supabase.vercel.app/design-system/docs/components/switch>)
side by side
2. hover and click the "airplane mode" label, and make sure that the
cursor is a pointer and the switch toggles
3. change the theme to light and to dark, and make sure that the thumb
stays white in the on and off states
4. scroll to the form example, and make sure that the disabled "security
emails" switch does not toggle or stretch
5. open
[/dashboard/project/\_/storage/files](<https://studio-git-feat-switch-base-ui-supabase.vercel.app/dashboard/project/_/storage/files>),
click "new bucket" and turn on "public bucket", and make sure that the
"public buckets are not protected" warning shows

## Checklist

Check all before review:

- [X] I have read
[CONTRIBUTING.md](<https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md>)
- [X] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](<https://github.com/supabase/supabase/tree/master/apps/docs/style-guide>)
2026-11-19 21:32:09 +00:00
Gildas Garcia 10488ed799 feat(studio): Wire the OAuth apps consent screen to the backend (#53511)
## Description

Part of the work for OAuth apps with the scoped permissions. This PR
wires consent screen to the backend.

## Review instructions

### Setup
Copy the `examples/oauth-app-authorization-flow/.env.example` to
`examples/oauth-app-authorization-flow/.env`

> [!IMPORTANT]  
> In next steps, make sure to copy the apps ids/secrets in the
`examples/oauth-app-authorization-flow/.env` with a way to differentiate
them:
> ```
> # org bound all projects
> SUPABASE_CLIENT_ID=xxx
> SUPABASE_CLIENT_SECRET=xxx
> ```

As an organization admin, go to the _Organization settings/OAuth Apps_
and create the following _Publishable apps_:

- `test_org_bound`: 
  - _Use the permissions of the person who connects_ unchecked
  - _Ask for specific projects_ unchecked
  - Select only _Database Read_ for the permissions
 
- `test_org_bound_projects`: 
  - _Use the permissions of the person who connects_ unchecked
  - _Ask for specific projects_ checked
  - Select only _Database Read_ for the permissions

- `test_member_bound`: 
  - _Use the permissions of the person who connects_ checked
  - _Ask for specific projects_ unchecked
  - Select only _Database Read/Write_ for the permissions
 
- `test_member_bound_projects`: 
  - _Use the permissions of the person who connects_ checked
  - _Ask for specific projects_ checked
  - Select only _Database Read/Write_ for the permissions

Make sure you have 3 projects in the org. Add a team member that have
Administration rights on the first project, read-only access to the 2nd
and no access to the third.

Install the `examples/oauth-app-authorization-flow` dependencies and
start the app.
- `test_org_bound`: 
  - connected on studio as the org admin
    - click the `oauth-app-authorization-flow` button
- check that you don't have to select a project on the consent screen
- check that the permissions requested are correct and you can approve
the app
- update the published app to include the _Database Write_ permissions
- return to the `oauth-app-authorization-flow` index and click its
button again
- check that the consent screen shows the permissions difference and
approve it again
- connected as a simple team member, check that you have a message
indicating you can't approve this app
  
- `test_org_bound_projects`: 
  - connected on studio as the org admin
    - click the `oauth-app-authorization-flow` button
    - check that you have to select projects on the consent screen
- check that the permissions requested are correct and you can approve
the app
- update the published app to include the _Database Write_ permissions
- return to the `oauth-app-authorization-flow` index and click its
button again
- check that the consent screen shows the permissions difference and
approve it again
- connected as a simple team member, check that you have a message
indicating you can't approve this app

- `test_member_bound`: 
  - connected on studio as a member 
    - click the `oauth-app-authorization-flow` button
- check that you don't have to select a project on the consent screen
- check that the permissions requested are correct and you can approve
the app
    - update the published app to add another permission
- return to the `oauth-app-authorization-flow` index and click its
button again
- check that the consent screen shows the permissions difference and
approve it again
   
- `test_member_bound_projects`: 
  - connected on studio as the org admin
    - click the `oauth-app-authorization-flow` button
- check that you have to select projects on the consent screen (you
should see only the two you have access to) and select them all one by
one
    - check that the permissions requested are correct
- approve the app and check that you have an error related to the
project with read-only access
    - unselect it and approve the app
- update the published app to include the _Database Write_ permissions
- return to the `oauth-app-authorization-flow` index and click its
button again
- check that the consent screen shows the permissions difference and
approve it again
2026-11-19 17:47:03 +01:00
Alaister YoungandAlaister Young 960cf92854 [FE-5150] fix(studio): make router hooks follow renderRoute's URL in tests (#53660)
In Studio's vitest setup, `useParams` from `common` is mocked globally
to return `{ ref: 'default' }`, and `next/router`, `next/compat/router`
and `next/navigation` are mocked with `next-router-mock`. `renderRoute`
mounts a real TanStack memory router, but nothing connected it to those
mocks. So components under a route test never saw the route's path or
search params, and `router.push` from legacy code never moved the
TanStack router. Route tests worked around this by hand-mocking
`useParams` to repeat their URL.

Inside `renderRoute`, these hooks now defer to the app's own
`compat/next` shims, which read the memory router, so they match
runtime: kebab-case keys are camelCased, repeated keys collapse to the
first value, and the hooks follow in-test navigation. All other tests
keep the static mocks.

**Changed:**
- `tests/vitestSetup.ts`: the `common` `useParams`, `next/router`,
`next/compat/router` and `next/navigation` mocks are route-aware.
- `tests/lib/route-render.tsx`: the root route provides a
`RenderedRouteContext` marker. The switch keys off this marker rather
than any TanStack router context, because some component tests mount
their own `RouterContextProvider` or mock `@tanstack/react-router`.
- Route tests that relied on the old behavior:
- The EdgeFunctionOverview self-hosted test, `new/$slug` and
`logs/index.platform` now assert on `router.state.location` instead of
`next-router-mock`.
- The `logs` test's `useSignOut` mock is now stable, like the real hook;
an unstable mock made the redirect effect push in a loop.
- The EdgeFunctionOverview periods test now seeds the function detail
under its real slug instead of `undefined`.
- Removed the hand-written `useParams` mocks from the `authorize`,
Stripe `login`, `sign-in-mfa`, Vercel `new-project` and storage
`vectors` route tests; their URLs carry the params now.

**Added:**
- `tests/lib/route-aware-hooks.ts`: `routeAwareHook` and
`mockNextRouter`.
- `tests/lib/route-render.test.tsx`: renders a route at
`/project/abc/probe?query-tab=logs&id=1&id=2`, asserts what
`useParams()`, `useRouter().query` and `usePathname()` return, then
navigates and asserts again.

Addresses
[FE-5150](https://linear.app/supabase/issue/FE-5150/useparams-in-routes-tests-doesnt-return-any-querystring-params)

## To test
- [ ] `pnpm --filter studio exec vitest --run
tests/lib/route-render.test.tsx` passes.
- [ ] With `tests/vitestSetup.ts`, `tests/lib/route-render.tsx` and
`tests/lib/route-aware-hooks.ts` reverted to `master`, the same test
fails with `expected { ref: 'default' } to deeply equal { ref: 'abc',
queryTab: 'logs', id: '1' }`.
- [ ] Regression checks: `pnpm --filter studio exec vitest --run
tests/routes components/interfaces/Functions
components/interfaces/Database/Replication
components/interfaces/Account/Preferences` passes. These include route
tests and the component tests that mount their own TanStack router or
mock `next/router`.

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-11-19 17:01:01 +09:00
Danny WhiteandJoshen Lim 8fcd5e7f65 feat(studio): add Warehouse report date controls (#53494)
## Problem

The Warehouse report only shows the last hour.

## Solution

Add date selection and refresh using the shared report controls. Respect
the organisation’s log retention limits and the metrics API’s 30-day
maximum.

| After |
| --- |
| <img width="1688" height="1050" alt="CleanShot 2026-11-18 at 11 35
24@2x"
src="https://github.com/user-attachments/assets/88267bf8-1054-480b-ac26-c0c2b58386bc"
/> |
| _The new controls._ |
| <img width="2420" height="1028" alt="CleanShot 2026-11-18 at 11 47
52@2x"
src="https://github.com/user-attachments/assets/383c06a0-5470-4748-b9a6-fe80647a1399"
/> |
| _The standard retention upgrade prompt follow tapping either of these
on a Pro plan._ |

## Review instructions

1. Open the [Studio staging
preview](https://studio-staging-git-dnywh-warehouse-metrics-range-supabase.vercel.app)
and select a staging project with Warehouse access.
2. Open **Observability > Warehouse**, or
`/project/<ref>/observability/warehouse`
([example](https://studio-staging-git-dnywh-warehouse-metrics-range-supabase.vercel.app/dashboard/project/yirnfrgkxmnqgexikhfc/observability/warehouse)).
Change Last 60 minutes to Last 24 hours and check that the chart or
no-data state reflects the selected period.
3. Refresh the report. Check that the selected period stays selected.
4. On a paid staging organisation, select a period beyond its log
retention (for example, Last 14 days with 7-day retention). Check that
the retention upgrade prompt appears and the current period stays
selected.

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2026-11-19 15:08:18 +11:00
Pamela Chia f678d3682f fix(studio): load PostHog flags after MFA verification (#53587)
For a user with MFA enabled, Studio requests PostHog flags once with the
pre-MFA token, the API refuses it, and nothing requests them again after
the challenge is verified. The flags stay missing until the user opens
an organization or project, or reloads, so pages reached straight after
MFA (`/organizations`, `/new`, `/account`) get no flag values.

I made `FeatureFlagProvider` refetch when the auth client reports a
verified MFA challenge. Verification changes none of the existing fetch
inputs (user, organization, project), which is why the refused first
response stuck.

**Note:** The refetch runs on any verified MFA challenge (sign-in,
enrolling a factor, identity re-verification), so users who never verify
a challenge make the same flag requests as before. I did not key it on
the access token, because that would refetch on every token refresh.

## To test

Tested on the PR preview, with a temporary TOTP factor on a staging
account:
- [x] Sign in with an MFA-enabled account, with the network log open,
landing on `/organizations`. Expect a `GET
/platform/telemetry/feature-flags` returning 200 with the account's
flags after `POST /auth/v1/factors/:id/verify`, before opening any
organization or project. Observed: flags 403 before the verify, verify
200, then one flags 200 with no organization or project param.
- [x] Repeat with `returnTo=/new`. Expect the same 200 after the verify
request. Observed: landed on `/new`, same order (403, verify 200, flags
200).
- [x] On the landing page after MFA, open the dev toolbar's Flags tab,
which reads the provider's PostHog flags. Expect the account's flags and
no `message` entry. Observed: the account's flags listed, no `message`
entry, and no flag-lookup console errors.
- [x] Sign in with an account without MFA. Expect no verify request, so
no refetch from this change. Observed: no `factors/:id/verify` request;
every flags request returned 200.
- [x] Enroll a TOTP factor in Account > Security. Expect one flags
request after the enrollment verify (the case the Note describes).
Observed: verify 200, then flags 200.

## Linear
- fixes GROWTH-1507
2026-11-18 16:26:38 +09:00
Danny WhiteandJoshen Lim cc2024fca5 fix(studio): clarify data access during project creation (#53430)
Resolves
[FE-5087](https://linear.app/supabase/issue/FE-5087/gradually-default-automatic-table-exposure-to-unchecked-behind-a)

## Problem

The new project form does not clearly distinguish API access, automatic
table grants, and RLS.

## Solution

Rename “Security” to “Data access”, shorten the copy, and align the
checkboxes. Show automatic table grants only when Data API is enabled.
Keep automatic RLS available independently. Default automatic grants to
off, with inline warnings for disabled Data API queries and unrestricted
table access.

<!-- linear:table-colwidths:689 -->
<table>
<thead>
<tr>
<th>After</th>
</tr>
</thead>
<tbody>
<tr>
<td>


https://github.com/user-attachments/assets/b545a6ec-7f05-46e7-badc-382020d44d5e

</td>
</tr>
</tbody>
</table>

## Review instructions

1. Open an organisation’s **New project** form from the
[dashboard](<https://studio-staging-git-fix-studio-project-data-access-supabase.vercel.app/>).
2. Under **Data access**, toggle Data API off and on. Check that
automatic table grants hide and reappear with the selection preserved.

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2026-11-18 10:03:21 +07:00
Alaister YoungandAlaister Young 801e4ad285 [FE-3106] (part 12) – refactor(studio): replace the org and project catch-all pages (#53221)
Gives the `/org/_/…` and `/project/_/…` catch-alls proper TanStack
routes and deletes `pages/org/_/[[...routeSlug]].tsx` and
`pages/project/_/[[...routeSlug]].tsx` (FE-3106). They show an org or
project picker whose links forward the trailing path and the query
string (and, for projects, the hash) to the real org or project. Part 12
of the stack.

**Depends on:** #53220

**Changed:**
- `components/interfaces/Organization/SelectOrganizationPage.tsx`,
`components/interfaces/Home/ProjectList/SelectProjectPage.tsx` – the
picker bodies. The trailing path and query string come from
`useLocation()` (repeated query keys survive): the splat routes nest
under the `/org/_` and `/project/_` routes, which render the picker with
no `<Outlet>`, so the picker can't rely on its own route's `_splat`
- `routes/{org,project}.[_].tsx`, `routes/{org,project}.[_].$.tsx` –
render the pickers
- `tests/routes/org.[_].$.test.tsx` – covers path and query forwarding

**Removed:**
- both catch-all pages, and `parseCatchAllRoute` from
`compat/next/router.ts`

Addresses
[FE-3106](https://linear.app/supabase/issue/FE-3106/move-page-bodies-into-route-files-and-delete-pages).

## To test

- `/project/_/database/tables?schema=auth#x` – pick a project, lands on
`/project/<ref>/database/tables?schema=auth#x`
- `/org/_/billing?panel=x` – pick an org, lands on
`/org/<slug>/billing?panel=x`
- `/org/_` and `/project/_` – pickers link to the org or project home

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-11-17 17:04:17 +09:00
Alaister YoungandAlaister Young f8cbf2ae56 [FE-3106] (part 11) – refactor(studio): move sql, editor, explorer and integrations (#53220)
Moves the SQL editor, table editor, explorer and project integrations
page bodies into their route files and deletes the pages (FE-3106). Part
11 of the stack.

**Depends on:** #53219

**Changed:**
- `routes/project/$ref/{sql,editor,explorer,integrations}/**` – 15 page
bodies inlined. Every `router.push/replace` became the equivalent
`navigate` with the same path, `search` and `replace`; the
last-opened-table redirect splits `buildTableEditorUrl`'s absolute URL
with `splitInternalUrl` so it stays a client-side navigation
- `components/interfaces/SQLEditor/SnippetNotFound.tsx` – the
invalid-snippet state moves out of the route because
`tabs.handleTabClose` still takes a Next-shaped router
- `tests/routes/project/$ref/explorer/index.test.tsx` – moved and
rendered with `renderRoute`

**Removed:**
- 15 page files

Addresses
[FE-3106](https://linear.app/supabase/issue/FE-3106/move-page-bodies-into-route-files-and-delete-pages).

## To test

- SQL editor: open `/sql` (redirects to the last snippet or `new`),
open/close snippets and tabs, an invalid snippet id shows "Unable to
find snippet"
- Table editor: open `/editor` (redirects to the last table), create a
table – lands on it with `?schema=`
- Explorer and Integrations pages – same layout; integration sub-pages
redirect as before

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-11-17 16:52:36 +09:00
Alaister YoungandAlaister Young 00bd19f06c [FE-3106] (part 10) – refactor(studio): move settings, advisors and issues pages (#53219)
Moves the `/settings/*`, `/advisors/*` and `/issues/*` page bodies into
their route files and deletes the pages (FE-3106). Part 10 of the stack.

**Depends on:** #53218

**Changed:**
- `routes/project/$ref/settings/**` – 16 page bodies inlined.
`settings/api` redirects with `<Navigate>`; billing usage, dashboard and
replica pages use typed `navigate`/`Link`
- `routes/project/$ref/{advisors,issues}/**` – 7 page bodies inlined
- Settings tests moved from `tests/pages/**` to `tests/routes/**` and
rendered with `renderRoute`

-
`routes/project/$ref/advisors{.tsx,/rules.tsx,/security.tsx,/performance.tsx,/health.tsx}`
– carry master's #52993 (Advisors → Issues behind `issuesInbox`:
`IssuesCategoryRedirect`, `LegacyAdvisorsLayout`, `parseLinterLevel`,
named `LinterFilters`/`LintPageTabs`), ported from the deleted pages and
checked against master's pages + route adapters;
`LegacyAdvisorsPages.platform.test.tsx` now renders the routes
(`tests/routes/project/$ref/advisors/legacy-advisors.platform.test.tsx`)

**Removed:**
- 23 page files, and `AdvisorRulesLayout` (only the deleted rules pages
used it; `routes/project/$ref/advisors/rules.tsx` already inlines it)

Addresses
[FE-3106](https://linear.app/supabase/issue/FE-3106/move-page-bodies-into-route-files-and-delete-pages).

## To test

- Project Settings (General, Compute, Infrastructure, Add-ons, API keys,
JWT, Log drains, Webhooks, Integrations) – same layout and sidebar
- `/project/<ref>/settings/api` – redirects as before
- Advisors (Security, Performance, Rules) and Issues – same layout

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-11-17 16:43:20 +09:00
Alaister YoungandAlaister Young d31c7d1603 [FE-5104] fix(studio): validate site url and redirect urls (#53492)
The Auth URL Configuration page saved Site URLs and redirect URLs
containing spaces or backslashes. `SiteUrl` only checked that the value
was non-empty. `urlRegex()` in `Auth.constants.ts` wasn't anchored, so
any valid prefix passed (`https://foo bar.com`,
`http://localhost:3000\`). This isn't a TanStack regression: both gaps
go back to before the migration (#44803, #30138), and the Next and
TanStack routes render the same `SiteUrl`/`AddNewURLModal` components.

**Changed:**
- `urlRegex()` is anchored and rejects whitespace and backslashes. This
also tightens its other callers (provider forms, SMTP host), which now
reject trailing junk after a valid prefix. The localhost branch also
accepts `?`/`#` right after the host, so scheme-less values such as
`localhost:3000?x=1` that pass today still pass.
- New `getUrlCharacterError` and `getSiteUrlError` helpers give specific
inline errors ("can't contain spaces/backslashes/wildcards", "Please
provide a valid URL, such as https://example.com").
- `SiteUrl` still trims, then rejects interior whitespace, backslashes,
wildcards and non-absolute URLs. `getSiteUrlError` also rejects the
`javascript:`, `data:`, `file:` and `vbscript:` protocols and requires
`scheme://`. Without that, a scheme-less `localhost:3000` would parse
with `localhost:` as its scheme. Custom app schemes such as
`myapp://callback` still work. `onSubmitSiteUrl` is now typed instead of
`any`.
- The Azure, GitLab, Keycloak, WorkOS and SAML URL fields in
`AuthProvidersFormValidation.tsx` now `.trim()` before checking
`urlRegex()`, so a trailing space no longer fails the now-anchored
regex.
- `AddNewURLModal` shows the specific character error before falling
back to "Please provide a valid URL".

**Added:**
- Unit tests for `urlRegex()`, `getUrlCharacterError` and
`getSiteUrlError`, including unsafe protocols and scheme-less
`host:port`.
- `AuthProvidersFormValidation.test.ts`: each provider URL field trims
surrounding whitespace and rejects interior spaces.
- Component tests for `SiteUrl` and `AddNewURLModal` covering spaces,
backslashes, wildcards and invalid URLs, plus saving every supported
redirect URL form. The new rejection tests fail without the fix.
- `AddNewURLModal.test.tsx` now uses MSW (`customRender` + `addAPIMock`)
instead of `vi.mock('@/data/...')`.

Addresses
[FE-5104](https://linear.app/supabase/issue/FE-5104/dashboard-allows-spaces-in-the-site-url).

## To test
- [ ] Auth > URL Configuration, set Site URL to `https://my
app.example.com` and save – "Site URL can't contain spaces", nothing
saved
- [ ] Site URL `http://localhost:3000\` – "Site URL can't contain
backslashes"
- [ ] Site URL `https://*.example.com` – "Site URL can't contain
wildcards"
- [ ] Site URL `example.com` or `localhost:3000` – "Please provide a
valid URL, such as https://example.com"
- [ ] Site URL `javascript:alert(1)` – "Site URL can't use the
javascript: protocol"
- [ ] Site URL `myapp://callback` – saves
- [ ] Site URL ` http://localhost:3000 ` – saves as
`http://localhost:3000`
- [ ] Add URL, enter `https://my app.example.com` – "URL can't contain
spaces"; `myapp://callback\` – "URL can't contain backslashes"
- [ ] Sign In / Providers > Keycloak, enter a Realm URL with a trailing
space and save – no "Must be a valid URL" error; saved without the space
- [ ] Add URL, paste `https://*.example.com/** http://localhost:3000/*
com.example.app://callback chrome-extension://abcdefghijklmnop` – splits
into 4 rows and saves all 4

Ran typecheck, lint ratchet, knip, Prettier, and the Auth vitest suites.

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-11-17 16:31:59 +09:00
Alaister YoungandAlaister Young 96e4543ea9 [FE-3106] (part 9) – refactor(studio): move logs and observability page bodies (#53218)
Moves the `/logs/*` and `/observability/*` page bodies into their route
files and deletes the pages (FE-3106). Part 9 of the stack.

**Depends on:** #53217

**Changed:**
- `routes/project/$ref/logs/**` – 20 page bodies inlined. `logs/index`
keeps its `withAuth` wrapper; `replication-logs` redirects with
`<Navigate search hash>`; the Logs Explorer save navigates with `search:
{ queryId }` (never a query inside `to`)
- `routes/project/$ref/observability/**` – 12 page bodies inlined; chart
highlight actions navigate with `search` params
- `components/interfaces/Observability/DatabaseReport.hooks.ts` – the
database report's URL hooks move out of the page (with their test)
- `components/ui/Charts/ComposedChartHandler.tsx` – imports
`UpdateDateRange` from `ChartHighlightActions` instead of a page

**Removed:**
- 32 page files

Addresses
[FE-3106](https://linear.app/supabase/issue/FE-3106/move-page-bodies-into-route-files-and-delete-pages).

## To test

- Logs Explorer: run a multi-line query, save it – the URL keeps
newlines and the saved query reopens
- Each log source (Postgres, Auth, Edge, Storage, Realtime, …) – same
layout and title
- Observability reports – charts render; highlighting a range links to
the right logs page

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-11-17 16:24:24 +09:00
Alaister YoungandAlaister Young 2695cf117a [FE-3106] (part 8) – refactor(studio): move storage, functions and branches pages (#53217)
Moves the `/storage`, `/realtime`, `/compute`, `/functions` and
`/branches` page bodies into their route files and deletes the pages
(FE-3106). Part 8 of the stack.

**Depends on:** #53216

**Changed:**
- `routes/project/$ref/{storage,realtime,compute,functions,branches}/**`
– 26 page bodies inlined. Wrappers the routes imported from pages
(`BranchesPageWrapper`, `MergeRequestsPageWrapper`, …) are now private
to their route files. Bucket redirects, function create/deploy
navigation and merge-request links use typed `navigate`/`Link`; function
logs/invocations use `useLocation().href`
- Edge function overview, logs-navigation, vectors, compute and branches
tests render the routes with `renderRoute`

- `routes/project/$ref/storage/files/buckets/$bucketId.tsx` – also
carries master's #52777 (Purge CDN cache action and single `action`
query param for the bucket modals), ported from the deleted page so it
isn't reverted

**Removed:**
- 26 page files

Addresses
[FE-3106](https://linear.app/supabase/issue/FE-3106/move-page-bodies-into-route-files-and-delete-pages).

## To test

- Storage: open a bucket, its policies link and S3 settings – same
layout; deleting a bucket returns to the list
- Edge Functions: create a function, open
Overview/Code/Logs/Invocations/Details – same layout
- Branches and merge requests – lists and "Review" links work

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-11-17 16:13:36 +09:00
Alaister YoungandAlaister Young 33ae2caa0d [FE-3106] (part 4) – refactor(studio): move sign-in and standalone page bodies (#53213)
Moves the sign-in and standalone page bodies (`/sign-in`, `/sign-up`,
`/sign-in-sso`, `/sign-in-partner`, `/sign-in-mfa`,
`/sign-in-recovery-code`, `/forgot-password`, `/forgot-password-mfa`,
`/reset-password`, `/cli/login`, `/partners/stripe/projects/login`,
`/authorize`, `/redeem`, `/logout`, `/maintenance`, `/verify-email`,
`/support/csat`, `/mcp/secrets`) into their route files and deletes the
pages (FE-3106). Part 4 of the stack.

**Depends on:** #53212

**Changed:**
- `routes/_auth/**` and the standalone routes – page bodies inlined;
`next/router`/`next/link`/`next/head` → native TanStack (`navigate({ to,
search })`, `search: true` to carry the query, `href` for runtime return
URLs) and inline `<title>`. Layout chains match the old `getLayout`s
- `components/interfaces/CliLogin/CliLoginScreen.tsx` – the CLI login
screen moves out of the page so its test can import it without the route
file exporting it
- `tests/routes/{authorize,_auth/**}.test.tsx` – moved from
`tests/pages/**` and rendered with `renderRoute`

**Removed:**
- 18 page files

Addresses
[FE-3106](https://linear.app/supabase/issue/FE-3106/move-page-bodies-into-route-files-and-delete-pages).

## To test

- Sign out, open `/sign-in` and `/sign-up` – same layout and title;
switching between them keeps `returnTo`
- Sign in with MFA – `/sign-in-mfa` returns to the original page
- `/cli/login?session_id=…` and `/authorize?…` – flows complete as
before
- `/logout` – redirects to `/sign-in`

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-11-17 14:57:50 +09:00
Alaister YoungandAlaister Young d2eb58a0e7 [FE-3106] (part 3) – refactor(studio): move account and top-level page bodies (#53212)
Moves the account and top-level app page bodies (`/account/*`,
`/organizations`, `/new`, `/new/$slug`, `/join`, `/claim-project`,
`/aws-marketplace-onboarding`, `/stripe-atlas-application`,
`/support/new`, `/support/link`, `/integrations/github|vercel/*`) from
`pages/**` into their TanStack route files and deletes the pages. Part
of the final pass of the TanStack migration (FE-3106). Part 3 of the
stack, and the first page-move PR.

**Depends on:** #53202

**Changed:**
- `routes/_app/account/**`,
`routes/_app/{organizations,new/index,support/*}.tsx`,
`routes/{new/$slug,join,claim-project,aws-marketplace-onboarding,stripe-atlas-application}.tsx`,
`routes/integrations/**` – page bodies inlined.
`next/router`/`next/link`/`next/head` → `useNavigate`, `Link`,
`<Navigate>` and inline `<title>`. `getLayout` dropped; every old
`getLayout` was checked against the route tree and matches
- `routes/aws-marketplace-onboarding.tsx` – reads `buyer_id` through
`validateSearch` + `Route.useSearch()`
- `tests/lib/route-render.tsx` – new `renderRoute(Route, { routeId, url
})` helper that mounts a file route in a memory router (with the app's
search serializers) so route components can be tested; used by the moved
tests
- `tests/lib/route-mock.ts` – the `next/router` mock now derives its
dynamic-route patterns from `routes/**` instead of globbing `pages/**`,
so tests keep parsing params as pages disappear
- `tests/routes/**` – page tests moved from `tests/pages/**` and
rendered through the route
- `.github/CODEOWNERS` – `pages/new/index.tsx` owner moved to
`routes/_app/new/index.tsx`

**Removed:**
- 19 files under `pages/account/**`, `pages/new/**`,
`pages/support/{new,link}.tsx`, `pages/integrations/**` and the
top-level pages listed above

Addresses
[FE-3106](https://linear.app/supabase/issue/FE-3106/move-page-bodies-into-route-files-and-delete-pages).

## To test

- Open `/account/me`, `/account/security`, `/account/tokens`,
`/account/audit` – same Account layout, header title and sidebar as
before
- Open an old email-change link (`/account/me#message=...`) – lands on
`/account/security` with the hash
- `/account/tokens/scoped` – redirects to `/account/tokens`
- `/organizations` and `/new/<org>` – render with the same layout; "New
organization" links work
- Vercel install/marketplace flows – navigation keeps `?…` params

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-11-17 14:46:37 +09:00
K-Dog (Kevin) 412df7746e feat: revamped free plan limit modals / downgrade improvements (#53257)
Whenever customers run into their 2 Free Plan project limit, we were
previously just listed the affected members:

<img width="1044" height="566" alt="image"
src="https://github.com/user-attachments/assets/d1c1327d-2532-4d8e-8af2-425da9ce1ee5"
/>

While this lists the affected members, it is pretty unclear which
organizations are affected or which projects contribute to this and what
the best course of action is.

This PR revamps all components that are displayed in this situation (new
project launch, downgrade to Free, project unpause) to show the affected
organizations + projects primarily and give more actionable tips:

<img width="1014" height="638" alt="Screenshot 2026-11-11 at 3 57 45 PM
(1)"
src="https://github.com/user-attachments/assets/ae38f71d-bbde-4181-a623-24bef778afee"
/>

<img width="768" height="152" alt="image"
src="https://github.com/user-attachments/assets/b3b0efd7-678b-4ac0-9602-4cc5d735a9aa"
/>


---

Additionally, this contains small improvements to the downgrade flow:
- Rename button to "Downgrade Now" as opposed to "Confirm" to make it
more clear that this is immediate
- Explicitly mention downgrades are immediate and there is still another
invoice for unbilled usage
- Larger modal width for improved readability
2026-11-17 12:25:05 +08:00
Charis b046f12571 chore(api-types): update generated API types from production (#53364)
Regenerates the API types with `pnpm api:codegen:prod` and fixes the
Studio type errors the new types caused.

## Changes from the API

- **Branch merge now requires production write permission.** `POST
/v1/branches/{branch_id_or_ref}/merge` changed from accepting either
`branching_development_write` or `branching_production_write` to
requiring `branching_production_write`. Studio's FGA refinement for
merge no longer matched and failed typecheck.
  - Removed the merge entry from `lib/fga-refinements.ts`.
- `merge.tsx` checks merge permission with `useGrant` instead of
`useBranchGrant`.
  - `BranchMergeGrant` uses `GrantFor` instead of `GrantForVariants`.
- Removed merge from the "requires a variant" test in
`guarded-fetch.test.ts`.
- Users with only development branching permissions can no longer merge
in Studio. This matches what the API now enforces.
- **Replication pipelines have a required `cluster_id`.** Added it to
the pipeline fixtures in six test files.
- **`MemberWithFreeProjectLimit` has a required
`free_plan_organizations`.** Added it to the mock in
`tests/pages/new/[slug].test.tsx`. No app code reads it yet.

## Testing

- `pnpm typecheck` passes.
- Vitest passes for the affected Studio tests.
2026-11-13 08:02:50 -05:00
Danny White 652c085dd0 chore(studio): remove legacy email confirmation redirect (#53250)
## Problem

Preferences still forwards email-change confirmation messages to
Security for links generated before CTRL-2060. The [platform change now
targets Security
directly](https://github.com/supabase/platform/pull/41579), so this
temporary compatibility path can be retired after rollout and link
expiry.

## Solution

Remove the legacy redirect and its two tests. Keep normal Preferences
anchor scrolling and the Security confirmation handler.

Merge after CTRL-2060 is deployed to all relevant environments and old
links have expired. The checked-in platform Auth configuration uses a
10-minute expiry; allow at least 24 hours after rollout.
2026-11-13 14:38:30 +11:00
Pamela Chia f2af7ea280 chore(studio): remove the terms of service update notice (#53323)
I removed the "We've updated our Terms of Service" notice from the
dashboard. It was added in #51302 and has been up since early October,
and it had no expiry of its own. I also removed its landing-path helper,
its tests and its dismissal key.

## To test
Tested on the PR preview, in a browser profile that never dismissed the
notice:
- [x] Open an organization's landing page (`/org/<slug>`): expect no
"We've updated our Terms of Service" card in the bottom right. Observed:
no card on the organizations list or on an org's landing page, with the
dismissal key unset on both.

## Linear
- fixes GROWTH-1494
2026-11-12 22:41:33 +09:00
Pamela Chia 362c974153 fix(studio): record onboarding survey exposure only for signed-in users (#53253) 2026-11-12 10:21:20 +09:00
Alaister YoungandAlaister Young 1854331fb6 [FE-3106] (part 2) – refactor(studio): move api handlers into route files (#53202)
Moves every `pages/api/**` handler into its TanStack server route under
`routes/api/**` and deletes `pages/api/**`, part of the final pass of
the TanStack Start migration (FE-3106). Handlers move verbatim and still
run through `toWebHandler`, so auth (`apiWrapper`), response shapes and
headers are unchanged. Part 2 of the stack.

**Depends on:** #53199

**Changed:**
- `routes/api/**` – each route now holds its handler (formerly the
`pages/api` default export) as a local `nextHandler`/named function.
Next-only `config`/`maxDuration` exports are dropped: `vite.config.ts`
already sets the function `maxDuration`, and `toWebHandler` parses
bodies itself
- `routes/api/ai/docs.ts` – Web-native handler inlined, `NextRequest` →
`Request`
- `lib/api/apiHelpers.ts` – `getPgMetaRedirectUrl` moved here from the
old `tables` handler, which the other pg-meta routes imported it from
- `eslint.config.cjs`, `.github/CODEOWNERS` – `pages/api` paths →
`routes/api`
- `tests/routes/api/**`, `lib/api/{generate-v4,rate}.test.ts`,
`scripts/__tests__/server-source-maps.test.ts` – call the route's
registered handler with a Web `Request` (`tests/lib/server-route.ts`);
the MCP query-validation cases now run against the native route

**Removed:**
- `pages/api/**` (102 files), including the Next twins of the
already-native `routes/api/mcp/index.ts` and `functions/$slug/body.ts`
- unused `ProjectSettings` types and the `node-mocks-http` dev
dependency

Parity: every route registers the same methods its handler serves. The
exceptions are `check-cname`, `get-ip-address`, `get-utc-time`,
`get-s3-keys`, `get-deployment-commit`, `cli-release-version` and
`connect`: in Next they answered any method, and their routes register
`GET` only, as before this PR.

Addresses
[FE-3106](https://linear.app/supabase/issue/FE-3106/move-page-bodies-into-route-files-and-delete-pages).

## To test

- Load the table editor, SQL editor and Auth users on a self-hosted
build – `/api/platform/**` and `/api/v1/**` respond as before
- Use the Assistant and the docs search – `/api/ai/**` streams as before
- `GET /api/get-deployment-commit` – same JSON and `Cache-Control`

Ran typecheck, ESLint, lint ratchet, knip, Prettier, the TanStack build
and the full Studio vitest suite: all pass except
`lib/server/configcat.test.ts`, which also fails on `master` in an
environment with ConfigCat env vars set. Self-hosted E2E is CI-only.

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-11-11 22:24:43 +09:00
Alaister YoungandAlaister Young 31711c0762 fix(studio): validate edge function test proxy target url (#53256)
The edge function test proxy (`pages/api/edge-functions/test.ts`, also
served by `routes/api/edge-functions/test.ts`) fetched the URL from the
request body after checking it only with the regexes in
`isValidEdgeFunctionURL`, and on self-hosted any
`http(s)://<host>/functions/vN/...` URL passed. It now fetches only a
URL rebuilt from parts it has validated.

**Changed:**
- `apps/studio/lib/api/edgeFunctions.ts` – replaced
`isValidEdgeFunctionURL` with `getEdgeFunctionTestUrl`, which parses the
URL, rejects non-http(s) schemes and credentials, requires a
`/functions/vN/` path, checks the host (platform:
`<ref>.supabase.co|red` over https; the Nimbus apex domain when
`NIMBUS_PROD_PROJECTS_URL` is set; self-hosted: the `SUPABASE_URL` or
`SUPABASE_PUBLIC_URL` host) and returns the fetch target rebuilt from
the validated origin, path and query. Self-hosted requests always go to
the `SUPABASE_URL` origin, replacing the old `SUPABASE_PUBLIC_URL`
string rewrite.
- `apps/studio/pages/api/edge-functions/test.ts` – fetches the URL
returned by `getEdgeFunctionTestUrl` and returns 400 when there is none.
`redirect: 'manual'` is unchanged.

**Added:**
- `apps/studio/lib/api/edgeFunctions.test.ts` – allowed platform,
`.red`, Nimbus and self-hosted URLs, and rejected cases: other hosts,
lookalike hosts, userinfo, ports, non-http schemes, paths outside
`/functions/vN/`.
- `apps/studio/tests/pages/api/edge-functions/test.test.ts` – handler
rejects userinfo and non-functions paths, and on self-hosted calls the
public URL through `SUPABASE_URL` and rejects other hosts.

## To test
- [ ] On platform (including staging `.red`), open an edge function,
click **Test**, and send a request with a query parameter: the response
shows as before.
- [ ] On self-hosted (`docker compose`), do the same from the edge
function tester: the response shows as before.
- [ ] `POST /api/edge-functions/test` with `{ "url":
"https://example.com/functions/v1/hello", "method": "GET" }`: the
response is 400 with "Provided URL is not a valid Supabase edge function
URL".

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-11-11 16:34:02 +09:00
Danny WhiteandAlaister Young c68595e3b7 fix(studio): show MFA after a successful sign-in retry (#53196)
## Problem

After a callback error, a successful password retry can show the
second-factor toast and then bounce back to sign-in. The MFA page acts
on the cached callback error before checking for the new session. This
follows up on #46414.

## Solution

Check for a current session before handling the initialisation error.

```text
Current session → check whether MFA is required
Callback error with no session → show the error on sign-in
```

## Review instructions

1. In a signed-out browser, open the Studio preview at
`/dashboard/sign-in?error=server_error&error_description=Test&returnTo=%2Forg`.
Sign in with a password account that has MFA enabled. The code entry
form should open.
2. In a separate signed-out session, open
`/dashboard/sign-in-mfa?method=github#error=server_error&error_description=Test`.
Studio should return to sign-in and show the callback error.

The local reproduction passed with the fix, along with 22 existing
sign-in tests.

## Checklist

- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-11-11 09:01:15 +11:00
Charis 395a54f2b7 feat(studio): gate jwt signing keys, legacy api keys, and third-party auth on grants (#53241)
Resolves
[FE-4732](https://linear.app/supabase/issue/FE-4732/grants-rollout-jwt-signing-keys-legacy-api-keys-and-third-party-auth).

## Changes
Gates the JWT signing keys, legacy API keys, and third-party auth
endpoints on grants instead of `unguarded.migrating`, and replaces their
V2 permission guards with `useGrant`:
- **Data layer (11 sites):** `data/jwt-signing-keys/*`,
`data/api-keys/legacy-api-keys-status-query`,
`data/api-keys/legacy-api-key-toggle-mutation`, and
`data/third-party-auth/*`. Queries become grant-gated query option
factories; mutations take the grant in their variables.
- **Consumers:** the JWT settings page, the JWT signing keys table and
its dialogs, `jwt-settings`, `ToggleLegacyApiKeys`, `Project/APIKeys`,
and the third-party auth page, form, and create dialogs. Each consumer
renders denied and error states.
- **JWT signing keys table:**
- It's gated only on the signing keys reads (`GET signing-keys` and `GET
signing-keys/legacy`, both `auth_signing_keys_read`).
- The legacy API keys status is only used by the revoke dialogs. If it
can't be read, revoking the legacy JWT secret fails closed: the user
sees the "disable legacy API keys first" warning, with copy explaining
why, instead of the confirm modal.
- **Legacy JWT secret query:** a 404 (secret not imported as a signing
key yet) resolves to `null` and shows the "Migrate JWT secret" panel.
Other errors now render an error instead of being treated as "not
migrated".
- **Write actions:**
- `getWriteGrantTooltip` moves from `APIKeys.utils` to `lib/grants` and
takes a resource noun. Disabled write actions use it to explain why
they're disabled.
- New `getWriteGrantToastMessage`: handlers that run without a grant now
show a toast instead of silently doing nothing. This includes the API
keys handlers from #52966.

## Permission changes
- **Legacy API keys toggle and status** (`GET`/`PUT
/v1/projects/{ref}/api-keys/legacy`): the guard moves from
`auth_signing_keys_read`/`_write` to the endpoint annotation,
`api_gateway_keys_read`/`_write`. The annotation was confirmed against
the backend controller (FE-4728). As a result, the JWT signing keys
table's legacy revoke check now depends on `api_gateway_keys_read`.
- **API keys last-used analytics**
(`/platform/projects/{ref}/analytics/endpoints/api_keys.last_used.otel`):
this endpoint uses legacy permissions (`analytics:Read` on `logflare`),
not FGA. Its check moves from the V2 `auth_signing_keys_read` check to
`useAsyncCheckPermissions(PermissionAction.ANALYTICS_READ, 'logflare')`.
- Every other guard already matched its annotation:
  - `auth_signing_keys_read`/`_write` for signing keys
  - `auth_config_read`/`_write` for third-party auth

## Testing
- Data layer: `jwt-signing-keys.test.ts`, `legacy-api-keys.test.ts`, and
`third-party-auth.test.ts` cover every migrated fetcher, check that
factories stay disabled without a grant, and cover legacy-key 404 vs.
500.
- `jwt-secret-keys-table/index.platform.test.tsx`:
- Legacy status denied: the table still renders, and revoking the legacy
key shows only the warning.
  - Legacy status known enabled or disabled.
  - Signing keys read denied.
  - Legacy key 404 vs. 500.
- `create-key-dialog.platform.test.tsx`: triggering create without a
grant shows the toast and sends no request.
- `ToggleLegacyApiKeys.platform.test.tsx`,
`ThirdPartyAuthForm.platform.test.tsx`, and
`settings/jwt/index.platform.test.tsx`: granted, denied, error, and
partial-permission cases.
- `lib/grants.test.ts`: the tooltip and toast helpers.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-11-10 15:30:58 -05:00
Gildas GarciaandJoshen Lim de63769998 feat(studio): add ability to purge CDN cache to storage UI (#52777)
## Problem

Users should be able to purge the CDN cache for an individual object or
entire bucket via the UI.
This feature is only available for Pro+ customers. Free tier customers
should be encouraged to upgrade to get access.

## Solution

- Add a _Purge CDN cache_ action to the bucket menu. Prompt users on
Free plan to upgrade if needed.
<img width="182" height="149" alt="image"
src="https://github.com/user-attachments/assets/b665c8d0-b540-400e-a328-85c48ddafee0"
/>
<img width="534" height="242" alt="image"
src="https://github.com/user-attachments/assets/15dfd3d3-c8a9-4ad7-9046-0929fd715511"
/>

<img width="538" height="211" alt="image"
src="https://github.com/user-attachments/assets/3e29644e-9335-4b1d-b321-49303c2e8476"
/>


- Add a _Purge CDN cache_ action to the bucket item menu. Prompt users
on Free plan to upgrade if needed.
<img width="283" height="313" alt="image"
src="https://github.com/user-attachments/assets/a801297e-04b5-46c7-aaf7-4569e66e4714"
/>
  
<img width="541" height="249" alt="image"
src="https://github.com/user-attachments/assets/b58d264b-76ba-43d4-9579-6c07be9cb684"
/>

  
<img width="537" height="207" alt="image"
src="https://github.com/user-attachments/assets/132b37bd-3a29-48b5-aa7e-7df29abcbfe6"
/>

## Notes

- Refactored the _Edit bucket_ menu so that only one modal is allowed
- Fixed focus management related to the modals displayed by the _Edit
bucket_ menu items
- Introduced a way to mock the authenticated users in tests

## Review instructions

- On an org on at least _Pro_ plan
  - Open a bucket _Edit bucket_ menu and click _Purge CDN cache_
- Confirming should call the `/platform/storage/{ref}/cdn/purge-bucket`
API endpoint
  - Open a bucket item menu and click _Purge CDN cache_
- Confirming should call the `/platform/storage/{ref}/cdn/purge-object`
API endpoint

- On an org on _Free_ plan
  - Open a bucket _Edit bucket_ menu and click _Purge CDN cache_
  - You should be prompted to upgrade
  - Open a bucket item menu and click _Purge CDN cache_
  - You should be prompted to upgrade

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2026-11-10 16:08:08 +01:00
Saxon Fletcher d7f2b501b5 feat(studio): add the issue detail page (#52991)
Add issue details, affected resources, and copy actions with coverage for secondary checks and clipboard outcomes.
2026-11-09 16:35:02 +01:00
Danny White 5cf3cf1032 feat(studio): make security the home for sign-in and recovery setup (#52358)
## Problem

- Sign-in methods are in Preferences, separate from MFA and recovery
settings.
- The risk of a single sign-in method (e.g. GitHub, and getting locked
out of that account) isn’t clearly communicated.

## Solution

- Bring sign-in methods, MFA and recovery codes together on the Security
page. If Security is disabled, sign-in methods remain accessible in
Preferences.
- Highlight the most important next step with a primary button. For
example, when MFA is off, “Set up MFA” takes priority over adding a
password.
- Explain the risk of relying on a single sign-in provider, and make it
clear which email address a new password will apply to.
- After connecting a sign-in provider, return users to the settings page
they can access. Links to password setup open the password dialog
directly.

| After |
| --- |
| <img width="1460" height="1426" alt="CleanShot 2026-11-06 at 14 54
23@2x"
src="https://github.com/user-attachments/assets/afb82601-1b6f-43be-9e98-a0edb8d529c8"
/> |
| _The “Sign-in methods” section moved to Account → Security. Note also
the new Admonition regarding the risk of a single (GitHub) sign-in
method._ |

## Review instructions

1. Open
[Security](https://studio-staging-git-dnywh-recovery-security-home-supabase.vercel.app/dashboard/account/security#sign-in-methods).
Check sign-in methods appear above MFA and recovery codes. With MFA off,
“Set up MFA” should be primary.
2. Open Preferences. Sign-in methods should be absent unless Security is
disabled.
3. On a test account, check password setup, email editing and provider
linking. [Open password setup
directly](https://studio-staging-git-dnywh-recovery-security-home-supabase.vercel.app/dashboard/account/security?securityAction=set-password#sign-in-methods),
then cancel and confirm it stays closed.
2026-11-09 17:42:43 +11:00
Pedro Rodrigues da6360147c chore(studio): bump @supabase/mcp-server-supabase to 0.16.0 (#53044)
## Summary
- Bump `@supabase/mcp-server-supabase` from `^0.15.0` to `^0.16.0`.
- Share the self-hosted MCP platform between both `/api/mcp` routes,
typed without `notebooks`, so the notebook tools enabled in 0.16.0 stay
out of self-hosted. Self-hosted Studio doesn't support notebooks yet.

Closes
[AI-1407](https://linear.app/supabase/issue/AI-1407/2b-update-self-hosted-remote-mcp-server-self-hosted-studio-assistant)
2026-11-05 17:06:51 +00:00
Joshen Lim 6d08d66b7d Add eslint rule for google translate dynamic spans + address all issues (#52949)
## Context

We've been seeing many `NotFoundError: Failed to execute 'removeChild'
on 'Node'` and `NotFoundError: Failed to execute 'insertBefore' on
'Node'` events on Sentry which are historically known to be caused by
Google Translate in the browser.

There's technically no _right way_ to address this unfortunately, but
one of the solutions which should address most of these issues is to
wrap any dynamic text within a span - we've considered that quite a
while back tbh but never took the time to do this until today with the
help of Claude. Although just a heads up that it might not necessarily
completely eradicate those issues.

Also added an eslint rule which should prevent future occurences of this
<img width="1264" height="192" alt="image"
src="https://github.com/user-attachments/assets/b2c32ea0-45a2-4ccd-82fe-1a859905fc29"
/>
2026-11-05 23:28:46 +08:00