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
+60
-56
No files matched your search
@@ -158,32 +158,56 @@ 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>
|
||||||
|
|
||||||
|
<div className="settings-stack">
|
||||||
{jobs.length ? (
|
{jobs.length ? (
|
||||||
<section
|
<section
|
||||||
aria-label={tx("settings.automations.viewOptions", "Search and filter")}
|
aria-label={tx("settings.automations.viewOptions", "Search and filter")}
|
||||||
className="space-y-3 pb-5 pt-1"
|
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 basis-full sm:flex-1 sm:basis-[240px]">
|
||||||
<div className="relative min-w-0">
|
<Search className="pointer-events-none absolute start-4 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" aria-hidden />
|
||||||
<Search className="pointer-events-none absolute left-3 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>
|
||||||
|
<div role="group" aria-label={tx("settings.nav.automations", "Automations")} className="min-w-0 max-w-full">
|
||||||
|
<SegmentedControl
|
||||||
|
value={filter}
|
||||||
|
className="flex-wrap justify-start"
|
||||||
|
itemClassName="px-2.5"
|
||||||
|
options={summaryOptions.map((option) => ({
|
||||||
|
value: option.value,
|
||||||
|
label: <>{option.label} <span className="ml-0.5 tabular-nums opacity-65">{option.count}</span></>,
|
||||||
|
}))}
|
||||||
|
onChange={onFilterChange}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
<SettingsGroup>
|
||||||
|
{jobs.length ? (
|
||||||
|
<div className="flex min-w-0 flex-wrap items-center justify-between gap-x-3 px-5 pb-2 pt-3 sm:px-6">
|
||||||
|
<div className="flex items-center gap-2 py-1.5">
|
||||||
|
<h2 className="text-[11px] font-semibold uppercase tracking-[0.08em] text-muted-foreground">
|
||||||
|
{tx("settings.automations.yourTasks", "Your automations")}
|
||||||
|
</h2>
|
||||||
|
<span className="text-[11px] tabular-nums text-muted-foreground/60">{personal.length}</span>
|
||||||
|
</div>
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
<Button variant="ghost" className="h-9 gap-2 rounded-full text-[12px] text-muted-foreground">
|
<Button variant="ghost" className="h-8 gap-1.5 px-2 text-[11px] text-muted-foreground">
|
||||||
<ArrowUpDown className="h-3.5 w-3.5" aria-hidden />
|
<ArrowUpDown className="h-3.5 w-3.5" aria-hidden />
|
||||||
{sortLabel[sort]}
|
{sortLabel[sort]}
|
||||||
<ChevronDown className="h-3.5 w-3.5" aria-hidden />
|
<ChevronDown className="h-3.5 w-3.5" aria-hidden />
|
||||||
@@ -199,24 +223,6 @@ export function AutomationsSettings({
|
|||||||
</DropdownMenuContent>
|
</DropdownMenuContent>
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
</div>
|
</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}
|
) : null}
|
||||||
|
|
||||||
{error ? <AutomationError message={error} /> : null}
|
{error ? <AutomationError message={error} /> : null}
|
||||||
@@ -226,14 +232,14 @@ export function AutomationsSettings({
|
|||||||
{tx("settings.automations.loading", "Loading automations...")}
|
{tx("settings.automations.loading", "Loading automations...")}
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<div className="space-y-5 px-3 pb-3 sm:px-4">
|
||||||
{personal.length ? (
|
{personal.length ? (
|
||||||
<ul aria-label={tx("settings.automations.yourTasks", "Your automations")} className="divide-y divide-border/45">
|
<ul aria-label={tx("settings.automations.yourTasks", "Your automations")} className="space-y-1">
|
||||||
{personal.map(renderJob)}
|
{personal.map(renderJob)}
|
||||||
</ul>
|
</ul>
|
||||||
) : !personalJobs.length && !query && filter === "all" ? (
|
) : !personalJobs.length && !query && filter === "all" ? (
|
||||||
<div className="py-12 text-center sm:py-16">
|
<div className="px-2 py-12 text-center">
|
||||||
<p className="text-[17px] font-medium text-foreground">
|
<p className="text-[14px] font-medium text-foreground">
|
||||||
{tx("settings.automations.empty", "No automations yet.")}
|
{tx("settings.automations.empty", "No automations yet.")}
|
||||||
</p>
|
</p>
|
||||||
<p className="mx-auto mt-2 max-w-sm text-[13px] leading-6 text-muted-foreground">
|
<p className="mx-auto mt-2 max-w-sm text-[13px] leading-6 text-muted-foreground">
|
||||||
@@ -252,7 +258,7 @@ export function AutomationsSettings({
|
|||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
{system.length ? (
|
{system.length ? (
|
||||||
<section className="mt-8 border-t border-border/45 pt-2">
|
<section className="space-y-1">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
aria-expanded={systemOpen}
|
aria-expanded={systemOpen}
|
||||||
@@ -267,12 +273,12 @@ export function AutomationsSettings({
|
|||||||
// Unavailable storage must not prevent expanding or collapsing.
|
// Unavailable storage must not prevent expanding or collapsing.
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
className={cn("flex min-h-16 w-full items-center gap-3 rounded-lg py-4 text-left text-[14px] font-medium", formControlFocusClassName)}
|
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>{tx("settings.automations.systemTasks", "System tasks")}</span>
|
||||||
<span className="text-[12px] font-normal tabular-nums text-muted-foreground">{system.length}</span>
|
<span className="font-normal tabular-nums tracking-normal text-muted-foreground/60">{system.length}</span>
|
||||||
{system.some(automationNeedsAttention) ? (
|
{system.some(automationNeedsAttention) ? (
|
||||||
<span className="ml-auto inline-flex items-center gap-1.5 text-[12px] font-normal text-amber-700 dark:text-amber-400">
|
<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 />
|
<CircleAlert className="h-3.5 w-3.5" aria-hidden />
|
||||||
{tx("settings.automations.filters.failed", "Needs attention")}
|
{tx("settings.automations.filters.failed", "Needs attention")}
|
||||||
</span>
|
</span>
|
||||||
@@ -283,16 +289,16 @@ export function AutomationsSettings({
|
|||||||
id="automation-system-tasks"
|
id="automation-system-tasks"
|
||||||
open={systemOpen}
|
open={systemOpen}
|
||||||
>
|
>
|
||||||
<SettingsGroup>
|
<ul aria-label={tx("settings.automations.systemTasks", "System tasks")} className="space-y-1">
|
||||||
<ul aria-label={tx("settings.automations.systemTasks", "System tasks")} className="divide-y divide-border/45">
|
|
||||||
{system.map(renderJob)}
|
{system.map(renderJob)}
|
||||||
</ul>
|
</ul>
|
||||||
</SettingsGroup>
|
|
||||||
</DisclosureContent>
|
</DisclosureContent>
|
||||||
</section>
|
</section>
|
||||||
) : null}
|
) : 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