fix(webui): align automation styling with settings pages
Reuse the Channels search styling and segmented filters, and bring the Skills catalog surface, typography, and compact row spacing to Automations so the feature pages share a consistent visual language. Preserve task dialogs, disclosure motion, search and sort behavior, and the deletion focus regression coverage.
This commit is contained in:
1 parent
5b2f21c431
commit
092410d3f2
3 files changed
+142
-138
No files matched your search
@@ -158,141 +158,147 @@ export function AutomationsSettings({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="automations-page">
|
<div className="automations-page">
|
||||||
<header className="mb-6 flex items-center justify-between gap-4 sm:mb-8">
|
<header className="mb-7">
|
||||||
<h1 ref={pageTitle} tabIndex={-1} className="text-[26px] font-semibold leading-tight tracking-[-0.025em] text-foreground outline-none sm:text-[30px]">
|
<h1 ref={pageTitle} tabIndex={-1} className="text-[24px] font-normal leading-tight tracking-normal text-foreground outline-none sm:text-[28px]">
|
||||||
{tx("settings.nav.automations", "Automations")}
|
{tx("settings.nav.automations", "Automations")}
|
||||||
</h1>
|
</h1>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
{jobs.length ? (
|
<div className="settings-stack">
|
||||||
<section
|
{jobs.length ? (
|
||||||
aria-label={tx("settings.automations.viewOptions", "Search and filter")}
|
<section
|
||||||
className="space-y-3 pb-5 pt-1"
|
aria-label={tx("settings.automations.viewOptions", "Search and filter")}
|
||||||
>
|
className="flex min-w-0 flex-wrap items-center gap-3"
|
||||||
<div className="grid min-w-0 gap-2 sm:grid-cols-[minmax(0,1fr)_auto]">
|
>
|
||||||
<div className="relative min-w-0">
|
<div className="relative min-w-0 basis-full sm:flex-1 sm:basis-[240px]">
|
||||||
<Search className="pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" aria-hidden />
|
<Search className="pointer-events-none absolute start-4 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" aria-hidden />
|
||||||
<Input
|
<Input
|
||||||
ref={searchInput}
|
ref={searchInput}
|
||||||
value={query}
|
value={query}
|
||||||
onChange={(event) => onQueryChange(event.target.value)}
|
onChange={(event) => onQueryChange(event.target.value)}
|
||||||
aria-label={tx("settings.automations.search", "Search task, message, linked chat, or schedule")}
|
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")}
|
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)}
|
className={cn("h-12 ps-11 text-[15px]", SETTINGS_SEARCH_INPUT_CLASS)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<DropdownMenu>
|
<div role="group" aria-label={tx("settings.nav.automations", "Automations")} className="min-w-0 max-w-full">
|
||||||
<DropdownMenuTrigger asChild>
|
<SegmentedControl
|
||||||
<Button variant="ghost" className="h-9 gap-2 rounded-full text-[12px] text-muted-foreground">
|
value={filter}
|
||||||
<ArrowUpDown className="h-3.5 w-3.5" aria-hidden />
|
className="flex-wrap justify-start"
|
||||||
{sortLabel[sort]}
|
itemClassName="px-2.5"
|
||||||
<ChevronDown className="h-3.5 w-3.5" aria-hidden />
|
options={summaryOptions.map((option) => ({
|
||||||
</Button>
|
value: option.value,
|
||||||
</DropdownMenuTrigger>
|
label: <>{option.label} <span className="ml-0.5 tabular-nums opacity-65">{option.count}</span></>,
|
||||||
<DropdownMenuContent align="end">
|
}))}
|
||||||
{(Object.keys(sortLabel) as AutomationSort[]).map((value) => (
|
onChange={onFilterChange}
|
||||||
<DropdownMenuItem key={value} onClick={() => onSortChange(value)}>
|
/>
|
||||||
<span>{sortLabel[value]}</span>
|
</div>
|
||||||
{sort === value ? <Check className="ml-auto h-3.5 w-3.5" aria-hidden /> : null}
|
</section>
|
||||||
</DropdownMenuItem>
|
) : null}
|
||||||
))}
|
|
||||||
</DropdownMenuContent>
|
|
||||||
</DropdownMenu>
|
|
||||||
</div>
|
|
||||||
<div role="group" aria-label={tx("settings.nav.automations", "Automations")} className="flex flex-wrap gap-1">
|
|
||||||
{summaryOptions.map((option) => (
|
|
||||||
<button
|
|
||||||
key={option.value}
|
|
||||||
type="button"
|
|
||||||
aria-pressed={filter === option.value}
|
|
||||||
onClick={() => onFilterChange(option.value)}
|
|
||||||
className={cn(
|
|
||||||
"touch-target inline-flex min-h-8 max-w-full items-center gap-2 rounded-full px-3 py-1.5 text-[12px] text-muted-foreground transition-colors hover:text-foreground",
|
|
||||||
filter === option.value && "bg-muted text-foreground",
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<span className="min-w-0 [overflow-wrap:anywhere]">{option.label}</span>
|
|
||||||
<span className="shrink-0 text-[11px] tabular-nums text-muted-foreground">{option.count}</span>
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
) : null}
|
|
||||||
|
|
||||||
{error ? <AutomationError message={error} /> : null}
|
<SettingsGroup>
|
||||||
{loading && !payload ? (
|
{jobs.length ? (
|
||||||
<div role="status" className="flex h-44 items-center justify-center text-[13px] text-muted-foreground">
|
<div className="flex min-w-0 flex-wrap items-center justify-between gap-x-3 px-5 pb-2 pt-3 sm:px-6">
|
||||||
<Loader2 className="mr-2 h-4 w-4 animate-spin" aria-hidden />
|
<div className="flex items-center gap-2 py-1.5">
|
||||||
{tx("settings.automations.loading", "Loading automations...")}
|
<h2 className="text-[11px] font-semibold uppercase tracking-[0.08em] text-muted-foreground">
|
||||||
</div>
|
{tx("settings.automations.yourTasks", "Your automations")}
|
||||||
) : (
|
</h2>
|
||||||
<>
|
<span className="text-[11px] tabular-nums text-muted-foreground/60">{personal.length}</span>
|
||||||
{personal.length ? (
|
</div>
|
||||||
<ul aria-label={tx("settings.automations.yourTasks", "Your automations")} className="divide-y divide-border/45">
|
<DropdownMenu>
|
||||||
{personal.map(renderJob)}
|
<DropdownMenuTrigger asChild>
|
||||||
</ul>
|
<Button variant="ghost" className="h-8 gap-1.5 px-2 text-[11px] text-muted-foreground">
|
||||||
) : !personalJobs.length && !query && filter === "all" ? (
|
<ArrowUpDown className="h-3.5 w-3.5" aria-hidden />
|
||||||
<div className="py-12 text-center sm:py-16">
|
{sortLabel[sort]}
|
||||||
<p className="text-[17px] font-medium text-foreground">
|
<ChevronDown className="h-3.5 w-3.5" aria-hidden />
|
||||||
{tx("settings.automations.empty", "No automations yet.")}
|
</Button>
|
||||||
</p>
|
</DropdownMenuTrigger>
|
||||||
<p className="mx-auto mt-2 max-w-sm text-[13px] leading-6 text-muted-foreground">
|
<DropdownMenuContent align="end">
|
||||||
{tx("settings.automations.emptyHint", "Tell nanobot in a chat what you'd like it to do on a schedule.")}
|
{(Object.keys(sortLabel) as AutomationSort[]).map((value) => (
|
||||||
</p>
|
<DropdownMenuItem key={value} onClick={() => onSortChange(value)}>
|
||||||
</div>
|
<span>{sortLabel[value]}</span>
|
||||||
) : !filtered.length ? (
|
{sort === value ? <Check className="ml-auto h-3.5 w-3.5" aria-hidden /> : null}
|
||||||
<div className="py-12 text-center text-[13px] text-muted-foreground">
|
</DropdownMenuItem>
|
||||||
<p>{tx("settings.automations.noMatches", "No automations match this view.")}</p>
|
))}
|
||||||
<Button variant="outline" className="mt-4 rounded-full" onClick={() => {
|
</DropdownMenuContent>
|
||||||
onQueryChange("");
|
</DropdownMenu>
|
||||||
onFilterChange("all");
|
|
||||||
}}>
|
|
||||||
{tx("settings.automations.clearFilters", "Clear filters")}
|
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
{system.length ? (
|
|
||||||
<section className="mt-8 border-t border-border/45 pt-2">
|
{error ? <AutomationError message={error} /> : null}
|
||||||
<button
|
{loading && !payload ? (
|
||||||
type="button"
|
<div role="status" className="flex h-44 items-center justify-center text-[13px] text-muted-foreground">
|
||||||
aria-expanded={systemOpen}
|
<Loader2 className="mr-2 h-4 w-4 animate-spin" aria-hidden />
|
||||||
aria-controls="automation-system-tasks"
|
{tx("settings.automations.loading", "Loading automations...")}
|
||||||
onClick={() => {
|
</div>
|
||||||
const open = !systemOpen;
|
) : (
|
||||||
setSystemOpen(open);
|
<div className="space-y-5 px-3 pb-3 sm:px-4">
|
||||||
try {
|
{personal.length ? (
|
||||||
// Persist only the user's choice, not automatic search expansion.
|
<ul aria-label={tx("settings.automations.yourTasks", "Your automations")} className="space-y-1">
|
||||||
window.localStorage.setItem(SYSTEM_TASKS_OPEN_STORAGE_KEY, String(open));
|
{personal.map(renderJob)}
|
||||||
} catch {
|
</ul>
|
||||||
// Unavailable storage must not prevent expanding or collapsing.
|
) : !personalJobs.length && !query && filter === "all" ? (
|
||||||
}
|
<div className="px-2 py-12 text-center">
|
||||||
}}
|
<p className="text-[14px] font-medium text-foreground">
|
||||||
className={cn("flex min-h-16 w-full items-center gap-3 rounded-lg py-4 text-left text-[14px] font-medium", formControlFocusClassName)}
|
{tx("settings.automations.empty", "No automations yet.")}
|
||||||
>
|
</p>
|
||||||
<span>{tx("settings.automations.systemTasks", "System tasks")}</span>
|
<p className="mx-auto mt-2 max-w-sm text-[13px] leading-6 text-muted-foreground">
|
||||||
<span className="text-[12px] font-normal tabular-nums text-muted-foreground">{system.length}</span>
|
{tx("settings.automations.emptyHint", "Tell nanobot in a chat what you'd like it to do on a schedule.")}
|
||||||
{system.some(automationNeedsAttention) ? (
|
</p>
|
||||||
<span className="ml-auto inline-flex items-center gap-1.5 text-[12px] font-normal text-amber-700 dark:text-amber-400">
|
</div>
|
||||||
<CircleAlert className="h-3.5 w-3.5" aria-hidden />
|
) : !filtered.length ? (
|
||||||
{tx("settings.automations.filters.failed", "Needs attention")}
|
<div className="py-12 text-center text-[13px] text-muted-foreground">
|
||||||
</span>
|
<p>{tx("settings.automations.noMatches", "No automations match this view.")}</p>
|
||||||
) : null}
|
<Button variant="outline" className="mt-4 rounded-full" onClick={() => {
|
||||||
<ChevronDown className={cn("ml-auto h-4 w-4 shrink-0 text-muted-foreground transition-transform motion-reduce:transition-none", systemOpen && "rotate-180")} aria-hidden />
|
onQueryChange("");
|
||||||
</button>
|
onFilterChange("all");
|
||||||
<DisclosureContent
|
}}>
|
||||||
id="automation-system-tasks"
|
{tx("settings.automations.clearFilters", "Clear filters")}
|
||||||
open={systemOpen}
|
</Button>
|
||||||
>
|
</div>
|
||||||
<SettingsGroup>
|
) : null}
|
||||||
<ul aria-label={tx("settings.automations.systemTasks", "System tasks")} className="divide-y divide-border/45">
|
{system.length ? (
|
||||||
{system.map(renderJob)}
|
<section className="space-y-1">
|
||||||
</ul>
|
<button
|
||||||
</SettingsGroup>
|
type="button"
|
||||||
</DisclosureContent>
|
aria-expanded={systemOpen}
|
||||||
</section>
|
aria-controls="automation-system-tasks"
|
||||||
) : null}
|
onClick={() => {
|
||||||
</>
|
const open = !systemOpen;
|
||||||
)}
|
setSystemOpen(open);
|
||||||
|
try {
|
||||||
|
// Persist only the user's choice, not automatic search expansion.
|
||||||
|
window.localStorage.setItem(SYSTEM_TASKS_OPEN_STORAGE_KEY, String(open));
|
||||||
|
} catch {
|
||||||
|
// Unavailable storage must not prevent expanding or collapsing.
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
className={cn("flex min-h-9 w-full items-center gap-2 rounded-control px-2 py-1.5 text-left text-[11px] font-semibold uppercase tracking-[0.08em] text-muted-foreground settings-hover", formControlFocusClassName)}
|
||||||
|
>
|
||||||
|
<span>{tx("settings.automations.systemTasks", "System tasks")}</span>
|
||||||
|
<span className="font-normal tabular-nums tracking-normal text-muted-foreground/60">{system.length}</span>
|
||||||
|
{system.some(automationNeedsAttention) ? (
|
||||||
|
<span className="ml-auto inline-flex items-center gap-1.5 font-normal normal-case tracking-normal text-amber-700 dark:text-amber-400">
|
||||||
|
<CircleAlert className="h-3.5 w-3.5" aria-hidden />
|
||||||
|
{tx("settings.automations.filters.failed", "Needs attention")}
|
||||||
|
</span>
|
||||||
|
) : null}
|
||||||
|
<ChevronDown className={cn("ml-auto h-4 w-4 shrink-0 text-muted-foreground transition-transform motion-reduce:transition-none", systemOpen && "rotate-180")} aria-hidden />
|
||||||
|
</button>
|
||||||
|
<DisclosureContent
|
||||||
|
id="automation-system-tasks"
|
||||||
|
open={systemOpen}
|
||||||
|
>
|
||||||
|
<ul aria-label={tx("settings.automations.systemTasks", "System tasks")} className="space-y-1">
|
||||||
|
{system.map(renderJob)}
|
||||||
|
</ul>
|
||||||
|
</DisclosureContent>
|
||||||
|
</section>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</SettingsGroup>
|
||||||
|
</div>
|
||||||
|
|
||||||
<Dialog open={detailOpen} onOpenChange={setDetailOpen}>
|
<Dialog open={detailOpen} onOpenChange={setDetailOpen}>
|
||||||
{selectedJob ? (
|
{selectedJob ? (
|
||||||
@@ -356,22 +362,15 @@ function AutomationListItem({ job, locale, disabled, onSelect }: {
|
|||||||
aria-haspopup="dialog"
|
aria-haspopup="dialog"
|
||||||
onClick={(event) => onSelect(event.currentTarget)}
|
onClick={(event) => onSelect(event.currentTarget)}
|
||||||
className={cn(
|
className={cn(
|
||||||
"automation-task-row grid w-full grid-cols-1 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 rounded-control px-2 py-3 text-left transition-colors duration-150 settings-hover",
|
||||||
compact ? "settings-list-row py-3 settings-hover" : "min-h-[92px] rounded-lg py-5 hover:bg-muted/35",
|
|
||||||
formControlFocusClassName,
|
formControlFocusClassName,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<span className="min-w-0">
|
<span className="min-w-0">
|
||||||
<span className={cn(
|
<span className="block truncate text-[14px] font-semibold leading-5 text-foreground">{job.name || job.id}</span>
|
||||||
"block truncate font-medium text-foreground",
|
{summary ? <span className="mt-0.5 block truncate text-[12px] leading-5 text-muted-foreground">{summary}</span> : null}
|
||||||
compact ? "text-[14px] leading-5" : "text-[16px] leading-6 tracking-[-0.015em] sm:text-[17px]",
|
|
||||||
)}>{job.name || job.id}</span>
|
|
||||||
{summary ? <span className="mt-1 block truncate text-[13px] leading-5 text-muted-foreground">{summary}</span> : null}
|
|
||||||
</span>
|
</span>
|
||||||
<span className={cn(
|
<span className="automation-task-state flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground">
|
||||||
"automation-task-state flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-[12px] text-muted-foreground",
|
|
||||||
!compact && "sm:text-[13px]",
|
|
||||||
)}>
|
|
||||||
{running ? <Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden /> : null}
|
{running ? <Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden /> : null}
|
||||||
{attention && !running ? (
|
{attention && !running ? (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -222,20 +222,25 @@ describe("Automation task list and detail sheet", () => {
|
|||||||
expect(dialog).not.toHaveAttribute("aria-describedby");
|
expect(dialog).not.toHaveAttribute("aria-describedby");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("reuses compact settings rows for system tasks without changing personal rows", async () => {
|
it("uses channel search controls and the skills catalog surface for both task groups", async () => {
|
||||||
const user = userEvent.setup();
|
const user = userEvent.setup();
|
||||||
render(<Harness payload={{ jobs: [task, systemTask, {
|
render(<Harness payload={{ jobs: [task, systemTask, {
|
||||||
...systemTask, id: "dream", name: "dream",
|
...systemTask, id: "dream", name: "dream",
|
||||||
state: { last_status: "error", last_error: "Memory update failed" },
|
state: { last_status: "error", last_error: "Memory update failed" },
|
||||||
}] }} />);
|
}] }} />);
|
||||||
|
expect(screen.getByRole("heading", { name: "Automations" })).toHaveClass("font-normal", "text-[24px]");
|
||||||
const personalRow = screen.getByRole("button", { name: /PR watch/ });
|
const personalRow = screen.getByRole("button", { name: /PR watch/ });
|
||||||
expect(personalRow).toHaveClass("min-h-[92px]");
|
expect(personalRow).toHaveClass("rounded-control", "px-2", "py-3", "settings-hover");
|
||||||
expect(personalRow).not.toHaveClass("settings-list-row");
|
|
||||||
const list = screen.getByRole("list", { name: "System tasks" });
|
const list = screen.getByRole("list", { name: "System tasks" });
|
||||||
expect(list.parentElement).toHaveClass("rounded-panel", "bg-settings-surface");
|
const surface = personalRow.closest(".bg-settings-surface");
|
||||||
|
expect(surface).toHaveClass("rounded-panel");
|
||||||
|
expect(list.closest(".bg-settings-surface")).toBe(surface);
|
||||||
|
const search = screen.getByRole("textbox");
|
||||||
|
expect(search.closest(".rounded-panel")).toBeNull();
|
||||||
|
expect(search).toHaveClass("h-12", "bg-settings-surface", "focus-visible:bg-background");
|
||||||
|
expect(screen.getByRole("button", { name: "All 1" }).parentElement).toHaveClass("segmented-control", "flex-wrap");
|
||||||
const heartbeat = within(list).getByRole("button", { name: /heartbeat/ });
|
const heartbeat = within(list).getByRole("button", { name: /heartbeat/ });
|
||||||
expect(heartbeat).toHaveClass("settings-list-row", "settings-hover");
|
expect(heartbeat.className).toBe(personalRow.className);
|
||||||
expect(heartbeat).not.toHaveClass("min-h-[92px]");
|
|
||||||
expect(within(list).queryByText("System-managed automation")).not.toBeInTheDocument();
|
expect(within(list).queryByText("System-managed automation")).not.toBeInTheDocument();
|
||||||
expect(within(list).getByText("Memory update failed")).toBeVisible();
|
expect(within(list).getByText("Memory update failed")).toBeVisible();
|
||||||
expect(within(list).getByText("Needs attention")).toBeVisible();
|
expect(within(list).getByText("Needs attention")).toBeVisible();
|
||||||
|
|||||||
@@ -241,7 +241,7 @@ describe("Settings system domains", () => {
|
|||||||
renderSettingsView({ initialSection: "automations", initialSettings: settingsPayload(), showSidebar: false });
|
renderSettingsView({ initialSection: "automations", initialSettings: settingsPayload(), showSidebar: false });
|
||||||
|
|
||||||
const filters = await screen.findByRole("group", { name: "Automations" });
|
const filters = await screen.findByRole("group", { name: "Automations" });
|
||||||
expect(filters).toHaveClass("flex-wrap");
|
expect(within(filters).getByRole("button", { name: "All 1" }).parentElement).toHaveClass("segmented-control", "flex-wrap");
|
||||||
expect(within(filters).getAllByRole("button")).toHaveLength(4);
|
expect(within(filters).getAllByRole("button")).toHaveLength(4);
|
||||||
expect(within(filters).getByRole("button", { name: "All 1" })).toHaveAttribute("aria-pressed", "true");
|
expect(within(filters).getByRole("button", { name: "All 1" })).toHaveAttribute("aria-pressed", "true");
|
||||||
expect(within(filters).queryByRole("button", { name: /System/ })).not.toBeInTheDocument();
|
expect(within(filters).queryByRole("button", { name: /System/ })).not.toBeInTheDocument();
|
||||||
|
|||||||
Reference in new issue
Block a user