Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(web): disable onboarding in just run_local unless --enable-onboarding (#5876)

Wolf Mermelstein157875e43db6
diff --git a/apps/web/src/features/setup/flow/useOnboardingV4Flag.ts b/apps/web/src/features/setup/flow/useOnboardingV4Flag.ts
index 2f00fc14e7..b21dcf3f9d 100644
--- a/apps/web/src/features/setup/flow/useOnboardingV4Flag.ts
+++ b/apps/web/src/features/setup/flow/useOnboardingV4Flag.ts
@@ -26,6 +26,7 @@ export type OnboardingV4Flag = {
/**
* Gate for onboarding v4, controlled by the `enable-onboarding-v4` PostHog
* flag and overridable locally with `VITE_ENABLE_ONBOARDING_V4`.
+ * `just run_local` sets that env to false unless `--enable-onboarding`.
*/
export function useOnboardingV4Flag(): Accessor<OnboardingV4Flag> {
const posthog = usePosthog();
diff --git a/apps/web/src/lib/core/constant/featureFlags.ts b/apps/web/src/lib/core/constant/featureFlags.ts
index f3d84b09a7..7439705f7b 100644
--- a/apps/web/src/lib/core/constant/featureFlags.ts
+++ b/apps/web/src/lib/core/constant/featureFlags.ts
@@ -581,13 +581,13 @@ export const BOT_MANAGEMENT_OVERRIDE =
// Onboarding v4: the full-screen stepper new users land in after signup
// (unified with /login), driving the import machinery with auto-import.
-// PostHog-gated with a dev-mode default; override with
-// VITE_ENABLE_ONBOARDING_V4. Read it through `useOnboardingV4Flag()` so the
-// gate reacts when PostHog answers (and so callers can wait instead of
-// treating "flags not loaded yet" as "off").
+// PostHog-gated; override with VITE_ENABLE_ONBOARDING_V4. Read it through
+// `useOnboardingV4Flag()` so the gate reacts when PostHog answers (and so
+// callers can wait instead of treating "flags not loaded yet" as "off").
export const ENABLE_ONBOARDING_V4_FLAG = 'enable-onboarding-v4';
// Honor an explicit VITE_ENABLE_ONBOARDING_V4=false (don't coerce it to
// undefined), else default on in dev and defer to PostHog in prod.
+// `just run_local` sets the env to false unless `--enable-onboarding`.
export const ENABLE_ONBOARDING_V4_OVERRIDE =
getFeatureFlagOverride('ENABLE_ONBOARDING_V4') ??
(DEV_MODE_ENV ? true : undefined);
diff --git a/apps/web/src/routes/Root.tsx b/apps/web/src/routes/Root.tsx
index 6875bc671c..88aa43caa6 100644
--- a/apps/web/src/routes/Root.tsx
+++ b/apps/web/src/routes/Root.tsx
@@ -36,6 +36,7 @@ import { publishLoginSuccess } from '@core/auth/login-events';
import { ChatAttachmentsInit } from '@core/component/AI/signal/globalAttachments';
import { LoadingBlock } from '@core/component/LoadingBlock';
import { ToastRegion } from '@core/component/Toast/ToastRegion';
+import { ENABLE_ONBOARDING_V4_OVERRIDE } from '@core/constant/featureFlags';
import { ChannelsContextProvider } from '@core/context/channels';
import { EmailLinksContextProvider } from '@core/context/emailLinks';
import { QuickAccessProvider } from '@core/context/quickAccess';
@@ -492,6 +493,10 @@ function InitialInteractiveOnboardingModal() {
const modalOpen = () =>
open() &&
+ // `just run_local` sets VITE_ENABLE_ONBOARDING_V4=false; without this the
+ // v4-off fallback would still open this legacy modal. Opt in with
+ // `just run_local --enable-onboarding`.
+ ENABLE_ONBOARDING_V4_OVERRIDE !== false &&
// Onboarding-v4 replaces this modal on desktop; the Layout redirect
// sends first-time users to /onboarding instead. Desktop waits for the
// flag to resolve so this doesn't flash before that redirect fires.
diff --git a/tooling/just/xtask.just b/tooling/just/xtask.just
index 3ca878e212..23fbde3a93 100644
--- a/tooling/just/xtask.just
+++ b/tooling/just/xtask.just
@@ -9,6 +9,7 @@ xtask := "cargo run --quiet --manifest-path Cargo.toml -p xtask_local --features
# just run_local # default instance
# just run_local --instance agent-a # isolated, concurrent instance
# just run_local --no-doppler --env-file ./local.env --no-frontend --no-build
+# just run_local --enable-onboarding # opt into the existing onboarding v4 flag
run_local *ARGS:
{{ xtask }} run-local "$@"
diff --git a/tooling/xtask/crates/xtask_local/src/local.rs b/tooling/xtask/crates/xtask_local/src/local.rs
index 3da21dff31..a3fb54a1cb 100644
--- a/tooling/xtask/crates/xtask_local/src/local.rs
+++ b/tooling/xtask/crates/xtask_local/src/local.rs
@@ -272,7 +272,13 @@ pub fn run_stack(mode: Mode, args: &cli::RunArgs) -> Result<()> {
stage.note("frontend disabled (--no-frontend)");
None
} else {
- frontend::start(&stage, &instance, mode, args.traces.is_some())?
+ frontend::start(
+ &stage,
+ &instance,
+ mode,
+ args.traces.is_some(),
+ args.enable_onboarding,
+ )?
};
summary::print(
diff --git a/tooling/xtask/crates/xtask_local/src/local/cli.rs b/tooling/xtask/crates/xtask_local/src/local/cli.rs
index f08888d90e..8cd5a9f9a2 100644
--- a/tooling/xtask/crates/xtask_local/src/local/cli.rs
+++ b/tooling/xtask/crates/xtask_local/src/local/cli.rs
@@ -113,6 +113,11 @@ pub struct RunArgs {
/// Do not start or serve the frontend.
#[arg(long)]
pub no_frontend: bool,
+ /// Turn on onboarding v4 for the attached vite server
+ /// (`VITE_ENABLE_ONBOARDING_V4=true`). Off by default so signing in does
+ /// not dump you into the stepper. No effect on `stack up` static bundles.
+ #[arg(long)]
+ pub enable_onboarding: bool,
/// Stream subprocess output and show per-step timings.
#[arg(long, short)]
pub verbose: bool,
diff --git a/tooling/xtask/crates/xtask_local/src/local/cli/test.rs b/tooling/xtask/crates/xtask_local/src/local/cli/test.rs
index 663810ecfb..bea8485439 100644
--- a/tooling/xtask/crates/xtask_local/src/local/cli/test.rs
+++ b/tooling/xtask/crates/xtask_local/src/local/cli/test.rs
@@ -46,6 +46,24 @@ fn stack_update_accepts_binaries_dir_with_build_aux_services() {
assert!(args.build_aux_services);
}
+#[test]
+fn run_local_defaults_onboarding_off() {
+ let cli = Cli::try_parse_from(["cargo-x", "run-local"]).unwrap();
+ let Cmd::RunLocal(args) = cli.command else {
+ panic!("expected run-local command");
+ };
+ assert!(!args.enable_onboarding);
+}
+
+#[test]
+fn run_local_accepts_enable_onboarding() {
+ let cli = Cli::try_parse_from(["cargo-x", "run-local", "--enable-onboarding"]).unwrap();
+ let Cmd::RunLocal(args) = cli.command else {
+ panic!("expected run-local command");
+ };
+ assert!(args.enable_onboarding);
+}
+
#[test]
fn stack_has_no_snapshot_verb() {
match Cli::try_parse_from(["cargo-x", "stack", "snapshot"]) {
diff --git a/tooling/xtask/crates/xtask_local/src/local/e2e.rs b/tooling/xtask/crates/xtask_local/src/local/e2e.rs
index 2a67f8d86a..644869e53f 100644
--- a/tooling/xtask/crates/xtask_local/src/local/e2e.rs
+++ b/tooling/xtask/crates/xtask_local/src/local/e2e.rs
@@ -122,6 +122,7 @@ pub fn run(args: &LocalE2eArgs) -> Result<()> {
env: EnvArgs::default(),
build: BuildArgs::default(),
no_frontend: true,
+ enable_onboarding: false,
traces: None,
verbose: false,
},
diff --git a/tooling/xtask/crates/xtask_local/src/local/frontend.rs b/tooling/xtask/crates/xtask_local/src/local/frontend.rs
index f678c1183e..9d5f5f1845 100644
--- a/tooling/xtask/crates/xtask_local/src/local/frontend.rs
+++ b/tooling/xtask/crates/xtask_local/src/local/frontend.rs
@@ -101,7 +101,12 @@ pub fn build_static(stage: &Stage, instance: &Instance, mode: Mode) -> Result<()
/// and exercises the real browser -> proxy -> collector path. Left unset
/// otherwise. This overrides the bare-dev defaults in apps/web/.env.local
/// (Vite lets process env win).
-fn dev_env(instance: &Instance, mode: Mode, traces_enabled: bool) -> Vec<(String, String)> {
+fn dev_env(
+ instance: &Instance,
+ mode: Mode,
+ traces_enabled: bool,
+ enable_onboarding: bool,
+) -> Vec<(String, String)> {
let mut env = vec![
(
"PORT".to_string(),
@@ -136,6 +141,12 @@ fn dev_env(instance: &Instance, mode: Mode, traces_enabled: bool) -> Vec<(String
"VITE_ENABLE_BROWSER_OTEL".to_string(),
traces_enabled.to_string(),
));
+ // Existing override: always set so the app's DEV_MODE default (on) does
+ // not win. `just run_local --enable-onboarding` is the opt-in.
+ env.push((
+ "VITE_ENABLE_ONBOARDING_V4".to_string(),
+ enable_onboarding.to_string(),
+ ));
env
}
@@ -211,6 +222,7 @@ pub fn start(
instance: &Instance,
mode: Mode,
traces_enabled: bool,
+ enable_onboarding: bool,
) -> Result<Option<Frontend>> {
if mode.spec().wait_backend_before_frontend {
wait_backend_ready(stage, instance)?;
@@ -260,7 +272,7 @@ pub fn start(
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.stderr(Stdio::piped());
- for (k, v) in dev_env(instance, mode, traces_enabled) {
+ for (k, v) in dev_env(instance, mode, traces_enabled, enable_onboarding) {
cmd.env(k, v);
}
let mut child = cmd.spawn().context("launching `bun run dev`")?;
diff --git a/tooling/xtask/crates/xtask_local/src/local/stack.rs b/tooling/xtask/crates/xtask_local/src/local/stack.rs
index f3fded1a9f..ecba20a85d 100644
--- a/tooling/xtask/crates/xtask_local/src/local/stack.rs
+++ b/tooling/xtask/crates/xtask_local/src/local/stack.rs
@@ -313,6 +313,7 @@ fn bootstrap_from_update(args: &UpdateArgs) -> Result<()> {
binaries_dir: args.binaries_dir.clone(),
},
no_frontend: false,
+ enable_onboarding: false,
verbose: args.verbose,
traces: None,
},