`WORKSPACE_DEFAULT_APP` is ignored when set in the workspace `.env`, and workspace deploys always send `/` to Dispatch
Environment: multi-app workspace with dispatch and one app from the chat template, @agent-native/core 0.222.1, Windows 11, Node 24. The code is unchanged on main at 6f85adff10; nothing here is platform-specific.
What happens: I want the workspace root to open my own app instead of Dispatch. The multi-app-workspace skill of the builder-code-starter template (packages/core/src/templates/builder-code-starter/.agents/skills/multi-app-workspace/SKILL.md, "Default app resolution") says WORKSPACE_DEFAULT_APP wins if it names a real app.
- With
WORKSPACE_DEFAULT_APP=programsin the workspace root.env,agent-native devstill prints[workspace] Default: http://127.0.0.1:8080/dispatch, and/redirects to/dispatch. OtherWORKSPACE_*values in the same file (WORKSPACE_ORG_NAME,WORKSPACE_ORG_DOMAIN,WORKSPACE_OWNER_EMAIL) work. - Setting it in the shell (
WORKSPACE_DEFAULT_APP=programs pnpm dev) works:/redirects to/programs. - In a workspace deploy, the variable is never consulted: when a
dispatchapp exists,/always goes to/dispatch/overview.
Why:
- The gateway in
packages/core/src/cli/workspace-dev.tsreads onlyprocess.env(:677,:755) and never loads the.env. The root.envis loaded by each app's Vite config (packages/core/src/vite/client.ts:4639,loadEnv(mode, workspaceRoot, "")), so variables the apps read work from.envand the one only the gateway reads doesn't. packages/core/src/deploy/workspace-deploy.tshardcodes/ → /dispatch/overviewfor Netlify (:758) and Vercel (:845). The only knob isdeployment.workspace.rootPage, which is"redirect" | "directory"(packages/core/src/config.ts:59) and can't name an app.createwrites the same redirect (packages/core/src/cli/create.ts:4078).- Neither
WORKSPACE_DEFAULT_APPnorrootPageis mentioned inpackages/core/docs/; the template skill doesn't say the variable is dev-only or must be in the process environment.
The app id is not a way around it: it is the folder name and the mount path, and only an app with id dispatch gets the root without the variable.
Workaround: set WORKSPACE_DEFAULT_APP in the shell or in a small script that wraps pnpm dev. No workaround for deploys short of editing the generated redirects.
Possible fix:
- Have the gateway load the workspace root
.envbefore reading its own settings (without overriding variables already in the environment), the same way the apps' Vite config does. - Let deploys honor the default app: either accept an app id in
deployment.workspace.rootPage, or readWORKSPACE_DEFAULT_APPat build time, keeping/dispatchand/dispatch/→/dispatch/overview. - If the variable is meant for local dev only, say so in the main docs, with the resolution order and the fact that it must be in the process environment.
Tests: a gateway started with WORKSPACE_DEFAULT_APP only in the root .env redirects / to that app; the generated _redirects / Vercel routes send / to the chosen app.
Is the variable meant to apply to deploys too, or only to agent-native dev?
Thanks for the detailed report, Renan, and for pointing at the exact lines. You were right on both counts. We've opened https://github.com/BuilderIO/agent-native/pull/8661, which is in review now. It makes agent-native dev read WORKSPACE_DEFAULT_APP from the workspace root .env (a value already in your shell still wins). Netlify and Vercel deploys also use it for /, and /dispatch still goes to /dispatch/overview. The docs now describe the variable and its resolution order. So the answer to your question is that it applies to both dev and deploys.
Thanks for the report - this is fixed by https://github.com/BuilderIO/agent-native/pull/8661, which is merged and will be on beta shortly.