Skip to content

πŸ™Œ OpenHands: AI-Driven Development

feat(automations): filter the automations dashboard by creator (#17814)

Henrique Hirako8b0be7d5181d
diff --git a/__tests__/api/automation-service.test.ts b/__tests__/api/automation-service.test.ts
index aec847e6f0..ede2e341df 100644
--- a/__tests__/api/automation-service.test.ts
+++ b/__tests__/api/automation-service.test.ts
@@ -191,6 +191,16 @@ describe("AutomationService", () => {
params: { limit: 50, offset: 0 },
});
});
+
+ it("sends the creator filter as created_by", async () => {
+ mockGet.mockResolvedValue({ data: { automations: [], total: 0 } });
+
+ await AutomationService.listAutomations({ createdBy: "others" });
+
+ expect(mockGet).toHaveBeenCalledWith("/api/automation/v1", {
+ params: { limit: 50, offset: 0, created_by: "others" },
+ });
+ });
});
describe("getAutomations", () => {
@@ -389,6 +399,18 @@ describe("AutomationService", () => {
expect(result).toEqual(response);
});
+ it("listAutomations adds the creator filter to the path", async () => {
+ mockCallCloudProxy.mockResolvedValue({ automations: [], total: 0 });
+
+ await AutomationService.listAutomations({ createdBy: "me" });
+
+ expect(mockCallCloudProxy).toHaveBeenCalledWith(
+ expect.objectContaining({
+ path: "/api/automation/v1?limit=50&offset=0&created_by=me",
+ }),
+ );
+ });
+
it("getAutomation routes to callCloudProxy with the id in the path", async () => {
mockCallCloudProxy.mockResolvedValue(mockAutomation);
diff --git a/__tests__/components/features/automations/dashboard/automations-dashboard-controls.test.tsx b/__tests__/components/features/automations/dashboard/automations-dashboard-controls.test.tsx
new file mode 100644
index 0000000000..c22ea642ec
--- /dev/null
+++ b/__tests__/components/features/automations/dashboard/automations-dashboard-controls.test.tsx
@@ -0,0 +1,55 @@
+import { render, screen, within } from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
+import { describe, expect, it } from "vitest";
+import { AutomationsDashboardControls } from "#/components/features/automations/dashboard/automations-dashboard-controls";
+import type { DashboardSpec } from "#/manifests/automation-interface";
+import { createInterfaceManifestWithSubPages } from "../../../../manifests/manifest-test-data";
+
+describe("AutomationsDashboardControls β€” creator filter declaration", () => {
+ const noop = () => {};
+
+ it("hides the creator field and its value when the manifest does not declare it", async () => {
+ // Arrange β€” a cloud team workspace, which offers the creator filter
+ // whenever the manifest declares it, and a manifest without created_by
+ // (as in a package before the filter was added). The creator value is
+ // not the default, so a badge or Reset all would come only from it.
+ const user = userEvent.setup();
+ const list = createInterfaceManifestWithSubPages().pages.list;
+ const spec: DashboardSpec = {
+ overview: list.overview!,
+ filters: list.filters!.filter((filter) => filter.id !== "created_by"),
+ sort: list.sort!,
+ insights: list.insights!,
+ };
+ render(
+ <AutomationsDashboardControls
+ spec={spec}
+ status="all"
+ trigger="all"
+ createdBy="me"
+ canFilterByCreator
+ sort={spec.sort.default}
+ onStatusChange={noop}
+ onTriggerChange={noop}
+ onCreatedByChange={noop}
+ onSortChange={noop}
+ />,
+ );
+ const filtersButton = within(
+ screen.getByTestId("automations-filters"),
+ ).getByTestId("dropdown-trigger");
+
+ // Act
+ await user.click(filtersButton);
+
+ // Assert β€” no field, no active-filter badge, no Reset all.
+ const menu = screen.getByTestId("automations-filters-menu");
+ expect(
+ within(menu).queryByTestId("automations-filter-created-by"),
+ ).not.toBeInTheDocument();
+ expect(
+ within(menu).queryByTestId("automations-filters-reset"),
+ ).not.toBeInTheDocument();
+ expect(within(filtersButton).queryByText(/^\d+$/)).not.toBeInTheDocument();
+ });
+});
diff --git a/__tests__/hooks/query/use-automations-backend-switch.test.tsx b/__tests__/hooks/query/use-automations-backend-switch.test.tsx
index 30c7248420..16aed76939 100644
--- a/__tests__/hooks/query/use-automations-backend-switch.test.tsx
+++ b/__tests__/hooks/query/use-automations-backend-switch.test.tsx
@@ -165,6 +165,26 @@ describe("automation hooks β€” backend switch", () => {
});
});
+ it("useAutomations shows no automations of the previous backend while the next one loads", async () => {
+ // Arrange β€” the local backend's list is loaded; the cloud one never settles.
+ const { result } = renderHook(() => useAutomations(), {
+ wrapper: makeWrapper(),
+ });
+ await waitFor(() => expect(result.current.isSuccess).toBe(true));
+ vi.mocked(AutomationService.getAutomations).mockReturnValue(
+ new Promise(() => {}),
+ );
+
+ // Act
+ act(() => setActiveSelection({ backendId: cloudBackend.id }));
+
+ // Assert
+ await waitFor(() =>
+ expect(AutomationService.getAutomations).toHaveBeenCalledTimes(2),
+ );
+ expect(result.current.data).toBeUndefined();
+ });
+
it("useAutomationDetail refetches when the active backend changes", async () => {
const { result } = renderHook(() => useAutomationDetail({ id: "auto-1" }), {
wrapper: makeWrapper(),
diff --git a/__tests__/manifests/automation-insights.test.ts b/__tests__/manifests/automation-insights.test.ts
index 9ae25dce59..e3a8dead6b 100644
--- a/__tests__/manifests/automation-insights.test.ts
+++ b/__tests__/manifests/automation-insights.test.ts
@@ -316,6 +316,8 @@ describe("applyDashboardView", () => {
search: "",
status: "all",
trigger: "all",
+ createdBy: "all",
+ currentUserId: null,
sort: "name",
} as const;
@@ -351,6 +353,70 @@ describe("applyDashboardView", () => {
}).toEqual({ scheduled: ["healthy", "failing"], events: ["evented"] });
});
+ it("splits automations by creator, counting a missing creator as someone else's", () => {
+ // Arrange
+ const mine = createAutomation({
+ id: "mine",
+ name: "A mine",
+ user_id: "me",
+ });
+ const theirs = createAutomation({
+ id: "theirs",
+ name: "B theirs",
+ user_id: "teammate",
+ });
+ const unowned = createAutomation({ id: "unowned", name: "C unowned" });
+ const automations = [unowned, theirs, mine];
+
+ // Act
+ const view = (createdBy: "all" | "me" | "others") =>
+ applyDashboardView(
+ automations,
+ { ...neutral, createdBy, currentUserId: "me" },
+ byId,
+ ).map((a) => a.id);
+
+ // Assert
+ expect({
+ all: view("all"),
+ me: view("me"),
+ others: view("others"),
+ }).toEqual({
+ all: ["mine", "theirs", "unowned"],
+ me: ["mine"],
+ others: ["theirs", "unowned"],
+ });
+ });
+
+ it("leaves the creator filter inert while the caller's identity is unknown", () => {
+ // Arrange
+ const mine = createAutomation({
+ id: "mine",
+ name: "A mine",
+ user_id: "me",
+ });
+ const automations = [mine];
+
+ // Act
+ const askingForMe = applyDashboardView(
+ automations,
+ { ...neutral, createdBy: "me", currentUserId: null },
+ byId,
+ );
+ const askingForOthers = applyDashboardView(
+ automations,
+ { ...neutral, createdBy: "others", currentUserId: null },
+ byId,
+ );
+
+ // Assert β€” no identity means neither bucket can claim anything, so it
+ // behaves exactly like "all".
+ expect({
+ me: askingForMe.map((a) => a.id),
+ others: askingForOthers.map((a) => a.id),
+ }).toEqual({ me: ["mine"], others: ["mine"] });
+ });
+
it("orders by lifetime run count under the runs sort", () => {
// Act
const visible = applyDashboardView(all, { ...neutral, sort: "runs" }, byId);
diff --git a/__tests__/manifests/interface-validation.test.ts b/__tests__/manifests/interface-validation.test.ts
index 951e9527ec..4f885f00f8 100644
--- a/__tests__/manifests/interface-validation.test.ts
+++ b/__tests__/manifests/interface-validation.test.ts
@@ -317,6 +317,28 @@ describe("validateInterfaceManifest", () => {
},
}),
],
+ [
+ "a creator filter value this host does not implement",
+ (manifest) => ({
+ ...manifest,
+ pages: {
+ ...manifest.pages,
+ list: {
+ ...manifest.pages.list,
+ filters: [
+ {
+ id: "created_by",
+ label: "Filter widgets by maker",
+ options: [
+ { value: "all", label: "Any maker" },
+ { value: "my-team" as "me", label: "My team's widgets" },
+ ],
+ },
+ ],
+ },
+ },
+ }),
+ ],
[
"a sort default the options do not offer",
(manifest) => ({
diff --git a/__tests__/manifests/manifest-test-data.ts b/__tests__/manifests/manifest-test-data.ts
index a52d0bd7d8..0eed81535e 100644
--- a/__tests__/manifests/manifest-test-data.ts
+++ b/__tests__/manifests/manifest-test-data.ts
@@ -215,6 +215,15 @@ export function createInterfaceManifestWithSubPages(): InterfaceManifest {
{ value: "event", label: "Evented" },
],
},
+ {
+ id: "created_by",
+ label: "Filter widgets by maker",
+ options: [
+ { value: "all", label: "Any maker" },
+ { value: "me", label: "My widgets" },
+ { value: "others", label: "Teammates' widgets" },
+ ],
+ },
],
sort: {
label: "Order widgets",
diff --git a/__tests__/routes/automations-dashboard.test.tsx b/__tests__/routes/automations-dashboard.test.tsx
index 4152414154..225e2bfd0f 100644
--- a/__tests__/routes/automations-dashboard.test.tsx
+++ b/__tests__/routes/automations-dashboard.test.tsx
@@ -1,6 +1,6 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import React from "react";
-import { render, screen, waitFor, within } from "@testing-library/react";
+import { act, render, screen, waitFor, within } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { MemoryRouter } from "react-router";
@@ -18,6 +18,11 @@ import AutomationTemplates, {
clientLoader as templatesLoader,
} from "#/routes/automation-templates";
import type { Backend } from "#/api/backend-registry/types";
+import {
+ getCloudOrganizationMe,
+ getCloudOrganizations,
+ getCurrentCloudApiKey,
+} from "#/api/cloud/organization-service.api";
import {
AutomationRunStatus,
type Automation,
@@ -37,6 +42,15 @@ vi.mock("#/manifests/manifest-sources", async (importOriginal) => {
};
});
+vi.mock("#/api/cloud/organization-service.api", async (importOriginal) => ({
+ ...(await importOriginal<
+ typeof import("#/api/cloud/organization-service.api")
+ >()),
+ getCloudOrganizations: vi.fn(),
+ getCloudOrganizationMe: vi.fn(),
+ getCurrentCloudApiKey: vi.fn(),
+}));
+
vi.mock("#/api/automation-service/automation-service.api", () => ({
default: {
getAutomations: vi.fn(),
@@ -268,6 +282,10 @@ describe("AutomationsList β€” manifest-declared dashboard", () => {
"automations-sort",
),
).toBeInTheDocument();
+ // Local backends have no per-user creators to split by.
+ expect(
+ screen.queryByTestId("automations-filter-created-by"),
+ ).not.toBeInTheDocument();
expect(
within(screen.getByTestId("automations-filters-menu")).getByText(
"Filter widgets by state",
@@ -362,6 +380,405 @@ describe("AutomationsList β€” manifest-declared dashboard", () => {
});
});
+describe("AutomationsList β€” created-by filter on cloud workspaces", () => {
+ const TEAM_ORG_ID = "org-team";
+ const CURRENT_USER_ID = "user-me";
+ const cloudBackend: Backend = {
+ id: "cloud-1",
+ name: "Production",
+ host: "https://app.all-hands.dev",
+ apiKey: "bearer-key",
+ kind: "cloud",
+ };
+ const mine = createAutomation({
+ id: "a-mine",
+ name: "Alpha widget",
+ user_id: CURRENT_USER_ID,
+ });
+ const theirs = createAutomation({
+ id: "a-theirs",
+ name: "Beta widget",
+ user_id: "user-teammate",
+ });
+ const unowned = createAutomation({ id: "a-unowned", name: "Gamma widget" });
+
+ function selectWorkspace(orgId: string) {
+ setRegisteredBackends([cloudBackend]);
+ setActiveSelection({ backendId: cloudBackend.id, orgId });
+ }
+
+ async function openFiltersMenu(user: ReturnType<typeof userEvent.setup>) {
+ await user.click(
+ within(screen.getByTestId("automations-filters")).getByTestId(
+ "dropdown-trigger",
+ ),
+ );
+ }
+
+ async function pickCreatedBy(
+ user: ReturnType<typeof userEvent.setup>,
+ value: "all" | "me" | "others",
+ ) {
+ await user.click(
+ within(
+ await screen.findByTestId("automations-filter-created-by"),
+ ).getByTestId("dropdown-trigger"),
+ );
+ await user.click(
+ screen.getByTestId(`automations-filter-created-by-${value}`),
+ );
+ }
+
+ function visibleCardIds() {
+ return screen
+ .queryAllByTestId(/^automation-card-/)
+ .map((card) => card.getAttribute("data-testid"));
+ }
+
+ beforeEach(() => {
+ vi.mocked(AutomationService.getAutomations).mockResolvedValue({
+ automations: [mine, theirs, unowned],
+ total: 3,
+ });
+ vi.mocked(AutomationService.getAutomationRuns).mockResolvedValue({
+ runs: [createRun({})],
+ total: 1,
+ });
+ vi.mocked(getCloudOrganizations).mockResolvedValue({
+ items: [
+ { id: TEAM_ORG_ID, name: "Widget team", is_personal: false },
+ { id: CURRENT_USER_ID, name: "Personal", is_personal: true },
+ ],
+ currentOrgId: TEAM_ORG_ID,
+ });
+ vi.mocked(getCurrentCloudApiKey).mockResolvedValue({
+ orgId: null,
+ isLegacyKey: true,
+ });
+ vi.mocked(getCloudOrganizationMe).mockImplementation(async (orgId) => ({
+ orgId,
+ userId: CURRENT_USER_ID,
+ role: "member",
+ permissions: ["view_automations"],
+ }));
+ });
+
+ it("narrows a team workspace to my automations", async () => {
+ // Arrange
+ const user = userEvent.setup();
+ selectWorkspace(TEAM_ORG_ID);
+ renderAt("/automations", <AutomationsList />);
+ await screen.findByTestId("automation-card-a-unowned");
+ await openFiltersMenu(user);
+
+ // Act
+ await pickCreatedBy(user, "me");
+
+ // Assert
+ await waitFor(() => {
+ expect(visibleCardIds()).toEqual(["automation-card-a-mine"]);
+ });
+ expect(
+ screen.getByRole("button", { name: I18nKey.AUTOMATIONS$FILTERS }),
+ ).toHaveTextContent("1");
+ });
+
+ it("asks the server for my automations when they are past the first page", async () => {
+ // Arrange β€” the newest page is all teammates'; mine is older. The server
+ // honours created_by, so only a server-side filter can find it.
+ const teammates = Array.from({ length: 50 }, (_, index) =>
+ createAutomation({
+ id: `a-teammate-${index}`,
+ name: `Teammate widget ${index}`,
+ user_id: "user-teammate",
+ }),
+ );
+ vi.mocked(AutomationService.getAutomations).mockImplementation(
+ async (_limit, _offset, createdBy) =>
+ createdBy === "me"
+ ? { automations: [mine], total: 1 }
+ : { automations: teammates, total: 51 },
+ );
+ const user = userEvent.setup();
+ selectWorkspace(TEAM_ORG_ID);
+ renderAt("/automations", <AutomationsList />);
+ await screen.findByTestId("automation-card-a-teammate-0");
+ await openFiltersMenu(user);
+
+ // Act
+ await pickCreatedBy(user, "me");
+
+ // Assert
+ await waitFor(() => {
+ expect(visibleCardIds()).toEqual(["automation-card-a-mine"]);
+ });
+ expect(AutomationService.getAutomations).toHaveBeenLastCalledWith(
+ 50,
+ 0,
+ "me",
+ );
+ });
+
+ it("keeps Load more under the filtered empty state when a service ignores the creator filter", async () => {
+ // Arrange β€” an automation service without created_by returns every
+ // creator, newest first; mine is only on the second page.
+ const teammates = Array.from({ length: 50 }, (_, index) =>
+ createAutomation({
+ id: `a-teammate-${index}`,
+ name: `Teammate widget ${index}`,
+ user_id: "user-teammate",
+ }),
+ );
+ vi.mocked(AutomationService.getAutomations).mockImplementation(
+ async (_limit, offset) =>
+ offset === 0
+ ? { automations: teammates, total: 51 }
+ : { automations: [mine], total: 51 },
+ );
+ const user = userEvent.setup();
+ selectWorkspace(TEAM_ORG_ID);
+ renderAt("/automations", <AutomationsList />);
+ await screen.findByTestId("automation-card-a-teammate-0");
+ await openFiltersMenu(user);
+ await pickCreatedBy(user, "me");
+ await screen.findByTestId("automations-filtered-empty");
+
+ // Act
+ await user.click(
+ screen.getByRole("button", { name: I18nKey.AUTOMATIONS$LOAD_MORE }),
+ );
+
+ // Assert
+ await waitFor(() => {
+ expect(visibleCardIds()).toEqual(["automation-card-a-mine"]);
+ });
+ });
+
+ it("keeps the overview tiles on the whole list when filtering by creator", async () => {
+ // Arrange β€” the server honours created_by.
+ vi.mocked(AutomationService.getAutomations).mockImplementation(
+ async (_limit, _offset, createdBy) =>
+ createdBy === "me"
+ ? { automations: [mine], total: 1 }
+ : { automations: [mine, theirs, unowned], total: 3 },
+ );
+ const user = userEvent.setup();
+ selectWorkspace(TEAM_ORG_ID);
+ renderAt("/automations", <AutomationsList />);
+ await screen.findByTestId("automation-card-a-unowned");
+ await openFiltersMenu(user);
+
+ // Act
+ await pickCreatedBy(user, "me");
+
+ // Assert
+ await waitFor(() => {
+ expect(visibleCardIds()).toEqual(["automation-card-a-mine"]);
+ });
+ const tile = screen.getByTestId("overview-tile-automations");
+ expect(within(tile).getByText("3", { exact: true })).toBeInTheDocument();
+ });
+
+ it("keeps the loaded list on screen while the creator-filtered page loads", async () => {
+ // Arrange β€” the created_by=me request never settles.
+ vi.mocked(AutomationService.getAutomations).mockImplementation(
+ (_limit, _offset, createdBy) =>
+ createdBy === "me"
+ ? new Promise(() => {})
+ : Promise.resolve({ automations: [mine, theirs, unowned], total: 3 }),
+ );
+ const user = userEvent.setup();
+ selectWorkspace(TEAM_ORG_ID);
+ renderAt("/automations", <AutomationsList />);
+ await screen.findByTestId("automation-card-a-unowned");
+ await openFiltersMenu(user);
+
+ // Act
+ await pickCreatedBy(user, "me");
+
+ // Assert β€” the loaded rows, narrowed on the client, instead of skeletons.
+ await waitFor(() => {
+ expect(visibleCardIds()).toEqual(["automation-card-a-mine"]);
+ });
+ expect(
+ screen.queryByTestId("automation-card-skeleton"),
+ ).not.toBeInTheDocument();
+ });
+
+ it("shows loading, not a false no-match, while my page loads past the first page", async () => {
+ // Arrange β€” the loaded page has none of mine; created_by=me never settles.
+ vi.mocked(AutomationService.getAutomations).mockImplementation(
+ (_limit, _offset, createdBy) =>
+ createdBy === "me"
+ ? new Promise(() => {})
+ : Promise.resolve({ automations: [theirs, unowned], total: 3 }),
+ );
+ const user = userEvent.setup();
+ selectWorkspace(TEAM_ORG_ID);
+ renderAt("/automations", <AutomationsList />);
+ await screen.findByTestId("automation-card-a-theirs");
+ await openFiltersMenu(user);
+
+ // Act
+ await pickCreatedBy(user, "me");
+
+ // Assert
+ expect(
+ (await screen.findAllByTestId("automation-card-skeleton")).length,
+ ).toBeGreaterThan(0);
+ expect(
+ screen.queryByTestId("automations-filtered-empty"),
+ ).not.toBeInTheDocument();
+ });
+
+ it("keeps the first-run empty state when an empty org filters by creator", async () => {
+ // Arrange β€” the org has no automations at all; the "me" page is held
+ // until the test sends it.
+ const empty = { automations: [], total: 0 };
+ let sendMine: (page: typeof empty) => void = () => {};
+ vi.mocked(AutomationService.getAutomations).mockImplementation(
+ async (_limit, _offset, createdBy) =>
+ createdBy === "me"
+ ? new Promise((resolve) => {
+ sendMine = resolve;
+ })
+ : empty,
+ );
+ const user = userEvent.setup();
+ selectWorkspace(TEAM_ORG_ID);
+ renderAt("/automations", <AutomationsList />);
+ await screen.findByTestId("automations-empty");
+ await openFiltersMenu(user);
+
+ // Act
+ await pickCreatedBy(user, "me");
+
+ // Assert β€” while "me" loads, the empty state shows without skeletons.
+ await waitFor(() =>
+ expect(AutomationService.getAutomations).toHaveBeenLastCalledWith(
+ 50,
+ 0,
+ "me",
+ ),
+ );
+ expect(screen.getByTestId("automations-empty")).toBeInTheDocument();
+ expect(
+ screen.queryByTestId("automation-card-skeleton"),
+ ).not.toBeInTheDocument();
+
+ // Act
+ act(() => sendMine(empty));
+
+ // Assert
+ await waitFor(() =>
+ expect(screen.getByTestId("automations-empty")).toBeInTheDocument(),
+ );
+ expect(
+ screen.queryByTestId("automation-card-skeleton"),
+ ).not.toBeInTheDocument();
+ expect(
+ screen.queryByTestId("automations-filtered-empty"),
+ ).not.toBeInTheDocument();
+ });
+
+ it("offers Clear filters when the server finds none of my automations", async () => {
+ // Arrange β€” the org has automations, but none are the caller's.
+ vi.mocked(AutomationService.getAutomations).mockImplementation(
+ async (_limit, _offset, createdBy) =>
+ createdBy === "me"
+ ? { automations: [], total: 0 }
+ : { automations: [theirs, unowned], total: 2 },
+ );
+ const user = userEvent.setup();
+ selectWorkspace(TEAM_ORG_ID);
+ renderAt("/automations", <AutomationsList />);
+ await screen.findByTestId("automation-card-a-theirs");
+ await openFiltersMenu(user);
+ await pickCreatedBy(user, "me");
+
+ // Act
+ await user.click(await screen.findByTestId("automations-clear-filters"));
+
+ // Assert
+ await waitFor(() => {
+ expect(visibleCardIds()).toEqual([
+ "automation-card-a-theirs",
+ "automation-card-a-unowned",
+ ]);
+ });
+ });
+
+ it("returns to every creator from Reset all and from Clear filters", async () => {
+ // Arrange
+ const user = userEvent.setup();
+ selectWorkspace(TEAM_ORG_ID);
+ renderAt("/automations", <AutomationsList />);
+ await screen.findByTestId("automation-card-a-unowned");
+ await openFiltersMenu(user);
+ await pickCreatedBy(user, "me");
+ await waitFor(() => {
+ expect(visibleCardIds()).toEqual(["automation-card-a-mine"]);
+ });
+
+ // Act β€” Reset all from the Filters menu.
+ await user.click(screen.getByTestId("automations-filters-reset"));
+
+ // Assert
+ await waitFor(() => {
+ expect(visibleCardIds()).toHaveLength(3);
+ });
+
+ // Arrange β€” "me" plus a search only a teammate's automation matches.
+ await pickCreatedBy(user, "me");
+ await user.type(
+ screen.getByLabelText(I18nKey.AUTOMATIONS$SEARCH_PLACEHOLDER),
+ "beta",
+ );
+ await screen.findByTestId("automations-filtered-empty");
+
+ // Act β€” Clear filters from the filtered empty state.
+ await user.click(screen.getByTestId("automations-clear-filters"));
+
+ // Assert
+ await waitFor(() => {
+ expect(visibleCardIds()).toHaveLength(3);
+ });
+ });
+
+ it("ignores a creator selection while the workspace hides the filter", async () => {
+ // Arrange
+ const user = userEvent.setup();
+ selectWorkspace(TEAM_ORG_ID);
+ renderAt("/automations", <AutomationsList />);
+ await screen.findByTestId("automation-card-a-unowned");
+ await openFiltersMenu(user);
+ await pickCreatedBy(user, "me");
+ await waitFor(() => {
+ expect(visibleCardIds()).toEqual(["automation-card-a-mine"]);
+ });
+
+ // Act β€” the personal workspace, where every automation is the caller's.
+ act(() => selectWorkspace(CURRENT_USER_ID));
+
+ // Assert
+ await waitFor(() => {
+ expect(visibleCardIds()).toEqual([
+ "automation-card-a-mine",
+ "automation-card-a-theirs",
+ "automation-card-a-unowned",
+ ]);
+ });
+ expect(
+ screen.queryByTestId("automations-filter-created-by"),
+ ).not.toBeInTheDocument();
+ expect(AutomationService.getAutomations).toHaveBeenLastCalledWith(
+ 50,
+ 0,
+ undefined,
+ );
+ });
+});
+
describe("AutomationTemplates β€” manifest-declared templates page", () => {
it("admits the route and renders the manifest identity above the launcher", async () => {
// Arrange & Act
diff --git a/__tests__/routes/automations-list-behavior.test.tsx b/__tests__/routes/automations-list-behavior.test.tsx
index a91d15a9e8..df9a46c895 100644
--- a/__tests__/routes/automations-list-behavior.test.tsx
+++ b/__tests__/routes/automations-list-behavior.test.tsx
@@ -70,6 +70,7 @@ vi.mock("#/manifests/manifest-sources", async (importOriginal) => {
vi.mock("#/hooks/use-automation-permissions", () => ({
useAutomationPermissions: () => ({ canManage: mocks.canManage }),
+ useAutomationCreatorFilterUserId: () => null,
}));
vi.mock("#/context/navigation-context", () => ({
diff --git a/__tests__/routes/automations-list.test.tsx b/__tests__/routes/automations-list.test.tsx
index 80824ce553..3c6e7048e4 100644
--- a/__tests__/routes/automations-list.test.tsx
+++ b/__tests__/routes/automations-list.test.tsx
@@ -545,9 +545,9 @@ describe("AutomationsList β€” Load more", () => {
// Assert
await screen.findByText("Automation 120");
expect(vi.mocked(AutomationService.getAutomations).mock.calls).toEqual([
- [50, 0],
- [50, 50],
- [50, 100],
+ [50, 0, undefined],
+ [50, 50, undefined],
+ [50, 100, undefined],
]);
expect(
screen.queryByRole("button", { name: I18nKey.AUTOMATIONS$LOAD_MORE }),
@@ -631,8 +631,8 @@ describe("AutomationsList β€” Load more", () => {
expect(
vi.mocked(AutomationService.getAutomations).mock.calls.slice(1),
).toEqual([
- [50, 50],
- [50, 50],
+ [50, 50, undefined],
+ [50, 50, undefined],
]);
});
});
diff --git a/src/api/automation-service/automation-service.api.ts b/src/api/automation-service/automation-service.api.ts
index 78588b192b..8fbd7e2300 100644
--- a/src/api/automation-service/automation-service.api.ts
+++ b/src/api/automation-service/automation-service.api.ts
@@ -8,6 +8,7 @@ import {
} from "#/services/telemetry";
import type {
Automation,
+ AutomationCreatedByFilter,
AutomationRun,
AutomationSpec,
AutomationTrigger,
@@ -129,10 +130,21 @@ function getAutomationSdkVersionFromResponse(
);
}
-function buildPaginationQuery(limit: number, offset: number): string {
+/**
+ * The query string for a paged list request. `extra` adds params such as
+ * filters; keys whose value is undefined are left out.
+ */
+function buildListQuery(
+ limit: number,
+ offset: number,
+ extra: Record<string, string | undefined> = {},
+): string {
const params = new URLSearchParams();
params.set("limit", String(limit));
params.set("offset", String(offset));
+ for (const [key, value] of Object.entries(extra)) {
+ if (value !== undefined) params.set(key, value);
+ }
return params.toString();
}
@@ -273,32 +285,41 @@ class AutomationService {
}
static async listAutomations(
- params: { limit?: number; offset?: number } = {},
+ params: {
+ limit?: number;
+ offset?: number;
+ createdBy?: AutomationCreatedByFilter;
+ } = {},
): Promise<AutomationsResponse> {
- const { limit = 50, offset = 0 } = params;
+ const { limit = 50, offset = 0, createdBy } = params;
const active = getActiveBackend().backend;
if (active.kind === "cloud") {
return callCloudProxy<AutomationsResponse>({
backend: active,
method: "GET",
- path: `${AUTOMATION_BASE_PATH}${getAutomationEndpoint("list")}?${buildPaginationQuery(limit, offset)}`,
+ path: `${AUTOMATION_BASE_PATH}${getAutomationEndpoint("list")}?${buildListQuery(limit, offset, { created_by: createdBy })}`,
headers: await buildAutomationRequestHeaders(),
});
}
const { data } = await localAutomationAxios.get<AutomationsResponse>(
`${AUTOMATION_BASE_PATH}${getAutomationEndpoint("list")}`,
- { params: { limit, offset } },
+ { params: { limit, offset, created_by: createdBy } },
);
return data;
}
+ /**
+ * One page of the org's automations. `createdBy` narrows it on the server;
+ * an automation service that predates the param ignores it.
+ */
static async getAutomations(
limit = 50,
offset = 0,
+ createdBy?: AutomationCreatedByFilter,
): Promise<AutomationsResponse> {
- return AutomationService.listAutomations({ limit, offset });
+ return AutomationService.listAutomations({ limit, offset, createdBy });
}
static async getAutomation(id: string): Promise<Automation> {
@@ -476,7 +497,7 @@ class AutomationService {
return callCloudProxy<AutomationRunsResponse>({
backend: active,
method: "GET",
- path: `${basePath}?${buildPaginationQuery(limit, offset)}`,
+ path: `${basePath}?${buildListQuery(limit, offset)}`,
headers: await buildAutomationRequestHeaders(),
});
}
diff --git a/src/components/features/automations/dashboard/automations-dashboard-controls.tsx b/src/components/features/automations/dashboard/automations-dashboard-controls.tsx
index 212c888b65..1283f63bc7 100644
--- a/src/components/features/automations/dashboard/automations-dashboard-controls.tsx
+++ b/src/components/features/automations/dashboard/automations-dashboard-controls.tsx
@@ -6,6 +6,7 @@ import { EnumFilterDropdown } from "#/components/shared/filters/enum-filter-drop
import { useClickOutsideElement } from "#/hooks/use-click-outside-element";
import type { DashboardSpec } from "#/manifests/automation-interface";
import type {
+ DashboardCreatedByValue,
DashboardSortValue,
DashboardStatusValue,
DashboardTriggerValue,
@@ -40,25 +41,31 @@ interface AutomationsDashboardControlsProps {
spec: DashboardSpec;
status: DashboardStatusValue;
trigger: DashboardTriggerValue;
+ createdBy: DashboardCreatedByValue;
+ canFilterByCreator: boolean;
sort: DashboardSortValue;
onStatusChange: (value: DashboardStatusValue) => void;
onTriggerChange: (value: DashboardTriggerValue) => void;
+ onCreatedByChange: (value: DashboardCreatedByValue) => void;
onSortChange: (value: DashboardSortValue) => void;
}
/**
- * One Filters trigger that nests the manifest-declared status, trigger, and
- * sort dropdowns. Which filters exist, their options, and every caption stay
- * the manifest's; the predicates and comparators behind the values stay the
- * host's.
+ * One Filters trigger that nests the manifest-declared status, trigger,
+ * created-by, and sort dropdowns. Which filters exist, their options, and
+ * every caption stay the manifest's; the predicates and comparators behind
+ * the values stay the host's.
*/
export function AutomationsDashboardControls({
spec,
status,
trigger,
+ createdBy,
+ canFilterByCreator,
sort,
onStatusChange,
onTriggerChange,
+ onCreatedByChange,
onSortChange,
}: AutomationsDashboardControlsProps) {
const { t } = useTranslation("openhands");
@@ -69,18 +76,24 @@ export function AutomationsDashboardControls({
const statusFilter = spec.filters.find((filter) => filter.id === "status");
const triggerFilter = spec.filters.find((filter) => filter.id === "trigger");
+ const createdByFilter = canFilterByCreator
+ ? spec.filters.find((filter) => filter.id === "created_by")
+ : undefined;
const activeCount = [
statusFilter && status !== statusFilter.options[0]?.value,
triggerFilter && trigger !== triggerFilter.options[0]?.value,
+ createdByFilter && createdBy !== createdByFilter.options[0]?.value,
sort !== spec.sort.default,
].filter(Boolean).length;
const filtersLabel = t(I18nKey.AUTOMATIONS$FILTERS);
const defaultStatus = statusFilter?.options[0]?.value;
const defaultTrigger = triggerFilter?.options[0]?.value;
+ const defaultCreatedBy = createdByFilter?.options[0]?.value;
const resetAll = () => {
if (defaultStatus) onStatusChange(defaultStatus);
if (defaultTrigger) onTriggerChange(defaultTrigger);
+ if (defaultCreatedBy) onCreatedByChange(defaultCreatedBy);
onSortChange(spec.sort.default);
};
@@ -152,6 +165,19 @@ export function AutomationsDashboardControls({
/>
</FilterField>
) : null}
+ {createdByFilter ? (
+ <FilterField label={createdByFilter.label}>
+ <EnumFilterDropdown
+ testId="automations-filter-created-by"
+ value={createdBy}
+ onChange={onCreatedByChange}
+ options={createdByFilter.options.map((option) => option.value)}
+ labelByValue={toLabelMap(createdByFilter.options)}
+ ariaLabel={createdByFilter.label}
+ fullWidth
+ />
+ </FilterField>
+ ) : null}
<FilterField label={spec.sort.label}>
<EnumFilterDropdown
testId="automations-sort"
diff --git a/src/components/features/automations/dashboard/automations-filtered-empty-state.tsx b/src/components/features/automations/dashboard/automations-filtered-empty-state.tsx
index 3eab3ca5ee..6b0227318a 100644
--- a/src/components/features/automations/dashboard/automations-filtered-empty-state.tsx
+++ b/src/components/features/automations/dashboard/automations-filtered-empty-state.tsx
@@ -6,8 +6,8 @@ interface AutomationsFilteredEmptyStateProps {
}
/**
- * Automations exist but the active search/filters match none. Chrome copy, so
- * it stays the host's translations rather than manifest copy.
+ * The active search or filters match no automations. Chrome copy, so it stays
+ * the host's translations rather than manifest copy.
*/
export function AutomationsFilteredEmptyState({
onClear,
diff --git a/src/hooks/query/use-automation-run-summaries.ts b/src/hooks/query/use-automation-run-summaries.ts
index 92070faab3..9d46715f9f 100644
--- a/src/hooks/query/use-automation-run-summaries.ts
+++ b/src/hooks/query/use-automation-run-summaries.ts
@@ -39,8 +39,8 @@ interface UseAutomationRunSummariesOptions {
}
/**
- * One runs query per listed automation β€” a deliberate fan-out, bounded by the
- * list's page size. Summaries drive the dashboard's tiles, health badges,
+ * One runs query per automation passed in β€” a deliberate fan-out, bounded by
+ * the loaded rows. Summaries drive the dashboard's tiles, health badges,
* filters, and sorts.
*/
export function useAutomationRunSummaries(
diff --git a/src/hooks/query/use-automations.ts b/src/hooks/query/use-automations.ts
index 49d09fee18..e57348791a 100644
--- a/src/hooks/query/use-automations.ts
+++ b/src/hooks/query/use-automations.ts
@@ -10,6 +10,7 @@ import { useTracking } from "#/hooks/use-tracking";
import { uniqueById } from "#/utils/unique-by-id";
import type {
Automation,
+ AutomationCreatedByFilter,
AutomationSpec,
AutomationsResponse,
} from "#/types/automation";
@@ -38,6 +39,7 @@ function joinAutomationPages(
interface UseAutomationsOptions {
/** Automations per request; at most 100. A count-only caller passes 1. */
pageSize?: number;
+ createdBy?: AutomationCreatedByFilter;
enabled?: boolean;
}
@@ -48,17 +50,21 @@ interface UseAutomationsOptions {
* listed once.
*/
export function useAutomations(options: UseAutomationsOptions = {}) {
- const { pageSize = AUTOMATIONS_PAGE_SIZE, enabled = true } = options;
+ const {
+ pageSize = AUTOMATIONS_PAGE_SIZE,
+ createdBy,
+ enabled = true,
+ } = options;
const active = useActiveBackend();
return useInfiniteQuery({
queryKey: [
...AUTOMATIONS_QUERY_KEY,
- { pageSize },
+ { pageSize, createdBy },
active.backend.id,
active.orgId,
],
queryFn: ({ pageParam }) =>
- AutomationService.getAutomations(pageSize, pageParam),
+ AutomationService.getAutomations(pageSize, pageParam, createdBy),
initialPageParam: 0,
getNextPageParam: (lastPage, _pages, lastOffset) => {
const nextOffset = lastOffset + lastPage.automations.length;
@@ -66,6 +72,14 @@ export function useAutomations(options: UseAutomationsOptions = {}) {
},
select: joinAutomationPages,
staleTime: 0,
+ // A new filter keeps the last list on screen until its first page lands;
+ // another backend or org starts empty, so its list never shows foreign rows.
+ placeholderData: (previousData, previousQuery) => {
+ const [, , backendId, orgId] = previousQuery?.queryKey ?? [];
+ return backendId === active.backend.id && orgId === active.orgId
+ ? previousData
+ : undefined;
+ },
enabled,
});
}
diff --git a/src/hooks/use-automation-permissions.ts b/src/hooks/use-automation-permissions.ts
index 68afe49eb5..c9b017de61 100644
--- a/src/hooks/use-automation-permissions.ts
+++ b/src/hooks/use-automation-permissions.ts
@@ -100,3 +100,19 @@ export function useIsAutomationOwner(automation: Automation): boolean {
if (!entry || entry.isLoading || !entry.userId) return false;
return automation.user_id === entry.userId;
}
+
+/**
+ * The caller's user id when splitting automations by creator is meaningful:
+ * a cloud team workspace whose `/me` has resolved. `null` on local backends
+ * (no per-user creators) and personal workspaces (every automation is the
+ * caller's), where the "Created by" filter is hidden.
+ */
+export function useAutomationCreatorFilterUserId(): string | null {
+ const active = useActiveBackend();
+ const userIds = useCloudCurrentUserId();
+
+ if (active.backend.kind !== "cloud") return null;
+ const userId = userIds[active.backend.id]?.userId ?? null;
+ if (!userId || active.orgId === userId) return null;
+ return userId;
+}
diff --git a/src/manifests/automation-insights.ts b/src/manifests/automation-insights.ts
index cc61aff7ad..870a1c1f29 100644
--- a/src/manifests/automation-insights.ts
+++ b/src/manifests/automation-insights.ts
@@ -22,6 +22,7 @@ import {
} from "#/types/automation";
import { getAutomationRunDisplay } from "#/utils/automation-run-display";
import type {
+ DashboardCreatedByValue,
DashboardSortValue,
DashboardStatusValue,
DashboardTriggerValue,
@@ -203,6 +204,17 @@ const TRIGGER_PREDICATES: Record<
schedule: (automation) => automation.trigger.type !== "event",
};
+// The caller's id is non-null whenever these run; applyDashboardView skips the
+// creator check until identity resolves, so "me" is an exact match and
+// "others" is everything else, including creator-less automations.
+const CREATED_BY_PREDICATES: Record<
+ Exclude<DashboardCreatedByValue, "all">,
+ (automation: Automation, currentUserId: string) => boolean
+> = {
+ me: (automation, currentUserId) => automation.user_id === currentUserId,
+ others: (automation, currentUserId) => automation.user_id !== currentUserId,
+};
+
function runCount(automation: Automation, byId: Summaries): number {
return byId.get(automation.id)?.summary?.total ?? 0;
}
@@ -229,6 +241,8 @@ export interface DashboardViewState {
search: string;
status: DashboardStatusValue;
trigger: DashboardTriggerValue;
+ createdBy: DashboardCreatedByValue;
+ currentUserId: string | null;
sort: DashboardSortValue;
}
@@ -256,6 +270,15 @@ export function applyDashboardView(
) {
return false;
}
+ // With no caller id (local backend, personal workspace, or /me
+ // loading), the creator filter is inert.
+ if (
+ view.currentUserId !== null &&
+ view.createdBy !== "all" &&
+ !CREATED_BY_PREDICATES[view.createdBy](automation, view.currentUserId)
+ ) {
+ return false;
+ }
return true;
})
.sort((a, b) => SORT_COMPARATORS[view.sort](a, b, byId));
diff --git a/src/manifests/types.ts b/src/manifests/types.ts
index 03e9c798ca..60ff403e11 100644
--- a/src/manifests/types.ts
+++ b/src/manifests/types.ts
@@ -430,6 +430,7 @@ export interface InterfaceOverview {
export const DASHBOARD_FILTER_VALUES = {
status: ["all", "active", "failing", "disabled"],
trigger: ["all", "schedule", "event"],
+ created_by: ["all", "me", "others"],
} as const;
export type DashboardFilterId = keyof typeof DASHBOARD_FILTER_VALUES;
@@ -444,6 +445,9 @@ export type DashboardStatusValue =
export type DashboardTriggerValue =
(typeof DASHBOARD_FILTER_VALUES.trigger)[number];
+export type DashboardCreatedByValue =
+ (typeof DASHBOARD_FILTER_VALUES.created_by)[number];
+
export interface InterfaceStatusFilter {
id: "status";
/** The control's accessible name. */
@@ -458,9 +462,17 @@ export interface InterfaceTriggerFilter {
options: { value: DashboardTriggerValue; label: string }[];
}
+export interface InterfaceCreatedByFilter {
+ id: "created_by";
+ /** The control's accessible name. */
+ label: string;
+ options: { value: DashboardCreatedByValue; label: string }[];
+}
+
export type InterfaceDashboardFilter =
| InterfaceStatusFilter
- | InterfaceTriggerFilter;
+ | InterfaceTriggerFilter
+ | InterfaceCreatedByFilter;
/** Sort values name comparators this host implements. */
export const DASHBOARD_SORT_VALUES = ["last-run", "runs", "name"] as const;
diff --git a/src/routes/automations-list.tsx b/src/routes/automations-list.tsx
index 73cd22ec94..1cf31db74f 100644
--- a/src/routes/automations-list.tsx
+++ b/src/routes/automations-list.tsx
@@ -38,7 +38,10 @@ import { ImportAutomationModal } from "#/components/features/automations/import-
import { RecommendedAutomationsLauncher } from "#/components/features/automations/recommended-automations-launcher";
import { BrandButton } from "#/components/features/settings/brand-button";
import { useTracking } from "#/hooks/use-tracking";
-import { useAutomationPermissions } from "#/hooks/use-automation-permissions";
+import {
+ useAutomationCreatorFilterUserId,
+ useAutomationPermissions,
+} from "#/hooks/use-automation-permissions";
import type { Automation, AutomationSpec } from "#/types/automation";
import {
getAutomationExportFilename,
@@ -58,6 +61,7 @@ import {
} from "#/manifests/automation-insights";
import { interpolateValues } from "#/manifests/manifest-template";
import type {
+ DashboardCreatedByValue,
DashboardSortValue,
DashboardStatusValue,
DashboardTriggerValue,
@@ -70,6 +74,7 @@ import { MANIFEST_ICON_BY_SLUG } from "#/components/features/manifest/manifest-i
import { ManifestOverviewTiles } from "#/components/features/manifest/manifest-overview-tiles";
import { ManifestSubpageLayout } from "#/components/features/manifest/manifest-subpage-layout";
import { cn, downloadBlob } from "#/utils/utils";
+import { uniqueById } from "#/utils/unique-by-id";
/**
* The page renders the interface manifest's copy, so without an admitted
@@ -99,6 +104,8 @@ export default function AutomationsList() {
const [statusFilter, setStatusFilter] = useState<DashboardStatusValue>("all");
const [triggerFilter, setTriggerFilter] =
useState<DashboardTriggerValue>("all");
+ const [createdByFilter, setCreatedByFilter] =
+ useState<DashboardCreatedByValue>("all");
const [sortValue, setSortValue] = useState<DashboardSortValue>(
dashboardSpec?.sort.default ?? "last-run",
);
@@ -119,6 +126,13 @@ export default function AutomationsList() {
// Git Sync is org-level config, so its entry point requires
// manage_automations (admins/owners) on every backend kind.
const { canManage } = useAutomationPermissions();
+ const creatorFilterUserId = useAutomationCreatorFilterUserId();
+ // The creator the server filters by; undefined while the filter is hidden
+ // or set to "all".
+ const serverCreatedBy =
+ creatorFilterUserId !== null && createdByFilter !== "all"
+ ? createdByFilter
+ : undefined;
const {
data: healthData,
@@ -137,9 +151,27 @@ export default function AutomationsList() {
hasNextPage,
fetchNextPage,
isFetching,
- } = useAutomations({ enabled: isBackendHealthy });
- // One runs query per listed automation β€” dashboard mode only.
- const runSummaries = useAutomationRunSummaries(data?.automations ?? [], {
+ isPlaceholderData,
+ } = useAutomations({
+ enabled: isBackendHealthy,
+ // The server filters by creator so pages and `total` cover only matches;
+ // the client predicate in applyDashboardView stays as the fallback for
+ // an automation service that ignores the param.
+ createdBy: serverCreatedBy,
+ });
+ // The overview tiles summarize the org list above the filters, so they read
+ // it unfiltered; with no creator selected this is the same query as above.
+ const { data: orgData } = useAutomations({ enabled: isBackendHealthy });
+ const runSummaryAutomations = useMemo(
+ () =>
+ uniqueById([
+ ...(orgData?.automations ?? []),
+ ...(data?.automations ?? []),
+ ]),
+ [orgData?.automations, data?.automations],
+ );
+ // One runs query per automation in either list β€” dashboard mode only.
+ const runSummaries = useAutomationRunSummaries(runSummaryAutomations, {
enabled: isBackendHealthy && dashboard !== null,
});
const { trackPrebuiltAutomationEnabled, trackAutomationExported } =
@@ -162,6 +194,11 @@ export default function AutomationsList() {
search: searchQuery,
status: statusFilter,
trigger: triggerFilter,
+ // A null id (local backend, personal workspace, or /me loading)
+ // leaves the creator filter inert, so a selection made on a team
+ // workspace has no effect while the filter is hidden.
+ createdBy: createdByFilter,
+ currentUserId: creatorFilterUserId,
sort: sortValue,
},
runSummaries,
@@ -172,6 +209,8 @@ export default function AutomationsList() {
searchQuery,
statusFilter,
triggerFilter,
+ createdByFilter,
+ creatorFilterUserId,
sortValue,
runSummaries,
]);
@@ -288,11 +327,12 @@ export default function AutomationsList() {
setSearchQuery("");
setStatusFilter("all");
setTriggerFilter("all");
+ setCreatedByFilter("all");
};
const overviewTiles = useMemo(() => {
if (!dashboardSpec) return [];
- const automations = data?.automations ?? [];
+ const automations = orgData?.automations ?? [];
return dashboardSpec.overview.tiles.map((tile) => {
const value = computeOverviewTile(tile.metric, automations, runSummaries);
const template =
@@ -305,7 +345,7 @@ export default function AutomationsList() {
Icon: MANIFEST_ICON_BY_SLUG[tile.icon],
};
});
- }, [dashboardSpec, data?.automations, runSummaries]);
+ }, [dashboardSpec, orgData?.automations, runSummaries]);
const groupInsights = dashboard
? { spec: dashboard.spec.insights, byId: runSummaries }
@@ -330,8 +370,15 @@ export default function AutomationsList() {
// A failed refetch or Load more keeps the loaded rows; Load more retries.
const isListError = isError && !data;
- const hasNoAutomations =
- !isLoading && !isListError && data?.automations.length === 0;
+ // Whether the org has any automations comes from the unfiltered list, so an
+ // empty filtered response shows the filtered empty state with Clear filters.
+ const hasNoAutomations = !isListError && orgData?.total === 0;
+ // The previous filter's rows stand in while the next page loads; when none
+ // of them match, show loading rather than a no-match that is not final. An
+ // empty org keeps its empty state instead.
+ const isListLoading =
+ !hasNoAutomations &&
+ (isLoading || (isPlaceholderData && visible.length === 0));
// Show loading state while checking health
if (isHealthLoading) {
@@ -419,9 +466,12 @@ export default function AutomationsList() {
spec={dashboard.spec}
status={statusFilter}
trigger={triggerFilter}
+ createdBy={createdByFilter}
+ canFilterByCreator={creatorFilterUserId !== null}
sort={sortValue}
onStatusChange={setStatusFilter}
onTriggerChange={setTriggerFilter}
+ onCreatedByChange={setCreatedByFilter}
onSortChange={setSortValue}
/>
)}
@@ -434,7 +484,7 @@ export default function AutomationsList() {
{/* Content */}
<div className={cn("flex flex-col gap-6", !dashboard && "mt-6")}>
- {isLoading && (
+ {isListLoading && (
<div className="flex flex-col gap-3">
{Array.from({ length: 3 }).map((_, i) => (
<AutomationCardSkeleton key={`skeleton-${String(i)}`} />
@@ -446,61 +496,62 @@ export default function AutomationsList() {
{hasNoAutomations && <EmptyState />}
- {!isLoading &&
- !isListError &&
- data &&
- data.automations.length > 0 &&
- (dashboard && visible.length === 0 ? (
- <AutomationsFilteredEmptyState onClear={handleClearFilters} />
- ) : (
- <>
- <AutomationGroup
- title={t(I18nKey.AUTOMATIONS$ACTIVE)}
- count={activeAutomations.length}
- automations={activeAutomations}
- view={viewMode}
- onToggle={handleToggle}
- onRunNow={handleRunNow}
- runPendingId={
- dispatchMutation.isPending
- ? (dispatchMutation.variables ?? null)
- : null
- }
- onDelete={handleDeleteRequest}
- onExport={handleExport}
- onEdit={handleEditRequest}
- insights={groupInsights}
- />
- <AutomationGroup
- title={t(I18nKey.AUTOMATIONS$INACTIVE)}
- count={inactive.length}
- automations={inactive}
- view={viewMode}
- onToggle={handleToggle}
- onRunNow={handleRunNow}
- runPendingId={
- dispatchMutation.isPending
- ? (dispatchMutation.variables ?? null)
- : null
- }
- onDelete={handleDeleteRequest}
- onExport={handleExport}
- onEdit={handleEditRequest}
- insights={groupInsights}
- />
-
- {hasNextPage && (
- <button
- type="button"
- onClick={() => fetchNextPage()}
- disabled={isFetching}
- className="self-center rounded-lg border border-border px-6 py-2 text-sm text-contrast hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-50"
- >
- {t(I18nKey.AUTOMATIONS$LOAD_MORE)}
- </button>
- )}
- </>
- ))}
+ {!isListLoading && !isListError && data && !hasNoAutomations && (
+ <>
+ {dashboard && visible.length === 0 ? (
+ <AutomationsFilteredEmptyState onClear={handleClearFilters} />
+ ) : (
+ <>
+ <AutomationGroup
+ title={t(I18nKey.AUTOMATIONS$ACTIVE)}
+ count={activeAutomations.length}
+ automations={activeAutomations}
+ view={viewMode}
+ onToggle={handleToggle}
+ onRunNow={handleRunNow}
+ runPendingId={
+ dispatchMutation.isPending
+ ? (dispatchMutation.variables ?? null)
+ : null
+ }
+ onDelete={handleDeleteRequest}
+ onExport={handleExport}
+ onEdit={handleEditRequest}
+ insights={groupInsights}
+ />
+ <AutomationGroup
+ title={t(I18nKey.AUTOMATIONS$INACTIVE)}
+ count={inactive.length}
+ automations={inactive}
+ view={viewMode}
+ onToggle={handleToggle}
+ onRunNow={handleRunNow}
+ runPendingId={
+ dispatchMutation.isPending
+ ? (dispatchMutation.variables ?? null)
+ : null
+ }
+ onDelete={handleDeleteRequest}
+ onExport={handleExport}
+ onEdit={handleEditRequest}
+ insights={groupInsights}
+ />
+ </>
+ )}
+ {/* Also under the filtered empty state: the matches may be on a
+ page that is not loaded yet. */}
+ {hasNextPage && (
+ <button
+ type="button"
+ onClick={() => fetchNextPage()}
+ disabled={isFetching}
+ className="self-center rounded-lg border border-border px-6 py-2 text-sm text-contrast hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-50"
+ >
+ {t(I18nKey.AUTOMATIONS$LOAD_MORE)}
+ </button>
+ )}
+ </>
+ )}
</div>
{/* The launcher lives on the templates sub-page in dashboard mode */}
diff --git a/src/types/automation.ts b/src/types/automation.ts
index 618874854f..3afbf6718b 100644
--- a/src/types/automation.ts
+++ b/src/types/automation.ts
@@ -114,6 +114,12 @@ export interface AutomationsResponse {
total: number;
}
+/**
+ * Mirrors the list endpoint's `created_by` query param: the caller's
+ * automations (`me`) or the rest of the org's (`others`).
+ */
+export type AutomationCreatedByFilter = "me" | "others";
+
/** Mirrors `RunStatus` in the automation service's OpenAPI schema. */
export enum AutomationRunStatus {
PENDING = "PENDING",