Skip to content

πŸ™Œ OpenHands: AI-Driven Development

chore: remove unused feature components (#557)

Hiep Lee3c4cf9d9dd2
diff --git a/__tests__/components/context-menu/context-menu-container.test.tsx b/__tests__/components/context-menu/context-menu-container.test.tsx
deleted file mode 100644
index cc9e619209..0000000000
--- a/__tests__/components/context-menu/context-menu-container.test.tsx
+++ /dev/null
@@ -1,78 +0,0 @@
-import { render, screen } from "@testing-library/react";
-import userEvent from "@testing-library/user-event";
-import { describe, expect, it, vi } from "vitest";
-import { ContextMenuContainer } from "#/components/features/context-menu/context-menu-container";
-
-describe("ContextMenuContainer", () => {
- const user = userEvent.setup();
- const onCloseMock = vi.fn();
-
- it("should render children", () => {
- render(
- <ContextMenuContainer onClose={onCloseMock}>
- <div data-testid="child-1">Child 1</div>
- <div data-testid="child-2">Child 2</div>
- </ContextMenuContainer>,
- );
-
- expect(screen.getByTestId("child-1")).toBeInTheDocument();
- expect(screen.getByTestId("child-2")).toBeInTheDocument();
- });
-
- it("should apply consistent base styling", () => {
- render(
- <ContextMenuContainer onClose={onCloseMock} testId="test-container">
- <div>Content</div>
- </ContextMenuContainer>,
- );
-
- const container = screen.getByTestId("test-container");
- expect(container).toHaveClass("bg-[var(--oh-surface-deep)]");
- expect(container).toHaveClass("border");
- expect(container).toHaveClass("border-[var(--oh-border-subtle)]");
- expect(container).toHaveClass("rounded-[12px]");
- expect(container).toHaveClass("p-[25px]");
- expect(container).toHaveClass("context-menu-box-shadow");
- });
-
- it("should call onClose when clicking outside", async () => {
- render(
- <ContextMenuContainer onClose={onCloseMock} testId="test-container">
- <div>Content</div>
- </ContextMenuContainer>,
- );
-
- await user.click(document.body);
- expect(onCloseMock).toHaveBeenCalledOnce();
- });
-
- it("should render children in a flex row layout", () => {
- render(
- <ContextMenuContainer onClose={onCloseMock} testId="test-container">
- <div data-testid="child-1">Child 1</div>
- <div data-testid="child-2">Child 2</div>
- </ContextMenuContainer>,
- );
-
- const container = screen.getByTestId("test-container");
- const innerDiv = container.firstChild as HTMLElement;
- expect(innerDiv).toHaveClass("flex");
- expect(innerDiv).toHaveClass("flex-row");
- expect(innerDiv).toHaveClass("gap-4");
- });
-
- it("should apply additional className when provided", () => {
- render(
- <ContextMenuContainer
- onClose={onCloseMock}
- testId="test-container"
- className="custom-class"
- >
- <div>Content</div>
- </ContextMenuContainer>,
- );
-
- const container = screen.getByTestId("test-container");
- expect(container).toHaveClass("custom-class");
- });
-});
diff --git a/__tests__/components/features/context-menu/context-menu-nav-link.test.tsx b/__tests__/components/features/context-menu/context-menu-nav-link.test.tsx
deleted file mode 100644
index 629b19eb33..0000000000
--- a/__tests__/components/features/context-menu/context-menu-nav-link.test.tsx
+++ /dev/null
@@ -1,50 +0,0 @@
-import { screen } from "@testing-library/react";
-import userEvent from "@testing-library/user-event";
-import { describe, it, expect, vi } from "vitest";
-import { renderWithProviders } from "test-utils";
-import { ContextMenuNavLink } from "#/components/features/context-menu/context-menu-nav-link";
-import { I18nKey } from "#/i18n/declaration";
-
-const mockNavItem = {
- to: "/settings/test",
- icon: <span data-testid="test-icon">Icon</span>,
- text: I18nKey.SETTINGS$NAV_API_KEYS,
- subtitle: I18nKey.SETTINGS$PAGE_SECRETS_SUBLINE,
-};
-
-const renderContextMenuNavLink = (item = mockNavItem, onClick = vi.fn()) =>
- renderWithProviders(<ContextMenuNavLink item={item} onClick={onClick} />);
-
-describe("ContextMenuNavLink", () => {
- it("should render the link with icon and text", () => {
- // Arrange & Act
- renderContextMenuNavLink();
-
- // Assert
- expect(screen.getByRole("link")).toBeInTheDocument();
- expect(screen.getByTestId("test-icon")).toBeInTheDocument();
- expect(screen.getByText("SETTINGS$NAV_API_KEYS")).toBeInTheDocument();
- });
-
- it("should navigate to the correct route", () => {
- // Arrange & Act
- renderContextMenuNavLink();
-
- // Assert
- const link = screen.getByRole("link");
- expect(link).toHaveAttribute("href", "/settings/test");
- });
-
- it("should call onClick when clicked", async () => {
- // Arrange
- const user = userEvent.setup();
- const onClick = vi.fn();
- renderContextMenuNavLink(mockNavItem, onClick);
-
- // Act
- await user.click(screen.getByRole("link"));
-
- // Assert
- expect(onClick).toHaveBeenCalledTimes(1);
- });
-});
diff --git a/__tests__/components/features/home/repo-connector.test.tsx b/__tests__/components/features/home/repo-connector.test.tsx
deleted file mode 100644
index aa86ef36d6..0000000000
--- a/__tests__/components/features/home/repo-connector.test.tsx
+++ /dev/null
@@ -1,58 +0,0 @@
-import { render, screen } from "@testing-library/react";
-import { beforeEach, describe, expect, it, vi } from "vitest";
-
-import { RepoConnector } from "#/components/features/home/repo-connector";
-
-const mockUseUserProviders = vi.fn();
-const mockUseActiveBackend = vi.fn();
-
-vi.mock("#/hooks/use-user-providers", () => ({
- useUserProviders: () => mockUseUserProviders(),
-}));
-
-vi.mock("#/contexts/active-backend-context", () => ({
- useActiveBackend: () => mockUseActiveBackend(),
-}));
-
-vi.mock("#/components/features/home/workspace-selection-form", () => ({
- WorkspaceSelectionForm: () => <div data-testid="stub-workspace-form" />,
-}));
-
-vi.mock("#/components/features/home/repo-selection-form", () => ({
- RepositorySelectionForm: () => <div data-testid="stub-repository-form" />,
-}));
-
-describe("RepoConnector", () => {
- beforeEach(() => {
- mockUseUserProviders.mockReturnValue({
- isLoadingSettings: false,
- providers: ["github"],
- });
- });
-
- it("shows the workspace launcher when the active backend is local", () => {
- mockUseActiveBackend.mockReturnValue({
- backend: { kind: "local" },
- orgId: null,
- });
-
- render(<RepoConnector />);
-
- expect(screen.getByTestId("stub-workspace-form")).toBeInTheDocument();
- expect(
- screen.queryByTestId("stub-repository-form"),
- ).not.toBeInTheDocument();
- });
-
- it("shows the git repository launcher when the active backend is cloud", () => {
- mockUseActiveBackend.mockReturnValue({
- backend: { kind: "cloud" },
- orgId: null,
- });
-
- render(<RepoConnector />);
-
- expect(screen.getByTestId("stub-repository-form")).toBeInTheDocument();
- expect(screen.queryByTestId("stub-workspace-form")).not.toBeInTheDocument();
- });
-});
diff --git a/src/components/features/context-menu/context-menu-container.tsx b/src/components/features/context-menu/context-menu-container.tsx
deleted file mode 100644
index 5c434ce976..0000000000
--- a/src/components/features/context-menu/context-menu-container.tsx
+++ /dev/null
@@ -1,39 +0,0 @@
-import React from "react";
-import { cn } from "#/utils/utils";
-import { useClickOutsideElement } from "#/hooks/use-click-outside-element";
-
-interface ContextMenuContainerProps {
- children: React.ReactNode;
- onClose: () => void;
- testId?: string;
- className?: string;
-}
-
-export function ContextMenuContainer({
- children,
- onClose,
- testId,
- className,
-}: ContextMenuContainerProps) {
- const ref = useClickOutsideElement<HTMLDivElement>(onClose);
-
- return (
- <div
- ref={ref}
- data-testid={testId}
- className={cn(
- // Base styling
- "absolute rounded-[12px] p-[25px]",
- "bg-[var(--oh-surface-deep)] border border-[var(--oh-border-subtle)]",
- "text-white overflow-hidden z-[9999]",
- "context-menu-box-shadow",
- // Positioning
- "right-0 md:right-auto md:left-full md:bottom-0",
- "w-fit",
- className,
- )}
- >
- <div className="flex flex-row gap-4 items-stretch">{children}</div>
- </div>
- );
-}
diff --git a/src/components/features/context-menu/context-menu-nav-link.tsx b/src/components/features/context-menu/context-menu-nav-link.tsx
deleted file mode 100644
index 32b870f0f0..0000000000
--- a/src/components/features/context-menu/context-menu-nav-link.tsx
+++ /dev/null
@@ -1,31 +0,0 @@
-import React from "react";
-import { useTranslation } from "react-i18next";
-import { I18nKey } from "#/i18n/declaration";
-import { NavigationLink } from "#/components/shared/navigation-link";
-import { SettingsNavItem } from "#/constants/settings-nav";
-
-interface ContextMenuNavLinkProps {
- item: SettingsNavItem;
- onClick: () => void;
-}
-
-export function ContextMenuNavLink({ item, onClick }: ContextMenuNavLinkProps) {
- const { t } = useTranslation("openhands");
- const { to, icon, text } = item;
-
- return (
- <NavigationLink
- to={to}
- onClick={onClick}
- className="flex items-center gap-2 p-2 cursor-pointer hover:bg-white/10 hover:text-white rounded w-full text-xs"
- >
- {React.cloneElement(icon, {
- className: "text-white",
- width: 16,
- height: 16,
- size: 16, // For react-icons compatibility
- } as React.SVGProps<SVGSVGElement>)}
- {t(text as I18nKey)}
- </NavigationLink>
- );
-}
diff --git a/src/components/features/context-menu/context-menu-separator.tsx b/src/components/features/context-menu/context-menu-separator.tsx
deleted file mode 100644
index ee161494d8..0000000000
--- a/src/components/features/context-menu/context-menu-separator.tsx
+++ /dev/null
@@ -1,18 +0,0 @@
-import { cn } from "#/utils/utils";
-
-interface ContextMenuSeparatorProps {
- className?: string;
- testId?: string;
-}
-
-export function ContextMenuSeparator({
- className,
- testId,
-}: ContextMenuSeparatorProps) {
- return (
- <div
- data-testid={testId}
- className={cn("w-full h-[1px] bg-[var(--oh-border)]", className)}
- />
- );
-}
diff --git a/src/components/features/controls/security-lock.tsx b/src/components/features/controls/security-lock.tsx
deleted file mode 100644
index 1826806371..0000000000
--- a/src/components/features/controls/security-lock.tsx
+++ /dev/null
@@ -1,28 +0,0 @@
-import { IoLockClosed } from "react-icons/io5";
-import { useTranslation } from "react-i18next";
-import { NavigationLink } from "#/components/shared/navigation-link";
-import { I18nKey } from "#/i18n/declaration";
-import { StyledTooltip } from "#/components/shared/buttons/styled-tooltip";
-
-export function SecurityLock() {
- const { t } = useTranslation("openhands");
-
- return (
- <StyledTooltip
- content={
- <div className="max-w-xs p-2">
- {t(I18nKey.SETTINGS$CONFIRMATION_MODE_LOCK_TOOLTIP)}
- </div>
- }
- placement="top"
- >
- <NavigationLink
- to="/settings"
- className="mr-2 cursor-pointer hover:opacity-80 transition-all"
- aria-label={t(I18nKey.SETTINGS$TITLE)}
- >
- <IoLockClosed size={20} />
- </NavigationLink>
- </StyledTooltip>
- );
-}
diff --git a/src/components/features/home/repo-connector.tsx b/src/components/features/home/repo-connector.tsx
deleted file mode 100644
index 00d09ced30..0000000000
--- a/src/components/features/home/repo-connector.tsx
+++ /dev/null
@@ -1,27 +0,0 @@
-import { useActiveBackend } from "#/contexts/active-backend-context";
-import { useUserProviders } from "#/hooks/use-user-providers";
-
-import { RepositorySelectionForm } from "./repo-selection-form";
-import { WorkspaceSelectionForm } from "./workspace-selection-form";
-
-export function RepoConnector() {
- const { isLoadingSettings } = useUserProviders();
- const isCloud = useActiveBackend().backend.kind === "cloud";
-
- // Local (agent-server) backends operate on folders on the host machine, so
- // the launcher shows the workspace picker. Cloud backends run conversations
- // against remote git repositories, so the launcher shows the git provider /
- // repo / branch dropdowns instead.
- return (
- <section
- data-testid="repo-connector"
- className="w-full flex flex-col gap-6 rounded-[12px] p-[20px] border border-[var(--oh-border)] bg-[var(--oh-surface)] min-h-[263.5px] relative"
- >
- {isCloud ? (
- <RepositorySelectionForm isLoadingSettings={isLoadingSettings} />
- ) : (
- <WorkspaceSelectionForm isLoadingSettings={isLoadingSettings} />
- )}
- </section>
- );
-}
diff --git a/src/components/features/settings/pro-pill.tsx b/src/components/features/settings/pro-pill.tsx
deleted file mode 100644
index f427fd6fb0..0000000000
--- a/src/components/features/settings/pro-pill.tsx
+++ /dev/null
@@ -1,22 +0,0 @@
-import { useTranslation } from "react-i18next";
-import { cn } from "#/utils/utils";
-import { I18nKey } from "#/i18n/declaration";
-
-interface ProPillProps {
- className?: string;
-}
-
-export function ProPill({ className }: ProPillProps) {
- const { t } = useTranslation("openhands");
-
- return (
- <span
- className={cn(
- "bg-tertiary border border-[#ffeeaa] text-[#ffeeaa] text-[8px] font-medium px-1.5 py-0.5 rounded-full whitespace-nowrap",
- className,
- )}
- >
- {t(I18nKey.SETTINGS$PRO_PILL)}
- </span>
- );
-}
diff --git a/src/components/features/settings/upgrade-banner-with-backdrop.tsx b/src/components/features/settings/upgrade-banner-with-backdrop.tsx
deleted file mode 100644
index bbd88e91bb..0000000000
--- a/src/components/features/settings/upgrade-banner-with-backdrop.tsx
+++ /dev/null
@@ -1,29 +0,0 @@
-import { useTranslation } from "react-i18next";
-import { UpgradeBanner } from "#/components/features/settings";
-
-interface UpgradeBannerWithBackdropProps {
- onUpgradeClick: () => void;
- isDisabled?: boolean;
-}
-
-export function UpgradeBannerWithBackdrop({
- onUpgradeClick,
- isDisabled,
-}: UpgradeBannerWithBackdropProps) {
- const { t } = useTranslation("openhands");
-
- return (
- <>
- <UpgradeBanner
- message={t("SETTINGS$UPGRADE_BANNER_MESSAGE")}
- onUpgradeClick={onUpgradeClick}
- className="sticky top-0 z-30 mb-6"
- isDisabled={isDisabled}
- />
- <div
- data-testid="settings-backdrop"
- className="absolute inset-0 z-20 opacity-50 bg-[var(--oh-surface)]"
- />
- </>
- );
-}