Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix: scope the settings nav to Application when locked to Cloud (#17045)

Hiep Led1dc7b95c2e7
diff --git a/.pr/17010-readiness-heading-evidence.png b/.pr/17010-readiness-heading-evidence.png
deleted file mode 100644
index fb7edc7b0a..0000000000
Binary files a/.pr/17010-readiness-heading-evidence.png and /dev/null differ
diff --git a/__tests__/components/features/settings/integrations-settings-link.test.tsx b/__tests__/components/features/settings/integrations-settings-link.test.tsx
new file mode 100644
index 0000000000..3a5f9221df
--- /dev/null
+++ b/__tests__/components/features/settings/integrations-settings-link.test.tsx
@@ -0,0 +1,76 @@
+import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
+import { render, screen } from "@testing-library/react";
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import {
+ __resetActiveStoreForTests,
+ setActiveSelection,
+ setRegisteredBackends,
+} from "#/api/backend-registry/active-store";
+import type { Backend } from "#/api/backend-registry/types";
+import { ActiveBackendProvider } from "#/contexts/active-backend-context";
+import { IntegrationsSettingsLink } from "#/components/features/settings/integrations-settings-link";
+
+const cloudBackend: Backend = {
+ id: "cloud-1",
+ name: "OpenHands Cloud",
+ host: "https://app.all-hands.dev",
+ apiKey: "token",
+ kind: "cloud",
+};
+
+function renderWithProviders() {
+ const queryClient = new QueryClient({
+ defaultOptions: { queries: { retry: false } },
+ });
+ return render(
+ <QueryClientProvider client={queryClient}>
+ <ActiveBackendProvider>
+ <IntegrationsSettingsLink />
+ </ActiveBackendProvider>
+ </QueryClientProvider>,
+ );
+}
+
+beforeEach(() => {
+ window.localStorage.clear();
+ __resetActiveStoreForTests();
+});
+
+afterEach(() => {
+ vi.unstubAllEnvs();
+ window.localStorage.clear();
+ __resetActiveStoreForTests();
+});
+
+describe("IntegrationsSettingsLink", () => {
+ it("renders a link to {cloudHost}/settings/integrations when a cloud backend is active", () => {
+ // Arrange
+ setRegisteredBackends([cloudBackend]);
+ setActiveSelection({ backendId: cloudBackend.id });
+
+ // Act
+ renderWithProviders();
+
+ // Assert
+ const link = screen.getByTestId("settings-integrations-link");
+ expect(link).toHaveAttribute(
+ "href",
+ "https://app.all-hands.dev/settings/integrations",
+ );
+ expect(link).toHaveAttribute("target", "_blank");
+ });
+
+ it("renders nothing when the canvas is locked to a Cloud host", () => {
+ // Arrange β€” SaaS / self-hosted OHE serve the canvas with `--lock-to-cloud`;
+ // the OHE settings shell already exposes Integrations.
+ vi.stubEnv("VITE_LOCK_TO_CLOUD", "https://app.all-hands.dev");
+ setRegisteredBackends([cloudBackend]);
+ setActiveSelection({ backendId: cloudBackend.id });
+
+ // Act
+ renderWithProviders();
+
+ // Assert
+ expect(screen.queryByTestId("settings-integrations-link")).toBeNull();
+ });
+});
diff --git a/__tests__/hooks/use-settings-nav-items.test.tsx b/__tests__/hooks/use-settings-nav-items.test.tsx
index 3cdde0732a..2b95fc2b1a 100644
--- a/__tests__/hooks/use-settings-nav-items.test.tsx
+++ b/__tests__/hooks/use-settings-nav-items.test.tsx
@@ -1,5 +1,5 @@
import { renderHook } from "@testing-library/react";
-import { beforeEach, describe, expect, it, vi } from "vitest";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { OSS_NAV_ITEMS } from "#/constants/settings-nav";
import { useSettingsNavItems } from "#/hooks/use-settings-nav-items";
import { WebClientConfig } from "#/api/option-service/option.types";
@@ -63,6 +63,10 @@ describe("useSettingsNavItems", () => {
useActiveAgentProfileMock.mockReturnValue({ activeProfile: null });
});
+ afterEach(() => {
+ vi.unstubAllEnvs();
+ });
+
it("returns the LLM settings item unchanged on local backends", () => {
useConfigMock.mockReturnValue({ data: createConfig() });
@@ -176,4 +180,24 @@ describe("useSettingsNavItems", () => {
});
}
});
+
+ it("lists only the Application page when the canvas is locked to a Cloud host", () => {
+ // Arrange β€” SaaS / self-hosted OHE serve the canvas with `--lock-to-cloud`;
+ // the OHE settings shell ("All Cloud Settings") owns every other page.
+ vi.stubEnv("VITE_LOCK_TO_CLOUD", "https://app.all-hands.dev");
+ useConfigMock.mockReturnValue({ data: createConfig() });
+ useActiveBackendMock.mockReturnValue({
+ backend: { kind: "cloud" },
+ orgId: "org-123",
+ });
+
+ // Act
+ const { result } = renderHook(() => useSettingsNavItems());
+
+ // Assert
+ const paths = result.current
+ .filter((item) => item.type === "item")
+ .map((item) => (item.type === "item" ? item.item.to : null));
+ expect(paths).toEqual(["/settings/app"]);
+ });
});
diff --git a/__tests__/routes/settings-index.test.tsx b/__tests__/routes/settings-index.test.tsx
new file mode 100644
index 0000000000..0836f8296d
--- /dev/null
+++ b/__tests__/routes/settings-index.test.tsx
@@ -0,0 +1,84 @@
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import { render, screen } from "@testing-library/react";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import { createRoutesStub } from "react-router";
+import SettingsIndex from "#/routes/settings-index";
+import OptionService from "#/api/option-service/option-service.api";
+import { __resetActiveStoreForTests } from "#/api/backend-registry/active-store";
+import { ActiveBackendProvider } from "#/contexts/active-backend-context";
+
+function renderSettingsIndex() {
+ const RouterStub = createRoutesStub([
+ { path: "/settings", Component: SettingsIndex },
+ {
+ path: "/settings/agents",
+ Component: () => <div data-testid="agent-profiles-screen" />,
+ },
+ {
+ path: "/settings/app",
+ Component: () => <div data-testid="app-settings-screen" />,
+ },
+ ]);
+
+ return render(
+ <QueryClientProvider
+ client={
+ new QueryClient({ defaultOptions: { queries: { retry: false } } })
+ }
+ >
+ <ActiveBackendProvider>
+ <RouterStub initialEntries={["/settings"]} />
+ </ActiveBackendProvider>
+ </QueryClientProvider>,
+ );
+}
+
+describe("settings index route", () => {
+ beforeEach(() => {
+ vi.restoreAllMocks();
+ window.localStorage.clear();
+ __resetActiveStoreForTests();
+ vi.spyOn(OptionService, "getConfig").mockResolvedValue({
+ feature_flags: {
+ hide_llm_settings: false,
+ hide_users_page: true,
+ },
+ providers_configured: [],
+ maintenance_start_time: null,
+ recaptcha_site_key: null,
+ faulty_models: [],
+ error_message: null,
+ updated_at: new Date().toISOString(),
+ });
+ });
+
+ afterEach(() => {
+ vi.unstubAllEnvs();
+ window.localStorage.clear();
+ __resetActiveStoreForTests();
+ });
+
+ it("lands on the Agent library by default", async () => {
+ // Arrange β€” no lock-to-cloud; jsdom's default viewport is desktop width.
+ // Act
+ renderSettingsIndex();
+
+ // Assert
+ expect(
+ await screen.findByTestId("agent-profiles-screen"),
+ ).toBeInTheDocument();
+ });
+
+ it("lands on Application when the canvas is locked to a Cloud host", async () => {
+ // Arrange β€” SaaS / self-hosted OHE serve the canvas with `--lock-to-cloud`.
+ vi.stubEnv("VITE_LOCK_TO_CLOUD", "https://app.all-hands.dev");
+
+ // Act
+ renderSettingsIndex();
+
+ // Assert
+ expect(
+ await screen.findByTestId("app-settings-screen"),
+ ).toBeInTheDocument();
+ });
+});
diff --git a/__tests__/routes/settings.test.tsx b/__tests__/routes/settings.test.tsx
index 4812e85e0d..dd7a3b44eb 100644
--- a/__tests__/routes/settings.test.tsx
+++ b/__tests__/routes/settings.test.tsx
@@ -130,6 +130,40 @@ describe("settings route", () => {
expect(screen.getByTestId("app-settings-screen")).toBeInTheDocument();
});
+ it("keeps the section title of a page that is not in the listed navigation", () => {
+ // Arrange β€” the nav mock above lists only LLM + Application, mirroring a
+ // locked-to-Cloud deployment where deep-linked pages stay routable but are
+ // unlisted; the header must still describe the visited page.
+ const RouterStub = createRoutesStub([
+ {
+ path: "/settings",
+ Component: SettingsScreen,
+ children: [
+ {
+ path: "/settings/agents",
+ Component: () => <div data-testid="agent-profiles-screen" />,
+ },
+ ],
+ },
+ ]);
+
+ // Act
+ render(
+ <QueryClientProvider client={new QueryClient()}>
+ <ActiveBackendProvider>
+ <RouterStub initialEntries={["/settings/agents"]} />
+ </ActiveBackendProvider>
+ </QueryClientProvider>,
+ );
+
+ // Assert β€” "Agent" is absent from the nav mock, so its only occurrence is
+ // the page header.
+ expect(screen.getByText("SETTINGS$NAV_AGENT")).toBeInTheDocument();
+ expect(screen.getByTestId("settings-page-subtitle")).toHaveTextContent(
+ "SETTINGS$PAGE_AGENT_PROFILES_SUBLINE",
+ );
+ });
+
it.each(["/settings/llm", "/settings/condenser", "/settings/verification"])(
"renders %s directly when ACP settings are active",
async (path) => {
diff --git a/src/components/features/settings/integrations-settings-link.tsx b/src/components/features/settings/integrations-settings-link.tsx
index 07fd9cfc18..41b6cc9558 100644
--- a/src/components/features/settings/integrations-settings-link.tsx
+++ b/src/components/features/settings/integrations-settings-link.tsx
@@ -3,6 +3,7 @@ import { ExternalLink, Puzzle } from "lucide-react";
import { I18nKey } from "#/i18n/declaration";
import { useActiveBackendContext } from "#/contexts/active-backend-context";
import { isNoBackend } from "#/api/backend-registry/active-store";
+import { getLockedCloudHost } from "#/api/agent-server-config";
import { cn } from "#/utils/utils";
import {
SIDEBAR_ICON_SLOT_CLASS,
@@ -13,7 +14,9 @@ import {
/**
* Renders only for cloud backends β€” local backends have no equivalent
- * hosted integrations settings page.
+ * hosted integrations settings page. Also hidden when the canvas is locked to
+ * a Cloud host (SaaS / self-hosted OHE): the OHE settings shell behind
+ * "All Cloud Settings" already exposes Integrations (OHE-3168).
*/
export function IntegrationsSettingsLink() {
const { t } = useTranslation("openhands");
@@ -21,6 +24,7 @@ export function IntegrationsSettingsLink() {
const { backend } = active;
if (isNoBackend(backend) || backend.kind !== "cloud") return null;
+ if (getLockedCloudHost() !== null) return null;
const integrationsUrl = `${backend.host.replace(/\/+$/, "")}/settings/integrations`;
diff --git a/src/constants/settings-nav.tsx b/src/constants/settings-nav.tsx
index aeb4ebc730..9d7d800c9a 100644
--- a/src/constants/settings-nav.tsx
+++ b/src/constants/settings-nav.tsx
@@ -66,3 +66,12 @@ export const OSS_NAV_ITEMS: SettingsNavItem[] = [
subtitle: "SETTINGS$PAGE_SECRETS_SUBLINE",
},
];
+
+/**
+ * The only OSS nav entry listed when the canvas is locked to a Cloud host β€”
+ * i.e. deployed into SaaS / self-hosted OHE next to the OHE web app, whose own
+ * settings shell (reached via "All Cloud Settings") owns everything else. The
+ * other pages stay routable for in-app deep links; they are just unlisted
+ * (OHE-3168).
+ */
+export const LOCKED_CLOUD_SETTINGS_NAV_PATH = "/settings/app";
diff --git a/src/hooks/use-settings-nav-items.ts b/src/hooks/use-settings-nav-items.ts
index c1ba0c3f50..ce863ba439 100644
--- a/src/hooks/use-settings-nav-items.ts
+++ b/src/hooks/use-settings-nav-items.ts
@@ -1,8 +1,13 @@
import { useConfig } from "#/hooks/query/use-config";
-import { OSS_NAV_ITEMS, SettingsNavItem } from "#/constants/settings-nav";
+import {
+ LOCKED_CLOUD_SETTINGS_NAV_PATH,
+ OSS_NAV_ITEMS,
+ SettingsNavItem,
+} from "#/constants/settings-nav";
import { isSettingsPageHidden } from "#/utils/settings-utils";
import { I18nKey } from "#/i18n/declaration";
import { useActiveBackend } from "#/contexts/active-backend-context";
+import { getLockedCloudHost } from "#/api/agent-server-config";
export type SettingsNavRenderedItem =
| {
@@ -16,9 +21,14 @@ export function useSettingsNavItems(): SettingsNavRenderedItem[] {
const { data: config } = useConfig();
const { backend } = useActiveBackend();
const featureFlags = config?.feature_flags;
+ // Locked-to-Cloud (SaaS / self-hosted OHE) lists only the Application page;
+ // the OHE settings shell behind "All Cloud Settings" owns the rest (OHE-3168).
+ const isLockedToCloud = getLockedCloudHost() !== null;
return OSS_NAV_ITEMS.filter(
- (item) => !isSettingsPageHidden(item.to, featureFlags),
+ (item) =>
+ !isSettingsPageHidden(item.to, featureFlags) &&
+ (!isLockedToCloud || item.to === LOCKED_CLOUD_SETTINGS_NAV_PATH),
).map((item) => {
const renamedItem =
item.to === "/settings"
diff --git a/src/routes/settings-index.tsx b/src/routes/settings-index.tsx
index d63f059826..d971d4c1d7 100644
--- a/src/routes/settings-index.tsx
+++ b/src/routes/settings-index.tsx
@@ -4,6 +4,8 @@ import { useConfig } from "#/hooks/query/use-config";
import { useSettingsNavItems } from "#/hooks/use-settings-nav-items";
import { SettingsMobileHub } from "#/components/features/settings/settings-mobile-hub";
import { getFirstAvailablePath } from "#/utils/settings-utils";
+import { getLockedCloudHost } from "#/api/agent-server-config";
+import { LOCKED_CLOUD_SETTINGS_NAV_PATH } from "#/constants/settings-nav";
export default function SettingsIndex() {
const isMobile = useBreakpoint(768);
@@ -14,8 +16,12 @@ export default function SettingsIndex() {
return <SettingsMobileHub navigationItems={navigationItems} />;
}
+ // Locked-to-Cloud (SaaS / self-hosted OHE) lists only the Application page,
+ // so land there instead of the Agent library (OHE-3168).
const fallbackPath =
- getFirstAvailablePath(config?.feature_flags) ?? "/settings/app";
+ getLockedCloudHost() !== null
+ ? LOCKED_CLOUD_SETTINGS_NAV_PATH
+ : (getFirstAvailablePath(config?.feature_flags) ?? "/settings/app");
return <Navigate to={fallbackPath} replace />;
}
diff --git a/src/routes/settings.tsx b/src/routes/settings.tsx
index 402ac124a5..5316be8068 100644
--- a/src/routes/settings.tsx
+++ b/src/routes/settings.tsx
@@ -10,6 +10,7 @@ import { QUERY_KEYS, CONFIG_CACHE_OPTIONS } from "#/hooks/query/query-keys";
import { Typography } from "#/ui/typography";
import { useBreakpoint } from "#/hooks/use-breakpoint";
import { useSettingsNavItems } from "#/hooks/use-settings-nav-items";
+import { OSS_NAV_ITEMS } from "#/constants/settings-nav";
import {
getFirstAvailablePath,
isSettingsPageHidden,
@@ -47,13 +48,15 @@ function SettingsScreen() {
const [hideSectionHeader, setHideSectionHeader] = useState(false);
const { currentSectionTitle, currentSectionSubtitle } = useMemo(() => {
- const currentRenderedItem = navItems.find(
- (item) => item.type === "item" && item.item.to === location.pathname,
+ // Resolve from the full list, not the listed subset: locked-to-Cloud
+ // unlists most pages but they stay reachable via deep links (OHE-3168).
+ const currentItem = OSS_NAV_ITEMS.find(
+ (item) => item.to === location.pathname,
);
- if (currentRenderedItem?.type === "item") {
+ if (currentItem) {
return {
- currentSectionTitle: currentRenderedItem.item.text,
- currentSectionSubtitle: currentRenderedItem.item.subtitle,
+ currentSectionTitle: currentItem.text,
+ currentSectionSubtitle: currentItem.subtitle,
};
}
const firstItem = navItems.find((item) => item.type === "item");