`spawnSync` was wedging the dev path — `vite dev` would print "ready"
then exit ~1s later, taking turbo down with it. Node's synchronous
spawn blocks the event loop and doesn't pipe stdin to the child the
way an interactive dev server expects, so vite's stdin watcher saw EOF
and shut down. Async `spawn` with stdio inheritance keeps the child
interactive, and a small signal-forwarding bridge passes Ctrl-C and
friends through so killing the dispatcher still kills vite.
`build` and `start` continue to work for the same reason — they were
short-lived enough that the spawnSync flaw never showed up.
Switching from `node --env-file-if-exists=.env.local` to a hand-rolled
one-key reader. The previous shape loaded *all* of .env.local into the
parent's process.env before spawning the child, which broke e2e:
`scripts/serve.js:50` has a "don't clobber shell-set vars" guard that
treats anything pre-set in process.env as authoritative, and it can't
distinguish "really set by the shell" from "preloaded by --env-file".
So .env.test's `NEXT_PUBLIC_IS_PLATFORM=false` (the whole point of
scripts/generateLocalEnv.js) was silently overridden by .env.local's
`true`, the studio booted in platform mode, and every e2e test
auth-redirected.
The dispatcher only needs one var (STUDIO_FRAMEWORK) to pick a script.
The downstream tools (vite for build/dev, scripts/serve.js for start)
load `.env` files themselves with the correct precedence.
The top-level dev/build/start scripts now run scripts/dispatch.js, which
loads .env.local via node --env-file-if-exists and execs either the
:next or :tanstack variant based on STUDIO_FRAMEWORK. Locally the env
var lives in apps/studio/.env.local (gitignored) so the developer's
machine opts into TanStack; Vercel's Next.js prod project leaves it
unset and gets the next path. Adds :tanstack variants alongside the
existing :next ones for explicit selection.