π OpenHands: AI-Driven Development
feat: replace ENABLE_ONBOARDING with OH_ENABLE_ONBOARDING server flag (#14197)
HeyItsChloed7312691aee1
diff --git a/enterprise/server/config.py b/enterprise/server/config.pyindex c21db1eafa..ba73541599 100644--- a/enterprise/server/config.py+++ b/enterprise/server/config.py@@ -80,6 +80,7 @@ class SaaSServerConfig(ServerConfig):enable_jira = ENABLE_JIRAenable_jira_dc = ENABLE_JIRA_DCenable_linear = ENABLE_LINEAR+ enable_onboarding = os.environ.get('OH_ENABLE_ONBOARDING', 'false') == 'true'app_slug: None | str = None@@ -171,6 +172,7 @@ class SaaSServerConfig(ServerConfig):'ENABLE_JIRA_DC': self.enable_jira_dc,'ENABLE_LINEAR': self.enable_linear,'DEPLOYMENT_MODE': DEPLOYMENT_MODE,+ 'ENABLE_ONBOARDING': self.enable_onboarding,},'PROVIDERS_CONFIGURED': providers_configured,}diff --git a/frontend/__tests__/components/chat/expandable-message.test.tsx b/frontend/__tests__/components/chat/expandable-message.test.tsxindex 96f5f8ee4a..740a1e8c01 100644--- a/frontend/__tests__/components/chat/expandable-message.test.tsx+++ b/frontend/__tests__/components/chat/expandable-message.test.tsx@@ -125,6 +125,7 @@ describe("ExpandableMessage", () => {hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,},});const RouterStub = createRoutesStub([diff --git a/frontend/__tests__/components/features/onboarding/onboarding-form.test.tsx b/frontend/__tests__/components/features/onboarding/onboarding-form.test.tsxindex 6af305e8c1..8d589ae65b 100644--- a/frontend/__tests__/components/features/onboarding/onboarding-form.test.tsx+++ b/frontend/__tests__/components/features/onboarding/onboarding-form.test.tsx@@ -58,11 +58,7 @@ vi.mock("#/api/option-service/option-service.api", () => ({},}));-// Mock feature flag - enable onboarding by default for tests-const mockEnableOnboarding = vi.fn(() => true);-vi.mock("#/utils/feature-flags", () => ({- ENABLE_ONBOARDING: () => mockEnableOnboarding(),-}));+const renderOnboardingForm = async () => {const queryClient = new QueryClient({@@ -602,15 +598,13 @@ describe("onboarding-form clientLoader", () => {mockQueryClientGetData.mockReset();mockQueryClientSetData.mockReset();mockGetConfig.mockReset();- mockEnableOnboarding.mockReturnValue(true);});describe("redirect behavior", () => {- it("should redirect to / when ENABLE_ONBOARDING feature flag is false", async () => {- mockEnableOnboarding.mockReturnValue(false);+ it("should redirect to / when enable_onboarding feature flag is false", async () => {const saasConfig = {app_mode: "saas",- feature_flags: { deployment_mode: "cloud" },+ feature_flags: { deployment_mode: "cloud", enable_onboarding: false },};mockQueryClientGetData.mockReturnValue(saasConfig);@@ -624,7 +618,7 @@ describe("onboarding-form clientLoader", () => {it("should redirect to / when app_mode is oss", async () => {const ossConfig = {app_mode: "oss",- feature_flags: { deployment_mode: undefined },+ feature_flags: { deployment_mode: undefined, enable_onboarding: true },};mockQueryClientGetData.mockReturnValue(ossConfig);@@ -638,7 +632,7 @@ describe("onboarding-form clientLoader", () => {it("should redirect to / when app_mode is undefined", async () => {const undefinedConfig = {app_mode: undefined,- feature_flags: { deployment_mode: "cloud" },+ feature_flags: { deployment_mode: "cloud", enable_onboarding: true },};mockQueryClientGetData.mockReturnValue(undefinedConfig);@@ -660,10 +654,10 @@ describe("onboarding-form clientLoader", () => {expect((result as Response).headers.get("Location")).toBe("/");});- it("should allow access and return config when app_mode is saas with cloud deployment", async () => {+ it("should allow access and return config when app_mode is saas with cloud deployment and enable_onboarding is true", async () => {const saasCloudConfig = {app_mode: "saas",- feature_flags: { deployment_mode: "cloud" },+ feature_flags: { deployment_mode: "cloud", enable_onboarding: true },};mockQueryClientGetData.mockReturnValue(saasCloudConfig);@@ -672,10 +666,10 @@ describe("onboarding-form clientLoader", () => {expect(result).toEqual({ config: saasCloudConfig });});- it("should allow access and return config when app_mode is saas with self_hosted deployment", async () => {+ it("should allow access and return config when app_mode is saas with self_hosted deployment and enable_onboarding is true", async () => {const saasSelfHostedConfig = {app_mode: "saas",- feature_flags: { deployment_mode: "self_hosted" },+ feature_flags: { deployment_mode: "self_hosted", enable_onboarding: true },};mockQueryClientGetData.mockReturnValue(saasSelfHostedConfig);@@ -689,7 +683,7 @@ describe("onboarding-form clientLoader", () => {it("should use cached config from queryClient when available", async () => {const cachedConfig = {app_mode: "saas",- feature_flags: { deployment_mode: "cloud" },+ feature_flags: { deployment_mode: "cloud", enable_onboarding: true },};mockQueryClientGetData.mockReturnValue(cachedConfig);@@ -702,7 +696,7 @@ describe("onboarding-form clientLoader", () => {it("should fetch config from OptionService when not cached", async () => {const fetchedConfig = {app_mode: "saas",- feature_flags: { deployment_mode: "cloud" },+ feature_flags: { deployment_mode: "cloud", enable_onboarding: true },};mockQueryClientGetData.mockReturnValue(null);mockGetConfig.mockResolvedValue(fetchedConfig);diff --git a/frontend/__tests__/components/features/payment/payment-form.test.tsx b/frontend/__tests__/components/features/payment/payment-form.test.tsxindex 48979d3c52..ecb26e8c9b 100644--- a/frontend/__tests__/components/features/payment/payment-form.test.tsx+++ b/frontend/__tests__/components/features/payment/payment-form.test.tsx@@ -41,6 +41,7 @@ describe("PaymentForm", () => {hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,},});});diff --git a/frontend/__tests__/components/features/sidebar/sidebar.test.tsx b/frontend/__tests__/components/features/sidebar/sidebar.test.tsxindex 4f9249592c..f0b17e54c2 100644--- a/frontend/__tests__/components/features/sidebar/sidebar.test.tsx+++ b/frontend/__tests__/components/features/sidebar/sidebar.test.tsx@@ -32,6 +32,7 @@ const createMockConfig = (hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,...featureFlagOverrides,},providers_configured: [],diff --git a/frontend/__tests__/components/features/user/user-context-menu.test.tsx b/frontend/__tests__/components/features/user/user-context-menu.test.tsxindex a1953bbb03..4281fbbbe6 100644--- a/frontend/__tests__/components/features/user/user-context-menu.test.tsx+++ b/frontend/__tests__/components/features/user/user-context-menu.test.tsx@@ -186,6 +186,7 @@ describe("UserContextMenu", () => {hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,},}),);@@ -229,6 +230,7 @@ describe("UserContextMenu", () => {hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,},}),);@@ -279,6 +281,7 @@ describe("UserContextMenu", () => {hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,},}),);@@ -343,6 +346,7 @@ describe("UserContextMenu", () => {hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,},}),);@@ -372,6 +376,7 @@ describe("UserContextMenu", () => {hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,},}),);@@ -477,6 +482,7 @@ describe("UserContextMenu", () => {hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,},}),);@@ -719,6 +725,7 @@ describe("UserContextMenu", () => {hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,},}),);@@ -772,6 +779,7 @@ describe("UserContextMenu", () => {hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,},}),);@@ -812,6 +820,7 @@ describe("UserContextMenu", () => {hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,},}),);@@ -841,6 +850,7 @@ describe("UserContextMenu", () => {hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,},}),);diff --git a/frontend/__tests__/routes/_oh.test.tsx b/frontend/__tests__/routes/_oh.test.tsxindex c12f278356..147fa638ed 100644--- a/frontend/__tests__/routes/_oh.test.tsx+++ b/frontend/__tests__/routes/_oh.test.tsx@@ -25,6 +25,7 @@ describe("frontend/routes/_oh", () => {hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,};return {@@ -145,6 +146,7 @@ describe("frontend/routes/_oh", () => {hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,},});@@ -186,6 +188,7 @@ describe("frontend/routes/_oh", () => {hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,},});useConfigMock.mockReturnValue({@@ -277,6 +280,7 @@ describe("frontend/routes/_oh", () => {hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,},});useConfigMock.mockReturnValue({diff --git a/frontend/__tests__/routes/billing.test.tsx b/frontend/__tests__/routes/billing.test.tsxindex a10eba83db..8f018b1c5e 100644--- a/frontend/__tests__/routes/billing.test.tsx+++ b/frontend/__tests__/routes/billing.test.tsx@@ -133,6 +133,7 @@ describe("Billing Route", () => {hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,...featureFlags,},}),diff --git a/frontend/__tests__/routes/git-settings.test.tsx b/frontend/__tests__/routes/git-settings.test.tsxindex 96b821e770..a435b16d57 100644--- a/frontend/__tests__/routes/git-settings.test.tsx+++ b/frontend/__tests__/routes/git-settings.test.tsx@@ -25,6 +25,7 @@ const VALID_OSS_CONFIG: WebClientConfig = {hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,},providers_configured: [],maintenance_start_time: null,@@ -50,6 +51,7 @@ const VALID_SAAS_CONFIG: WebClientConfig = {hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,},providers_configured: [],maintenance_start_time: null,diff --git a/frontend/__tests__/routes/home-screen.test.tsx b/frontend/__tests__/routes/home-screen.test.tsxindex c670c6f466..2e18671dce 100644--- a/frontend/__tests__/routes/home-screen.test.tsx+++ b/frontend/__tests__/routes/home-screen.test.tsx@@ -24,6 +24,7 @@ const { DEFAULT_FEATURE_FLAGS, useIsAuthedMock, useConfigMock, mockUseAppMode }hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,};return {diff --git a/frontend/__tests__/routes/login.test.tsx b/frontend/__tests__/routes/login.test.tsxindex 5d7a9f27d0..b26f0c67fc 100644--- a/frontend/__tests__/routes/login.test.tsx+++ b/frontend/__tests__/routes/login.test.tsx@@ -155,6 +155,7 @@ describe("LoginPage", () => {hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,},});@@ -222,6 +223,7 @@ describe("LoginPage", () => {hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,},});@@ -261,6 +263,7 @@ describe("LoginPage", () => {hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,},});@@ -424,6 +427,7 @@ describe("LoginPage", () => {hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,},});diff --git a/frontend/__tests__/routes/manage-org.test.tsx b/frontend/__tests__/routes/manage-org.test.tsxindex a72d963a3e..5a37bcd8ad 100644--- a/frontend/__tests__/routes/manage-org.test.tsx+++ b/frontend/__tests__/routes/manage-org.test.tsx@@ -173,6 +173,7 @@ describe("Manage Org Route", () => {hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,},}),);@@ -530,6 +531,7 @@ describe("Manage Org Route", () => {hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,},}),);@@ -562,6 +564,7 @@ describe("Manage Org Route", () => {hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,},}),);@@ -594,6 +597,7 @@ describe("Manage Org Route", () => {hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,},}),);@@ -627,6 +631,7 @@ describe("Manage Org Route", () => {hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,},}),);diff --git a/frontend/__tests__/routes/manage-organization-members.test.tsx b/frontend/__tests__/routes/manage-organization-members.test.tsxindex b37616eefc..865ffce70e 100644--- a/frontend/__tests__/routes/manage-organization-members.test.tsx+++ b/frontend/__tests__/routes/manage-organization-members.test.tsx@@ -112,6 +112,7 @@ describe("Manage Organization Members Route", () => {hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,},}),);diff --git a/frontend/__tests__/routes/root-layout.test.tsx b/frontend/__tests__/routes/root-layout.test.tsxindex d7e01c7920..9c6ddc4f83 100644--- a/frontend/__tests__/routes/root-layout.test.tsx+++ b/frontend/__tests__/routes/root-layout.test.tsx@@ -52,9 +52,8 @@ vi.mock("#/hooks/use-invitation", () => ({}),}));-// Mock feature flags - enable onboarding for tests that need it+// Mock feature flags - keep ENABLE_AUTOMATIONS for other testsvi.mock("#/utils/feature-flags", () => ({- ENABLE_ONBOARDING: () => true,ENABLE_AUTOMATIONS: () => false,}));@@ -208,6 +207,7 @@ describe("MainApp", () => {hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: true,},});diff --git a/frontend/__tests__/routes/settings.test.tsx b/frontend/__tests__/routes/settings.test.tsxindex f6b73010d6..337ca5d79f 100644--- a/frontend/__tests__/routes/settings.test.tsx+++ b/frontend/__tests__/routes/settings.test.tsx@@ -499,6 +499,7 @@ describe("Settings Screen", () => {hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,},}),);@@ -554,6 +555,7 @@ describe("Settings Screen", () => {hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,},}),);@@ -675,6 +677,7 @@ describe("Settings Screen", () => {hide_users_page: true,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,},};@@ -719,6 +722,7 @@ describe("Settings Screen", () => {hide_users_page: false,hide_billing_page: true,hide_integrations_page: false,+ enable_onboarding: false,},};@@ -972,6 +976,7 @@ describe("getFirstAvailablePath", () => {hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,};describe("SaaS mode", () => {@@ -1076,6 +1081,7 @@ describe("clientLoader redirect behavior", () => {hide_users_page: true,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,},};mockQueryClient.setQueryData(["web-client-config"], config);@@ -1101,6 +1107,7 @@ describe("clientLoader redirect behavior", () => {hide_users_page: false,hide_billing_page: true,hide_integrations_page: false,+ enable_onboarding: false,},};mockQueryClient.setQueryData(["web-client-config"], config);@@ -1174,6 +1181,7 @@ describe("clientLoader redirect behavior", () => {hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,},};mockQueryClient.setQueryData(["web-client-config"], config);diff --git a/frontend/src/api/option-service/option.types.ts b/frontend/src/api/option-service/option.types.tsindex 9bdb4d28e3..c4ed6fec39 100644--- a/frontend/src/api/option-service/option.types.ts+++ b/frontend/src/api/option-service/option.types.ts@@ -29,6 +29,7 @@ export interface WebClientFeatureFlags {hide_billing_page: boolean;hide_integrations_page: boolean;deployment_mode?: DeploymentMode;+ enable_onboarding: boolean;}export interface WebClientConfig {diff --git a/frontend/src/components/features/guards/onboarding-guard.tsx b/frontend/src/components/features/guards/onboarding-guard.tsxindex 2fd8759abd..4f00bf8e97 100644--- a/frontend/src/components/features/guards/onboarding-guard.tsx+++ b/frontend/src/components/features/guards/onboarding-guard.tsx@@ -1,7 +1,7 @@import React from "react";import { useLocation, useNavigate } from "react-router";import { useOnboardingStatus } from "#/hooks/query/use-onboarding-status";-import { ENABLE_ONBOARDING } from "#/utils/feature-flags";+import { useConfig } from "#/hooks/query/use-config";/*** Forces SaaS users with incomplete onboarding to /onboarding before they can@@ -9,6 +9,7 @@ import { ENABLE_ONBOARDING } from "#/utils/feature-flags";*/export function OnboardingGuard({ children }: { children: React.ReactNode }) {const { data, isLoading } = useOnboardingStatus();+ const { data: config } = useConfig();const navigate = useNavigate();const { pathname } = useLocation();@@ -16,13 +17,19 @@ export function OnboardingGuard({ children }: { children: React.ReactNode }) {if (isLoading) return;// Only redirect to onboarding if the feature flag is enabledif (- ENABLE_ONBOARDING() &&+ config?.feature_flags?.enable_onboarding &&data?.should_complete_onboarding &&pathname !== "/onboarding") {navigate("/onboarding", { replace: true });}- }, [data?.should_complete_onboarding, isLoading, pathname, navigate]);+ }, [+ config?.feature_flags?.enable_onboarding,+ data?.should_complete_onboarding,+ isLoading,+ pathname,+ navigate,+ ]);return children;}diff --git a/frontend/src/mocks/settings-handlers.ts b/frontend/src/mocks/settings-handlers.tsindex 3bff9b60cb..c56e11e06c 100644--- a/frontend/src/mocks/settings-handlers.ts+++ b/frontend/src/mocks/settings-handlers.ts@@ -52,6 +52,7 @@ export const createMockWebClientConfig = (hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,...overrides.feature_flags,},providers_configured: [],@@ -425,6 +426,7 @@ export const SETTINGS_HANDLERS = [hide_users_page: false,hide_billing_page: false,hide_integrations_page: false,+ enable_onboarding: false,},providers_configured: [],maintenance_start_time: null,diff --git a/frontend/src/routes/onboarding-form.tsx b/frontend/src/routes/onboarding-form.tsxindex e4fbe61c52..639738cc5d 100644--- a/frontend/src/routes/onboarding-form.tsx+++ b/frontend/src/routes/onboarding-form.tsx@@ -22,20 +22,19 @@ import {} from "#/api/option-service/option.types";import { queryClient } from "#/query-client-config";import OptionService from "#/api/option-service/option-service.api";-import { ENABLE_ONBOARDING } from "#/utils/feature-flags";export const clientLoader = async () => {- // Check feature flag FIRST (sync) to block access immediately without flash- if (!ENABLE_ONBOARDING()) {- return redirect("/");- }-let config = queryClient.getQueryData<WebClientConfig>(["web-client-config"]);if (!config) {config = await OptionService.getConfig();queryClient.setQueryData<WebClientConfig>(["web-client-config"], config);}+ // Check server feature flag to block access+ if (!config?.feature_flags?.enable_onboarding) {+ return redirect("/");+ }+// Only allow access to onboarding for SaaS mode (cloud or self-hosted)// OSS users should never reach /onboardingif (config?.app_mode !== "saas") {diff --git a/frontend/src/utils/feature-flags.ts b/frontend/src/utils/feature-flags.tsindex e0483cec31..5cdd19f9ef 100644--- a/frontend/src/utils/feature-flags.ts+++ b/frontend/src/utils/feature-flags.ts@@ -20,4 +20,3 @@ export const ENABLE_TRAJECTORY_REPLAY = () =>export const ENABLE_SANDBOX_GROUPING = () =>loadFeatureFlag("SANDBOX_GROUPING");export const ENABLE_AUTOMATIONS = () => loadFeatureFlag("AUTOMATIONS");-export const ENABLE_ONBOARDING = () => loadFeatureFlag("ONBOARDING");diff --git a/openhands/app_server/web_client/default_web_client_config_injector.py b/openhands/app_server/web_client/default_web_client_config_injector.pyindex 6d74678b05..61d3803fa2 100644--- a/openhands/app_server/web_client/default_web_client_config_injector.py+++ b/openhands/app_server/web_client/default_web_client_config_injector.py@@ -111,9 +111,9 @@ def _get_feature_flags() -> WebClientFeatureFlags:"""Get feature flags from environment variables.Reads ENABLE_BILLING, HIDE_LLM_SETTINGS, ENABLE_JIRA, ENABLE_JIRA_DC,- ENABLE_LINEAR, HIDE_USERS_PAGE, HIDE_BILLING_PAGE, and HIDE_INTEGRATIONS_PAGE- from environment. Each flag is True only if the corresponding env var is- exactly 'true', otherwise False.+ ENABLE_LINEAR, HIDE_USERS_PAGE, HIDE_BILLING_PAGE, HIDE_INTEGRATIONS_PAGE,+ and OH_ENABLE_ONBOARDING from environment. Each flag is True only if the+ corresponding env var is exactly 'true', otherwise False."""return WebClientFeatureFlags(enable_billing=os.getenv('ENABLE_BILLING', 'false') == 'true',@@ -124,6 +124,7 @@ def _get_feature_flags() -> WebClientFeatureFlags:hide_users_page=os.getenv('HIDE_USERS_PAGE', 'false') == 'true',hide_billing_page=os.getenv('HIDE_BILLING_PAGE', 'false') == 'true',hide_integrations_page=os.getenv('HIDE_INTEGRATIONS_PAGE', 'false') == 'true',+ enable_onboarding=os.getenv('OH_ENABLE_ONBOARDING', 'false') == 'true',)diff --git a/openhands/app_server/web_client/web_client_models.py b/openhands/app_server/web_client/web_client_models.pyindex 9aefdaa1c2..a141441a72 100644--- a/openhands/app_server/web_client/web_client_models.py+++ b/openhands/app_server/web_client/web_client_models.py@@ -21,6 +21,7 @@ class WebClientFeatureFlags(BaseModel):hide_billing_page: bool = Falsehide_integrations_page: bool = Falsedeployment_mode: DeploymentMode | None = None+ enable_onboarding: bool = False# This can be removed / replaced when a DeploymentMode (or similar) env var is created.@model_validator(mode='after')