Skip to content

🙌 OpenHands: AI-Driven Development

feat(home): dismiss recommended automations rail from Home and Application settings (#18538)

Liang Xuf69111678b76
diff --git a/__tests__/components/automations/recommended-automations-rail.test.tsx b/__tests__/components/automations/recommended-automations-rail.test.tsx
index cf220431dc..f93e96c07c 100644
--- a/__tests__/components/automations/recommended-automations-rail.test.tsx
+++ b/__tests__/components/automations/recommended-automations-rail.test.tsx
@@ -326,4 +326,46 @@ describe("RecommendedAutomationsRail", () => {
expect(scroller.scrollLeft).toBe(150);
});
});
+
+ describe("dismiss behavior", () => {
+ // @spec HL-002 — Rails that do not opt in (empty state, onboarding) get no X.
+ it("does not render dismiss button by default", () => {
+ render(
+ <RecommendedAutomationsRail
+ installedAutomations={[]}
+ onSelect={vi.fn()}
+ />,
+ );
+
+ expect(
+ screen.queryByTestId("recommended-automations-rail-dismiss"),
+ ).not.toBeInTheDocument();
+ });
+
+ // @spec HL-002 — The opted-in rail exposes a named X that dismisses it.
+ it("renders dismiss button when dismissible is true and calls onDismiss when clicked", async () => {
+ const user = userEvent.setup();
+ const onDismiss = vi.fn();
+ render(
+ <RecommendedAutomationsRail
+ installedAutomations={[]}
+ onSelect={vi.fn()}
+ dismissible
+ onDismiss={onDismiss}
+ />,
+ );
+
+ const dismissButton = screen.getByTestId(
+ "recommended-automations-rail-dismiss",
+ );
+ expect(dismissButton).toBeInTheDocument();
+ expect(dismissButton).toHaveAttribute(
+ "aria-label",
+ I18nKey.RECOMMENDED_AUTOMATIONS$DISMISS_LABEL,
+ );
+
+ await user.click(dismissButton);
+ expect(onDismiss).toHaveBeenCalledTimes(1);
+ });
+ });
});
diff --git a/__tests__/components/features/home/home-chat-launcher.test.tsx b/__tests__/components/features/home/home-chat-launcher.test.tsx
index b03e9d84d9..d91bf02e3c 100644
--- a/__tests__/components/features/home/home-chat-launcher.test.tsx
+++ b/__tests__/components/features/home/home-chat-launcher.test.tsx
@@ -12,6 +12,7 @@ import {
LAST_LOCAL_WORKSPACE_MODE_STORAGE_KEY,
writeStoredLocalWorkspaceMode,
} from "#/utils/workspace-mode";
+import { HOME_RECOMMENDED_AUTOMATIONS_DISMISSED_STORAGE_KEY } from "#/components/features/home/home-recommended-automations.constants";
const mockNavigate = vi.fn();
const mockUseActiveBackend = vi.fn();
@@ -236,12 +237,26 @@ vi.mock(
RecommendedAutomationsLauncher: ({
variant,
className,
+ dismissible,
+ onDismiss,
}: {
variant?: string;
className?: string;
+ dismissible?: boolean;
+ onDismiss?: () => void;
}) =>
variant === "rail" ? (
- <div data-testid="recommended-automations-rail" className={className} />
+ <div data-testid="recommended-automations-rail" className={className}>
+ {dismissible && onDismiss && (
+ <button
+ type="button"
+ data-testid="recommended-automations-rail-dismiss"
+ onClick={onDismiss}
+ >
+ Hide
+ </button>
+ )}
+ </div>
) : null,
}),
);
@@ -873,4 +888,42 @@ describe("HomeChatLauncher", () => {
screen.getByTestId("recommended-automations-rail"),
).toBeInTheDocument();
});
+
+ // @spec HL-002 — Dismissing Home's rail removes it and persists the choice.
+ it("renders recommended automations rail by default and hides it when dismissed", async () => {
+ const user = userEvent.setup();
+ renderLauncher();
+
+ expect(
+ screen.getByTestId("recommended-automations-rail"),
+ ).toBeInTheDocument();
+
+ const dismissBtn = screen.getByTestId(
+ "recommended-automations-rail-dismiss",
+ );
+ await user.click(dismissBtn);
+
+ expect(
+ screen.queryByTestId("recommended-automations-rail"),
+ ).not.toBeInTheDocument();
+ expect(
+ window.localStorage.getItem(
+ HOME_RECOMMENDED_AUTOMATIONS_DISMISSED_STORAGE_KEY,
+ ),
+ ).toBe("true");
+ });
+
+ // @spec HL-002 — A stored dismissal keeps the rail off Home.
+ it("does not render recommended automations rail when previously dismissed", () => {
+ window.localStorage.setItem(
+ HOME_RECOMMENDED_AUTOMATIONS_DISMISSED_STORAGE_KEY,
+ "true",
+ );
+
+ renderLauncher();
+
+ expect(
+ screen.queryByTestId("recommended-automations-rail"),
+ ).not.toBeInTheDocument();
+ });
});
diff --git a/__tests__/components/settings/app-settings/recommended-automations-switch.test.tsx b/__tests__/components/settings/app-settings/recommended-automations-switch.test.tsx
new file mode 100644
index 0000000000..8dff7e6216
--- /dev/null
+++ b/__tests__/components/settings/app-settings/recommended-automations-switch.test.tsx
@@ -0,0 +1,50 @@
+import { beforeEach, describe, expect, it } from "vitest";
+import { render, screen } from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
+import { RecommendedAutomationsSwitch } from "#/components/features/settings/app-settings/recommended-automations-switch";
+import { HOME_RECOMMENDED_AUTOMATIONS_DISMISSED_STORAGE_KEY } from "#/components/features/home/home-recommended-automations.constants";
+import { readHomeRecommendedAutomationsDismissed } from "#/components/features/home/home-recommended-automations-storage";
+
+describe("RecommendedAutomationsSwitch", () => {
+ beforeEach(() => {
+ window.localStorage.clear();
+ });
+
+ // @spec HL-002 — The switch defaults to on and writes the shared preference.
+ it("shows recommended automations by default and hides them when toggled off", async () => {
+ const user = userEvent.setup();
+ render(<RecommendedAutomationsSwitch />);
+
+ const toggle = screen.getByTestId("show-recommended-automations-switch");
+ expect(toggle).toBeChecked();
+ expect(readHomeRecommendedAutomationsDismissed()).toBe(false);
+
+ await user.click(toggle);
+
+ expect(toggle).not.toBeChecked();
+ expect(
+ window.localStorage.getItem(
+ HOME_RECOMMENDED_AUTOMATIONS_DISMISSED_STORAGE_KEY,
+ ),
+ ).toBe("true");
+ });
+
+ // @spec HL-002 — Turning the switch back on clears the dismissal.
+ it("re-enables recommended automations when toggled back on", async () => {
+ window.localStorage.setItem(
+ HOME_RECOMMENDED_AUTOMATIONS_DISMISSED_STORAGE_KEY,
+ "true",
+ );
+
+ const user = userEvent.setup();
+ render(<RecommendedAutomationsSwitch />);
+
+ const toggle = screen.getByTestId("show-recommended-automations-switch");
+ expect(toggle).not.toBeChecked();
+
+ await user.click(toggle);
+
+ expect(toggle).toBeChecked();
+ expect(readHomeRecommendedAutomationsDismissed()).toBe(false);
+ });
+});
diff --git a/specs/home-launcher.md b/specs/home-launcher.md
index 0f45078756..0147c7a051 100644
--- a/specs/home-launcher.md
+++ b/specs/home-launcher.md
@@ -3,3 +3,9 @@
### HL-001: Readable Code/Automate mode toggle
- [x] The selected mode label, and an unselected label while hovered, shall use the `contrast` high-emphasis ink on the `--oh-interactive-hover` pill. The built-in palettes keep that pairing at 4.5:1 or better: white in dark palettes, dark ink in Light+ and Solarized Light. Embedding roots may override `--oh-contrast`, and the toggle follows the nearest `[data-agent-server-ui]` scope. Mode selection, keyboard and radio semantics, and the pill animation are unchanged.
+
+### HL-002: Dismissible Recommended automations rail
+
+- [x] Home's Recommended automations rail shall show an X named "Hide Recommended automations" in its header. On fine-pointer devices the X appears while the rail is hovered or holds keyboard focus; on touch and coarse-pointer devices it is always visible.
+- [x] Clicking the X shall remove the whole rail from Home at once (heading, cards and bottom inset) and turn **Show Recommended automations** in Application settings off without a reload. Turning that switch back on shall restore the rail on the next Home render.
+- [x] The X and the switch shall share one browser-scoped preference that defaults to shown and survives a reload. The rails in the automations empty state and the onboarding say-hello step shall never show the X and shall ignore the preference.
diff --git a/src/components/features/automations/recommended-automations-launcher.tsx b/src/components/features/automations/recommended-automations-launcher.tsx
index fee6c56758..6e8308b2bf 100644
--- a/src/components/features/automations/recommended-automations-launcher.tsx
+++ b/src/components/features/automations/recommended-automations-launcher.tsx
@@ -55,6 +55,8 @@ interface RecommendedAutomationsLauncherProps {
*/
variant?: "catalog" | "rail";
className?: string;
+ dismissible?: boolean;
+ onDismiss?: () => void;
}
/**
@@ -90,6 +92,8 @@ export function RecommendedAutomationsLauncher({
scrollableGrid = false,
variant = "catalog",
className,
+ dismissible,
+ onDismiss,
}: RecommendedAutomationsLauncherProps) {
const activeBackend = useActiveBackend();
const { navigate } = useNavigation();
@@ -370,6 +374,8 @@ export function RecommendedAutomationsLauncher({
installedAutomations={automationsData?.automations ?? []}
hiddenAutomationIds={hiddenAutomationIds}
onSelect={handleSelectAutomation}
+ dismissible={dismissible}
+ onDismiss={onDismiss}
/>
) : (
<RecommendedAutomationsSection
diff --git a/src/components/features/automations/recommended-automations-rail.tsx b/src/components/features/automations/recommended-automations-rail.tsx
index 86bd8e447f..afef9db282 100644
--- a/src/components/features/automations/recommended-automations-rail.tsx
+++ b/src/components/features/automations/recommended-automations-rail.tsx
@@ -31,6 +31,8 @@ import {
extensionModuleCardInteractiveClassName,
extensionModuleCardSurfaceClassName,
} from "#/utils/extension-module-card-classes";
+import { X } from "lucide-react";
+import { hoverRevealActionClassName } from "#/utils/hover-reveal-classes";
interface RecommendedAutomationsRailProps {
installedAutomations: readonly Pick<Automation, "name">[];
@@ -38,6 +40,8 @@ interface RecommendedAutomationsRailProps {
hiddenAutomationIds?: ReadonlySet<string>;
onSelect: (automation: RecommendedAutomation) => void;
className?: string;
+ dismissible?: boolean;
+ onDismiss?: () => void;
}
/** Current catalog tiles reserve 40px for the icon; keep that row height. */
@@ -107,6 +111,8 @@ export function RecommendedAutomationsRail({
hiddenAutomationIds,
onSelect,
className,
+ dismissible = false,
+ onDismiss,
}: RecommendedAutomationsRailProps) {
const { t } = useTranslation("openhands");
const items = flattenRecommendedRailGroups(
@@ -151,11 +157,33 @@ export function RecommendedAutomationsRail({
<section
data-testid="recommended-automations-rail"
aria-label={t(I18nKey.RECOMMENDED_AUTOMATIONS$SECTION_LABEL)}
- className={cn("w-full", AUTOMATION_STACK_SECTION_BOTTOM_CLASS, className)}
+ className={cn(
+ "group w-full",
+ AUTOMATION_STACK_SECTION_BOTTOM_CLASS,
+ className,
+ )}
>
- <h2 className="mb-2 text-sm font-medium text-foreground">
- {t(I18nKey.RECOMMENDED_AUTOMATIONS$SECTION_LABEL)}
- </h2>
+ <div className="mb-2 flex items-center justify-between gap-2">
+ <h2 className="text-sm font-medium text-foreground">
+ {t(I18nKey.RECOMMENDED_AUTOMATIONS$SECTION_LABEL)}
+ </h2>
+ {/* @spec HL-002 — Named X, revealed on hover or focus, always visible on touch */}
+ {dismissible && onDismiss && (
+ <button
+ type="button"
+ data-testid="recommended-automations-rail-dismiss"
+ aria-label={t(I18nKey.RECOMMENDED_AUTOMATIONS$DISMISS_LABEL)}
+ onClick={onDismiss}
+ className={cn(
+ "inline-flex size-7 shrink-0 items-center justify-center rounded-md text-muted",
+ "transition-opacity motion-reduce:transition-none hover:text-content",
+ hoverRevealActionClassName(),
+ )}
+ >
+ <X className="size-4" />
+ </button>
+ )}
+ </div>
<div className="relative">
{/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions -- mouse drag-to-scroll is a pointer convenience; keyboard users scroll the list natively via the focusable cards. */}
diff --git a/src/components/features/home/home-chat-launcher.tsx b/src/components/features/home/home-chat-launcher.tsx
index a3efc68c37..ee363bd9af 100644
--- a/src/components/features/home/home-chat-launcher.tsx
+++ b/src/components/features/home/home-chat-launcher.tsx
@@ -37,6 +37,8 @@ import { markAutomationSetupHandoff } from "#/api/automation-setup-handoff-store
import { PluginPickerModal } from "#/components/features/plugins/plugin-picker-modal";
import { PluginPickerTrigger } from "#/components/features/plugins/plugin-picker-trigger";
import { RecommendedAutomationsLauncher } from "#/components/features/automations/recommended-automations-launcher";
+import { useHomeRecommendedAutomationsDismissed } from "./use-home-recommended-automations-dismissed";
+import { writeHomeRecommendedAutomationsDismissed } from "./home-recommended-automations-storage";
import { PinnedAutomationsDashboard } from "./featured-automations/pinned-automations-dashboard";
import { RunningAutomationsList } from "./featured-automations/running-automations-list";
import { HomeHeaderTitle } from "./home-header/home-header-title";
@@ -65,6 +67,8 @@ export function HomeChatLauncher() {
const [workspaceMode, setWorkspaceModeState] = useState<WorkspaceMode>(() =>
readStoredLocalWorkspaceMode(),
);
+ const isRecommendedAutomationsDismissed =
+ useHomeRecommendedAutomationsDismissed();
const [selectedPlugins, setSelectedPlugins] = useState<PluginSpec[]>([]);
const [isPluginPickerOpen, setIsPluginPickerOpen] = useState(false);
const [launcherMode, setLauncherMode] = useState<HomeLauncherMode>("code");
@@ -368,7 +372,14 @@ export function HomeChatLauncher() {
</div>
<div className="mt-8 flex w-full flex-col gap-8">
- <RecommendedAutomationsLauncher variant="rail" />
+ {/* @spec HL-002 — Only Home's rail is dismissible; dismissal unmounts it, inset included */}
+ {!isRecommendedAutomationsDismissed && (
+ <RecommendedAutomationsLauncher
+ variant="rail"
+ dismissible
+ onDismiss={() => writeHomeRecommendedAutomationsDismissed(true)}
+ />
+ )}
<PinnedAutomationsDashboard />
<RunningAutomationsList />
</div>
diff --git a/src/components/features/home/home-recommended-automations-storage.ts b/src/components/features/home/home-recommended-automations-storage.ts
new file mode 100644
index 0000000000..9f97219567
--- /dev/null
+++ b/src/components/features/home/home-recommended-automations-storage.ts
@@ -0,0 +1,52 @@
+import {
+ HOME_RECOMMENDED_AUTOMATIONS_DISMISSED_CHANGE_EVENT,
+ HOME_RECOMMENDED_AUTOMATIONS_DISMISSED_STORAGE_KEY,
+} from "./home-recommended-automations.constants";
+
+export function readHomeRecommendedAutomationsDismissed(): boolean {
+ if (typeof window === "undefined") {
+ return false;
+ }
+
+ return (
+ window.localStorage.getItem(
+ HOME_RECOMMENDED_AUTOMATIONS_DISMISSED_STORAGE_KEY,
+ ) === "true"
+ );
+}
+
+export function getHomeRecommendedAutomationsDismissedSnapshot(): boolean {
+ return readHomeRecommendedAutomationsDismissed();
+}
+
+export function subscribeHomeRecommendedAutomationsDismissed(
+ onStoreChange: () => void,
+): () => void {
+ const handleChange = () => onStoreChange();
+ window.addEventListener("storage", handleChange);
+ window.addEventListener(
+ HOME_RECOMMENDED_AUTOMATIONS_DISMISSED_CHANGE_EVENT,
+ handleChange,
+ );
+
+ return () => {
+ window.removeEventListener("storage", handleChange);
+ window.removeEventListener(
+ HOME_RECOMMENDED_AUTOMATIONS_DISMISSED_CHANGE_EVENT,
+ handleChange,
+ );
+ };
+}
+
+// @spec HL-002 — The Home X and the Application settings switch share this one writer.
+export function writeHomeRecommendedAutomationsDismissed(
+ dismissed: boolean,
+): void {
+ window.localStorage.setItem(
+ HOME_RECOMMENDED_AUTOMATIONS_DISMISSED_STORAGE_KEY,
+ dismissed ? "true" : "false",
+ );
+ window.dispatchEvent(
+ new Event(HOME_RECOMMENDED_AUTOMATIONS_DISMISSED_CHANGE_EVENT),
+ );
+}
diff --git a/src/components/features/home/home-recommended-automations.constants.ts b/src/components/features/home/home-recommended-automations.constants.ts
new file mode 100644
index 0000000000..1d6b370647
--- /dev/null
+++ b/src/components/features/home/home-recommended-automations.constants.ts
@@ -0,0 +1,4 @@
+export const HOME_RECOMMENDED_AUTOMATIONS_DISMISSED_STORAGE_KEY =
+ "openhands.home_recommended_automations_dismissed";
+export const HOME_RECOMMENDED_AUTOMATIONS_DISMISSED_CHANGE_EVENT =
+ "openhands:home-recommended-automations-dismissed-change";
diff --git a/src/components/features/home/use-home-recommended-automations-dismissed.ts b/src/components/features/home/use-home-recommended-automations-dismissed.ts
new file mode 100644
index 0000000000..db90ea99ab
--- /dev/null
+++ b/src/components/features/home/use-home-recommended-automations-dismissed.ts
@@ -0,0 +1,13 @@
+import { useSyncExternalStore } from "react";
+import {
+ getHomeRecommendedAutomationsDismissedSnapshot,
+ subscribeHomeRecommendedAutomationsDismissed,
+} from "./home-recommended-automations-storage";
+
+export function useHomeRecommendedAutomationsDismissed(): boolean {
+ return useSyncExternalStore(
+ subscribeHomeRecommendedAutomationsDismissed,
+ getHomeRecommendedAutomationsDismissedSnapshot,
+ () => false,
+ );
+}
diff --git a/src/components/features/settings/app-settings/recommended-automations-switch.tsx b/src/components/features/settings/app-settings/recommended-automations-switch.tsx
new file mode 100644
index 0000000000..1442b00d67
--- /dev/null
+++ b/src/components/features/settings/app-settings/recommended-automations-switch.tsx
@@ -0,0 +1,24 @@
+import { useTranslation } from "react-i18next";
+import { SettingsSwitch } from "#/components/features/settings/settings-switch";
+import { useHomeRecommendedAutomationsDismissed } from "#/components/features/home/use-home-recommended-automations-dismissed";
+import { writeHomeRecommendedAutomationsDismissed } from "#/components/features/home/home-recommended-automations-storage";
+import { I18nKey } from "#/i18n/declaration";
+
+export function RecommendedAutomationsSwitch() {
+ const { t } = useTranslation("openhands");
+ const isDismissed = useHomeRecommendedAutomationsDismissed();
+
+ const handleToggle = (showRail: boolean) => {
+ writeHomeRecommendedAutomationsDismissed(!showRail);
+ };
+
+ return (
+ <SettingsSwitch
+ testId="show-recommended-automations-switch"
+ isToggled={!isDismissed}
+ onToggle={handleToggle}
+ >
+ {t(I18nKey.SETTINGS$SHOW_RECOMMENDED_AUTOMATIONS)}
+ </SettingsSwitch>
+ );
+}
diff --git a/src/i18n/translation.json b/src/i18n/translation.json
index 9479913a13..50b2477f3c 100644
--- a/src/i18n/translation.json
+++ b/src/i18n/translation.json
@@ -38915,6 +38915,24 @@
"uk": "Рекомендовані автоматизації",
"id": "Otomatisasi yang disarankan"
},
+ "RECOMMENDED_AUTOMATIONS$DISMISS_LABEL": {
+ "en": "Hide Recommended automations",
+ "ja": "おすすめの自動化を非表示",
+ "zh-CN": "隐藏推荐的自动化",
+ "zh-TW": "隱藏推薦的自動化",
+ "ko-KR": "추천 자동화 숨기기",
+ "no": "Skjul anbefalte automatiseringer",
+ "ar": "إخفاء الأتمتات الموصى بها",
+ "de": "Empfohlene Automatisierungen ausblenden",
+ "fr": "Masquer les automatisations recommandées",
+ "it": "Nascondi automazioni consigliate",
+ "pt": "Ocultar automações recomendadas",
+ "es": "Ocultar automatizaciones recomendadas",
+ "ca": "Amaga les automatitzacions recomanades",
+ "tr": "Önerilen otomasyonları gizle",
+ "uk": "Сховати рекомендовані автоматизації",
+ "id": "Sembunyikan otomatisasi yang disarankan"
+ },
"RECOMMENDED_AUTOMATIONS$SECTION_TITLE": {
"en": "Start from a proven workflow",
"ja": "実績のあるワークフローから始める",
@@ -45917,6 +45935,24 @@
"ca": "Mostra la llista Per començar",
"id": "Tampilkan daftar periksa Memulai"
},
+ "SETTINGS$SHOW_RECOMMENDED_AUTOMATIONS": {
+ "en": "Show Recommended automations",
+ "ja": "おすすめの自動化を表示",
+ "zh-CN": "显示推荐的自动化",
+ "zh-TW": "顯示推薦的自動化",
+ "ko-KR": "추천 자동화 표시",
+ "de": "Empfohlene Automatisierungen anzeigen",
+ "no": "Vis anbefalte automatiseringer",
+ "it": "Mostra automazioni consigliate",
+ "pt": "Mostrar automações recomendadas",
+ "es": "Mostrar automatizaciones recomendadas",
+ "ar": "إظهار الأتمتات الموصى بها",
+ "fr": "Afficher les automatisations recommandées",
+ "tr": "Önerilen otomasyonları göster",
+ "uk": "Показувати рекомендовані автоматизації",
+ "ca": "Mostra les automatitzacions recomanades",
+ "id": "Tampilkan otomatisasi yang disarankan"
+ },
"ONBOARDING$SKIP_GETTING_STARTED_CHECKLIST": {
"en": "Skip Getting Started checklist",
"ja": "Getting Started チェックリストをスキップ",
diff --git a/src/routes/app-settings.tsx b/src/routes/app-settings.tsx
index 639a21dfd1..0ef025c81c 100644
--- a/src/routes/app-settings.tsx
+++ b/src/routes/app-settings.tsx
@@ -12,6 +12,7 @@ import { I18nKey } from "#/i18n/declaration";
import { LanguageInput } from "#/components/features/settings/app-settings/language-input";
import { ThemeInput } from "#/components/features/settings/app-settings/theme-input";
import { GettingStartedChecklistSwitch } from "#/components/features/settings/app-settings/getting-started-checklist-switch";
+import { RecommendedAutomationsSwitch } from "#/components/features/settings/app-settings/recommended-automations-switch";
import { VoiceInputSettings } from "#/components/features/settings/app-settings/voice-input-settings";
import {
displayErrorToast,
@@ -240,6 +241,7 @@ function AppSettingsForm() {
</SettingsSwitch>
<GettingStartedChecklistSwitch />
+ <RecommendedAutomationsSwitch />
<div className="border-t border-border pt-6 mt-2">
<h3 className="text-lg font-medium mb-2">