Repository navigation
ci(studio): run E2E against both Next + TanStack (stack 6/6, from #46424) - #47119
Conversation
…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/).
…outes (stack 4/6, from #46424) Adds routes/api/** — ~104 thin TanStack server routes, each wrapping the existing pages/api handler via toWebHandler (compat shim from S2). Mechanical and homogeneous: createFileRoute(...).server.handlers = { METHOD: handler }. Covers platform (pg-meta, auth, storage, integrations, telemetry, ...), ai, v1, connect, content/mcp, and the standalone utility endpoints. routeTree.gen.ts is REGENERATED for the routes now present (root + auth/app + api). Project page routes + the full tree land in stack 5. Stacked on #47112. Verified: studio typecheck + lint (0 errors). Next is unaffected (builds pages/, ignores routes/).
…tack 5.1/6, from #46424) First half of the project routes (split from the original S5 to stay under CodeRabbit's 150-file review limit). Covers the data cluster — database, editor, sql, storage, realtime, branches — plus the top-level/onboarding routes (authorize, join, logout, redeem, verify-email, claim-project, vercel/ github integration entrypoints) and the _app/_auth layout shells + /org/_, /project/_ catch-alls. Supporting page edits: hoist BranchesPageWrapper out of getLayout, ConnectStepsSection import.meta.glob, api/server.js. routeTree.gen.ts regenerated for the routes present so far. Remaining product surfaces (auth, logs, settings, observability, functions, advisors, integrations) land in 5.2. Stacked on #47113. Verified: studio typecheck, lint (0 errors), Next build (181/181 pages).
…etc (stack 5.2/6, from #46424) Second half of the project routes (split from S5 for CodeRabbit's 150-file review cap). Covers the remaining product surfaces: auth, logs, settings, observability, functions, advisors, and project-level integrations. Supporting page edits: hoist EdgeFunctionsIndexPageWrapper out of getLayout (functions), functions/secrets, and move DefaultLayout to the root for logs. routeTree.gen.ts regenerated for the full route set — now byte-identical to the migration branch. After this the TanStack app is structurally complete; stack 6 flips on the E2E matrix. Stacked on #47117. Verified: studio typecheck, lint (0 errors), Next build (181/181 pages).
… from #46424) Final step of the migration stack. Adds a framework: [next, tanstack] matrix to the Studio E2E workflow so every PR exercises both builds (STUDIO_FRAMEWORK is consumed by scripts/dispatch.js). Until now only the Next build was tested.⚠️ MERGE LAST. The tanstack E2E shard only passes once master has the whole picture: - the route stack (S1-S5.2), - #47104 (lazy API-route clients — the TanStack server evaluates every route module at boot, so eager createClient crashes it), - #47106 (database E2E race fixes; #47077 already merged). Merging this before those land will make the tanstack shard red on master. Note: this renames the E2E jobs (E2E tests -> E2E tests (framework, shard)), so master's required-status-check names need updating in branch protection.
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
4 Skipped Deployments
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThis PR updates studio E2E reporting for two frameworks, adds Next-compatible URL parsing and navigation helpers across router and redirect paths, replaces Node path basename usage in browser code, and switches integration markdown loading to a static registry with Vite compatibility changes. ChangesStudio E2E Two-Framework Matrix
Studio URL Semantics and Router Wiring
Browser-Safe Edge Function Diff Helpers
Markdown Loading and Vite Build Tooling
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant AppRouter
participant CompatRouter
participant InternalUrlHelper
participant TanStackRouter
AppRouter->>CompatRouter: navigate(url) / push(href)
CompatRouter->>CompatRouter: withDefaultPathname / resolveSearchOrHashOnlyTarget
CompatRouter->>InternalUrlHelper: splitInternalUrl(resolvedUrl)
InternalUrlHelper-->>CompatRouter: { to, search, hash }
CompatRouter->>TanStackRouter: navigate({ to, search, hash })
sequenceDiagram
participant Route
participant RedirectsShared
participant Location
Route->>RedirectsShared: matchRedirect({ pathname, search, hash })
RedirectsShared->>RedirectsShared: preserveQueryAndHash(destination, search, options)
RedirectsShared-->>Route: destination with merged query/hash
Route->>Location: redirect to computed href
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🎭 Playwright Test Results (next)Details
Skipped testsFeatures › auth-users.spec.ts › should show web3 users as enabled when the matching web3 provider is enabled |
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.
…backpressure - mcp: stringify the non-Error throw in the 500 fallback instead of embedding the raw value, so a circular/non-serializable cause can't make JSON.stringify throw inside the catch. - functions body: build the multipart stream from an async generator via Readable.from(...).toWeb() so file reads honour consumer backpressure and close the file handle on client disconnect, instead of eagerly buffering every file in ReadableStream.start(). Addresses PR review feedback.
The DatabaseLayout title read only the leaf match's staticData, so trigger sub-routes (triggers/data, triggers/event, the index) that don't define their own title rendered an empty title instead of inheriting 'Triggers' from the triggers.tsx section layout. Walk up the match chain to the nearest databaseLayoutTitle. Still returns a string so the select() memoization holds. Addresses PR review feedback.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.github/workflows/studio-e2e-test.yml (1)
14-21: Plan branch-protection required-check updates before merge.With the new framework matrix, required check names will change from the prior shard-only naming. Update branch protection in the same rollout window to avoid merge blockage right after this lands.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/studio-e2e-test.yml around lines 14 - 21, The addition of the framework matrix strategy in the E2E tests workflow will change the generated check names in GitHub Actions. Prior to merging this change, update the branch protection rules for the repository to reflect the new required check names that will be generated by the expanded matrix combinations (framework: [next, tanstack] and shardIndex: [1, 2]). The old shard-only check names will no longer be generated, so updating branch protection settings in the same deployment window will prevent merge blockage after this workflow change goes live.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In @.github/workflows/studio-e2e-test.yml:
- Around line 14-21: The addition of the framework matrix strategy in the E2E
tests workflow will change the generated check names in GitHub Actions. Prior to
merging this change, update the branch protection rules for the repository to
reflect the new required check names that will be generated by the expanded
matrix combinations (framework: [next, tanstack] and shardIndex: [1, 2]). The
old shard-only check names will no longer be generated, so updating branch
protection settings in the same deployment window will prevent merge blockage
after this workflow change goes live.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: 2c03551c-36ab-4fa2-a8b1-cd00b59f8d20
📒 Files selected for processing (1)
.github/workflows/studio-e2e-test.yml
This comment has been minimized.
This comment has been minimized.
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.
…anStack build The built TanStack bundle (vite build) crashed at module load on the table editor route (and any other lazy route whose chunk pulled in Sentry) with "ReferenceError: process is not defined". The chain: studio code does `import * as Sentry from '@sentry/nextjs'` in ~25 client files -> @sentry/nextjs's client entry imports next/dist/shared/lib/constants -> its module scope evaluates `...(process?.features?.typescript ? ['next.config.mts'] : [])`, and optional chaining does not guard an undeclared `process` identifier in the browser, so the whole chunk throws before any component runs. The Vite dev server shims `process`, which is why this only surfaced in the production/test build (caught by E2E). Fix: alias the bare `@sentry/nextjs` id to compat/sentry-nextjs.ts in vite.config.ts (TanStack build only -- the Next build doesn't read this config). The shim re-exports @sentry/react (the same-version package @sentry/nextjs wraps on the client; every API studio uses at runtime -- captureException, captureMessage, startSpan, withScope, setTag, setUser, init, and the Event/Breadcrumb/StackFrame types -- exists there) and adds explicit stand-ins for the Next-only APIs (captureRouterTransitionStart, captureRequestError, withSentryConfig) so the alias can never surface an "undefined is not a function". The alias also obsoletes the previous @sentry/nextjs SSR workarounds (ssr.noExternal entry + ssr.optimizeDeps.include) -- the id is rewritten before SSR resolution ever sees it, and @sentry/react ships real ESM. No dependency changes: @sentry/react is already a direct studio dep resolving to 10.59.0, exactly matching @sentry/[email protected]'s own dependency. Verified: test-mode TanStack build passes (prerender + smoke), no built client chunk contains process?.features / middleware-manifest.json / PHASE_PRODUCTION_BUILD / next/dist / __NEXT_DATA__, and tsc is clean apart from the known pre-existing ui-patterns InstructionBlocks error. Claude-Session: https://claude.ai/code/session_01MLH8WVg8zBJnmZTYTV3ooo
…k build The routerPush helper reached for window.next.router, which only exists under the Next runtime — on the TanStack build both coexistence tests failed with 'Next router not available'. Fall back to History-API pushState + popstate, which TanStack Router subscribes to, keeping the client-side (chunk-preserving) navigation these tests depend on. Claude-Session: https://claude.ai/code/session_01MLH8WVg8zBJnmZTYTV3ooo
…ack build AIEditor loaded Monaco's Deno extra libs via /* @vite-ignore */ dynamic imports of @/public/deno/*.d.ts. Under Next/turbopack the raw-loader rule serves them as text modules, but under Vite the ignored imports failed at runtime (caught + console.error), so edge-function editors silently got no Deno type hints in the TanStack build. Extend the md raw loader in vite.config.ts into rawTextLoader, mirroring both next.config.ts raw-loader rules. The two .d.ts files resolve through an exact-specifier allowlist to \0-virtual ids served from a load hook: Rolldown's native dep scanner skips JS plugin hooks and hard-fails parsing TS declaration syntax (get stdin(): ...;) as runtime TS — which is why the @vite-ignore hack existed — and the \0 id keeps the scanner externalizing the module instead. The AIEditor imports stay literal (statically analyzable by both bundlers) with the 'as string' cast keeping tsc from resolving the .d.ts files as declaration files. Verified: vite dev serves both modules as JS string modules and the dep scan passes; vite build emits them as string chunks; next dev (turbopack) still compiles /project/[ref]/functions/new; tsc --noEmit clean. Claude-Session: https://claude.ai/code/session_01MLH8WVg8zBJnmZTYTV3ooo
…he TanStack build
GraphiQLTab imports graphiql/setup-workers/webpack, whose
new Worker(new URL('monaco-editor/...', import.meta.url)) registrations
only work when the bundler rewrites the URLs. Vite doesn't rewrite bare
specifiers inside new URL(..., import.meta.url), so on
/project/[ref]/integrations/graphiql/graphiql the json /
editorWorkerService / graphql workers 404'd and Monaco fell back to the
main thread ('Could not create web worker(s)...' console warning).
Add a graphiqlViteWorkers plugin that resolves the import to graphiql's
own setup-workers/vite variant (same workers via ?worker imports) in
client builds, leaving SSR resolution and the Next build untouched — app
source keeps the .../webpack specifier. The setup-workers chain is also
excluded from optimizeDeps: the Rolldown dep optimizer can't load ?worker
ids (UNLOADABLE_DEPENDENCY), so the modules must go through the normal
transform pipeline where Vite's built-in worker plugin handles them.
Verified: vite dev serves the vite setup-workers module for GraphiQLTab
with each ?worker import transformed into a WorkerWrapper constructor;
vite build emits json.worker/editor.worker/graphql.worker chunks; next
dev (turbopack) still compiles the graphiql route; tsc --noEmit clean.
Claude-Session: https://claude.ai/code/session_01MLH8WVg8zBJnmZTYTV3ooo
- X-Content-Type-Options: 'no-sniff' -> 'nosniff' in all three header
paths (security-headers.ts, next.config.ts, scripts/serve.js) — the
old value is invalid, so MIME-sniffing protection was silently off.
- Unquote Manrope in fonts.css (stylelint).
- eslint-disable the compat shim's export * (barrel-files rule) — the
shim's whole job is to mirror @sentry/react's surface.
- Extract the Monaco loader config shared by pages/_app.tsx and
routes/__root.tsx into lib/configure-monaco-loader.ts so the asset
path can't drift between the two runtimes.
- Deduplicate fileKey between useEdgeFunctionsDiff and
EdgeFunctionsDiffPanel (matching must stay behaviourally identical).
- Prettier over compat/next/router{,.test}.ts and TANSTACK_MIGRATION.md
(CI format failure).
Claude-Session: https://claude.ai/code/session_01MLH8WVg8zBJnmZTYTV3ooo
- Replace the as-any casts around router.navigate/preloadRoute/ buildLocation in the compat shims, nuqs adapter, and URL-shape test with TanStack's own loose generics (<AnyRouter, string>), which relax `to`/`search` typing at the library boundary without casts, and document why the loose generics are needed. - Name the SplitInternalUrlResult interface and reuse SearchRecord in lib/internal-url.ts. - Rename the boolean param consumeNext -> shouldConsumeNext in routes/index.tsx. No behavior changes; typecheck, eslint, prettier, and all PR unit tests stay green. Claude-Session: https://claude.ai/code/session_01MLH8WVg8zBJnmZTYTV3ooo
…path #47182 dropped CDN loading for Monaco in every environment and moved the locally-served assets from a flat public/monaco-editor/ layout into public/monaco-editor/vs/. The Next entry (pages/_app.tsx) was updated to match, but the TanStack root (routes/__root.tsx) still pointed loader.config at ${BASE_PATH}/monaco-editor, so after that landed the loader looked for loader.js at /monaco-editor/loader.js (404) and no Monaco editor mounted. Mirror the Next config: serve from ${origin}${BASE_PATH}/monaco-editor/vs for all environments, window-guarded since __root.tsx is also evaluated during SSR. Fixes the app-wide Monaco breakage that was failing the TanStack E2E shard (RLS policy editor, cron SQL, realtime JSON payload, database functions, GraphiQL coexistence).
#47306 renamed Tailwind's sans var from --font-custom to --font-sans and added --font-heading (Manrope), setting both via next/font on the Next build. The TanStack fonts.css was never updated — it still only set the now-ignored --font-custom, so --font-sans was unset and resolved to theme.css's fallback chain (Circular, custom-font, Helvetica Neue, ...) i.e. system fonts, and --font-heading/Manrope was missing entirely. Body text rendered as Helvetica at weight 450, which is why the Inter weights looked wrong. - fonts.css: set --font-sans (vendored Inter) and --font-heading (Manrope) to match what next/font provides on Next; drop the dead --font-custom. - __root.tsx: load Manrope over the same Google Fonts <link> already used for Source Code Pro (Inter stays vendored via @font-face). Verified against the built CSS bundle in a browser: computed body font-family is now Inter (was the Circular/system fallback) and headings resolve to Manrope. The unlayered :root wins over theme.css's @layer theme self-referential --font-sans, same as the Next inline-style approach.
Follow-up to the font fix: drop the Google Fonts <link> and self-host all three families via @font-face in fonts.css, matching next/font (which self-hosts them on the Next build). Keeps self-hosted / offline studio working — no runtime CDN dependency. - Inter + Source Code Pro reuse the woff2 fonts/index.ts already ships. - Manrope: vendored latin + latin-ext subset variable woff2 (fonts/manrope/, from @fontsource-variable/manrope) with the standard Google unicode-ranges; no italic axis. Weight ranges mirror fonts/index.ts. - __root.tsx: remove the googleapis/gstatic preconnects + stylesheet link. Verified in a browser against the built bundle: Inter (body), Manrope (headings) and Source Code Pro (mono) all load from local /assets/*.woff2, and no fonts.googleapis/gstatic references remain in the client output.
The Next build sets X-Frame-Options / X-Content-Type-Options / HSTS / Content-Security-Policy / Referrer-Policy via next.config.ts `headers()`. The TanStack build never carried these over — vercel.ts only set cache-control, so the deployed dashboard shipped with no CSP. The TanStack deploy serves a static shell (no server to attach headers), so the headers go in the Vercel config. Add security-headers.ts as the shared source of truth (reuses getCSP(), env-gated exactly like next.config) and: - vercel.ts: apply to every response (source '/(.*)'), all base-path prefixes — full getCSP() + HSTS on platform, the deployed surface that matters. - scripts/serve.js: apply the non-platform set (frame-ancestors 'none') for the self-hosted server, matching next.config's non-platform branch. Note: font-src in the CSP is 'self' + cloudflare + supabase-assets (no fonts.gstatic.com), so vendoring the fonts locally in the previous commit is what keeps them CSP-compliant. X-Content-Type-Options keeps next.config's 'no-sniff' value verbatim for parity.
GraphiQL's bundled Monaco ships the codicon icon font as a data: URI, and Stripe's payment element inlines its fonts the same way, but font-src didn't allow data: — so those fonts were blocked once the CSP is enforced (surfaced while testing the CSP on the TanStack build; would affect the Next build too). Verified in a browser: with the CSP applied, the data: font violations (37 of them on a cold load) drop to zero, and the SQL editor Monaco renders.
Applies the review-feedback hunks that were skipped when these files didn't exist on this branch yet: X-Content-Type-Options nosniff, unquoted Manrope, and the shared configureMonacoLoader() extraction. Claude-Session: https://claude.ai/code/session_01MLH8WVg8zBJnmZTYTV3ooo
The TanStack __root.tsx hardcoded the prod favicon route, so local and hosted staging showed the prod icon. pages/_app.tsx passes /favicon/staging to MetaFaviconsPagesRouter for non-prod (per Joshen's review) — mirror that with the same synchronous NEXT_PUBLIC_ENVIRONMENT signal already used by IS_DEV_TOOLBAR_ENABLED (the head() route option can't run _app's async CLI check, but the env signal covers the reported local/staging case). Claude-Session: https://claude.ai/code/session_01MLH8WVg8zBJnmZTYTV3ooo
- splitInternalUrl: compare against the parse base's origin unconditionally (not gated on window) so SSR no longer treats external absolute URLs like https://supabase.com/docs as internal paths; client behavior unchanged. - internal-url.test.ts: add SSR-mode cases (window stubbed undefined) — external absolute URL passes through untouched, relative path still splits. - __root.tsx: extract shared IS_NON_PROD_ENV const used by both IS_DEV_TOOLBAR_ENABLED and FAVICON_ROUTE (behavior identical). Claude-Session: https://claude.ai/code/session_01MLH8WVg8zBJnmZTYTV3ooo
…rom #46424) (#47657) Post-merge fixes for the TanStack Start migration (#46424) — things that broke on the TanStack build as master evolved under the migration branches. Kept on their own branch off master rather than piling onto the E2E-matrix PR (#47119); all land on master and cascade up to S6 + the big PR. Common theme: a master PR changed something the Next pipeline handles via `next/font` / `pages/_app.tsx` / `next.config.ts`, but the hand-rolled TanStack equivalent (`routes/__root.tsx`, `styles/fonts.css`, `vercel.ts`) wasn't updated to match — invisible on the Next deploy, broken only on TanStack. --- ## 1. Monaco loader path (#47182) #47182 re-nested the served Monaco assets from a flat `public/monaco-editor/` layout into `public/monaco-editor/vs/` and updated `pages/_app.tsx`, but `routes/__root.tsx` still pointed `loader.config` at the old path, so `loader.js` 404'd and **no Monaco editor mounted anywhere in the TanStack build**. Now mirrors the Next config (`${origin}${BASE_PATH}/monaco-editor/vs`, window-guarded for SSR). Was failing the whole `tanstack` E2E shard on #47119. ## 2. Inter + Manrope fonts (#47306) #47306 renamed Tailwind's sans var `--font-custom` → `--font-sans` and added `--font-heading` (Manrope), set via `next/font` on Next. `fonts.css` still only set the now-ignored `--font-custom`, so the body fell back to the theme's system chain (`Circular, custom-font, Helvetica…`) at weight 450 — that's the "Inter weights look wrong". Manrope was missing entirely. - Wire `--font-sans` (Inter) + `--font-heading` (Manrope) to match `next/font`. - **Vendor all three families** (Inter, Manrope, Source Code Pro) via `@font-face` so nothing depends on the Google Fonts CDN — matches `next/font` self-hosting, and (see below) `font-src` doesn't allow `fonts.gstatic.com` anyway. Verified in-browser: computed `body` → `Inter`, headings → `Manrope`, all loading from local `/assets/*.woff2`. ## 3. Security headers / CSP (next.config.ts `headers()`) The Next build sets X-Frame-Options / X-Content-Type-Options / HSTS / **Content-Security-Policy** / Referrer-Policy via `next.config.ts`. The TanStack build never carried these over — `vercel.ts` only set cache-control, so **the deployed TanStack dashboard shipped with no CSP at all**. The TanStack deploy serves a static shell (no server to attach headers), so they go in the Vercel config: - `security-headers.ts` — shared source of truth, reuses `getCSP()`, env-gated exactly like next.config. - `vercel.ts` — apply to every response (all base-path prefixes): full `getCSP()` + HSTS on platform. - `scripts/serve.js` — the non-platform set (`frame-ancestors 'none'`) for the self-hosted server. **Tested the policy in a real browser** (temporarily enforced it on the TanStack build via /test-supabase-local): everything passed except one real gap — `font-src` was missing `data:`, so GraphiQL's bundled Monaco codicon font and Stripe's payment-element fonts (both data: URIs) were blocked (37 violations on a cold load). Added `data:` to `font-src` in `csp.ts` → violations drop to zero, SQL editor Monaco renders clean. That gap affects the Next build too. --- ## 4. `node:path` import crashing `/project/[ref]/merge` Found by a full-site click-through of the TanStack build (all product areas, ongoing — see below). `useEdgeFunctionsDiff.ts` + `EdgeFunctionsDiffPanel.tsx` did `import { basename } from 'path'` in client code. Webpack (Next) polyfills `path` in the browser; Vite externalizes it, so the whole `/merge` route crashed with "Module \"path\" has been externalized for browser compatibility". Replaced the two `basename` call sites with a string helper. Verified in-browser: `/merge` renders. ## 5. URL shape — Next-style search-param semantics + shim fixes The dashboard produced malformed URLs vs the Next build (strange query params, trailing slashes, `##` hashes). Root cause + audit verified empirically against `@tanstack/[email protected]`; all fixed with unit tests and browser-verified: - **`createRouter` used TanStack's default JSON search codec** — `?flag=true` became `?flag=%22true%22` via links, repeated `?filter=…&filter=…` collapsed into a JSON array (breaking multi-filter/sort table-editor URLs and the account-page round-trip, which double-encoded), and search values arrived as numbers/booleans where the app expects strings. New `lib/router-search-params.ts` (Next-style: strings in, strings out, repeated keys → string[]) wired into the router. - **Link shim** (`compat/next/link.tsx`): `URL.hash` includes the leading `#` while TanStack's `hash` prop adds its own → every `href="…#section"` navigated to `##section` (hash-scroll broke); `Object.fromEntries(searchParams)` dropped repeated query params. Both fixed. - **Trailing slash injected before the query** on every `?`-only relative navigation (`/auth/providers/?provider=…`): fixed in the compat router (prefix current pathname) and via a custom nuqs adapter (`lib/nuqs-tanstack-adapter.tsx`) replacing the stock tanstack-router adapter, whose `navigate({ to: '?…' })` writes hit the same TanStack behavior (123 files use nuqs). - **Pathname-less `router.push({ query })` leaked path params** — Next re-consumes `ref`/`id` from `query` into the path pattern; the shim didn't, yielding `/editor/17597?schema=public&ref=<ref>&id=17597&filter=…` from table-editor filter/sort, linter panels, and advisor shortcuts. The shim now defaults the pathname to the current route pattern and backfills omitted params. - **Redirects dropped query + hash** (Next's `redirects()` preserves them): `__root.tsx` `matchRedirect` and `routes/index.tsx` now carry incoming params/hash through (consumed rule params excluded, destination's own params win). `/?next=new-project&projectName=zzz` → `/new/new-project?projectName=zzz`; `/sql/quickstarts?template=x#frag` → `/sql/examples?template=x#frag`. Browser-verified post-fix: advisors `?preset=WARN`, providers `?provider=Google`, `?schema=auth` — all clean (no `/?`, no leaks); repeated `filter` params survive hydration; `=true` unquoted; single `#`. ## 6. TanStack `navigate` corrupting query values (Logs Explorer SQL newline loss) TanStack router-core treats a query string embedded in `navigate({ to })` as part of the *path*: `decodePath` percent-decodes it and `sanitizePathSegment` strips control characters, silently deleting every `%0A`. Logs Explorer's SQL (`s` param) lost its newlines on Run/reload — `order by timestamp desc` / `limit 5` glued into `desclimit 5`, which then failed the LIMIT lint. Pre-existing on the TanStack build (the stock nuqs adapter had the same shape); Next unaffected. Fixed by never embedding query strings in `to`: the nuqs adapter and the compat `router.push`/`replace`/`prefetch` (plus the `next/navigation` shim) now pass search as an object through the app codec (`splitInternalUrl` hoisted to `lib/internal-url.ts`). Guard test drives a real `createRouter` with multi-line SQL through both producers. Browser-verified: newlines survive the full Run → reload → re-Run cycle. ## 7. Integration overview markdown never loaded (all integrations) `MarkdownContent` used a template-literal dynamic import (``import(`@/static-data/integrations/${id}/overview.md`)``) — webpack builds a context module for that, Vite can't analyze it, so every integration detail page threw `Failed to resolve module specifier` and rendered no overview text. Fixed with an explicit lazy registry of literal imports (`static-data/integrations/overviews.ts`, drift-guarded by a test) plus an `mdRawLoader()` Vite plugin mirroring next.config's turbopack raw-loader rule. Both runtimes keep working; md stays out of the main bundle. ## 8. GraphiQL editor never mounted (`exports is not defined`) Our `umdAmdShortCircuit()` Vite plugin (which disarms Monaco's global AMD loader for deps like papaparse) rewrote `typeof define === 'function' && define.amd` to `false` inside `monaco-editor`'s bundled copy of marked — whose UMD relies on its own *local* `define` shim — so the whole optimized monaco chunk failed to evaluate and GraphiQL's editor pane stayed blank. The check now only short-circuits when `define` is the global AMD loader. Browser-verified: all four GraphiQL Monaco panes mount, queries execute. (Known follow-up: GraphiQL's Monaco workers fall back to the main thread under Vite — functional, worker wiring is Next-specific `setup-workers/webpack`.) ## 9. `@sentry/nextjs` bundling Next internals — built TanStack bundle crashed (caught by E2E) The E2E suite against the **built** TanStack bundle (not the dev server) found lazy chunks like `table-editor-*.js` dead on arrival: `@sentry/nextjs` (imported by ~25 client files) drags in `next/dist/shared/lib/constants`, whose module scope evaluates `process?.features?.typescript` — optional chaining doesn't guard an undeclared `process` in the browser, so the whole chunk failed at load with `ReferenceError: process is not defined`. Dev shims `process`, which is why weeks of dev-server testing never saw it. Fixed by aliasing `@sentry/nextjs` → `compat/sentry-nextjs.ts` (re-exports `@sentry/react`, same deduped 10.59.0, plus explicit stand-ins for the three Next-only APIs) in the Vite build only. Verified: fresh build has zero Next-internals markers in any chunk; table editor loads clean; full E2E suite run against the built bundle. Note for the stack: `alaister/tanstack-start` / the E2E-matrix branch already carried a different fix for the same crash (a `next/constants` shim) that never made it to master — the cherry-pick onto those branches keeps **both** (the shim covers any other transitive importer; the alias keeps Next internals out of the client bundle entirely). **Follow-up found while fixing:** Sentry is never *initialized* in the TanStack runtime — `instrumentation-client.ts` / `sentry.server.config.ts` are Next-convention files nothing imports under TanStack, so `captureException` calls are silent no-ops. Needs an `@sentry/react` init (+ `tanstackRouterBrowserTracingIntegration`) wired into the TanStack client entry as its own PR. ## 10. GraphiQL Monaco workers + edge-function Deno typings (Vite-only gaps) - **GraphiQL's Monaco workers ran on the main thread** under Vite ("Could not create web worker(s)…" — `setup-workers/webpack`'s `new URL(...)` form isn't rewritten by Vite). A `graphiqlViteWorkers()` plugin resolves the import to graphiql's own `setup-workers/vite` variant for client builds (SSR untouched, Next untouched); the setup-workers chain is `optimizeDeps.exclude`d because the Rolldown optimizer can't load `?worker` ids. - **Edge-function editors silently lost their Deno typings** — `AIEditor` loaded `public/deno/*.d.ts` via `/* @vite-ignore */` imports that always failed at runtime under Vite. The `.md` raw loader is generalized into `rawTextLoader` (exact-path allowlist for the two typings files, served as virtual string modules so the dep scanner never parses `.d.ts` syntax), and the imports are now static-analyzable literals that both bundlers handle (turbopack's raw-loader rules match them on the Next side). ## Split out for reviewability App-level fixes that reproduce on the Next build too (DOM-nesting hydration errors, the ghost deleted-snippet nav, the recurring pg-meta `migrations` 400) moved to their own PR: #47667. Sentry initialization for the TanStack runtime (captures were silent no-ops) is #47666, stacked on this PR. ## Full-site test campaign Drove every dashboard product area on the local TanStack build (Playwright, human-style) hunting migration regressions: redirects/404/catch-alls, org, account, project home/branches/merge, table editor CRUD, SQL editor (Monaco/run/save/templates/AI), all database pages, all auth pages, storage CRUD, edge functions + realtime, logs/observability, advisors, settings, integrations hub incl. nested routes, global UI (palette/connect/switchers/theme/fonts), and a cross-cutting sweep (document titles, back/forward chain, hard-refresh hydration on deep URLs, trailing-slash active state). Every failure found is fixed above and re-verified in-browser; remaining console quirks were cross-checked against the deployed Next build and are pre-existing (tracked separately). ## To test Most fixes are already browser-verified + covered by unit tests and the self-hosted E2E suite; the last two landed after the final browser pass and still need an in-browser check: 1. **GraphiQL Monaco workers** — restart the dev server (clear `apps/studio/node_modules/.vite` once first — the optimizer cache may hold a stale prebundle of the worker chain). Open `/project/<ref>/integrations/graphiql/graphiql` with the console open: the `Could not create web worker(s). Falling back to loading web worker code in main thread` warning must be gone, and DevTools → Sources → Threads shows the three workers (json, editor, graphql). Autocomplete in the query editor stays responsive. 2. **Edge-function Deno typings** — `/project/<ref>/functions/new`: no "Failed to load … typings" console error, and typing `Deno.` in the editor offers typed completions (e.g. `Deno.env`). Spot-checks for the rest (all previously verified): - `/project/<ref>/merge` renders (no "Module path" crash). - Multi-line SQL in Logs Explorer survives Run → reload (no `desclimit` gluing, no LIMIT-lint false failure); `s` param keeps `%0A`. - `/auth/providers` → open a provider → `?provider=…` with no trailing slash before `?`; table-editor filter/sort URLs carry no leaked `ref`/`id` params; `/?next=new-project&projectName=x` lands on `/new/new-project?projectName=x`. - Integration detail pages (cron/queues/vault/data_api) show their overview prose; GraphiQL query editor mounts. - Built bundle (`MODE=test vite build` + `start:tanstack`): table editor loads with no `process is not defined`. - `curl -sI` any page on a platform deploy: `X-Content-Type-Options: nosniff` (was the invalid `no-sniff`). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Centralized integration overview markdown loading with registry-based lookup. * Improved Monaco loading/asset path handling for smoother editor startup. * **Bug Fixes** * Next-style navigation/search handling now preserves pathname, hash, repeated query keys, and special characters (including newlines). * Redirects now reliably carry over query and hash with correct precedence. * **Security/Configuration** * Updated CSP font sourcing and unified security headers delivery across environments; conditional HSTS behavior. * Refreshed font CSS variables and font-face definitions to match the theme. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- ### Review feedback: non-prod favicon (Joshen) The TanStack `__root.tsx` hardcoded the prod favicon; local + hosted staging now use the white staging favicon (`/favicon/staging`), matching what `pages/_app.tsx` passes to `MetaFaviconsPagesRouter` for non-prod. Rather than pull the pages-router component into the TanStack head, it reuses the same synchronous `NEXT_PUBLIC_ENVIRONMENT` signal the file already uses for `IS_DEV_TOOLBAR_ENABLED` (the `head()` route option isn't a React component, so it can't run `_app`'s async CLI check — but the env signal covers the reported local/staging case). --------- Co-authored-by: Alaister Young <[email protected]> Co-authored-by: Joshen Lim <[email protected]>
…s6-e2e-matrix Resolve vite.config.ts: drop the stack-only next/constants alias + its compat shim (master fixes the Next-internals crash via the @sentry/nextjs alias alone, which both sides have).
Braintrust eval report
|
Stack 6/6 (final) of the TanStack Start migration (#46424). The middle slices (#47107 → #47118) have all merged, so this now sits directly on master.
What's in this PR
One file:
.github/workflows/studio-e2e-test.yml— addsframework: [next, tanstack]to the test/report matrices and setsSTUDIO_FRAMEWORK(consumed byscripts/dispatch.js). Until now CI only built/tested Next. This flips on the dual-framework E2E matrix so the TanStack build gets exercised end-to-end on every run.The
tanstackshard needs the Monaco loader fix in #47657 to be on master. Quick version: master's #47182 re-nested the Monaco assets underpublic/monaco-editor/vs/and the TanStack root was still pointing at the old flat path, so Monaco didn't mount anywhere in the TanStack build and every editor-backed test timed out (RLS, cron SQL, realtime JSON, db functions, GraphiQL). Kept that fix on its own branch rather than piling it onto this one.Merge order:
tanstackshard goes green → merge thisThis renames the E2E jobs (
E2E tests→E2E tests (next|tanstack, shard)), so master's current required status checks (E2E tests (1, 2)/(2, 2)) stop being reported. The required-check list in branch protection needs updating to the new names when this merges.Verification
Config-only, no app code. The real validation is this matrix running both shards green once #47657 lands — the
nextshards already pass here; thetanstackshards pass once the Monaco fix is on master.Summary by CodeRabbit
New Features
Bug Fixes
?/#targets and base-path handling.