Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix: keep settings and customization usable on tablets (#17910)

Engel Nystfd60abf93087
diff --git a/__tests__/routes/extensions-hub.test.tsx b/__tests__/routes/extensions-hub.test.tsx
index cc9506faf8..129e2e8db0 100644
--- a/__tests__/routes/extensions-hub.test.tsx
+++ b/__tests__/routes/extensions-hub.test.tsx
@@ -11,7 +11,8 @@ vi.mock("react-router", () => ({
},
}));
-vi.mock("#/hooks/use-breakpoint", () => ({
+vi.mock("#/hooks/use-breakpoint", async (importOriginal) => ({
+ ...(await importOriginal<typeof import("#/hooks/use-breakpoint")>()),
useBreakpoint: () => mockUseBreakpoint(),
}));
diff --git a/src/components/features/manifest/manifest-subpage-layout.tsx b/src/components/features/manifest/manifest-subpage-layout.tsx
index 529d3317c6..74a7bee453 100644
--- a/src/components/features/manifest/manifest-subpage-layout.tsx
+++ b/src/components/features/manifest/manifest-subpage-layout.tsx
@@ -60,10 +60,10 @@ export function ManifestSubpageLayout({
children,
}: ManifestSubpageLayoutProps) {
return (
- <div className="flex h-full gap-4 md:gap-6 md:pl-8 lg:gap-10 lg:pl-10">
+ <div className="flex h-full gap-4 lg:gap-10 lg:pl-10">
<aside
data-testid={`${navTestIdBase}-desktop`}
- className="hidden md:flex md:w-65 md:shrink-0 md:flex-col md:gap-2 md:sticky md:top-8 md:self-start"
+ className="hidden lg:flex lg:w-65 lg:shrink-0 lg:flex-col lg:gap-2 lg:sticky lg:top-8 lg:self-start"
>
<span className="px-2 text-sm font-normal text-contrast">
{heading}
@@ -78,7 +78,7 @@ export function ManifestSubpageLayout({
<div className="mx-auto flex w-full min-w-0 max-w-200 flex-col gap-6">
<nav
data-testid={`${navTestIdBase}-mobile`}
- className="md:hidden flex gap-1 overflow-x-auto border-b border-border pb-2"
+ className="lg:hidden flex gap-1 overflow-x-auto border-b border-border pb-2"
>
{items.map((item) => (
<SubPageNavLink key={item.to} item={item} />
diff --git a/src/components/features/settings/settings-desktop-sidebar.tsx b/src/components/features/settings/settings-desktop-sidebar.tsx
index f715889f71..e795dbc4b8 100644
--- a/src/components/features/settings/settings-desktop-sidebar.tsx
+++ b/src/components/features/settings/settings-desktop-sidebar.tsx
@@ -31,8 +31,8 @@ export function SettingsDesktopSidebar({
<aside
data-testid="settings-navbar-desktop"
className={cn(
- "hidden md:flex md:w-65 md:shrink-0 md:flex-col md:gap-2",
- "md:sticky md:top-8 md:self-start md:pl-8",
+ "hidden lg:flex lg:w-65 lg:shrink-0 lg:flex-col lg:gap-2",
+ "lg:sticky lg:top-8 lg:self-start lg:pl-8",
)}
>
<Typography.Text className="px-2 text-sm font-normal text-contrast">
diff --git a/src/components/features/settings/settings-layout.tsx b/src/components/features/settings/settings-layout.tsx
index 3b25461b0f..e6175b030c 100644
--- a/src/components/features/settings/settings-layout.tsx
+++ b/src/components/features/settings/settings-layout.tsx
@@ -17,8 +17,8 @@ export function SettingsLayout({
navigationItems,
}: SettingsLayoutProps) {
return (
- <div className="flex h-full flex-col md:pt-8">
- <div className="flex min-h-0 flex-1 gap-10 md:items-start">
+ <div className="flex h-full flex-col lg:pt-8">
+ <div className="flex min-h-0 flex-1 gap-10 lg:items-start">
<SettingsDesktopSidebar navigationItems={navigationItems} />
<main className={settingsLayoutMainScrollClassName}>
<div className="mx-auto w-full min-w-0 max-w-200">{children}</div>
diff --git a/src/components/features/settings/settings-mobile-hub.tsx b/src/components/features/settings/settings-mobile-hub.tsx
index 5770d8b030..fcce88ce01 100644
--- a/src/components/features/settings/settings-mobile-hub.tsx
+++ b/src/components/features/settings/settings-mobile-hub.tsx
@@ -23,7 +23,7 @@ export function SettingsMobileHub({ navigationItems }: SettingsMobileHubProps) {
return (
<div
data-testid="settings-mobile-hub"
- className="flex flex-col gap-4 px-4 py-2 md:hidden"
+ className="flex flex-col gap-4 px-4 py-2 lg:hidden"
>
<Typography.H2>{t(I18nKey.SETTINGS$TITLE)}</Typography.H2>
<nav className="flex flex-col gap-0.5">
diff --git a/src/components/features/skills/extensions-mobile-hub.tsx b/src/components/features/skills/extensions-mobile-hub.tsx
index c51c5db0cc..5a79a36a4c 100644
--- a/src/components/features/skills/extensions-mobile-hub.tsx
+++ b/src/components/features/skills/extensions-mobile-hub.tsx
@@ -29,7 +29,7 @@ export function ExtensionsMobileHub() {
return (
<div
data-testid="extensions-mobile-hub"
- className="flex flex-col gap-4 px-4 py-2 md:hidden"
+ className="flex flex-col gap-4 px-4 py-2 lg:hidden"
>
<Typography.H2>{t(I18nKey.NAV$CUSTOMIZE)}</Typography.H2>
<nav className="flex flex-col gap-0.5">
diff --git a/src/components/features/skills/extensions-navigation.tsx b/src/components/features/skills/extensions-navigation.tsx
index 86a3241cd9..3bf8bdf3a7 100644
--- a/src/components/features/skills/extensions-navigation.tsx
+++ b/src/components/features/skills/extensions-navigation.tsx
@@ -79,7 +79,7 @@ export function ExtensionsNavigation() {
return (
<aside
data-testid="extensions-navbar-desktop"
- className="hidden md:flex md:w-65 md:shrink-0 md:flex-col md:gap-2 md:sticky md:top-8 md:self-start"
+ className="hidden lg:flex lg:w-65 lg:shrink-0 lg:flex-col lg:gap-2 lg:sticky lg:top-8 lg:self-start"
>
<span className="px-2 text-sm font-normal text-contrast">
{t(I18nKey.NAV$CUSTOMIZE)}
diff --git a/src/hooks/use-breakpoint.ts b/src/hooks/use-breakpoint.ts
index 49b24b4a58..27e3344ced 100644
--- a/src/hooks/use-breakpoint.ts
+++ b/src/hooks/use-breakpoint.ts
@@ -2,6 +2,9 @@ import { useState, useEffect, useRef } from "react";
const MOBILE_BREAKPOINT = 1024;
+/** Compact settings/customization navigation below Tailwind lg (64rem). */
+export const SETTINGS_COMPACT_MAX_WIDTH = 1023;
+
/**
* Inclusive max width where the primary sidebar rail is hidden (`max-md:hidden`)
* and the slide-out drawer is used. Matches typical Tailwind `md` (48rem): rail
diff --git a/src/routes/extensions-hub.tsx b/src/routes/extensions-hub.tsx
index 07c79e6c10..84c50c301e 100644
--- a/src/routes/extensions-hub.tsx
+++ b/src/routes/extensions-hub.tsx
@@ -1,9 +1,12 @@
import { Navigate } from "react-router";
-import { useBreakpoint } from "#/hooks/use-breakpoint";
+import {
+ SETTINGS_COMPACT_MAX_WIDTH,
+ useBreakpoint,
+} from "#/hooks/use-breakpoint";
import { ExtensionsMobileHub } from "#/components/features/skills/extensions-mobile-hub";
export default function ExtensionsHub() {
- const isMobile = useBreakpoint(768);
+ const isMobile = useBreakpoint(SETTINGS_COMPACT_MAX_WIDTH);
if (isMobile) {
return <ExtensionsMobileHub />;
diff --git a/src/routes/mcp.tsx b/src/routes/mcp.tsx
index 283646396f..0fb635ebbb 100644
--- a/src/routes/mcp.tsx
+++ b/src/routes/mcp.tsx
@@ -95,10 +95,10 @@ export default function MCPPage() {
return (
<div
data-testid="mcp-page"
- className="flex h-full gap-4 md:gap-6 md:pl-8 lg:gap-10 lg:pl-10"
+ className="flex h-full gap-4 lg:gap-10 lg:pl-10"
>
<ExtensionsNavigation />
- <div className="flex h-full flex-1 items-center justify-center px-4 md:px-0">
+ <div className="flex h-full flex-1 items-center justify-center px-4 lg:px-0">
<div className="h-8 w-8 rounded-full border-2 border-transparent border-t-contrast animate-spin" />
</div>
</div>
@@ -108,7 +108,7 @@ export default function MCPPage() {
return (
<div
data-testid="mcp-page"
- className="flex h-full gap-4 md:gap-6 md:pl-8 lg:gap-10 lg:pl-10"
+ className="flex h-full gap-4 lg:gap-10 lg:pl-10"
>
<ExtensionsNavigation />
<main className={settingsLikeMainScrollClassName}>
diff --git a/src/routes/settings-index.tsx b/src/routes/settings-index.tsx
index d971d4c1d7..d7700d3bda 100644
--- a/src/routes/settings-index.tsx
+++ b/src/routes/settings-index.tsx
@@ -1,5 +1,8 @@
import { Navigate } from "react-router";
-import { useBreakpoint } from "#/hooks/use-breakpoint";
+import {
+ SETTINGS_COMPACT_MAX_WIDTH,
+ useBreakpoint,
+} from "#/hooks/use-breakpoint";
import { useConfig } from "#/hooks/query/use-config";
import { useSettingsNavItems } from "#/hooks/use-settings-nav-items";
import { SettingsMobileHub } from "#/components/features/settings/settings-mobile-hub";
@@ -8,7 +11,7 @@ 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);
+ const isMobile = useBreakpoint(SETTINGS_COMPACT_MAX_WIDTH);
const navigationItems = useSettingsNavItems();
const { data: config } = useConfig();
diff --git a/src/routes/settings.tsx b/src/routes/settings.tsx
index a055aba346..5f61946a62 100644
--- a/src/routes/settings.tsx
+++ b/src/routes/settings.tsx
@@ -14,7 +14,10 @@ import { SettingsLayout } from "#/components/features/settings";
import { WebClientConfig } from "#/api/option-service/option.types";
import { QUERY_KEYS, CONFIG_CACHE_OPTIONS } from "#/hooks/query/query-keys";
import { Typography } from "#/ui/typography";
-import { useBreakpoint } from "#/hooks/use-breakpoint";
+import {
+ SETTINGS_COMPACT_MAX_WIDTH,
+ useBreakpoint,
+} from "#/hooks/use-breakpoint";
import { useSettingsNavItems } from "#/hooks/use-settings-nav-items";
import {
LOCKED_CLOUD_SETTINGS_NAV_PATH,
@@ -54,7 +57,7 @@ function SettingsScreen() {
const location = useLocation();
const matches = useMatches();
const navItems = useSettingsNavItems();
- const isMobile = useBreakpoint(768);
+ const isMobile = useBreakpoint(SETTINGS_COMPACT_MAX_WIDTH);
const [hideSectionHeader, setHideSectionHeader] = useState(false);
const { currentSectionTitle, currentSectionSubtitle } = useMemo(() => {
diff --git a/src/routes/skills-plugins.tsx b/src/routes/skills-plugins.tsx
index 69e1ea29ae..d5738f1210 100644
--- a/src/routes/skills-plugins.tsx
+++ b/src/routes/skills-plugins.tsx
@@ -123,7 +123,7 @@ export default function SkillsPluginsScreen() {
return (
<div
data-testid="skills-plugins-screen"
- className="flex h-full gap-4 md:gap-6 md:pl-8 lg:gap-10 lg:pl-10"
+ className="flex h-full gap-4 lg:gap-10 lg:pl-10"
>
<ExtensionsNavigation />
<main className={cn(settingsLikeMainScrollClassName, "h-full")}>
diff --git a/src/routes/skills-settings.tsx b/src/routes/skills-settings.tsx
index e490f40947..7ef831ddcf 100644
--- a/src/routes/skills-settings.tsx
+++ b/src/routes/skills-settings.tsx
@@ -127,7 +127,7 @@ function SkillsSettingsScreen() {
return (
<div
data-testid="skills-settings-screen"
- className="flex h-full gap-4 md:gap-6 md:pl-8 lg:gap-10 lg:pl-10"
+ className="flex h-full gap-4 lg:gap-10 lg:pl-10"
>
<ExtensionsNavigation />
<main className={cn(settingsLikeMainScrollClassName, "h-full")}>
diff --git a/src/utils/settings-like-page-layout-classes.ts b/src/utils/settings-like-page-layout-classes.ts
index 8d54d54ce7..feec4ae17e 100644
--- a/src/utils/settings-like-page-layout-classes.ts
+++ b/src/utils/settings-like-page-layout-classes.ts
@@ -8,8 +8,8 @@
* scrollbar and the centered content jumps sideways into the freed space.
*/
export const settingsLikeMainScrollClassName =
- "flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden overflow-y-auto [scrollbar-gutter:stable] custom-scrollbar-always px-4 pt-8 pb-12 md:px-0 md:pr-3.5";
+ "flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden overflow-y-auto [scrollbar-gutter:stable] custom-scrollbar-always px-4 pt-8 pb-12 lg:px-0 lg:pr-3.5";
-/** Same scroll shell as {@link settingsLikeMainScrollClassName} but desktop top padding comes from the outer `md:pt-8` wrapper ({@link SettingsLayout}). */
+/** Same scroll shell as {@link settingsLikeMainScrollClassName} but desktop top padding comes from the outer `lg:pt-8` wrapper ({@link SettingsLayout}). */
export const settingsLayoutMainScrollClassName =
- "flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden overflow-y-auto [scrollbar-gutter:stable] custom-scrollbar-always px-4 pt-8 pb-12 md:px-0 md:pt-0 md:pr-3.5";
+ "flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden overflow-y-auto [scrollbar-gutter:stable] custom-scrollbar-always px-4 pt-8 pb-12 lg:px-0 lg:pt-0 lg:pr-3.5";
diff --git a/tests/e2e/settings-responsive.spec.ts b/tests/e2e/settings-responsive.spec.ts
new file mode 100644
index 0000000000..3e951fa292
--- /dev/null
+++ b/tests/e2e/settings-responsive.spec.ts
@@ -0,0 +1,86 @@
+import { expect, test, type Page } from "@playwright/test";
+
+test.beforeEach(async ({ page }) => {
+ await page.addInitScript(() => {
+ localStorage.setItem("analytics-consent", "false");
+ localStorage.setItem("openhands-telemetry-consent", "denied");
+ localStorage.setItem("openhands-telemetry-first-use", "true");
+ localStorage.setItem("openhands-onboarded", "1");
+ localStorage.setItem(
+ "openhands-sidebar",
+ JSON.stringify({ state: { collapsed: false }, version: 0 }),
+ );
+ localStorage.setItem(
+ "openhands-backends",
+ JSON.stringify([
+ {
+ id: "default-local",
+ name: "Local QA",
+ host: location.origin,
+ apiKey: "",
+ kind: "local",
+ },
+ ]),
+ );
+ localStorage.setItem(
+ "openhands-active-backend",
+ JSON.stringify({ backendId: "default-local", orgId: null }),
+ );
+ });
+});
+
+async function openMockPage(page: Page, route: string) {
+ await page.goto(route);
+ const consent = page.getByRole("dialog", { name: "Help improve OpenHands" });
+ await expect(consent).toBeVisible({ timeout: 30000 });
+ await consent.getByRole("checkbox").uncheck();
+ await consent.getByRole("button", { name: "Confirm preferences" }).click();
+ await expect(consent).toBeHidden();
+}
+
+for (const width of [390, 767, 768, 820, 1023, 1024, 1440]) {
+ test(`settings and customization remain usable at ${width}px`, async ({
+ page,
+ }) => {
+ await page.setViewportSize({ width, height: 1024 });
+ await openMockPage(page, "/customize");
+ const compact = width < 1024;
+ if (compact) {
+ await expect(page.getByTestId("extensions-mobile-hub")).toBeVisible();
+ // Keyboard navigation out of the hub remains available.
+ await page
+ .getByTestId("extensions-mobile-hub")
+ .getByRole("link", { name: "MCP Servers", exact: true })
+ .press("Enter");
+ }
+ await expect(page.getByTestId("mcp-add-custom-server")).toBeVisible();
+ const nav = page.getByTestId("extensions-navbar-desktop");
+ if (compact) await expect(nav).toBeHidden();
+ else await expect(nav).toBeVisible();
+ const search = page.getByPlaceholder("Search MCP servers");
+ await expect(search).toBeVisible();
+ expect((await search.boundingBox())!.width).toBeGreaterThan(150);
+ await search.fill("GitHub");
+ await expect(
+ page.getByRole("heading", { name: "GitHub", exact: true }),
+ ).toBeVisible();
+ await page.getByTestId("mcp-add-custom-server").click();
+ await expect(page.getByRole("dialog")).toBeVisible();
+ await page.keyboard.press("Escape");
+
+ for (const route of ["/skills", "/plugins", "/apps", "/settings/app"]) {
+ await openMockPage(page, route);
+ const main = page.locator("main").last();
+ await expect(main).toBeVisible();
+ expect((await main.boundingBox())!.width).toBeGreaterThan(340);
+ expect(
+ await main.evaluate((el) => el.scrollWidth <= el.clientWidth + 1),
+ ).toBe(true);
+ }
+ await openMockPage(page, "/settings");
+ if (compact)
+ await expect(page.getByTestId("settings-mobile-hub")).toBeVisible();
+ else
+ await expect(page.getByTestId("settings-navbar-desktop")).toBeVisible();
+ });
+}