Skip to content

feat(studio): TanStack app shell — root + auth/org routes (stack 3/6, from #46424) - #47112

Merged
ivasilov merged 28 commits into
masterfrom
alaister/migration-s3-shell
Jun 29, 2026
Merged

ivasilov merged 28 commits into
masterfrom
alaister/migration-s3-shell

Conversation

@alaister

@alaister alaister commented Jun 19, 2026 •

Copy link
Copy Markdown
Member

Stack 3/6 of the TanStack Start migration (#46424). Stacked on #47110 (S2) → review that first; this PR's diff is the app shell.

Note

Thin route wrappers that render the existing pages-router page components through the compat shims (S2). Next is untouched — it builds pages/ and ignores routes/. The app doesn't function end-to-end on TanStack until the API + project routes land (S4/S5) and the flag is flipped.

What's in this PR

  • routes/__root.tsx — root layout + a beforeLoad that runs the shared redirect rules; router.tsx.
  • routes/_auth/* — sign-in/up, forgot/reset password, SSO/MFA/partner sign-in, CLI login, Stripe-projects login.
  • routes/_app/* — account (me/security/audit/tokens), org/$slug/* (general/billing/team/usage/…), support.
  • routeTree.gen.ts — regenerated by the tanstackStart vite plugin for exactly the routes in this PR (the migration branch's tree references all ~300 routes, so it can't be copied verbatim here). It's a generated artifact; the meaningful review surface is the route files.

Verification

On top of S1+S2: studio typecheck ✓, lint (0 errors) ✓.

Summary by CodeRabbit

  • Refactor
    • Enhanced internal routing infrastructure to improve application performance and code organization. These behind-the-scenes updates ensure a more stable and maintainable foundation for the platform without affecting existing functionality or user experience.

alaister added 3 commits June 19, 2026 15:33
…RAMEWORK flag (1/6, from #46424)

Foundation of the TanStack Start migration (#46424), split into a reviewable
stack. Next remains the default and only active framework after this PR — the
TanStack build pipeline is wired up but has no routes yet, so it isn't
functional or tested until later PRs flip the feature flag.

- package.json: dev/build/start now dispatch via scripts/dispatch.js (defaults
  to next); add :next/:tanstack variants, vite/tanstack deps.
- scripts: dispatch.js, serve.js, smoke-server.mjs, generateLocalEnv.js.
- vite.config.ts, turbo.jsonc, tsconfig.json (jsx: react-jsx, Bundler).
- next.config.ts + redirects.shared.ts (shared redirect rules with vercel.ts),
  proxy.ts/start.ts middleware + hosted-api-allowlist.ts.
- companion adaptations the tsconfig change requires to keep typecheck green
  (BufferSource casts, packages/ui unused-React import removals, etc.).

Verified: frozen install, studio typecheck, Next build, and lint ratchet all
green; Next stays the default build.
…46424)

Adds compat/next/* — drop-in shims for next/link, next/router, next/navigation,
next/head, next/image, next/script, next/dynamic, next/server, and a
toWebHandler (compat/next/api.ts) that lets pages-router API handlers run as
TanStack server routes. Under TanStack these are wired in via Vite aliases
(next/* -> @/compat/next/*); Next never imports them, so this is purely
additive. No routes consume them yet — that starts in the next stack PR.

Stacked on #47107. Verified: studio typecheck + lint (0 errors).
…outes (stack 3/6, from #46424)

Adds the TanStack Start app skeleton: routes/__root.tsx (root layout +
redirect beforeLoad), router.tsx, and the _auth (sign-in/up, forgot/reset
password, SSO/MFA/partner, CLI login) and _app (account, org/$slug, support)
route trees. These are thin wrappers that render the existing pages-router
page components via the compat shims from #47110.

routeTree.gen.ts is REGENERATED by the tanstackStart vite plugin for exactly
the routes present in this PR (not copied from the migration branch, whose
tree references all ~300 routes) — so it typechecks standalone. API routes and
project routes (and a full regenerated tree) land in the next stack PRs.

Stacked on #47110. Verified: studio typecheck + lint (0 errors). Next is
unaffected (it builds pages/, ignores routes/).
@alaister
alaister requested a review from a team as a code owner June 19, 2026 08:11
@vercel

vercel Bot commented Jun 19, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
design-system Ready Ready Preview, Comment Jun 29, 2026 12:05pm
docs Ready Ready Preview, Comment, Open in v0 Jun 29, 2026 12:05pm
studio-self-hosted Ready Ready Preview, Comment Jun 29, 2026 12:05pm
studio-staging Ready Ready Preview, Comment Jun 29, 2026 12:05pm
ui-library Ready Ready Preview, Comment Jun 29, 2026 12:05pm
zone-www-dot-com Ready Ready Preview, Comment, Open in v0 Jun 29, 2026 12:05pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
studio Ignored Ignored Jun 29, 2026 12:05pm

Request Review

@supabase

supabase Bot commented Jun 19, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project xguihxuzqibwxjnimxev because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@coderabbitai

coderabbitai Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (1)
  • develop

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: f211acd4-648f-4d2b-a788-2c3f29b35a7f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch alaister/migration-s3-shell

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/studio/routes/_app/org/`$slug/billing.tsx:
- Around line 12-14: The OrgBilling route component is missing the
OrganizationSettingsLayout wrapper that other org settings routes use. Wrap the
OrgBillingSettingsPage component inside OrganizationSettingsLayout in the
OrgBilling function's return statement to maintain consistency with sibling org
settings routes and preserve the expected settings UI and navigation layout.

In `@apps/studio/routes/_app/org/`$slug/integrations.tsx:
- Around line 12-14: The OrgIntegrations function in integrations.tsx is missing
the OrganizationSettingsLayout wrapper around OrgIntegrationSettingsPage, which
breaks the org settings route contract and removes shared navigation. Wrap the
OrgIntegrationSettingsPage component with OrganizationSettingsLayout following
the same pattern used in sibling org settings routes (security, sso, webhooks).
Apply this same wrapper pattern to team.tsx and usage.tsx routes as well to
maintain consistency across all org settings pages.

In `@apps/studio/routes/_auth/sign-in.tsx`:
- Around line 12-18: The SignInLayout component is missing the inboundFlow prop,
which is required for the focused-provider interstitial and destination-branded
heading logic to work correctly (as defined in the SignInLayout.tsx component
where these features are gated by the inboundFlow condition). Add the
inboundFlow prop to the SignInLayout component in the sign-in.tsx route file,
passing the appropriate inbound flow value from the route parameters or context.
Apply the same fix to sign-up.tsx and sign-in-sso.tsx route files where
SignInLayout is used without this prop.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: bc2797a5-60ca-4236-89a1-d110011d764a

📥 Commits

Reviewing files that changed from the base of the PR and between ad33834 and ad3c0b7.

📒 Files selected for processing (39)
  • apps/studio/routeTree.gen.ts
  • apps/studio/router.tsx
  • apps/studio/routes/__root.tsx
  • apps/studio/routes/_app/account.tsx
  • apps/studio/routes/_app/account/audit.tsx
  • apps/studio/routes/_app/account/me.tsx
  • apps/studio/routes/_app/account/security.tsx
  • apps/studio/routes/_app/account/tokens/index.tsx
  • apps/studio/routes/_app/account/tokens/scoped.tsx
  • apps/studio/routes/_app/new/index.tsx
  • apps/studio/routes/_app/org.tsx
  • apps/studio/routes/_app/org/$slug/apps.tsx
  • apps/studio/routes/_app/org/$slug/audit.tsx
  • apps/studio/routes/_app/org/$slug/billing.tsx
  • apps/studio/routes/_app/org/$slug/documents.tsx
  • apps/studio/routes/_app/org/$slug/general.tsx
  • apps/studio/routes/_app/org/$slug/index.tsx
  • apps/studio/routes/_app/org/$slug/integrations.tsx
  • apps/studio/routes/_app/org/$slug/private-apps/index.tsx
  • apps/studio/routes/_app/org/$slug/security.tsx
  • apps/studio/routes/_app/org/$slug/sso.tsx
  • apps/studio/routes/_app/org/$slug/team.tsx
  • apps/studio/routes/_app/org/$slug/usage.tsx
  • apps/studio/routes/_app/org/$slug/webhooks/$endpointId.tsx
  • apps/studio/routes/_app/org/$slug/webhooks/index.tsx
  • apps/studio/routes/_app/org/index.tsx
  • apps/studio/routes/_app/organizations.tsx
  • apps/studio/routes/_app/support/link.tsx
  • apps/studio/routes/_app/support/new.tsx
  • apps/studio/routes/_auth/cli/login.tsx
  • apps/studio/routes/_auth/forgot-password-mfa.tsx
  • apps/studio/routes/_auth/forgot-password.tsx
  • apps/studio/routes/_auth/partners/stripe/projects/login.tsx
  • apps/studio/routes/_auth/reset-password.tsx
  • apps/studio/routes/_auth/sign-in-mfa.tsx
  • apps/studio/routes/_auth/sign-in-partner.tsx
  • apps/studio/routes/_auth/sign-in-sso.tsx
  • apps/studio/routes/_auth/sign-in.tsx
  • apps/studio/routes/_auth/sign-up.tsx

Comment thread apps/studio/routes/_auth/sign-in.tsx Resolved
@github-actions

github-actions Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

🎭 Playwright Test Results

passed  219 passed
flaky  2 flaky
skipped  5 skipped

Details

stats  226 tests across 25 suites
duration  5 minutes, 6 seconds
commit  97d0b45

Flaky tests

Features › queue-table-operations.spec.ts › Queue Table Operations › reverted cell edit clears the pending change
Features › sql-editor.spec.ts › SQL Editor › should check if SQL editor is working as expected

Skipped tests

Features › auth-users.spec.ts › should show web3 users as enabled when the matching web3 provider is enabled
Features › sql-editor.spec.ts › SQL Editor › snippet favourite works as expected
Features › sql-editor.spec.ts › SQL Editor › share with team works as expected
Features › sql-editor.spec.ts › SQL Editor › folders works as expected
Features › sql-editor.spec.ts › SQL Editor › other SQL snippets actions work as expected

alaister and others added 20 commits June 19, 2026 16:54
Iterating response.headers and calling res.setHeader collapses duplicate
keys; for set-cookie the Headers iterator joins every cookie into one
comma-separated value, corrupting auth/session cookies. Pull cookies out
via getSetCookie() and set them as an array. Addresses PR review feedback.
The navigate() shim overloaded Next's `shallow` option as the
push-vs-replace signal, but the ternary was inverted so replace() did a
push. Inverting it naively would also break the 5 push(url, { shallow:
true }) call sites, since shallow is a real Next option (no-op here) and
has nothing to do with push vs replace. Use a dedicated internal
`_replace` flag instead, matching Next's pages-router where push always
pushes and replace always replaces regardless of shallow.

Addresses PR review feedback.
The Next pages pass inboundFlow to SignInLayout (sign-in -> 'sign-in',
sign-up -> 'sign-up'), which gates the focused-provider interstitial and
destination-branded heading for inbound auth links. The TanStack route
wrappers dropped it. sign-in-sso intentionally left unchanged — its Next
page doesn't pass inboundFlow either.

Addresses PR review feedback.
Extract the .env parser into scripts/lib/env.js so dispatch.js and serve.js
use one implementation instead of duplicating the regex. dispatch.js now
reads .env as well as .env.local (matching serve.js / vite precedence:
shell > .env.local > .env), so STUDIO_FRAMEWORK set in .env is picked up —
previously only .env.local was read, which is why setting it in .env
silently did nothing.

Addresses PR review feedback.
readEnvFiles swallowed every readFileSync error, so an existing-but-
unreadable env file (bad permissions, IO error) was silently treated as
absent — dropping its values and potentially booting serve.js without
secrets like POSTGRES_PASSWORD. Skip only ENOENT and rethrow the rest.

Addresses PR review feedback.
The Vercel SPA catch-all rewrite (`${prefix}/(.*)` -> /_shell) swallowed
missing extensioned paths, so a stale hashed chunk (e.g. requested after a
redeploy) returned text/html 200 instead of 404. The browser then threw
'Failed to load module script ... MIME type text/html', and because /assets/*
is cached immutable the bogus HTML poisoned the edge cache under the asset URL
(defeating skew protection, which is served after the cache).

Make the shell rewrite match only extensionless paths via a negative lookahead
so a missing file with an extension 404s cleanly — letting skew protection's
__vdpl routing serve the chunk from the deployment that still has it, or the
client's vite:preloadError backstop recover.
New org settings page added to master after the initial migration sweep; wraps
OrganizationSettingsLayout like the sibling audit route. Route tree regenerated.
useUrlState (table sort/filter) pushes { pathname: router.pathname, query }
where router.pathname is the bracketed route pattern (/project/[ref]/...).
Next's pages-router fills [ref]/[id] from query and drops them from the query
string; the compat shim just concatenated, so TanStack navigated to a LITERAL
/project/[ref]/... — no project matched (ref === '[ref]') and it bounced to a
'project not found' redirect. Most visible on column rename, which rewrites
sort/filter URL state after a successful (correct) rename.

resolveUrl now interpolates [name] / [...name] / [[...name]] from query and
removes the consumed keys, mirroring Next. String URLs and bracket-free
pathnames are unchanged.

Fixes the redirect and the database.spec column-CRUD e2e on the tanstack build.
Adds a unit test guarding the dynamic-param interpolation in the next/router
shim (the fix for the column-rename redirect), since the shim has been fragile
to changes. Exports resolveUrl for testing only.
Base automatically changed from alaister/migration-s2-compat to master June 25, 2026 08:52
@ivasilov
ivasilov merged commit 3d931ac into master Jun 29, 2026
32 checks passed
@ivasilov
ivasilov deleted the alaister/migration-s3-shell branch June 29, 2026 12:08
@github-actions

github-actions Bot commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

Braintrust eval report

Assistant (master-1782735007)

Score Average Improvements Regressions
Completeness 55.3% (-44pp) - 17 🔴
Conciseness 60% (+17pp) 18 🟢 4 🔴
Correctness 34.4% (-37pp) 1 🟢 10 🔴
Docs Faithfulness 67.9% (+5pp) 8 🟢 5 🔴
Goal Completion 41.2% (-39pp) 1 🟢 19 🔴
Knowledge Usage 89.7% (-5pp) - 1 🔴
SQL Identifier Quoting 100% (+0pp) - -
SQL Validity 100% (+0pp) - -
Tool Usage 70.6% (+0pp) - -
Safety 83.3% (-17pp) - 3 🔴
URL Validity 0% (-100pp) - -
Time_to_first_token 2.71tok (-0.13tok) 19 🟢 10 🔴
Llm_calls 7.08 (-0.06) 11 🟢 12 🔴
Tool_calls 2.99 (+0.17) 14 🟢 10 🔴
Errors 0.02 (+0.02) - 1 🔴
Llm_errors 0.01 (+0.01) - 1 🔴
Tool_errors 0 (+0) - -
Prompt_tokens 22193.11tok (-67.41tok) 13 🟢 12 🔴
Prompt_cached_tokens 7438.71tok (+559.08tok) 10 🟢 10 🔴
Prompt_cache_creation_tokens 0tok (+0tok) - -
Prompt_cache_creation_5m_tokens 0tok (+0tok) - -
Prompt_cache_creation_1h_tokens 0tok (+0tok) - -
Completion_tokens 633.52tok (+18.71tok) 17 🟢 11 🔴
Completion_reasoning_tokens 109.11tok (+2.47tok) 11 🟢 15 🔴
Completion_accepted_prediction_tokens 0tok (+0tok) - -
Completion_rejected_prediction_tokens 0tok (+0tok) - -
Completion_audio_tokens 0tok (+0tok) - -
Total_tokens 22826.63tok (-48.7tok) 15 🟢 14 🔴
Estimated_cost 0$ (0$) 12 🟢 11 🔴
Duration 15.17s (-0.3s) 18 🟢 11 🔴
Llm_duration 10.33s (+0.57s) 12 🟢 17 🔴

alaister added a commit that referenced this pull request Jun 30, 2026
… from #46424) (#47113)

**Stack 4/6** of the TanStack Start migration (#46424). Stacked on
**#47112** (S3).

> [!NOTE]
> Mechanical and homogeneous — every file is the same shape: a
`createFileRoute(...)` whose `server.handlers` delegate to the existing
`pages/api` handler via `toWebHandler` (the compat shim from S2). The
pages-router handlers are unchanged; Next still serves them directly and
ignores `routes/`.

## What's in this PR
- `routes/api/**` (~104 files): platform (`pg-meta`, auth, storage,
integrations, profile, telemetry, organizations, projects…), `ai/*`,
`v1/*`, `connect`, `content`/`mcp`, and standalone endpoints
(`deployment-mode`, `get-ip-address`, etc.).
- `routeTree.gen.ts` — **regenerated** for the routes present so far
(root + auth/app + api).

## Review tip
The route files are near-identical wrappers, so this is fast to skim.
The generated `routeTree.gen.ts` isn't meaningful review surface.

## Verification
On top of S1–S3: `studio` typecheck ✓, lint (0 errors) ✓.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Added Model Context Protocol (MCP) API endpoint with configurable
feature support and read-only mode
* Added function artifact streaming capability for self-hosted functions

* **Chores**
  * Migrated API route infrastructure for improved system architecture

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Alaister Young <[email protected]>
Co-authored-by: Ivan Vasilov <[email protected]>
@alaister alaister mentioned this pull request Jul 10, 2026
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants