🙌 OpenHands: AI-Driven Development
Cloud-aware nav item changes (#1890)
jpelletier1317a2f72bde0
diff --git a/__tests__/components/features/skills/extensions-mobile-hub.test.tsx b/__tests__/components/features/skills/extensions-mobile-hub.test.tsxindex 9e84bbbca0..510702cc5e 100644--- a/__tests__/components/features/skills/extensions-mobile-hub.test.tsx+++ b/__tests__/components/features/skills/extensions-mobile-hub.test.tsx@@ -1,11 +1,25 @@import type { ReactNode } from "react";import { render, screen, within } from "@testing-library/react";-import { describe, expect, it } from "vitest";+import { afterEach, beforeEach, describe, expect, it } from "vitest";import { MemoryRouter } from "react-router";import { QueryClient, QueryClientProvider } from "@tanstack/react-query";import { ActiveBackendProvider } from "#/contexts/active-backend-context";+import {+ __resetActiveStoreForTests,+ setActiveSelection,+ setRegisteredBackends,+} from "#/api/backend-registry/active-store";+import type { Backend } from "#/api/backend-registry/types";import { ExtensionsMobileHub } from "#/components/features/skills/extensions-mobile-hub";+const cloudBackend: Backend = {+ id: "cloud-1",+ name: "OpenHands Cloud",+ host: "https://app.all-hands.dev",+ apiKey: "token",+ kind: "cloud",+};+function renderMobileHub(ui: ReactNode) {return render(<QueryClientProvider@@ -21,6 +35,16 @@ function renderMobileHub(ui: ReactNode) {}describe("ExtensionsMobileHub", () => {+ beforeEach(() => {+ window.localStorage.clear();+ __resetActiveStoreForTests();+ });++ afterEach(() => {+ window.localStorage.clear();+ __resetActiveStoreForTests();+ });+it("renders the Plugins item as an enabled link", () => {renderMobileHub(<ExtensionsMobileHub />);@@ -28,4 +52,38 @@ describe("ExtensionsMobileHub", () => {const pluginsItem = within(hub).getByTestId("sidebar-extensions-/plugins");expect(pluginsItem).not.toHaveAttribute("aria-disabled");});++ describe("cloud backend", () => {+ it("renders the Skills item as an external link to {cloudHost}/settings/skills with the renamed label", () => {+ setRegisteredBackends([cloudBackend]);+ setActiveSelection({ backendId: cloudBackend.id });++ renderMobileHub(<ExtensionsMobileHub />);++ const hub = screen.getByTestId("extensions-mobile-hub");+ const skillsItem = within(hub).getByTestId("sidebar-extensions-/skills");+ expect(skillsItem.tagName).toBe("A");+ expect(skillsItem).toHaveAttribute(+ "href",+ "https://app.all-hands.dev/settings/skills",+ );+ expect(skillsItem).toHaveAttribute("target", "_blank");+ expect(skillsItem).toHaveAttribute("rel", "noopener noreferrer");+ expect(skillsItem).toHaveTextContent(+ "SIDEBAR$SKILLS_AND_PLUGINS_CLOUD_LINK",+ );+ });++ it("hides the Plugins item", () => {+ setRegisteredBackends([cloudBackend]);+ setActiveSelection({ backendId: cloudBackend.id });++ renderMobileHub(<ExtensionsMobileHub />);++ const hub = screen.getByTestId("extensions-mobile-hub");+ expect(+ within(hub).queryByTestId("sidebar-extensions-/plugins"),+ ).not.toBeInTheDocument();+ });+ });});diff --git a/__tests__/components/features/skills/extensions-navigation.test.tsx b/__tests__/components/features/skills/extensions-navigation.test.tsxindex f95667f6ba..4e59a49f8d 100644--- a/__tests__/components/features/skills/extensions-navigation.test.tsx+++ b/__tests__/components/features/skills/extensions-navigation.test.tsx@@ -1,13 +1,27 @@import type { ReactNode } from "react";import { render, screen, within } from "@testing-library/react";-import { afterEach, describe, expect, it } from "vitest";+import { afterEach, beforeEach, describe, expect, it } from "vitest";import { MemoryRouter } from "react-router";import { QueryClient, QueryClientProvider } from "@tanstack/react-query";import { ActiveBackendProvider } from "#/contexts/active-backend-context";+import {+ __resetActiveStoreForTests,+ setActiveSelection,+ setRegisteredBackends,+} from "#/api/backend-registry/active-store";+import type { Backend } from "#/api/backend-registry/types";import { useSidebarStore } from "#/stores/sidebar-store";import { ExtensionsNavigation } from "#/components/features/skills/extensions-navigation";+const cloudBackend: Backend = {+ id: "cloud-1",+ name: "OpenHands Cloud",+ host: "https://app.all-hands.dev",+ apiKey: "token",+ kind: "cloud",+};+function renderExtensionsNavigation(ui: ReactNode) {return render(<QueryClientProvider@@ -23,6 +37,16 @@ function renderExtensionsNavigation(ui: ReactNode) {}describe("ExtensionsNavigation", () => {+ beforeEach(() => {+ window.localStorage.clear();+ __resetActiveStoreForTests();+ });++ afterEach(() => {+ window.localStorage.clear();+ __resetActiveStoreForTests();+ });+it("renders the MCP item as a clickable link for non-ACP agents", () => {renderExtensionsNavigation(<ExtensionsNavigation />);@@ -68,6 +92,52 @@ describe("ExtensionsNavigation", () => {).not.toBeInTheDocument();});+ describe("cloud backend", () => {+ it("renders the Skills item as an external link to {cloudHost}/settings/skills with the renamed label", () => {+ setRegisteredBackends([cloudBackend]);+ setActiveSelection({ backendId: cloudBackend.id });++ renderExtensionsNavigation(<ExtensionsNavigation />);++ const nav = screen.getByTestId("extensions-navbar-desktop");+ const skillsItem = within(nav).getByTestId("sidebar-extensions-/skills");+ expect(skillsItem.tagName).toBe("A");+ expect(skillsItem).toHaveAttribute(+ "href",+ "https://app.all-hands.dev/settings/skills",+ );+ expect(skillsItem).toHaveAttribute("target", "_blank");+ expect(skillsItem).toHaveAttribute("rel", "noopener noreferrer");+ expect(skillsItem).toHaveTextContent(+ "SIDEBAR$SKILLS_AND_PLUGINS_CLOUD_LINK",+ );+ });++ it("hides the Plugins item", () => {+ setRegisteredBackends([cloudBackend]);+ setActiveSelection({ backendId: cloudBackend.id });++ renderExtensionsNavigation(<ExtensionsNavigation />);++ const nav = screen.getByTestId("extensions-navbar-desktop");+ expect(+ within(nav).queryByTestId("sidebar-extensions-/plugins"),+ ).not.toBeInTheDocument();+ });++ it("leaves the MCP Servers item as an in-app link", () => {+ setRegisteredBackends([cloudBackend]);+ setActiveSelection({ backendId: cloudBackend.id });++ renderExtensionsNavigation(<ExtensionsNavigation />);++ const nav = screen.getByTestId("extensions-navbar-desktop");+ const mcpItem = within(nav).getByTestId("sidebar-extensions-/mcp");+ expect(mcpItem).not.toHaveAttribute("target");+ expect(mcpItem).toHaveAttribute("href", "/mcp");+ });+ });+// Regression: the nav used to suppress itself at iPad-portrait widths// (768–1023px) whenever the primary Sidebar was expanded, leaving users// on /skills, /mcp, and /plugins with no way to switch between thosediff --git a/src/components/features/settings/integrations-settings-link.tsx b/src/components/features/settings/integrations-settings-link.tsxnew file mode 100644index 0000000000..07fd9cfc18--- /dev/null+++ b/src/components/features/settings/integrations-settings-link.tsx@@ -0,0 +1,50 @@+import { useTranslation } from "react-i18next";+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 { cn } from "#/utils/utils";+import {+ SIDEBAR_ICON_SLOT_CLASS,+ SIDEBAR_ROW_INTERACTIVE_CLASS,+ sidebarNavLabelClassName,+ sidebarNavRowClassName,+} from "#/components/features/sidebar/sidebar-layout";++/**+ * Renders only for cloud backends — local backends have no equivalent+ * hosted integrations settings page.+ */+export function IntegrationsSettingsLink() {+ const { t } = useTranslation("openhands");+ const { active } = useActiveBackendContext();+ const { backend } = active;++ if (isNoBackend(backend) || backend.kind !== "cloud") return null;++ const integrationsUrl = `${backend.host.replace(/\/+$/, "")}/settings/integrations`;++ return (+ <a+ data-testid="settings-integrations-link"+ href={integrationsUrl}+ target="_blank"+ rel="noopener noreferrer"+ className={cn(+ sidebarNavRowClassName({ collapsed: false }),+ SIDEBAR_ROW_INTERACTIVE_CLASS.idle,+ )}+ >+ <span className={SIDEBAR_ICON_SLOT_CLASS}>+ <Puzzle className="size-4 shrink-0" aria-hidden />+ </span>+ <span className={cn(sidebarNavLabelClassName(false), "flex-1")}>+ {t(I18nKey.SETTINGS$INTEGRATIONS_SETTINGS_LINK)}+ </span>+ <ExternalLink+ className="size-4 shrink-0 text-[var(--oh-muted)]"+ aria-hidden+ />+ </a>+ );+}diff --git a/src/components/features/settings/settings-desktop-sidebar.tsx b/src/components/features/settings/settings-desktop-sidebar.tsxindex 6464481d37..c8d06b826d 100644--- a/src/components/features/settings/settings-desktop-sidebar.tsx+++ b/src/components/features/settings/settings-desktop-sidebar.tsx@@ -6,6 +6,7 @@ import { SettingsNavRenderedItem } from "#/hooks/use-settings-nav-items";import { SidebarNavLink } from "#/components/features/sidebar/sidebar-nav-link";import { BackendSyncedSettingsBadge } from "#/components/features/settings/backend-synced-settings-badge";import { CloudSettingsLink } from "#/components/features/settings/cloud-settings-link";+import { IntegrationsSettingsLink } from "#/components/features/settings/integrations-settings-link";interface SettingsDesktopSidebarProps {navigationItems: SettingsNavRenderedItem[];@@ -62,6 +63,7 @@ export function SettingsDesktopSidebar({}/>))}+ <IntegrationsSettingsLink /><CloudSettingsLink /></div><div className="px-2 pt-3">diff --git a/src/components/features/settings/settings-mobile-drawer.tsx b/src/components/features/settings/settings-mobile-drawer.tsxindex 8c1e941ad4..a6151a3178 100644--- a/src/components/features/settings/settings-mobile-drawer.tsx+++ b/src/components/features/settings/settings-mobile-drawer.tsx@@ -11,6 +11,7 @@ import { SettingsNavLink } from "./settings-nav-link";import { navInteractiveTransitionClassName } from "#/components/features/sidebar/sidebar-layout";import { BackendSyncedSettingsBadge } from "#/components/features/settings/backend-synced-settings-badge";import { CloudSettingsLink } from "#/components/features/settings/cloud-settings-link";+import { IntegrationsSettingsLink } from "#/components/features/settings/integrations-settings-link";interface SettingsMobileDrawerProps {isMobileMenuOpen: boolean;@@ -88,6 +89,7 @@ export function SettingsMobileDrawer({/>);})}+ <IntegrationsSettingsLink /><CloudSettingsLink /></div>diff --git a/src/components/features/settings/settings-mobile-hub.tsx b/src/components/features/settings/settings-mobile-hub.tsxindex 3ccd8ff19b..ef21c103df 100644--- a/src/components/features/settings/settings-mobile-hub.tsx+++ b/src/components/features/settings/settings-mobile-hub.tsx@@ -5,6 +5,7 @@ import { SettingsNavRenderedItem } from "#/hooks/use-settings-nav-items";import { SidebarNavLink } from "#/components/features/sidebar/sidebar-nav-link";import { BackendSyncedSettingsBadge } from "#/components/features/settings/backend-synced-settings-badge";import { CloudSettingsLink } from "#/components/features/settings/cloud-settings-link";+import { IntegrationsSettingsLink } from "#/components/features/settings/integrations-settings-link";interface SettingsMobileHubProps {navigationItems: SettingsNavRenderedItem[];@@ -35,6 +36,7 @@ export function SettingsMobileHub({ navigationItems }: SettingsMobileHubProps) {icon={renderedItem.item.icon}/>))}+ <IntegrationsSettingsLink /><CloudSettingsLink /></nav><div className="pt-1">diff --git a/src/components/features/skills/extensions-mobile-hub.tsx b/src/components/features/skills/extensions-mobile-hub.tsxindex 81010ae224..9f65aeaa04 100644--- a/src/components/features/skills/extensions-mobile-hub.tsx+++ b/src/components/features/skills/extensions-mobile-hub.tsx@@ -1,12 +1,30 @@import { useTranslation } from "react-i18next";+import { ExternalLink } from "lucide-react";import { Typography } from "#/ui/typography";import { I18nKey } from "#/i18n/declaration";import { SidebarNavLink } from "#/components/features/sidebar/sidebar-nav-link";import { BackendSyncedSettingsBadge } from "#/components/features/settings/backend-synced-settings-badge";+import { useActiveBackendContext } from "#/contexts/active-backend-context";+import { isNoBackend } from "#/api/backend-registry/active-store";+import { cn } from "#/utils/utils";+import {+ SIDEBAR_ICON_SLOT_CLASS,+ SIDEBAR_ROW_INTERACTIVE_CLASS,+ sidebarNavLabelClassName,+ sidebarNavRowClassName,+} from "#/components/features/sidebar/sidebar-layout";import { EXTENSIONS_NAV_ITEMS } from "./extensions-navigation";+/** Only the Skills item points to a cloud-hosted page today. */+const CLOUD_LINKED_EXTENSION_PATH = "/skills";+/** Plugins are not available on Cloud backends, so this item is hidden there. */+const CLOUD_HIDDEN_EXTENSION_PATH = "/plugins";+export function ExtensionsMobileHub() {const { t } = useTranslation("openhands");+ const { active } = useActiveBackendContext();+ const { backend } = active;+ const isCloudBackend = !isNoBackend(backend) && backend.kind === "cloud";return (<div@@ -15,17 +33,48 @@ export function ExtensionsMobileHub() {><Typography.H2>{t(I18nKey.NAV$CUSTOMIZE)}</Typography.H2><nav className="flex flex-col gap-0.5">- {EXTENSIONS_NAV_ITEMS.map((item) => (- <SidebarNavLink- key={item.to}- to={item.to}- label={item.label}- end={item.end}- testId={`sidebar-extensions-${item.to}`}- icon={item.icon}- disabled={item.comingSoon}- />- ))}+ {EXTENSIONS_NAV_ITEMS.filter(+ (item) =>+ !(item.to === CLOUD_HIDDEN_EXTENSION_PATH && isCloudBackend),+ ).map((item) => {+ if (item.to === CLOUD_LINKED_EXTENSION_PATH && isCloudBackend) {+ const cloudSkillsUrl = `${backend.host.replace(/\/+$/, "")}/settings/skills`;+ return (+ <a+ key={item.to}+ data-testid={`sidebar-extensions-${item.to}`}+ href={cloudSkillsUrl}+ target="_blank"+ rel="noopener noreferrer"+ className={cn(+ sidebarNavRowClassName({ collapsed: false }),+ SIDEBAR_ROW_INTERACTIVE_CLASS.idle,+ )}+ >+ <span className={SIDEBAR_ICON_SLOT_CLASS}>{item.icon}</span>+ <span className={cn(sidebarNavLabelClassName(false), "flex-1")}>+ {t(I18nKey.SIDEBAR$SKILLS_AND_PLUGINS_CLOUD_LINK)}+ </span>+ <ExternalLink+ className="size-4 shrink-0 text-[var(--oh-muted)]"+ aria-hidden+ />+ </a>+ );+ }++ return (+ <SidebarNavLink+ key={item.to}+ to={item.to}+ label={item.label}+ end={item.end}+ testId={`sidebar-extensions-${item.to}`}+ icon={item.icon}+ disabled={item.comingSoon}+ />+ );+ })}</nav><div className="pt-1"><BackendSyncedSettingsBadge />diff --git a/src/components/features/skills/extensions-navigation.tsx b/src/components/features/skills/extensions-navigation.tsxindex 63cb571bfa..3160c6d09b 100644--- a/src/components/features/skills/extensions-navigation.tsx+++ b/src/components/features/skills/extensions-navigation.tsx@@ -1,4 +1,5 @@import { useTranslation } from "react-i18next";+import { ExternalLink } from "lucide-react";import { NavigationLink } from "#/components/shared/navigation-link";import { cn } from "#/utils/utils";import SkillsIcon from "#/icons/skills.svg?react";@@ -9,6 +10,13 @@ import {sidebarNavRowClassName,} from "#/components/features/sidebar/sidebar-layout";import { I18nKey } from "#/i18n/declaration";+import { useActiveBackendContext } from "#/contexts/active-backend-context";+import { isNoBackend } from "#/api/backend-registry/active-store";++/** Only the Skills item points to a cloud-hosted page today. */+const CLOUD_LINKED_EXTENSION_PATH = "/skills";+/** Plugins are not available on Cloud backends, so this item is hidden there. */+const CLOUD_HIDDEN_EXTENSION_PATH = "/plugins";interface ExtensionNavItem {to: string;@@ -58,6 +66,9 @@ export const EXTENSIONS_NAV_ITEMS: ExtensionNavItem[] = [export function ExtensionsNavigation() {const { t } = useTranslation("openhands");+ const { active } = useActiveBackendContext();+ const { backend } = active;+ const isCloudBackend = !isNoBackend(backend) && backend.kind === "cloud";return (<aside@@ -68,19 +79,55 @@ export function ExtensionsNavigation() {{t(I18nKey.NAV$CUSTOMIZE)}</span><div className="flex flex-col gap-0.5 pt-0.5">- {EXTENSIONS_NAV_ITEMS.map((item) => {+ {EXTENSIONS_NAV_ITEMS.filter(+ (item) =>+ !(item.to === CLOUD_HIDDEN_EXTENSION_PATH && isCloudBackend),+ ).map((item) => {+ const isCloudSkillsLink =+ item.to === CLOUD_LINKED_EXTENSION_PATH && isCloudBackend;const baseRow = (<span className="shrink-0 flex items-center justify-center">{item.icon}</span>);- const label = <span className="truncate">{item.label}</span>;+ const label = (+ <span className="truncate">+ {isCloudSkillsLink+ ? t(I18nKey.SIDEBAR$SKILLS_AND_PLUGINS_CLOUD_LINK)+ : item.label}+ </span>+ );const comingSoonBadge = item.comingSoon && (<span className="ml-auto shrink-0 rounded-full border border-white/20 bg-white/5 px-1.5 py-0.5 text-[10px] font-medium text-[var(--oh-text-dim)]">{t(I18nKey.NAV$COMING_SOON)}</span>);+ if (isCloudSkillsLink) {+ const cloudSkillsUrl = `${backend.host.replace(/\/+$/, "")}/settings/skills`;+ return (+ <a+ key={item.to}+ data-testid={`sidebar-extensions-${item.to}`}+ href={cloudSkillsUrl}+ target="_blank"+ rel="noopener noreferrer"+ className={cn(+ sidebarNavRowClassName(),+ "truncate",+ SIDEBAR_ROW_INTERACTIVE_CLASS.idle,+ )}+ >+ {baseRow}+ {label}+ <ExternalLink+ className="ml-auto size-4 shrink-0 text-[var(--oh-muted)]"+ aria-hidden+ />+ </a>+ );+ }+return (<NavigationLinkkey={item.to}diff --git a/src/i18n/translation.json b/src/i18n/translation.jsonindex 459987e159..e2ae8fdaa3 100644--- a/src/i18n/translation.json+++ b/src/i18n/translation.json@@ -14738,6 +14738,23 @@"tr": "Yetenekler","uk": "Навички"},+ "SIDEBAR$SKILLS_AND_PLUGINS_CLOUD_LINK": {+ "en": "Skills and Plugins",+ "ja": "スキルとプラグイン",+ "zh-CN": "技能和插件",+ "zh-TW": "技能和外掛",+ "ko-KR": "스킬 및 플러그인",+ "no": "Ferdigheter og plugins",+ "ar": "المهارات والمكونات الإضافية",+ "de": "Fähigkeiten und Plugins",+ "fr": "Compétences et plugins",+ "it": "Competenze e plugin",+ "pt": "Habilidades e plugins",+ "es": "Habilidades y plugins",+ "ca": "Habilitats i connectors",+ "tr": "Yetenekler ve Eklentiler",+ "uk": "Навички та плагіни"+ },"SIDEBAR$MCP_DIRECTORY": {"en": "MCP Directory","ja": "MCPディレクトリ",@@ -29052,22 +29069,39 @@"uk": "Ці налаштування синхронізовано з бекендом {{name}} ({{host}})","ca": "Aquesta configuració està sincronitzada amb el backend {{name}} ({{host}})"},+ "SETTINGS$INTEGRATIONS_SETTINGS_LINK": {+ "en": "Integrations",+ "ja": "連携",+ "zh-CN": "集成",+ "zh-TW": "整合",+ "ko-KR": "통합",+ "no": "Integrasjoner",+ "ar": "التكاملات",+ "de": "Integrationen",+ "fr": "Intégrations",+ "it": "Integrazioni",+ "pt": "Integrações",+ "es": "Integraciones",+ "ca": "Integracions",+ "tr": "Entegrasyonlar",+ "uk": "Інтеграції"+ },"SETTINGS$CLOUD_SETTINGS_LINK": {- "en": "Cloud",- "ja": "Cloud",- "zh-CN": "Cloud",- "zh-TW": "Cloud",- "ko-KR": "Cloud",- "no": "Cloud",- "it": "Cloud",- "pt": "Cloud",- "es": "Cloud",- "ar": "Cloud",- "fr": "Cloud",- "tr": "Cloud",- "de": "Cloud",- "uk": "Cloud",- "ca": "Cloud"+ "en": "All Cloud Settings",+ "ja": "All Cloud Settings",+ "zh-CN": "All Cloud Settings",+ "zh-TW": "All Cloud Settings",+ "ko-KR": "All Cloud Settings",+ "no": "All Cloud Settings",+ "it": "All Cloud Settings",+ "pt": "All Cloud Settings",+ "es": "All Cloud Settings",+ "ar": "All Cloud Settings",+ "fr": "All Cloud Settings",+ "tr": "All Cloud Settings",+ "de": "All Cloud Settings",+ "uk": "All Cloud Settings",+ "ca": "All Cloud Settings"},"BACKEND$REMOVE": {"en": "Remove",