Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(local): give just stack bundles the same local-only flags as run_local (#9490)
teoc780f2849086
diff --git a/.agents/skills/feature-flags/SKILL.md b/.agents/skills/feature-flags/SKILL.mdindex 83e52345b1..ea6eba7b25 100644--- a/.agents/skills/feature-flags/SKILL.md+++ b/.agents/skills/feature-flags/SKILL.md@@ -39,7 +39,7 @@ Add one `defineFlag` next to its neighbors. Do not add `ENABLE_*_FLAG` /(`DEV_MODE_ENV || undefined`), not the boolean itself. If it must stay off indev, say why in a comment above it. On a remote flag, `false` is a realoverride and **skips PostHog**. On-in-local only is- `LOCAL_ONLY || undefined`.+ `LOCAL_ONLY || undefined` (the Vite dev server and `just stack` bundles).- Never invert on the flag object. If the product question is "disable X",invert at the call site (`!isFeatureEnabled(disableX)`).- Env-only exports that are used as `if (ENABLE_FOO)` must be the boolean:diff --git a/apps/web/src/lib/core/constant/featureFlags.ts b/apps/web/src/lib/core/constant/featureFlags.tsindex c671550ac8..6c97add6a3 100644--- a/apps/web/src/lib/core/constant/featureFlags.ts+++ b/apps/web/src/lib/core/constant/featureFlags.ts@@ -1,15 +1,19 @@import { analytics } from '@app/lib/analytics';/**- * This constant reflects whether the app is running locally with hot reload enabled+ * This constant reflects whether the app is running locally: under the Vite+ * dev server with hot reload (`just run_local`, `bun run dev`), or as the+ * bundle `just stack` builds, which sets `VITE_LOCAL_ONLY` so a headless+ * stack gets the same local-only flags, routes and tools.*- * @returns true in bun run dev, false otherwise+ * @returns true in bun run dev and `just stack` bundles, false otherwise** Distinct from `import.meta.env.DEV` (true under vite serve *and* local-backend- * static bundles) and `DEV_MODE_ENV` (true whenever MODE=development, including- * dev.macro.com).+ * static bundles, including test builds) and `DEV_MODE_ENV` (true whenever+ * MODE=development, including dev.macro.com).*/-export const LOCAL_ONLY = !!import.meta.hot;+export const LOCAL_ONLY =+ !!import.meta.hot || import.meta.env.VITE_LOCAL_ONLY === 'true';const parseBooleanOverride = (value: unknown): boolean | undefined =>value === 'true' ? true : value === 'false' ? false : undefined;diff --git a/apps/web/src/vite-env.d.ts b/apps/web/src/vite-env.d.tsindex 9da033169e..b9594a7907 100644--- a/apps/web/src/vite-env.d.ts+++ b/apps/web/src/vite-env.d.ts@@ -8,6 +8,8 @@ interface ImportMetaEnv {readonly VITE_SEGMENT_WRITE_KEY: string;readonly VITE_POSTHOG_API_KEY: string;+ /** `true` in bundles `just stack` builds, which count as local (`LOCAL_ONLY`). */+ readonly VITE_LOCAL_ONLY?: string;readonly VITE_OTEL_EXPORTER_URL?: string;readonly VITE_OTEL_ENV?: string;readonly VITE_ENABLE_BROWSER_OTEL?: string;diff --git a/docs/development/running-locally.md b/docs/development/running-locally.mdindex 4cc3ad6203..6057cf4d32 100644--- a/docs/development/running-locally.md+++ b/docs/development/running-locally.md@@ -467,7 +467,7 @@ If you started without the flag and suspect a stale image, press `q`. Then start## Headless Mode-`just stack` runs the same stack without an attached terminal. There is no hotkey loop and no dev server. The frontend is built once and served statically by the proxy. The whole product lives behind one origin. A finished `up` leaves only Docker containers running.+`just stack` runs the same stack without an attached terminal. There is no hotkey loop and no dev server. The frontend is built once and served statically by the proxy. The bundle counts as local, as `run_local`'s dev server does: flags, routes and tools gated on `LOCAL_ONLY` are on. The whole product lives behind one origin. A finished `up` leaves only Docker containers running.Both headless and attached startup prepare the browser WebAssembly packagesthrough `bun run dev:prepare`. A fresh worktree builds them before serving the app;diff --git a/tooling/xtask/crates/xtask_local/src/local/frontend.rs b/tooling/xtask/crates/xtask_local/src/local/frontend.rsindex 90d5940202..954f6cc376 100644--- a/tooling/xtask/crates/xtask_local/src/local/frontend.rs+++ b/tooling/xtask/crates/xtask_local/src/local/frontend.rs@@ -69,6 +69,10 @@ pub fn static_dir(instance: &Instance) -> std::path::PathBuf {/// otherwise compiles DEV from `NODE_ENV=production`, which drops local-only/// paths such as passwordless auto-login (`just run_local` uses `vite serve`,/// where DEV is already true). Headless `stack up` sets the same origin env.+///+/// `VITE_LOCAL_ONLY` makes the bundle count as local, as the dev server does+/// through `import.meta.hot`, so local-only flags, routes and tools match+/// `just run_local`.pub fn build_static(stage: &Stage, instance: &Instance, mode: Mode) -> Result<()> {prepare_dependencies(stage)?;let dist = {@@ -78,7 +82,8 @@ pub fn build_static(stage: &Stage, instance: &Instance, mode: Mode) -> Result<().env("MODE", "development").env("NODE_ENV", "production").env("VITE_LOCAL_SERVERS", "ALL")- .env("VITE_LOCAL_BACKEND_ORIGIN", "same-origin");+ .env("VITE_LOCAL_BACKEND_ORIGIN", "same-origin")+ .env("VITE_LOCAL_ONLY", "true");if mode.spec().runs_local_infra {cmd.env("VITE_AI_EDITING_WORKER_URL", "/ai-editing");}