diff --git a/webui/src/components/settings/system/AutomationsSettings.tsx b/webui/src/components/settings/system/AutomationsSettings.tsx index 705302b39..60d631d81 100644 --- a/webui/src/components/settings/system/AutomationsSettings.tsx +++ b/webui/src/components/settings/system/AutomationsSettings.tsx @@ -11,7 +11,6 @@ import { Loader2, MoreHorizontal, Search, - SlidersHorizontal, } from "lucide-react"; import { useTranslation } from "react-i18next"; @@ -88,8 +87,6 @@ export function AutomationsSettings({ const locale = i18n.resolvedLanguage || i18n.language; const [inspectedJob, setInspectedJob] = useState(null); const [detailOpen, setDetailOpen] = useState(false); - const [toolsOpen, setToolsOpen] = useState(Boolean(query) || filter !== "all" || sort !== "next"); - const [sortMenuOpen, setSortMenuOpen] = useState(false); const [systemOpen, setSystemOpen] = useState(() => { try { return window.localStorage.getItem(SYSTEM_TASKS_OPEN_STORAGE_KEY) !== "false"; @@ -98,11 +95,9 @@ export function AutomationsSettings({ } }); const searchInput = useRef(null); - const toolsToggle = useRef(null); const pageTitle = useRef(null); const selectedTrigger = useRef(null); const afterDetailClose = useRef<((job: SessionAutomationJob) => void) | null>(null); - const toolsActive = Boolean(query) || filter !== "all" || sort !== "next"; const filtered = useMemo(() => { const searchTokens = parseAutomationSearchQuery(query); return sortAutomationJobs(jobs, sort) @@ -141,10 +136,6 @@ export function AutomationsSettings({ if (query) setSystemOpen(true); }, [query]); - useEffect(() => { - if (toolsOpen) searchInput.current?.focus({ preventScroll: true }); - }, [toolsOpen]); - const renderJob = (job: SessionAutomationJob) => ( {tx("settings.nav.automations", "Automations")} - {jobs.length ? ( - - ) : null} {jobs.length ? ( - { - if (event.key !== "Escape" || event.defaultPrevented || event.nativeEvent.isComposing || sortMenuOpen) return; - event.preventDefault(); - event.stopPropagation(); - toolsToggle.current?.focus({ preventScroll: true }); - setToolsOpen(false); - }} > -
-
- - onQueryChange(event.target.value)} - aria-label={tx("settings.automations.search", "Search task, message, linked chat, or schedule")} - placeholder={tx("settings.automations.search", "Search task, message, linked chat, or schedule")} - className={cn("h-9 w-full rounded-full pl-9 text-[13px]", SETTINGS_SEARCH_INPUT_CLASS)} - /> -
- - - - - - {(Object.keys(sortLabel) as AutomationSort[]).map((value) => ( - onSortChange(value)}> - {sortLabel[value]} - {sort === value ? : null} - - ))} - - -
-
- {summaryOptions.map((option) => ( - +
+
+ + onQueryChange(event.target.value)} + aria-label={tx("settings.automations.search", "Search task, message, linked chat, or schedule")} + placeholder={tx("settings.automations.search", "Search task, message, linked chat, or schedule")} + className={cn("h-9 w-full rounded-full pl-9 text-[13px]", SETTINGS_SEARCH_INPUT_CLASS)} + /> +
+ + + + + + {(Object.keys(sortLabel) as AutomationSort[]).map((value) => ( + onSortChange(value)}> + {sortLabel[value]} + {sort === value ? : null} + ))} -
- + + +
+
+ {summaryOptions.map((option) => ( + + ))} +
+ ) : null} {error ? : null} @@ -314,7 +277,7 @@ export function AutomationsSettings({ {tx("settings.automations.filters.failed", "Needs attention")} ) : null} - + onSelect(event.currentTarget)} className={cn( - "automation-task-row group grid w-full grid-cols-[minmax(0,1fr)_auto] items-center gap-x-4 gap-y-2 text-left transition-colors", + "automation-task-row grid w-full grid-cols-1 items-center gap-x-4 gap-y-2 text-left transition-colors", compact ? "settings-list-row py-3 settings-hover" : "min-h-[92px] rounded-lg py-5 hover:bg-muted/35", formControlFocusClassName, )} @@ -420,7 +383,6 @@ function AutomationListItem({ job, locale, disabled, onSelect }: { {formatAutomationNext(job, tx)} )} - ); @@ -536,7 +498,7 @@ function AutomationDetailPanel({ summaryClassName={cn("flex cursor-pointer items-center justify-between gap-3 rounded-lg py-4 text-[13px] text-muted-foreground", job.protected && "py-3", formControlFocusClassName)} summary={<> {tx("settings.automations.moreDetails", "More details")} - + } >
diff --git a/webui/src/globals.css b/webui/src/globals.css index 28d94cb8f..491ab79a6 100644 --- a/webui/src/globals.css +++ b/webui/src/globals.css @@ -1029,19 +1029,14 @@ grid-column: 1; grid-row: 2; } - .automation-task-chevron { - grid-column: 2; - grid-row: 1 / span 2; - } @container automations (min-width: 36rem) { - .automation-task-row { grid-template-columns: minmax(0, 1fr) auto auto; } + .automation-task-row { grid-template-columns: minmax(0, 1fr) auto; } .automation-task-state { grid-column: 2; grid-row: 1; max-width: 18rem; justify-content: flex-end; } - .automation-task-chevron { grid-column: 3; grid-row: 1; } } .settings-stack > :not([hidden]) ~ :not([hidden]) { margin-block-start: var(--settings-module-gap, 20px); diff --git a/webui/src/tests/app-layout.test.tsx b/webui/src/tests/app-layout.test.tsx index e83f8ad48..1e2253b70 100644 --- a/webui/src/tests/app-layout.test.tsx +++ b/webui/src/tests/app-layout.test.tsx @@ -1466,7 +1466,6 @@ describe("App layout", () => { ); expect(document.title).toBe("Automations · nanobot"); - fireEvent.click(screen.getByRole("button", { name: "Search and filter" })); const searchInput = within(automationsMain as HTMLElement).getByPlaceholderText( "Search task, message, linked chat, or schedule", ); diff --git a/webui/src/tests/automations-settings.test.tsx b/webui/src/tests/automations-settings.test.tsx index 6b6b36716..9719d36b8 100644 --- a/webui/src/tests/automations-settings.test.tsx +++ b/webui/src/tests/automations-settings.test.tsx @@ -133,8 +133,8 @@ describe("Automation task list and detail sheet", () => { const user = userEvent.setup(); render(); expect(screen.queryByRole("dialog")).not.toBeInTheDocument(); - expect(screen.queryByRole("textbox")).not.toBeInTheDocument(); - expect(screen.queryByRole("button", { name: /^Active/ })).not.toBeInTheDocument(); + expect(screen.getByRole("textbox")).toBeVisible(); + expect(screen.getByRole("button", { name: /^Active/ })).toBeVisible(); expect(screen.getByRole("button", { name: /heartbeat/ })).toBeVisible(); expect(screen.queryByRole("button", { name: "Create in chat" })).not.toBeInTheDocument(); const row = screen.getByRole("button", { name: /PR watch/ }); @@ -162,7 +162,7 @@ describe("Automation task list and detail sheet", () => { expect(screen.getByText("Tell nanobot in a chat what you'd like it to do on a schedule.")).toBeVisible(); expect(screen.queryByRole("button", { name: "Create in chat" })).not.toBeInTheDocument(); expect(screen.queryByRole("button", { name: "Open a chat" })).not.toBeInTheDocument(); - expect(screen.getByRole("button", { name: "Search and filter" })).toBeVisible(); + expect(screen.getByRole("region", { name: "Search and filter" })).toBeVisible(); fireEvent.click(screen.getByRole("button", { name: /heartbeat/ })); const dialog = screen.getByRole("dialog", { name: "heartbeat" }); expect(within(dialog).queryByRole("button", { name: "Edit" })).not.toBeInTheDocument(); @@ -288,11 +288,13 @@ describe("Automation task list and detail sheet", () => { expect(screen.getByRole("button", { name: /heartbeat/ })).toBe(row); }); - it("keeps search, status filters and sorting available on demand", async () => { + it("keeps search, status filters and sorting immediately available", async () => { const user = userEvent.setup(); render(); - await user.click(screen.getByRole("button", { name: "Search and filter" })); const search = screen.getByRole("textbox"); + expect(search).toBeVisible(); + expect(search).toBeEnabled(); + expect(screen.queryByRole("button", { name: "Search and filter" })).not.toBeInTheDocument(); await user.type(search, "chat:nanobot"); expect(screen.getByRole("button", { name: /PR watch/ })).toBeVisible(); await user.clear(search); @@ -303,9 +305,7 @@ describe("Automation task list and detail sheet", () => { await user.click(screen.getByRole("button", { name: "Paused 1" })); expect(screen.queryByRole("button", { name: /PR watch/ })).not.toBeInTheDocument(); expect(screen.getByRole("button", { name: /Weekly review/ })).toBeVisible(); - await user.click(screen.getByRole("button", { name: "Search and filter" })); - expect(screen.queryByRole("textbox")).not.toBeInTheDocument(); - await user.click(screen.getByRole("button", { name: "Search and filter" })); + expect(search).toBeVisible(); expect(screen.getByRole("button", { name: "Paused 1" })).toHaveAttribute("aria-pressed", "true"); await user.click(screen.getByRole("button", { name: "All 2" })); await user.click(screen.getByRole("button", { name: "Next run" })); @@ -334,7 +334,6 @@ describe("Automation task list and detail sheet", () => { })); expect(task.origin?.title).toBe("nanobot-development"); await user.click(within(dialog).getByRole("button", { name: "Done" })); - await user.click(screen.getByRole("button", { name: "Search and filter" })); await user.type(screen.getByRole("textbox"), "chat:新会话名称"); expect(screen.getByRole("button", { name: /PR watch/ })).toBeVisible(); rerender(); @@ -358,42 +357,36 @@ describe("Automation task list and detail sheet", () => { expect(screen.queryByRole("dialog")).not.toBeInTheDocument(); }); - it("focuses search on expansion and restores the toggle on Escape without clearing filters", async () => { + it("keeps controls visible and preserves search when Escape dismisses sorting", async () => { const user = userEvent.setup(); render(); - const toggle = screen.getByRole("button", { name: "Search and filter" }); - await user.click(toggle); const search = screen.getByRole("textbox"); + expect(search).not.toHaveFocus(); + await user.tab(); expect(search).toHaveFocus(); - await user.keyboard("PR"); + await user.type(search, "PR"); await user.keyboard("{Escape}"); - expect(toggle).toHaveAttribute("aria-expanded", "false"); - expect(toggle).toHaveFocus(); expect(search).toHaveValue("PR"); - expect(search).toBeDisabled(); - - await user.keyboard("{Enter}"); expect(search).toHaveFocus(); - expect(search).toHaveValue("PR"); + expect(search).toBeEnabled(); fireEvent.keyDown(search, { key: "Escape", isComposing: true }); - expect(toggle).toHaveAttribute("aria-expanded", "true"); + expect(search).toBeVisible(); await user.click(screen.getByRole("button", { name: "Next run", exact: true })); await user.keyboard("{Escape}"); expect(screen.queryByRole("menu")).not.toBeInTheDocument(); - expect(toggle).toHaveAttribute("aria-expanded", "true"); expect(screen.getByRole("button", { name: "Next run", exact: true })).toHaveFocus(); await user.keyboard("{Escape}"); - expect(toggle).toHaveAttribute("aria-expanded", "false"); - expect(toggle).toHaveFocus(); + expect(screen.getByRole("region", { name: "Search and filter" })).toBeVisible(); + expect(search).toHaveValue("PR"); }); - it("returns focus to the filter or page heading when the inspected row is no longer present", async () => { + it("returns focus to search or the page heading when the inspected row is no longer present", async () => { const user = userEvent.setup(); const { rerender } = render(); await user.click(screen.getByRole("button", { name: /PR watch/ })); rerender(); await user.click(screen.getByRole("button", { name: "Done" })); - await waitFor(() => expect(screen.getByRole("button", { name: "Search and filter" })).toHaveFocus()); + await waitFor(() => expect(screen.getByRole("textbox")).toHaveFocus()); rerender(); await user.click(screen.getByRole("button", { name: /PR watch/ })); @@ -404,46 +397,28 @@ describe("Automation task list and detail sheet", () => { expect(screen.queryByRole("button")).not.toBeInTheDocument(); }); - it("keeps the filter drawer mounted for both transitions and disables hidden controls", async () => { + it("uses chevrons only for disclosures, while task rows open dialogs", async () => { const user = userEvent.setup(); render(); - const toggle = screen.getByRole("button", { name: "Search and filter" }); - const drawer = document.getElementById(toggle.getAttribute("aria-controls")!)!; - const search = within(drawer).getByRole("textbox", { hidden: true }); - expect(drawer).toHaveClass("inline-disclosure"); - expect(drawer).toHaveAttribute("data-state", "closed"); - expect(drawer).toHaveAttribute("aria-hidden", "true"); - expect(drawer.firstElementChild).toHaveClass("inline-disclosure-clip"); - expect(drawer.firstElementChild?.firstElementChild).toHaveClass("inline-disclosure-content"); - for (const control of [search, ...within(drawer).getAllByRole("button", { hidden: true })]) { - expect(control).toBeDisabled(); + const toggle = screen.getByRole("button", { name: "System tasks 1" }); + const chevron = toggle.querySelector("svg"); + expect(chevron).toHaveClass("lucide-chevron-down", "rotate-180"); + await user.click(toggle); + expect(chevron).not.toHaveClass("rotate-180"); + expect(toggle).toHaveAttribute("aria-expanded", "false"); + await user.click(toggle); + for (const name of [/PR watch/, /heartbeat/]) { + const row = screen.getByRole("button", { name }); + expect(row).toHaveAttribute("aria-haspopup", "dialog"); + expect(row.querySelector(".lucide-chevron-right, .lucide-chevron-down")).toBeNull(); + await user.click(row); + const details = screen.getByRole("button", { name: "More details" }); + expect(details.querySelector("svg")).toHaveClass("lucide-chevron-down"); + await user.click(details); + expect(details).toHaveAttribute("aria-expanded", "true"); + expect(screen.getByRole("dialog")).toBeVisible(); + await user.click(screen.getByRole("button", { name: "Done" })); } - - await user.click(toggle); - expect(drawer).toHaveAttribute("data-state", "open"); - expect(drawer).not.toHaveAttribute("aria-hidden"); - expect(screen.getByRole("textbox")).toBe(search); - await user.type(search, "PR"); - await user.click(toggle); - expect(document.getElementById("automation-view-options")).toBe(drawer); - expect(drawer).toHaveAttribute("data-state", "closed"); - expect(search).toHaveValue("PR"); - expect(search).toBeDisabled(); - await user.tab(); - expect(screen.getByRole("button", { name: /PR watch/ })).toHaveFocus(); - - await user.click(toggle); - await user.dblClick(toggle); - expect(drawer).toHaveAttribute("data-state", "open"); - expect(screen.getByRole("textbox")).toBe(search); - expect(search).toHaveValue("PR"); - await user.click(screen.getByRole("button", { name: "Next run", exact: true })); - expect(screen.getByRole("menu")).toBeVisible(); - fireEvent.click(toggle); - await waitFor(() => expect(screen.queryByRole("menu")).not.toBeInTheDocument()); - expect(drawer).toHaveAttribute("data-state", "closed"); - await user.click(toggle); - expect(screen.queryByRole("menu")).not.toBeInTheDocument(); }); it("hands off editing and deletion without leaving a second modal open", async () => { diff --git a/webui/src/tests/settings-system.test.tsx b/webui/src/tests/settings-system.test.tsx index 46eaf8bf3..0241600a8 100644 --- a/webui/src/tests/settings-system.test.tsx +++ b/webui/src/tests/settings-system.test.tsx @@ -213,7 +213,6 @@ describe("Settings system domains", () => { }); expect(await screen.findByRole("button", { name: /Daily summary/ })).toBeInTheDocument(); - fireEvent.click(screen.getByRole("button", { name: "Search and filter" })); fireEvent.click(screen.getByRole("button", { name: "Paused 0" })); expect(await screen.findByText("No automations match this view.")).toBeInTheDocument(); fireEvent.click(screen.getByRole("button", { name: "Clear filters" })); @@ -241,8 +240,7 @@ describe("Settings system domains", () => { })); renderSettingsView({ initialSection: "automations", initialSettings: settingsPayload(), showSidebar: false }); - fireEvent.click(await screen.findByRole("button", { name: "Search and filter" })); - const filters = screen.getByRole("group", { name: "Automations" }); + const filters = await screen.findByRole("group", { name: "Automations" }); expect(filters).toHaveClass("flex-wrap"); expect(within(filters).getAllByRole("button")).toHaveLength(4); expect(within(filters).getByRole("button", { name: "All 1" })).toHaveAttribute("aria-pressed", "true");