Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix: block hidden Canvas settings pages when locked to a Cloud host (#17866)

Hiep Le8045f8bd7212
diff --git a/__tests__/hooks/use-settings-nav-items.test.tsx b/__tests__/hooks/use-settings-nav-items.test.tsx
index 033d1f5afb..2b95fc2b1a 100644
--- a/__tests__/hooks/use-settings-nav-items.test.tsx
+++ b/__tests__/hooks/use-settings-nav-items.test.tsx
@@ -181,9 +181,9 @@ describe("useSettingsNavItems", () => {
}
});
- it("lists every Canvas settings page when locked to an organization Cloud host", () => {
+ 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 Cloud settings shell stays reachable through "All Cloud Settings".
+ // 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({
@@ -198,6 +198,6 @@ describe("useSettingsNavItems", () => {
const paths = result.current
.filter((item) => item.type === "item")
.map((item) => (item.type === "item" ? item.item.to : null));
- expect(paths).toEqual(OSS_NAV_ITEMS.map((item) => item.to));
+ expect(paths).toEqual(["/settings/app"]);
});
});
diff --git a/src/components/features/chat/chat-interface.tsx b/src/components/features/chat/chat-interface.tsx
index c0d40d803b..0ff6f9516a 100644
--- a/src/components/features/chat/chat-interface.tsx
+++ b/src/components/features/chat/chat-interface.tsx
@@ -3,6 +3,7 @@ import { useNavigate } from "react-router";
import { useTracking } from "#/hooks/use-tracking";
import { useTranslation } from "react-i18next";
import { isAcpAuthErrorCode } from "#/utils/acp-error-codes";
+import { getLockedCloudHost } from "#/api/agent-server-config";
import { convertImageToBase64 } from "#/utils/convert-image-to-base-64";
import { createChatMessage } from "#/services/chat-service";
import { BtwMessages } from "./btw-messages";
@@ -611,8 +612,10 @@ export function ChatInterface() {
? () => conversationWebSocket?.reconnect()
: undefined
}
+ // Locked-to-Cloud blocks the Canvas agent settings page
+ // (OHE-3457).
onReauth={
- isAcpAuthErrorCode(errorCode)
+ isAcpAuthErrorCode(errorCode) && getLockedCloudHost() === null
? () => navigate("/settings/agents")
: undefined
}
diff --git a/src/components/features/chat/components/chat-input-actions.tsx b/src/components/features/chat/components/chat-input-actions.tsx
index 6c1298a136..45535d5620 100644
--- a/src/components/features/chat/components/chat-input-actions.tsx
+++ b/src/components/features/chat/components/chat-input-actions.tsx
@@ -25,6 +25,8 @@ import { useResumeConversation } from "#/hooks/mutation/use-resume-conversation"
import { useActiveBackend } from "#/contexts/active-backend-context";
import { useAgentProfiles } from "#/hooks/query/use-agent-profiles";
import { useChatInputModelState } from "#/hooks/use-chat-input-model-state";
+import { useChatInputLlmProfileState } from "#/hooks/use-chat-input-llm-profile-state";
+import { getLockedCloudHost } from "#/api/agent-server-config";
import { useConversationStore } from "#/stores/conversation-store";
import { useAgentState } from "#/hooks/use-agent-state";
import { AgentState } from "#/types/agent-state";
@@ -73,6 +75,7 @@ export function ChatInputActions({
const { backend } = useActiveBackend();
const isCloud = backend.kind === "cloud";
const modelState = useChatInputModelState();
+ const llmProfileState = useChatInputLlmProfileState();
// Agent-profile switching lives in the "+" tools menu while the conversation
// hasn't started (OSS-5735) β€” the pill itself is always an LLM selector. The
// gate is computed here (not in the menu) so ToolsContextMenu only mounts the
@@ -223,10 +226,27 @@ export function ChatInputActions({
const showAddFileInline = true;
const showAgentStatusInline = actionsRowWidth >= 360;
+ // Which chat-input LLM picker to show β€” the constrained ACP model picker or
+ // the LLM-profile picker (unit-tested in `resolve-picker-kind.test.ts`).
+ const pickerKind = resolvePickerKind({ isAcp: modelState.isAcpContext });
+
+ // Locked-to-Cloud drops the settings link from the Model menu (OHE-3457),
+ // so the overflow entry stays only while the menu still has rows β€” the same
+ // conditions ChatInputModelMenuContent / ChatInputLlmProfileMenuContent use.
+ const hasModelMenuRows =
+ pickerKind === "model"
+ ? modelState.showAcpPicker || Boolean(modelState.displayModel)
+ : (llmProfileState.canSwitchProfile &&
+ llmProfileState.profiles.length > 0) ||
+ (!llmProfileState.canSwitchProfile &&
+ Boolean(llmProfileState.currentProfileName));
+ const showOverflowModel =
+ !showModelInline && (getLockedCloudHost() === null || hasModelMenuRows);
+
const hasOverflowItems =
!showAddFileInline ||
(showChangeAgentButton && !showCodeInline) ||
- !showModelInline;
+ showOverflowModel;
React.useEffect(() => {
if (!hasOverflowItems) {
@@ -250,10 +270,6 @@ export function ChatInputActions({
setIsOverflowOpen(false);
};
- // Which chat-input LLM picker to show β€” the constrained ACP model picker or
- // the LLM-profile picker (unit-tested in `resolve-picker-kind.test.ts`).
- const pickerKind = resolvePickerKind({ isAcp: modelState.isAcpContext });
-
// Shared styling for the settings link inside the overflow submenu content.
const overflowSettingsLinkClassName = cn(
"group",
@@ -373,7 +389,7 @@ export function ChatInputActions({
)}
</div>
)}
- {!showModelInline && (
+ {showOverflowModel && (
<div className="relative group/overflow-model">
<ContextMenuListItem
testId="overflow-model-button"
diff --git a/src/components/features/chat/components/chat-input-llm-profile-picker.tsx b/src/components/features/chat/components/chat-input-llm-profile-picker.tsx
index 6a784ada1f..a8b1d10b9c 100644
--- a/src/components/features/chat/components/chat-input-llm-profile-picker.tsx
+++ b/src/components/features/chat/components/chat-input-llm-profile-picker.tsx
@@ -12,6 +12,7 @@ import { Divider } from "#/ui/divider";
import { Typography } from "#/ui/typography";
import { I18nKey } from "#/i18n/declaration";
import { cn } from "#/utils/utils";
+import { getLockedCloudHost } from "#/api/agent-server-config";
import { chatInputPillButtonClassName } from "#/utils/form-control-classes";
import { useFreeModels } from "#/hooks/query/use-free-models";
import { formatModelPillLabel } from "#/utils/format-model-name";
@@ -60,6 +61,8 @@ export function ChatInputLlmProfileMenuContent({
// uses when the ACP picker is gated off.
const showProfileList = canSwitchProfile && profiles.length > 0;
const readOnlyProfileName = canSwitchProfile ? null : currentProfileName;
+ // Locked-to-Cloud blocks the Canvas LLM page this links to (OHE-3457).
+ const showSettingsLink = getLockedCloudHost() === null;
const handleSelect = (profileName: string) => {
selectProfile(profileName);
@@ -143,27 +146,29 @@ export function ChatInputLlmProfileMenuContent({
</div>
</li>
)}
- {(showProfileList || readOnlyProfileName) && (
+ {showSettingsLink && (showProfileList || readOnlyProfileName) && (
<Divider inset={dividerInset} />
)}
- <li className="text-sm">
- <NavigationLink
- to="/settings/llm"
- onClick={onClose}
- className={cn(
- "flex h-7.5 items-center gap-2 rounded p-2 leading-5 text-foreground hover:bg-interactive-hover transition-colors",
- settingsLinkClassName,
- )}
- >
- <SettingsGearIcon
- width={16}
- height={16}
- className={cn("shrink-0", settingsIconClassName)}
- aria-hidden
- />
- <span>{t(I18nKey.SETTINGS$LLM_PROFILES)}</span>
- </NavigationLink>
- </li>
+ {showSettingsLink && (
+ <li className="text-sm">
+ <NavigationLink
+ to="/settings/llm"
+ onClick={onClose}
+ className={cn(
+ "flex h-7.5 items-center gap-2 rounded p-2 leading-5 text-foreground hover:bg-interactive-hover transition-colors",
+ settingsLinkClassName,
+ )}
+ >
+ <SettingsGearIcon
+ width={16}
+ height={16}
+ className={cn("shrink-0", settingsIconClassName)}
+ aria-hidden
+ />
+ <span>{t(I18nKey.SETTINGS$LLM_PROFILES)}</span>
+ </NavigationLink>
+ </li>
+ )}
</>
);
}
diff --git a/src/components/features/chat/components/chat-input-model.tsx b/src/components/features/chat/components/chat-input-model.tsx
index 1c5e54205d..bab1fbd78a 100644
--- a/src/components/features/chat/components/chat-input-model.tsx
+++ b/src/components/features/chat/components/chat-input-model.tsx
@@ -15,6 +15,7 @@ import { Divider } from "#/ui/divider";
import { Typography } from "#/ui/typography";
import { I18nKey } from "#/i18n/declaration";
import { cn } from "#/utils/utils";
+import { getLockedCloudHost } from "#/api/agent-server-config";
import { chatInputPillButtonClassName } from "#/utils/form-control-classes";
import React from "react";
@@ -52,6 +53,8 @@ export function ChatInputModelMenuContent({
const { t } = useTranslation("openhands");
const switchAcpModel = useSwitchAcpModel();
const hasModelRows = model.showAcpPicker || Boolean(model.displayModel);
+ // Locked-to-Cloud blocks the Canvas settings pages this links to (OHE-3457).
+ const showSettingsLink = getLockedCloudHost() === null;
const handleSelectAcpModel = (modelId: string) => {
if (modelId !== model.currentModelId) {
@@ -116,25 +119,27 @@ export function ChatInputModelMenuContent({
</div>
</li>
) : null}
- {hasModelRows && <Divider inset={dividerInset} />}
- <li className="text-sm">
- <NavigationLink
- to={model.destinationPath}
- onClick={onClose}
- className={cn(
- "flex h-7.5 items-center gap-2 rounded p-2 leading-5 text-foreground hover:bg-interactive-hover transition-colors",
- settingsLinkClassName,
- )}
- >
- <SettingsGearIcon
- width={16}
- height={16}
- className={cn("shrink-0", settingsIconClassName)}
- aria-hidden
- />
- <span>{model.destinationLabel}</span>
- </NavigationLink>
- </li>
+ {showSettingsLink && hasModelRows && <Divider inset={dividerInset} />}
+ {showSettingsLink && (
+ <li className="text-sm">
+ <NavigationLink
+ to={model.destinationPath}
+ onClick={onClose}
+ className={cn(
+ "flex h-7.5 items-center gap-2 rounded p-2 leading-5 text-foreground hover:bg-interactive-hover transition-colors",
+ settingsLinkClassName,
+ )}
+ >
+ <SettingsGearIcon
+ width={16}
+ height={16}
+ className={cn("shrink-0", settingsIconClassName)}
+ aria-hidden
+ />
+ <span>{model.destinationLabel}</span>
+ </NavigationLink>
+ </li>
+ )}
</>
);
}
diff --git a/src/components/features/chat/components/chat-input-profile-picker.tsx b/src/components/features/chat/components/chat-input-profile-picker.tsx
index e9290d3f9a..1484a8b4ab 100644
--- a/src/components/features/chat/components/chat-input-profile-picker.tsx
+++ b/src/components/features/chat/components/chat-input-profile-picker.tsx
@@ -8,6 +8,7 @@ import { Divider } from "#/ui/divider";
import { Typography } from "#/ui/typography";
import { I18nKey } from "#/i18n/declaration";
import { cn } from "#/utils/utils";
+import { getLockedCloudHost } from "#/api/agent-server-config";
interface ChatInputProfileMenuContentProps {
onClose: () => void;
@@ -38,6 +39,9 @@ export function ChatInputProfileMenuContent({
isSwitching,
selectProfile,
} = useChatInputProfileState();
+ // Locked-to-Cloud blocks the Canvas agent profiles page this links to
+ // (OHE-3457).
+ const showSettingsLink = getLockedCloudHost() === null;
const handleSelect = (profile: (typeof profiles)[number]) => {
selectProfile(profile);
@@ -103,25 +107,29 @@ export function ChatInputProfileMenuContent({
)}
</>
)}
- {profiles.length > 0 && <Divider inset={dividerInset} />}
- <li className="text-sm">
- <NavigationLink
- to="/settings/agents"
- onClick={onClose}
- className={cn(
- "flex h-7.5 items-center gap-2 rounded p-2 leading-5 text-foreground hover:bg-interactive-hover transition-colors",
- settingsLinkClassName,
- )}
- >
- <SettingsGearIcon
- width={16}
- height={16}
- className={cn("shrink-0", settingsIconClassName)}
- aria-hidden
- />
- <span>{t(I18nKey.CHAT$MANAGE_AGENT_PROFILES)}</span>
- </NavigationLink>
- </li>
+ {showSettingsLink && profiles.length > 0 && (
+ <Divider inset={dividerInset} />
+ )}
+ {showSettingsLink && (
+ <li className="text-sm">
+ <NavigationLink
+ to="/settings/agents"
+ onClick={onClose}
+ className={cn(
+ "flex h-7.5 items-center gap-2 rounded p-2 leading-5 text-foreground hover:bg-interactive-hover transition-colors",
+ settingsLinkClassName,
+ )}
+ >
+ <SettingsGearIcon
+ width={16}
+ height={16}
+ className={cn("shrink-0", settingsIconClassName)}
+ aria-hidden
+ />
+ <span>{t(I18nKey.CHAT$MANAGE_AGENT_PROFILES)}</span>
+ </NavigationLink>
+ </li>
+ )}
</>
);
}
diff --git a/src/components/features/home/llm-not-configured-banner.tsx b/src/components/features/home/llm-not-configured-banner.tsx
index b3a103ea29..bbd413a801 100644
--- a/src/components/features/home/llm-not-configured-banner.tsx
+++ b/src/components/features/home/llm-not-configured-banner.tsx
@@ -5,6 +5,7 @@ import { useNavigation } from "#/context/navigation-context";
import { useLlmConfigured } from "#/hooks/use-llm-configured";
import { BrandButton } from "#/components/features/settings/brand-button";
import { Typography } from "#/ui/typography";
+import { getLockedCloudHost } from "#/api/agent-server-config";
/**
* Warns the user on the home screen when the active agent has no usable LLM β€”
@@ -40,15 +41,18 @@ export function LlmNotConfiguredBanner() {
</Typography.Text>
</div>
- <BrandButton
- testId="home-llm-not-configured-action"
- type="button"
- variant="primary"
- className="w-fit shrink-0 self-start whitespace-nowrap sm:self-auto"
- onClick={() => navigate("/settings/llm")}
- >
- {t(I18nKey.HOME$LLM_NOT_CONFIGURED_ACTION)}
- </BrandButton>
+ {/* Locked-to-Cloud blocks the Canvas LLM page (OHE-3457). */}
+ {getLockedCloudHost() === null && (
+ <BrandButton
+ testId="home-llm-not-configured-action"
+ type="button"
+ variant="primary"
+ className="w-fit shrink-0 self-start whitespace-nowrap sm:self-auto"
+ onClick={() => navigate("/settings/llm")}
+ >
+ {t(I18nKey.HOME$LLM_NOT_CONFIGURED_ACTION)}
+ </BrandButton>
+ )}
</div>
);
}
diff --git a/src/components/features/sidebar/use-sidebar-onboarding-checklist.ts b/src/components/features/sidebar/use-sidebar-onboarding-checklist.ts
index 2d3909202d..03376fca64 100644
--- a/src/components/features/sidebar/use-sidebar-onboarding-checklist.ts
+++ b/src/components/features/sidebar/use-sidebar-onboarding-checklist.ts
@@ -8,6 +8,7 @@ import { useSettings } from "#/hooks/query/use-settings";
import { useLlmProfiles } from "#/hooks/query/use-llm-profiles";
import { useLlmConfigured } from "#/hooks/use-llm-configured";
import { parseMcpConfig } from "#/utils/mcp-config";
+import { getLockedCloudHost } from "#/api/agent-server-config";
import {
isCustomizeChecklistPath,
SIDEBAR_ONBOARDING_CHECKLIST_ITEM_IDS,
@@ -111,13 +112,22 @@ export function useSidebarOnboardingChecklist() {
settings?.agent_settings?.mcp_config,
]);
+ // Locked-to-Cloud blocks the Canvas LLM and Agent settings pages these two
+ // items link to, and "customize-agent" only completes by visiting one
+ // (OHE-3457).
+ const isLockedToCloud = getLockedCloudHost() !== null;
+
const items = useMemo(
(): SidebarOnboardingChecklistItemState[] =>
- SIDEBAR_ONBOARDING_CHECKLIST_ITEM_IDS.map((id) => ({
+ SIDEBAR_ONBOARDING_CHECKLIST_ITEM_IDS.filter(
+ (id) =>
+ !isLockedToCloud ||
+ (id !== "configure-llm" && id !== "customize-agent"),
+ ).map((id) => ({
id,
isComplete: completionById[id],
})),
- [completionById],
+ [completionById, isLockedToCloud],
);
const completedCount = items.filter((item) => item.isComplete).length;
diff --git a/src/constants/settings-nav.tsx b/src/constants/settings-nav.tsx
index 1e82cad8b2..2a3ae7f1d0 100644
--- a/src/constants/settings-nav.tsx
+++ b/src/constants/settings-nav.tsx
@@ -74,11 +74,10 @@ export const OSS_NAV_ITEMS: SettingsNavItem[] = [
];
/**
- * Default page for locked-to-Cloud deployments. The full Canvas settings nav
- * remains available; "All Cloud Settings" links out to the Cloud settings shell
- * for pages Canvas does not own directly.
+ * 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
+ * (OHE-3168). The other pages are not reachable there either: the settings
+ * layout redirects them here (OHE-3457).
*/
export const LOCKED_CLOUD_SETTINGS_NAV_PATH = "/settings/app";
-export const LOCKED_CLOUD_SETTINGS_NAV_PATHS = new Set(
- OSS_NAV_ITEMS.map((item) => item.to),
-);
diff --git a/src/hooks/use-settings-nav-items.ts b/src/hooks/use-settings-nav-items.ts
index cdb266bb74..ce863ba439 100644
--- a/src/hooks/use-settings-nav-items.ts
+++ b/src/hooks/use-settings-nav-items.ts
@@ -1,6 +1,6 @@
import { useConfig } from "#/hooks/query/use-config";
import {
- LOCKED_CLOUD_SETTINGS_NAV_PATHS,
+ LOCKED_CLOUD_SETTINGS_NAV_PATH,
OSS_NAV_ITEMS,
SettingsNavItem,
} from "#/constants/settings-nav";
@@ -21,14 +21,14 @@ export function useSettingsNavItems(): SettingsNavRenderedItem[] {
const { data: config } = useConfig();
const { backend } = useActiveBackend();
const featureFlags = config?.feature_flags;
- // Locked-to-Cloud still lists the full Canvas settings nav; the Cloud shell
- // remains available through "All Cloud Settings" for Cloud-owned pages.
+ // 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) &&
- (!isLockedToCloud || LOCKED_CLOUD_SETTINGS_NAV_PATHS.has(item.to)),
+ (!isLockedToCloud || item.to === LOCKED_CLOUD_SETTINGS_NAV_PATH),
).map((item) => {
const renamedItem =
item.to === "/settings"
diff --git a/src/routes/app-settings.tsx b/src/routes/app-settings.tsx
index 6c86e04540..2375c2dee6 100644
--- a/src/routes/app-settings.tsx
+++ b/src/routes/app-settings.tsx
@@ -25,6 +25,7 @@ import { useLlmProfiles } from "#/hooks/query/use-llm-profiles";
import { useFreeModels } from "#/hooks/query/use-free-models";
import { useActiveBackend } from "#/contexts/active-backend-context";
import { formatModelNameForDisplay } from "#/utils/format-model-name";
+import { getLockedCloudHost } from "#/api/agent-server-config";
const AUTOMATIC_TITLE_LLM_PROFILE_KEY = "__automatic__";
@@ -251,12 +252,15 @@ export function AppSettingsScreen() {
);
}}
/>
- <NavigationLink
- to="/settings/llm"
- className="mt-3 inline-block text-sm text-primary hover:underline"
- >
- {t(I18nKey.SETTINGS$MANAGE_LLM_PROFILES)}
- </NavigationLink>
+ {/* Locked-to-Cloud blocks the Canvas LLM page (OHE-3457). */}
+ {getLockedCloudHost() === null && (
+ <NavigationLink
+ to="/settings/llm"
+ className="mt-3 inline-block text-sm text-primary hover:underline"
+ >
+ {t(I18nKey.SETTINGS$MANAGE_LLM_PROFILES)}
+ </NavigationLink>
+ )}
</div>
<VoiceInputSettings />
diff --git a/src/routes/settings.tsx b/src/routes/settings.tsx
index 5316be8068..cb5f69f21a 100644
--- a/src/routes/settings.tsx
+++ b/src/routes/settings.tsx
@@ -1,5 +1,11 @@
import { useMemo, useState } from "react";
-import { Outlet, redirect, useLocation, useMatches } from "react-router";
+import {
+ Navigate,
+ Outlet,
+ redirect,
+ useLocation,
+ useMatches,
+} from "react-router";
import { useTranslation } from "react-i18next";
import { Route } from "./+types/settings";
import OptionService from "#/api/option-service/option-service.api";
@@ -10,12 +16,16 @@ 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 {
+ LOCKED_CLOUD_SETTINGS_NAV_PATH,
+ OSS_NAV_ITEMS,
+} from "#/constants/settings-nav";
import {
getFirstAvailablePath,
isSettingsPageHidden,
} from "#/utils/settings-utils";
import { SettingsSectionHeaderProvider } from "#/contexts/settings-section-header-context";
+import { getLockedCloudHost } from "#/api/agent-server-config";
export const clientLoader = async ({ request }: Route.ClientLoaderArgs) => {
const url = new URL(request.url);
@@ -48,8 +58,8 @@ function SettingsScreen() {
const [hideSectionHeader, setHideSectionHeader] = useState(false);
const { currentSectionTitle, currentSectionSubtitle } = useMemo(() => {
- // Resolve from the full list, not the listed subset: locked-to-Cloud
- // unlists most pages but they stay reachable via deep links (OHE-3168).
+ // Resolve from the full list, not the listed subset, so a page that is
+ // reachable but unlisted still gets its own title.
const currentItem = OSS_NAV_ITEMS.find(
(item) => item.to === location.pathname,
);
@@ -78,6 +88,17 @@ function SettingsScreen() {
const shouldHideTitle =
routeHandle?.hideTitle === true || isMobileHub || hideSectionHeader;
+ // Locked-to-Cloud (SaaS / self-hosted OHE) only exposes the Application
+ // page; the OHE settings shell owns the rest, so direct links to the other
+ // Canvas settings pages are sent to Application instead (OHE-3457).
+ if (
+ getLockedCloudHost() !== null &&
+ location.pathname !== "/settings" &&
+ location.pathname !== LOCKED_CLOUD_SETTINGS_NAV_PATH
+ ) {
+ return <Navigate to={LOCKED_CLOUD_SETTINGS_NAV_PATH} replace />;
+ }
+
return (
<main data-testid="settings-screen" className="min-h-0">
<SettingsSectionHeaderProvider