Skip to content

build(studio): Vite/TanStack-Start build pipeline behind flag (stack 1/6, from #46424) - #47107

Merged
alaister merged 7 commits into
masterfrom
alaister/migration-s1-foundation
Jun 24, 2026
Merged

alaister merged 7 commits into
masterfrom
alaister/migration-s1-foundation

Conversation

@alaister

@alaister alaister commented Jun 19, 2026 •

Copy link
Copy Markdown
Member

Stack 1/6 of the TanStack Start migration (#46424), split into reviewable, independently-mergeable PRs.

Important

Next stays the default and only active framework after this PR. This wires up the Vite/TanStack-Start build pipeline behind the STUDIO_FRAMEWORK flag, but there are no TanStack routes yet — so the TanStack build isn't functional or tested until later PRs in the stack. Nothing about the Next build, dev, or deploy changes behaviourally here.

What's in this PR

  • Dispatch: dev/build/start now go through scripts/dispatch.js, which runs the Next variant unless STUDIO_FRAMEWORK=tanstack. The original commands are preserved as dev:next/build:next/start:next.
  • Build pipeline: vite.config.ts, serve.js, smoke-server.mjs, vite/tanstack deps, turbo.jsonc.
  • tsconfig.json: jsx: react-jsx, moduleResolution: Bundler, target: ES2022. Because include is **/*.ts(x), this re-typechecks the whole app, so the companion adaptations below land with it.
  • Shared adaptations (companions to the tsconfig change): BufferSource casts, packages/ui unused-React import removals, etc.
  • Routing/middleware plumbing: next.config.ts + redirects.shared.ts (redirect rules now shared with vercel.ts), proxy.ts/start.ts middleware + hosted-api-allowlist.ts.

Verification

Run locally off master: frozen install ✓, studio typecheck ✓, Next build ✓ (compiles + generates all routes), lint ratchet ✓ ("some rules improved"), prettier ✓.

Summary by CodeRabbit

  • New Features

    • Added a hosted API allowlist to return 404 for unsupported /api/* paths.
    • Introduced TanStack route-migration guidance for Studio.
  • Improvements

    • Improved deployment “latest” refresh/detection via tighter cookie handling.
    • Centralized redirect and maintenance-mode logic for consistent platform behavior.
    • Updated production serving with a dedicated static+proxy server and added a post-build smoke test.
  • Dependencies

    • Updated TanStack/React Table and related package version specifiers.
  • Documentation / Chores

    • Added shared env parsing utilities and expanded build/serve scripting/tooling configuration.

@alaister
alaister requested review from a team as code owners June 19, 2026 07:21
@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 ↗︎.

@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)
studio-self-hosted Ready Ready Preview, Comment Jun 23, 2026 4:08pm
studio-staging Ready Ready Preview, Comment Jun 23, 2026 4:08pm
5 Skipped Deployments
Project Deployment Actions Updated (UTC)
studio Ignored Ignored Jun 23, 2026 4:08pm
design-system Skipped Skipped Jun 23, 2026 4:08pm
docs Skipped Skipped Jun 23, 2026 4:08pm
ui-library Skipped Skipped Jun 23, 2026 4:08pm
zone-www-dot-com Skipped Skipped Jun 23, 2026 4:08pm

Request Review

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Jun 19, 2026
@coderabbitai

coderabbitai Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: 127aff86-e12b-424e-9844-4383411673cc

📥 Commits

Reviewing files that changed from the base of the PR and between f9699ce and 3f7c8d9.

📒 Files selected for processing (4)
  • apps/studio/scripts/dispatch.js
  • apps/studio/scripts/lib/env.js
  • apps/studio/scripts/serve.js
  • apps/studio/vercel.ts

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


📝 Walkthrough

Walkthrough

Adds TanStack Start as a parallel runtime alongside Next.js in apps/studio, with shared redirects and API gating, a Vite build and deployment pipeline, new serve/dispatch/smoke scripts, and workspace/tooling updates across the repo.

Changes

TanStack Start parallel runtime infrastructure

Layer / File(s) Summary
Workspace and tooling alignment
pnpm-workspace.yaml, package.json, apps/design-system/package.json, apps/docs/package.json, apps/ui-library/package.json, packages/ui-patterns/package.json, apps/studio/package.json, apps/studio/turbo.jsonc, turbo.jsonc, apps/studio/.gitignore, .prettierignore, scripts/generateLocalEnv.js
Updates TanStack catalog entries and package specifiers across workspaces, expands studio scripts and dependencies, adds Turbo env/output declarations, updates ignore rules, and adjusts generated local env defaults and root script env for studio.
Shared redirects, allowlist, and platform guard
apps/studio/redirects.shared.ts, apps/studio/next.config.ts, apps/studio/lib/hosted-api-allowlist.ts, apps/studio/proxy.ts, apps/studio/start.ts
Defines shared redirect tables and runtime matching helpers, rewires next.config.ts to consume them, extracts the hosted API suffix allowlist, and applies the allowlist in both the Next proxy and TanStack Start request middleware.
TanStack build, deployment, and runtime entrypoints
apps/studio/vite.config.ts, apps/studio/tsconfig.json, apps/studio/styles/fonts.css, apps/studio/vercel.ts, apps/studio/scripts/lib/env.js, apps/studio/scripts/dispatch.js, apps/studio/scripts/serve.js, apps/studio/scripts/smoke-server.mjs
Adds the TanStack Vite pipeline, TS compiler settings, font declarations, TanStack-specific Vercel config, shared env parsing, framework dispatching, production serving, and smoke-test execution.
Supporting runtime fixes and migration notes
apps/studio/components/interfaces/Database/Replication/Destinations.tsx, apps/studio/components/interfaces/Organization/BillingSettings/Subscription/CancellationFlow.tsx, apps/studio/components/ui/AIEditor/index.tsx, apps/studio/data/utils/deployment-commit-query.ts, apps/studio/hooks/use-check-latest-deploy.tsx, apps/studio/lib/ai/util.ts, apps/studio/lib/role-impersonation.ts, apps/studio/lib/telemetry.tsx, apps/studio/scripts/ratchet-eslint-rules.ts, apps/studio/TANSTACK_MIGRATION.md
Memoizes replica filtering, updates React imports, switches Deno typings to dynamic imports, omits cookies on deployment commit fetches, clears the deployment pin cookie before reload, adds BufferSource casts for Web Crypto calls, increases ESLint JSON buffer size, and adds the TanStack migration checklist document.

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant dispatch.js
  participant serve.js
  participant start.ts
  participant hosted-api-allowlist.ts

  CLI->>dispatch.js: pnpm dev/build/start
  dispatch.js->>dispatch.js: resolve STUDIO_FRAMEWORK from env files
  dispatch.js->>serve.js: spawn pnpm run <target>:<framework>

  CLI->>serve.js: HTTP request
  serve.js->>serve.js: serve static file or bridge Node request
  serve.js->>start.ts: call TanStack fetch handler
  start.ts->>hosted-api-allowlist.ts: check hosted /api/* path
  alt unsupported hosted endpoint
    start.ts-->>serve.js: 404 JSON response
  else supported path
    start.ts-->>serve.js: Web Response
  end
  serve.js-->>CLI: streamed Node response
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Possibly related PRs

  • supabase/supabase#46241: Both PRs touch apps/studio/next.config.ts redirect assembly, including the /sql/quickstarts to /sql/examples rule set.

Suggested labels

frontend

Suggested reviewers

  • ivasilov
  • dnywh

Poem

🐇 I hop through redirects, crisp and neat,
TanStack paths and Next.js meet.
Static files hum, guards stand tall,
Cookies get cleared before the fall.
One tiny rabbit grins with glee—
“Builds and routes now bounce with me!”

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'build(studio): Vite/TanStack-Start build pipeline behind flag' accurately summarizes the main change—introducing the Vite/TanStack-Start build pipeline controlled by a feature flag.
Description check ✅ Passed The PR description is comprehensive and covers all key aspects: the dispatch system, build infrastructure, TypeScript updates, routing/middleware changes, and verification details. It clearly explains the scope and objectives within a six-part migration stack.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch alaister/migration-s1-foundation

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.

@github-actions

github-actions Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

🎭 Playwright Test Results

passed  218 passed
flaky  1 flaky
skipped  5 skipped

Details

stats  224 tests across 24 suites
duration  3 minutes, 22 seconds
commit  3f7c8d9

Flaky tests

Features › realtime-inspector.spec.ts › Realtime Inspector › Basic Inspector UI › channel selection popover opens and works

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

…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.
@alaister
alaister force-pushed the alaister/migration-s1-foundation branch from 6fc4bc3 to 5326d10 Compare June 19, 2026 07:33

@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: 2

🤖 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/scripts/serve.js`:
- Around line 151-153: The loop at line 152 that sets response headers using
res.setHeader(k, v) overwrites duplicate header keys, causing all but the last
Set-Cookie header to be lost when proxying responses. Replace the res.setHeader
call with res.appendHeader to properly append headers instead of overwriting
them, which will preserve all Set-Cookie headers and maintain
authentication/session flows.

In `@apps/studio/turbo.jsonc`:
- Around line 129-134: The outputs array in the turbo.jsonc file contains a
trailing comma after "dist/**" which is invalid JSON syntax and causes a parse
error. Remove the trailing comma from the last element in the outputs array so
that "dist/**" appears without a comma, allowing the JSON parser to correctly
recognize the closing bracket of the array.
🪄 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: eeb37489-8949-4a40-8aa7-10c472de7927

📥 Commits

Reviewing files that changed from the base of the PR and between 6fc234c and 6fc4bc3.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (38)
  • .prettierignore
  • apps/design-system/package.json
  • apps/docs/package.json
  • apps/studio/.gitignore
  • apps/studio/TANSTACK_MIGRATION.md
  • apps/studio/components/interfaces/Connect/content/nextjs/app/supabasejs/content.tsx
  • apps/studio/components/interfaces/Database/Replication/Destinations.tsx
  • apps/studio/components/interfaces/Organization/BillingSettings/Subscription/CancellationFlow.tsx
  • apps/studio/components/ui/AIEditor/index.tsx
  • apps/studio/data/utils/deployment-commit-query.ts
  • apps/studio/eslint.config.cjs
  • apps/studio/hooks/use-check-latest-deploy.tsx
  • apps/studio/lib/ai/util.ts
  • apps/studio/lib/hosted-api-allowlist.ts
  • apps/studio/lib/role-impersonation.ts
  • apps/studio/lib/telemetry.tsx
  • apps/studio/next.config.ts
  • apps/studio/package.json
  • apps/studio/proxy.ts
  • apps/studio/redirects.shared.ts
  • apps/studio/scripts/dispatch.js
  • apps/studio/scripts/ratchet-eslint-rules.ts
  • apps/studio/scripts/serve.js
  • apps/studio/scripts/smoke-server.mjs
  • apps/studio/start.ts
  • apps/studio/styles/fonts.css
  • apps/studio/tsconfig.json
  • apps/studio/turbo.jsonc
  • apps/studio/vercel.ts
  • apps/studio/vite.config.ts
  • apps/ui-library/package.json
  • package.json
  • packages/ui-patterns/package.json
  • packages/ui/src/components/AnimatedCounter/AnimatedCounter.tsx
  • packages/ui/src/components/Typography/Typography.tsx
  • pnpm-workspace.yaml
  • scripts/generateLocalEnv.js
  • turbo.jsonc
💤 Files with no reviewable changes (2)
  • packages/ui/src/components/Typography/Typography.tsx
  • apps/studio/components/interfaces/Connect/content/nextjs/app/supabasejs/content.tsx

Comment thread apps/studio/scripts/serve.js Resolved
Comment thread apps/studio/turbo.jsonc Resolved

@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.

♻️ Duplicate comments (2)
apps/studio/turbo.jsonc (1)

129-134: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Fix parse-breaking trailing comma in outputs.

The trailing comma after "dist/**" (Line 133) causes a parse error at Line 134 in current tooling, which blocks safe merge/CI config parsing.

Proposed minimal fix
       "outputs": [
         ".next/**",
         "!.next/cache/**",
         "!.next/dev/**/*",
-        "dist/**",
+        "dist/**"
       ],
#!/bin/bash
set -euo pipefail
python - <<'PY'
from pathlib import Path
import re, sys
p = Path("apps/studio/turbo.jsonc")
t = p.read_text()
m = re.search(r'"outputs"\s*:\s*\[(?s).*?"dist/\*\*",\s*\]', t)
print("trailing_comma_in_outputs =", bool(m))
sys.exit(1 if m else 0)
PY
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/studio/turbo.jsonc` around lines 129 - 134, The outputs array in the
turbo.jsonc file contains a trailing comma after the "dist/**" entry that causes
parse errors in the JSON configuration. Remove the trailing comma that appears
after "dist/**" in the outputs array to fix the parse error and allow safe
configuration parsing by the tooling.

Source: Linters/SAST tools

apps/studio/scripts/serve.js (1)

150-153: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Preserve multi-value Set-Cookie headers when proxying.

At Line 152, iterating headers and calling res.setHeader(k, v) overwrites duplicate keys. This can drop all but one Set-Cookie header and break auth/session flows.

Proposed minimal fix
 async function pipeWebResponse(response, res) {
   res.statusCode = response.status
-  for (const [k, v] of response.headers) res.setHeader(k, v)
+  const setCookies =
+    typeof response.headers.getSetCookie === 'function' ? response.headers.getSetCookie() : []
+  for (const [k, v] of response.headers) {
+    if (k.toLowerCase() === 'set-cookie') continue
+    res.setHeader(k, v)
+  }
+  if (setCookies.length > 0) res.setHeader('set-cookie', setCookies)
   if (!response.body) {
     res.end()
     return
   }
#!/bin/bash
set -euo pipefail
rg -n "for \\(const \\[k, v\\] of response\\.headers\\) res\\.setHeader\\(k, v\\)" apps/studio/scripts/serve.js
rg -n "set-cookie|getSetCookie|appendHeader" apps/studio/scripts/serve.js
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/studio/scripts/serve.js` around lines 150 - 153, In the pipeWebResponse
function, the loop iterating through response.headers and calling
res.setHeader(k, v) overwrites duplicate header keys instead of preserving them,
which breaks Set-Cookie headers needed for authentication. Modify the header
handling logic to detect multi-value headers (particularly Set-Cookie) and use
res.appendHeader instead of res.setHeader when a header with the same key
already exists, or use the appropriate Node.js method that supports multiple
values for the same header key.
🤖 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.

Duplicate comments:
In `@apps/studio/scripts/serve.js`:
- Around line 150-153: In the pipeWebResponse function, the loop iterating
through response.headers and calling res.setHeader(k, v) overwrites duplicate
header keys instead of preserving them, which breaks Set-Cookie headers needed
for authentication. Modify the header handling logic to detect multi-value
headers (particularly Set-Cookie) and use res.appendHeader instead of
res.setHeader when a header with the same key already exists, or use the
appropriate Node.js method that supports multiple values for the same header
key.

In `@apps/studio/turbo.jsonc`:
- Around line 129-134: The outputs array in the turbo.jsonc file contains a
trailing comma after the "dist/**" entry that causes parse errors in the JSON
configuration. Remove the trailing comma that appears after "dist/**" in the
outputs array to fix the parse error and allow safe configuration parsing by the
tooling.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: 0c162133-79c9-431d-9fc4-59e6bdd1b3e3

📥 Commits

Reviewing files that changed from the base of the PR and between 6fc4bc3 and 5326d10.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (37)
  • .prettierignore
  • apps/design-system/package.json
  • apps/docs/package.json
  • apps/studio/.gitignore
  • apps/studio/TANSTACK_MIGRATION.md
  • apps/studio/components/interfaces/Connect/content/nextjs/app/supabasejs/content.tsx
  • apps/studio/components/interfaces/Database/Replication/Destinations.tsx
  • apps/studio/components/interfaces/Organization/BillingSettings/Subscription/CancellationFlow.tsx
  • apps/studio/components/ui/AIEditor/index.tsx
  • apps/studio/data/utils/deployment-commit-query.ts
  • apps/studio/hooks/use-check-latest-deploy.tsx
  • apps/studio/lib/ai/util.ts
  • apps/studio/lib/hosted-api-allowlist.ts
  • apps/studio/lib/role-impersonation.ts
  • apps/studio/lib/telemetry.tsx
  • apps/studio/next.config.ts
  • apps/studio/package.json
  • apps/studio/proxy.ts
  • apps/studio/redirects.shared.ts
  • apps/studio/scripts/dispatch.js
  • apps/studio/scripts/ratchet-eslint-rules.ts
  • apps/studio/scripts/serve.js
  • apps/studio/scripts/smoke-server.mjs
  • apps/studio/start.ts
  • apps/studio/styles/fonts.css
  • apps/studio/tsconfig.json
  • apps/studio/turbo.jsonc
  • apps/studio/vercel.ts
  • apps/studio/vite.config.ts
  • apps/ui-library/package.json
  • package.json
  • packages/ui-patterns/package.json
  • packages/ui/src/components/AnimatedCounter/AnimatedCounter.tsx
  • packages/ui/src/components/Typography/Typography.tsx
  • pnpm-workspace.yaml
  • scripts/generateLocalEnv.js
  • turbo.jsonc
💤 Files with no reviewable changes (2)
  • packages/ui/src/components/Typography/Typography.tsx
  • apps/studio/components/interfaces/Connect/content/nextjs/app/supabasejs/content.tsx
✅ Files skipped from review due to trivial changes (6)
  • packages/ui/src/components/AnimatedCounter/AnimatedCounter.tsx
  • apps/studio/.gitignore
  • apps/studio/lib/ai/util.ts
  • .prettierignore
  • apps/studio/components/interfaces/Organization/BillingSettings/Subscription/CancellationFlow.tsx
  • apps/ui-library/package.json
🚧 Files skipped from review as they are similar to previous changes (23)
  • apps/studio/lib/telemetry.tsx
  • apps/design-system/package.json
  • apps/studio/scripts/smoke-server.mjs
  • turbo.jsonc
  • apps/studio/lib/hosted-api-allowlist.ts
  • apps/studio/tsconfig.json
  • apps/studio/hooks/use-check-latest-deploy.tsx
  • apps/studio/data/utils/deployment-commit-query.ts
  • apps/studio/proxy.ts
  • pnpm-workspace.yaml
  • packages/ui-patterns/package.json
  • apps/docs/package.json
  • apps/studio/start.ts
  • scripts/generateLocalEnv.js
  • apps/studio/scripts/ratchet-eslint-rules.ts
  • apps/studio/lib/role-impersonation.ts
  • apps/studio/components/interfaces/Database/Replication/Destinations.tsx
  • apps/studio/components/ui/AIEditor/index.tsx
  • package.json
  • apps/studio/redirects.shared.ts
  • apps/studio/package.json
  • apps/studio/vite.config.ts
  • apps/studio/vercel.ts

alaister and others added 2 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.
Comment thread apps/studio/vercel.ts
@@ -0,0 +1,144 @@
import { routes, type Redirect, type VercelConfig } from '@vercel/config/v1'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

If we use nitro we'll be running a Vercel function on every request – so I've opted for a simpler, pure SPA approach

Comment thread apps/studio/scripts/dispatch.js Outdated
process.exit(2)
}

function readEnvLocalKey(key) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should just use dotenv here, no need for this magic. I tried adding the env var in .env first, so got confused why it didn't work.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah makes sense – the real issue was dispatch.js only reading .env.local, while serve.js reads .env too, so anything in .env got silently ignored. Fixed it to read both now (shell > .env.local > .env, same as serve.js/vite).

On dotenv – I actually started this PR by loading the whole env in, but that's exactly what caused problems: it clobbers the dispatcher-set values like the e2e NEXT_PUBLIC_IS_PLATFORM override, which is why it ended up only pulling the one key.

alaister added 2 commits June 23, 2026 22:22
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.

@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: 1

🤖 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/scripts/lib/env.js`:
- Around line 41-44: The bare catch block in the readFileSync error handling
swallows all filesystem errors including permission and IO errors, which can
silently drop environment values. Modify the catch block to check if the caught
error has a code property equal to ENOENT (file not found), and only then
continue; for all other errors (permission denied, IO errors, etc.), rethrow the
error to prevent silent failures. This ensures only missing files are gracefully
skipped while real filesystem failures are properly surfaced.
🪄 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: c685b0cd-e08c-4e0c-89a8-6cf6573e84f1

📥 Commits

Reviewing files that changed from the base of the PR and between f9699ce and 7f95f7d.

📒 Files selected for processing (3)
  • apps/studio/scripts/dispatch.js
  • apps/studio/scripts/lib/env.js
  • apps/studio/scripts/serve.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/studio/scripts/serve.js

Comment thread apps/studio/scripts/lib/env.js Resolved
alaister added 2 commits June 23, 2026 22:48
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.

@dnywh dnywh 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.

Tested an instance of @tanstack/react-table on staging: PlatformWebhooksEndpointDetails.

@alaister
alaister merged commit 9eab4f8 into master Jun 24, 2026
33 checks passed
@alaister
alaister deleted the alaister/migration-s1-foundation branch June 24, 2026 09:55
alaister added a commit that referenced this pull request Jun 25, 2026
**Stack 2/6** of the TanStack Start migration (#46424). Stacked on
**#47107** (S1) — review that first; this PR's diff is just the compat
shims.

> [!NOTE]
> Purely additive. Next never imports these files — under TanStack
they're wired in via Vite aliases (`next/*` → `@/compat/next/*`). No
routes consume them yet (that begins in stack 3).

## What's in this PR
`apps/studio/compat/next/*` — drop-in shims so the existing pages-router
code runs unchanged under TanStack Start:
- `link`, `router`, `navigation`, `head`, `image`, `legacy/image`,
`script`, `dynamic`, `server`, `_router-events` — React/runtime shims
over `@tanstack/react-router`.
- `api.ts` — `toWebHandler`, which adapts a pages-router API handler
`(req, res)` into a TanStack server-route Web `fetch` handler.

## Verification
On top of S1: `studio` typecheck ✓, lint (0 errors) ✓. Next build is
unaffected (nothing imports these under tsc).


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

* **New Features**
* Added broad Next.js compatibility support for routing, links, dynamic
imports, images, scripts, head metadata, navigation hooks, server
responses, and API handlers.
* Improved handling of redirects, pathname/search params, base paths,
and event callbacks for smoother app behavior.

* **Tests**
* Added coverage for URL resolution and dynamic route interpolation to
verify Next-style routing behavior.
<!-- 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 added a commit that referenced this pull request Jul 10, 2026
) (#47119)

**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` — adds `framework:
[next, tanstack]` to the test/report matrices and sets
`STUDIO_FRAMEWORK` (consumed by `scripts/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.

## ⚠️ Depends on #47657 (merge that first)

The `tanstack` shard needs the Monaco loader fix in **#47657** to be on
master. Quick version: master's #47182 re-nested the Monaco assets under
`public/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:
1. #47657 → master
2. re-merge master into here (I'll cascade it)
3. `tanstack` shard goes green → merge this

## ⚠️ Branch-protection note

This 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 `next` shards already pass
here; the `tanstack` shards pass once the Monaco fix is on master.

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

* **New Features**
* Integration overview markdown can now be loaded more reliably from a
synchronized on-disk registry (raw markdown support).

* **Bug Fixes**
* Navigation, redirects, and prefetch now preserve query strings and
hash fragments more consistently using Next-like semantics (including
repeated keys, empty clearing, and lossless encoding like newlines).
* Improved internal-link/router compatibility for Next-style `?`/`#`
targets and base-path handling.
* Edge Functions diff tab matching works correctly in the browser
without Node-specific path utilities.
<!-- 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

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants