Skip to content

πŸ™Œ OpenHands: AI-Driven Development

feat: edit automations from the list row kebab (#613)

Hiep Le8bb3f8ec7f7b
diff --git a/__tests__/routes/automations-list.test.tsx b/__tests__/routes/automations-list.test.tsx
new file mode 100644
index 0000000000..00774955e9
--- /dev/null
+++ b/__tests__/routes/automations-list.test.tsx
@@ -0,0 +1,145 @@
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import React from "react";
+import { render, screen, waitFor } from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import { MemoryRouter } from "react-router";
+
+import { I18nKey } from "#/i18n/declaration";
+
+import AutomationService from "#/api/automation-service/automation-service.api";
+import {
+ __resetActiveStoreForTests,
+ setActiveSelection,
+ setRegisteredBackends,
+} from "#/api/backend-registry/active-store";
+import { ActiveBackendProvider } from "#/contexts/active-backend-context";
+import AutomationsList from "#/routes/automations-list";
+import type { Backend } from "#/api/backend-registry/types";
+import type { Automation, AutomationsResponse } from "#/types/automation";
+
+vi.mock("#/api/automation-service/automation-service.api", () => ({
+ default: {
+ getAutomations: vi.fn(),
+ updateAutomation: vi.fn(),
+ toggleAutomation: vi.fn(),
+ deleteAutomation: vi.fn(),
+ checkHealth: vi.fn(),
+ },
+}));
+
+const localBackend: Backend = {
+ id: "local-1",
+ name: "Local 1",
+ host: "http://localhost:8000",
+ apiKey: "session-key",
+ kind: "local",
+};
+
+const cloudBackend: Backend = {
+ id: "cloud-1",
+ name: "Production",
+ host: "https://app.all-hands.dev",
+ apiKey: "bearer-key",
+ kind: "cloud",
+};
+
+const automation: Automation = {
+ id: "auto-1",
+ name: "Daily digest",
+ prompt: "Summarize yesterday's PRs",
+ trigger: { type: "cron", schedule: "0 9 * * *", schedule_human: "Daily" },
+ enabled: true,
+ repository: "acme/repo",
+ model: "Claude",
+ created_at: "2026-01-01T00:00:00Z",
+ updated_at: "2026-01-01T00:00:00Z",
+};
+
+const listResponse: AutomationsResponse = {
+ automations: [automation],
+ total: 1,
+};
+
+function renderList() {
+ const queryClient = new QueryClient({
+ defaultOptions: { queries: { retry: false }, mutations: { retry: false } },
+ });
+ return render(
+ <QueryClientProvider client={queryClient}>
+ <ActiveBackendProvider>
+ <MemoryRouter initialEntries={["/automations"]}>
+ <AutomationsList />
+ </MemoryRouter>
+ </ActiveBackendProvider>
+ </QueryClientProvider>,
+ );
+}
+
+beforeEach(() => {
+ window.localStorage.clear();
+ __resetActiveStoreForTests();
+ vi.mocked(AutomationService.checkHealth).mockReset();
+ vi.mocked(AutomationService.checkHealth).mockResolvedValue({ status: "ok" });
+ vi.mocked(AutomationService.getAutomations).mockReset();
+ vi.mocked(AutomationService.getAutomations).mockResolvedValue(listResponse);
+ vi.mocked(AutomationService.updateAutomation).mockReset();
+ setRegisteredBackends([localBackend, cloudBackend]);
+ setActiveSelection({ backendId: localBackend.id });
+});
+
+afterEach(() => {
+ window.localStorage.clear();
+ __resetActiveStoreForTests();
+});
+
+describe("AutomationsList β€” Edit from the row kebab is local-only", () => {
+ it("opens the Edit modal pre-filled with the row's values when the active backend is local", async () => {
+ // Arrange β€” local backend is active (default beforeEach); render the list
+ // and wait for the row to appear.
+ const user = userEvent.setup();
+ renderList();
+ await waitFor(() => {
+ expect(AutomationService.getAutomations).toHaveBeenCalledTimes(1);
+ });
+ await screen.findByText(automation.name);
+
+ // Act β€” open the row kebab and pick Edit.
+ await user.click(screen.getByLabelText("Automation actions"));
+ await user.click(
+ screen.getByRole("button", { name: I18nKey.AUTOMATIONS$EDIT }),
+ );
+
+ // Assert β€” the shared Edit modal mounts wired to this row (name input is
+ // pre-filled with that row's name, proving the list page passed the right
+ // automation through).
+ const nameInput = (await screen.findByTestId(
+ "edit-automation-name",
+ )) as HTMLInputElement;
+ expect(nameInput.value).toBe(automation.name);
+ });
+
+ it("hides Edit in the row kebab when the active backend is cloud", async () => {
+ // Arrange β€” switch to the cloud backend before mounting so the page sees
+ // it as the active backend on first render.
+ setActiveSelection({ backendId: cloudBackend.id });
+ const user = userEvent.setup();
+ renderList();
+ await waitFor(() => {
+ expect(AutomationService.getAutomations).toHaveBeenCalledTimes(1);
+ });
+ await screen.findByText(automation.name);
+
+ // Act β€” open the row kebab.
+ await user.click(screen.getByLabelText("Automation actions"));
+
+ // Assert β€” Edit must not appear on cloud; Delete still does, proving the
+ // menu actually opened and we didn't merely fail to render it.
+ expect(
+ screen.queryByRole("button", { name: I18nKey.AUTOMATIONS$EDIT }),
+ ).not.toBeInTheDocument();
+ expect(
+ screen.getByRole("button", { name: I18nKey.AUTOMATIONS$DELETE }),
+ ).toBeInTheDocument();
+ });
+});
diff --git a/src/components/features/automations/automation-card.tsx b/src/components/features/automations/automation-card.tsx
index 6a8644d52b..4834321acb 100644
--- a/src/components/features/automations/automation-card.tsx
+++ b/src/components/features/automations/automation-card.tsx
@@ -12,17 +12,20 @@ import ClockIcon from "#/icons/clock.svg?react";
import SparkleIcon from "#/icons/sparkle.svg?react";
import PowerIcon from "#/icons/power.svg?react";
import TrashIcon from "#/icons/trash.svg?react";
+import EditIcon from "#/icons/u-edit.svg?react";
interface AutomationCardProps {
automation: Automation;
onToggle: (id: string, enabled: boolean) => void;
onDelete: (id: string) => void;
+ onEdit?: (id: string) => void;
}
export function AutomationCard({
automation,
onToggle,
onDelete,
+ onEdit,
}: AutomationCardProps) {
const { navigate } = useNavigation();
const { t } = useTranslation("openhands");
@@ -32,6 +35,15 @@ export function AutomationCard({
automation.trigger.schedule_human || automation.trigger.type;
const menuItems: KebabMenuItem[] = [
+ ...(onEdit
+ ? [
+ {
+ label: t(I18nKey.AUTOMATIONS$EDIT),
+ icon: <EditIcon className="size-4" />,
+ onClick: () => onEdit(automation.id),
+ },
+ ]
+ : []),
{
label: automation.enabled
? t(I18nKey.AUTOMATIONS$TURN_OFF)
diff --git a/src/components/features/automations/automation-group.tsx b/src/components/features/automations/automation-group.tsx
index 70e0251dfa..225adfba4c 100644
--- a/src/components/features/automations/automation-group.tsx
+++ b/src/components/features/automations/automation-group.tsx
@@ -8,6 +8,7 @@ interface AutomationGroupProps {
automations: Automation[];
onToggle: (id: string, enabled: boolean) => void;
onDelete: (id: string) => void;
+ onEdit?: (id: string) => void;
}
export function AutomationGroup({
@@ -16,6 +17,7 @@ export function AutomationGroup({
automations,
onToggle,
onDelete,
+ onEdit,
}: AutomationGroupProps) {
if (automations.length === 0) return null;
@@ -32,6 +34,7 @@ export function AutomationGroup({
automation={automation}
onToggle={onToggle}
onDelete={onDelete}
+ onEdit={onEdit}
/>
))}
</div>
diff --git a/src/routes/automations-list.tsx b/src/routes/automations-list.tsx
index c18c59ca5b..e03f6dbae5 100644
--- a/src/routes/automations-list.tsx
+++ b/src/routes/automations-list.tsx
@@ -7,6 +7,7 @@ import {
useDeleteAutomation,
} from "#/hooks/query/use-automations";
import { useAutomationHealth } from "#/hooks/query/use-automation-health";
+import { useActiveBackend } from "#/contexts/active-backend-context";
import { SearchInput } from "#/components/features/automations/search-input";
import { AutomationGroup } from "#/components/features/automations/automation-group";
import { AutomationCardSkeleton } from "#/components/features/automations/automation-card-skeleton";
@@ -14,7 +15,9 @@ import { EmptyState } from "#/components/features/automations/empty-state";
import { ErrorState } from "#/components/features/automations/error-state";
import { BackendNotConfigured } from "#/components/features/automations/backend-not-configured";
import { DeleteConfirmationModal } from "#/components/features/automations/delete-confirmation-modal";
+import { EditAutomationModal } from "#/components/features/automations/detail/edit-automation-modal";
import { CreateInstructions } from "#/components/features/automations/create-instructions";
+import type { Automation } from "#/types/automation";
const PAGE_SIZE = 50;
@@ -26,6 +29,12 @@ export default function AutomationsList() {
id: string;
name: string;
} | null>(null);
+ const [editTarget, setEditTarget] = useState<Automation | null>(null);
+
+ const active = useActiveBackend();
+ // Edit is a local-backend-only feature in MVP β€” cloud automations
+ // are managed elsewhere and we don't yet surface them here.
+ const canEdit = active.backend.kind === "local";
const {
data: healthData,
@@ -57,7 +66,10 @@ export default function AutomationsList() {
);
}, [data?.automations, searchQuery]);
- const active = useMemo(() => filtered.filter((a) => a.enabled), [filtered]);
+ const activeAutomations = useMemo(
+ () => filtered.filter((a) => a.enabled),
+ [filtered],
+ );
const inactive = useMemo(
() => filtered.filter((a) => !a.enabled),
[filtered],
@@ -74,6 +86,13 @@ export default function AutomationsList() {
}
};
+ const handleEditRequest = (id: string) => {
+ const automation = data?.automations.find((a) => a.id === id);
+ if (automation) {
+ setEditTarget(automation);
+ }
+ };
+
const handleDeleteConfirm = () => {
if (deleteTarget) {
deleteMutation.mutate(deleteTarget.id);
@@ -160,10 +179,11 @@ export default function AutomationsList() {
<AutomationGroup
title={t(I18nKey.AUTOMATIONS$ACTIVE)}
- count={active.length}
- automations={active}
+ count={activeAutomations.length}
+ automations={activeAutomations}
onToggle={handleToggle}
onDelete={handleDeleteRequest}
+ onEdit={canEdit ? handleEditRequest : undefined}
/>
<AutomationGroup
title={t(I18nKey.AUTOMATIONS$INACTIVE)}
@@ -171,6 +191,7 @@ export default function AutomationsList() {
automations={inactive}
onToggle={handleToggle}
onDelete={handleDeleteRequest}
+ onEdit={canEdit ? handleEditRequest : undefined}
/>
{hasMore && (
@@ -193,6 +214,15 @@ export default function AutomationsList() {
onConfirm={handleDeleteConfirm}
onCancel={() => setDeleteTarget(null)}
/>
+
+ {/* Edit modal β€” local backends only */}
+ {editTarget && (
+ <EditAutomationModal
+ automation={editTarget}
+ isOpen={editTarget !== null}
+ onClose={() => setEditTarget(null)}
+ />
+ )}
</div>
</div>
);